rvcc-course's Issues
parse 函数定义语法存在歧义
第25个commit, 零参数的函数定义中函数语法是这样给出的
// functionDefinition = declspec declarator? ident "(" ")" "{" compoundStmt*
然后declarator的语法要求必须有标识符的
// declarator = "" ident typeSuffix
这样一个函数声明就有两个标识符了
另外functionDefinition 中对declarator 标记了"?",然后function函数实现中, 逻辑中要求必须有declarator
函数实现的语法 应该是 // functionDefinition = declspec declarator"{" compoundStmt*
为什么我运行该脚本后没有gcc,qemu等文件
$ sudo chmod +x install-riscv.sh
$ ./install-riscv.sh
$ pwd
/home/ubuntu20
$ ls riscv/bin/ | grep gcc
b站视频课程中的main和rvcc项目提供的main不一样
vscode下断点调试launch.json配置文件
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "cppdbg",
"request": "launch",
"name": "Debug",
"program": "${workspaceFolder}/rvcc",
"args": [
"1-8/(2*2)+3*6"
],
"environment": [
{
"name": "config",
"value": "Debug"
}
],
"cwd": "${workspaceFolder}",
"linux": {
"MIMode": "gdb",
"miDebuggerPath": "/usr/bin/gdb"
},
"osx": {
"MIMode": "lldb"
},
"windows": {
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGw\\bin\\gdb.exe"
}
}
]
}
args修改为需要执行的参数
以上配置仅在macOS 12.5下经过测试,请Windows用户自行安装MinGw或使用其他方式
参考文档:https://code.visualstudio.com/docs/cpp/launch-json-reference
如何在 VSCode Debug 过程中为 mian 函数 int **Argv 传递参数
关于 commit15 中 for 的语法规则定义的问题
注释顺序错误
https://github.com/sunshaoce/rvcc/blob/37f8a4fc34f8b3a805bb927dfb20feb8d3b8530d/codegen.c#L73
// neg a0, a0是 sub a0, x0的别名, a0,即a0=0-a0
应该为
// neg a0, a0是 sub a0, x0, a0的别名,即a0=0-a0
rvcc 仓库 CMakeLists.txt 可改进的地方
project(rvcc)
没有写 language,默认的 language 是C CXX
(见 文档 的LANGUAGES
一节),而这个项目应该只会用到 c 语言,所以可以改为project(rvcc C)
SET( CMAKE_C_FLAGS "-std=c11 -g -fno-common" )
有两处可以改进的地方,一个是 set 可以改为小写,和其它地方(project
、add_executable
等)大小写统一,一个是可以重写为 target-based 的 modern cmake 风格:target_compile_options(rvcc PRIVATE -std=c11 -g -fno-common)
,如果后期 target 变多,逐个 target 设置不方便,可以改为使用add_compile_options
设置全局的 flags,也比直接设置 CMAKE_C_FLAGS 要更现代一些
44 域处理中的一个疑问
在commit 44 处理代码块域中, rvcc是不支持一个作用域中同名标识符声明的冲突检测的, 比如下列情况可以正常运行
ASSERT(4, ({ int x=2; int x = 4;{ int x=3; } int y=4; x; }));
我往后看写一些(只看了一点), 没看到这个问题的解决
不过我想这个只需要在当前的scope
中遍历下是否声明过就能解决, 所以觉得应该是作者故意这么写的
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.