Skip to content

add if statement#4

Merged
shenao78 merged 2 commits intomainfrom
add_more_statements
Jul 20, 2021
Merged

add if statement#4
shenao78 merged 2 commits intomainfrom
add_more_statements

Conversation

@shenao78
Copy link
Copy Markdown
Contributor

No description provided.

%token <identifier> IDENTIFIER;
%token FUNCTION IF ELSE FOR RETURN BREAK CONTINUE NIL

%type <expression> expr bool_expr
Copy link
Copy Markdown
Contributor

@boomyl boomyl Jul 20, 2021

Choose a reason for hiding this comment

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

逻辑没啥问题,就是感觉摆在一起有些突兀,应该是一般表达式,bool表达式

%token FUNCTION IF ELSE FOR RETURN BREAK CONTINUE NIL

%type <expression> expr bool_expr
%type <statement> stmt if_stmt
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

同上,一般语句,if语句

%type <statement_list> stmt_list
%type <block> block
%type <elseif> elseif elseif_list

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

%nonassoc '\n' 不要了?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

之前发现会冲突,加了这个,文法改了之后没有这个问题

| if_stmt
;

if_stmt:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

这4类if场景最好有个示意图,$有些晕

"func" return FUNCTION;
"return" return RETURN;
"break" return BREAK;
"continue" return CONTINUE;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

漏了lock?

%token <double_value> DOUBLE_LITERAL
%token <int_value> INT_LITERAL
%token <identifier> IDENTIFIER;
%token FUNCTION IF ELSE FOR RETURN BREAK CONTINUE NIL
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

这个只是符号,在lex中实际匹配的就是"func"

@shenao78 shenao78 merged commit 83d98d5 into main Jul 20, 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