Git Product home page Git Product logo

rvcc-course's Issues

parse 函数定义语法存在歧义

第25个commit, 零参数的函数定义中函数语法是这样给出的
// functionDefinition = declspec declarator? ident "(" ")" "{" compoundStmt*
然后declarator的语法要求必须有标识符的
// declarator = "" ident typeSuffix
这样一个函数声明就有两个标识符了
另外functionDefinition 中对declarator 标记了"?",然后function函数实现中, 逻辑中要求必须有declarator
函数实现的语法 应该是 // functionDefinition = declspec declarator"{" compoundStmt*

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

rvcc 仓库 CMakeLists.txt 可改进的地方

  1. project(rvcc) 没有写 language,默认的 language 是 C CXX(见 文档LANGUAGES 一节),而这个项目应该只会用到 c 语言,所以可以改为 project(rvcc C)
  2. SET( CMAKE_C_FLAGS "-std=c11 -g -fno-common" ) 有两处可以改进的地方,一个是 set 可以改为小写,和其它地方(projectadd_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 photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.