Merged
Conversation
boomyl
reviewed
Jul 26, 2021
| { | ||
| Compiler *compiler = malloc(sizeof(Compiler)); | ||
| compiler->func_definition_list = malloc(sizeof(FuncDefinition)); | ||
| Compiler *compiler = (Compiler *)malloc(sizeof(Compiler)); |
Contributor
There was a problem hiding this comment.
C编译器多隐转,也便于维护。报错的场景是sizeof的类型跟强转类型不一致吧
Contributor
Author
There was a problem hiding this comment.
原因是这样,我的解释器需要用STL,用c++写的,c++的编译器,malloc没有做转换编译会报错。而且我感觉后面开发很可能还是需要用到STL
boomyl
reviewed
Jul 26, 2021
| Statement *stmt = alloc_statement(ASSIGN_STATEMENT); | ||
| AssignStatement *assign_s = malloc(sizeof(AssignStatement)); | ||
| AssignStatement *assign_s = (AssignStatement *)malloc(sizeof(AssignStatement)); | ||
| assign_s->variable = variable; |
boomyl
reviewed
Jul 26, 2021
| { | ||
| Statement *stmt = alloc_statement(ASSIGN_STATEMENT); | ||
| AssignStatement *assign_s = malloc(sizeof(AssignStatement)); | ||
| AssignStatement *assign_s = (AssignStatement *)malloc(sizeof(AssignStatement)); |
Contributor
There was a problem hiding this comment.
另外,这个赋值语句需不需要加filed表征类型。初始化是在赋值前的declaration_stmt里的?
Contributor
Author
There was a problem hiding this comment.
是的,类型是在声明的时候,赋值你只能拿到一个变量名
boomyl
reviewed
Jul 26, 2021
compiler/grammar.y
Outdated
|
|
||
| stmt_list: | ||
| stmt {$$ = alloc_statement_list($1); } | ||
| stmt {$$ = chain_statement_list(NULL, $1); } |
Contributor
There was a problem hiding this comment.
风格问题,这里命名建议统一一下,比如statement用缩写stmt,反正意义比较明显
boomyl
reviewed
Jul 26, 2021
| Expression *right; | ||
| } BinaryExpression; | ||
|
|
||
| typedef struct ArgumentList |
Contributor
There was a problem hiding this comment.
note: 总感觉参数列表漏了类型标识(用于语义类型检查)、行号(用于报错系统)
Contributor
Author
There was a problem hiding this comment.
Expression里面有type,至于行号后面统一加吧
boomyl
reviewed
Jul 26, 2021
| { | ||
| char *identifier; | ||
| ArgumentList *argument_list; | ||
| } FuncCallExpression; |
boomyl
approved these changes
Jul 26, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.