File tree Expand file tree Collapse file tree 2 files changed +23
-21
lines changed
Expand file tree Collapse file tree 2 files changed +23
-21
lines changed Original file line number Diff line number Diff line change @@ -11,7 +11,6 @@ int yyerror(AstProgram **out_program, const char *msg);
1111extern int yylex (void );
1212extern FILE *yyin;
1313static void parser_error_cleanup (AstProgram **out_program);
14-
1514%}
1615
1716%code requires {
@@ -27,19 +26,19 @@ static void parser_error_cleanup(AstProgram **out_program);
2726%parse-param { AstProgram **out_program }
2827
2928%union {
30- long long intValue;
31- double floatValue;
32- char *id;
33- TypeKind type;
34- AstExpr *expr;
35- AstStmt *stmt;
36- AstBlock block;
37- AstStmtList stmt_list;
38- AstExprList expr_list;
39- AstParam param;
40- AstParamList param_list;
41- AstFunction *function;
42- AstProgram *program;
29+ long long intValue;
30+ double floatValue;
31+ char *id;
32+ TypeKind type;
33+ AstExpr *expr;
34+ AstStmt *stmt;
35+ AstBlock block;
36+ AstStmtList stmt_list;
37+ AstExprList expr_list;
38+ AstParam param;
39+ AstParamList param_list;
40+ AstFunction *function;
41+ AstProgram *program;
4342}
4443
4544%token <intValue> INT_LITERAL
@@ -55,6 +54,7 @@ static void parser_error_cleanup(AstProgram **out_program);
5554%token LPAREN RPAREN
5655%token LBRACE RBRACE
5756
57+ /* ---------- Precedência ---------- */
5858%left PLUS MINUS
5959%left TIMES DIVIDE MOD
6060%right UMINUS
@@ -80,7 +80,6 @@ program
8080 *out_program = $1;
8181 }
8282 ;
83-
8483function_sequence
8584 : function_definition
8685 {
@@ -404,7 +403,7 @@ int yyerror(AstProgram **out_program, const char *msg)
404403{
405404 (void )out_program;
406405 fprintf (stderr, " syntax error: %s\n " , msg);
407- return 0 ;
406+ return 0 ;
408407}
409408
410409AstProgram *c2lua_parse (FILE *input)
Original file line number Diff line number Diff line change 1- 1 + 2 * 3 ;
2- (4 + 5 ) / 2 ;
3- 10 % 3 ;
4- true;
5- false;
1+ int main ()
2+ {
3+ int a = 10 ;
4+ int b = 20 ;
5+ int sum = a + b ;
6+ printf ("Sum: %d\n" , sum );
7+ return 0 ;
8+ }
You can’t perform that action at this time.
0 commit comments