Skip to content

func call expr#10

Merged
boomyl merged 5 commits intomainfrom
func_call_expr
Jul 26, 2021
Merged

func call expr#10
boomyl merged 5 commits intomainfrom
func_call_expr

Conversation

@shenao78
Copy link
Contributor

No description provided.

{
Compiler *compiler = malloc(sizeof(Compiler));
compiler->func_definition_list = malloc(sizeof(FuncDefinition));
Compiler *compiler = (Compiler *)malloc(sizeof(Compiler));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

C编译器多隐转,也便于维护。报错的场景是sizeof的类型跟强转类型不一致吧

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

原因是这样,我的解释器需要用STL,用c++写的,c++的编译器,malloc没有做转换编译会报错。而且我感觉后面开发很可能还是需要用到STL

Statement *stmt = alloc_statement(ASSIGN_STATEMENT);
AssignStatement *assign_s = malloc(sizeof(AssignStatement));
AssignStatement *assign_s = (AssignStatement *)malloc(sizeof(AssignStatement));
assign_s->variable = variable;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

赋值之前是漏掉的么

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,之前漏了,发现了这个bug

{
Statement *stmt = alloc_statement(ASSIGN_STATEMENT);
AssignStatement *assign_s = malloc(sizeof(AssignStatement));
AssignStatement *assign_s = (AssignStatement *)malloc(sizeof(AssignStatement));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

另外,这个赋值语句需不需要加filed表征类型。初始化是在赋值前的declaration_stmt里的?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是的,类型是在声明的时候,赋值你只能拿到一个变量名


stmt_list:
stmt {$$ = alloc_statement_list($1); }
stmt {$$ = chain_statement_list(NULL, $1); }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

风格问题,这里命名建议统一一下,比如statement用缩写stmt,反正意义比较明显

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

好的

Expression *right;
} BinaryExpression;

typedef struct ArgumentList
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: 总感觉参数列表漏了类型标识(用于语义类型检查)、行号(用于报错系统)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expression里面有type,至于行号后面统一加吧

{
char *identifier;
ArgumentList *argument_list;
} FuncCallExpression;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

总感觉这个函数调用表达式怪怪的

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

具体什么问题?

Copy link
Contributor

@boomyl boomyl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~

@boomyl boomyl merged commit 2378153 into main Jul 26, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants