Skip to content
GitLab
Projects Groups Topics Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in
  • Q QA-2022s
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributor statistics
    • Graph
    • Compare revisions
  • Issues 1
    • Issues 1
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • Deployments
    • Deployments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Terraform modules
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Commits
  • Issue Boards
Collapse sidebar
  • pku-minicpku-minic
  • QA-2022s
  • Issues
  • #11
Closed
Open
Issue created Jun 04, 2022 by 郑加毅@pku1800017824

8.3中VarDecl和FuncDef出现了归约/归约冲突

在make的时候会出现

/root/src/sysy.y: warning: 1 reduce/reduce conflict [-Wconflicts-rr]

然后当编译同时含有VarDecl和FuncDef的程序时就会出现错误

error: syntax error

比如

int one = 1;

int main() {
  return one;
}

如果第一行加const则不会出现错误。

不是特别理解为什么会形成冲突。语法分析除了把Stmt拆分为MatchedStmt和OpenStmt以外都是按照手册里的示例写的,感觉自己的代码可以保证FuncDef中如果出现等号必须首先出现括号,而VarDecl中如果出现括号必须首先出现等号……

Assignee
Assign to
Time tracking