Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add if statement #4

Merged
merged 2 commits into from
Jul 20, 2021
Merged

add if statement #4

merged 2 commits into from
Jul 20, 2021

Conversation

shenao78
Copy link
Contributor

No description provided.

}

%token <int_value> BOOL_LITERAL
%token <double_value> DOUBLE_LITERAL
%token <int_value> INT_LITERAL
%token <identifier> IDENTIFIER;
%token FUNCTION IF ELSE FOR RETURN BREAK CONTINUE NIL

%type <expression> expr bool_expr
Copy link
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
Contributor

Choose a reason for hiding this comment

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

同上,一般语句,if语句

%type <statement> stmt if_stmt
%type <statement_list> stmt_list
%type <block> block
%type <elseif> elseif elseif_list

Copy link
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
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
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
Contributor

Choose a reason for hiding this comment

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

漏了lock?

}

%token <int_value> BOOL_LITERAL
%token <double_value> DOUBLE_LITERAL
%token <int_value> INT_LITERAL
%token <identifier> IDENTIFIER;
%token FUNCTION IF ELSE FOR RETURN BREAK CONTINUE NIL
Copy link
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