mirror of
https://github.com/openmoh/openmohaa.git
synced 2025-04-28 13:47:58 +03:00
Fixed grammar like "$(value).field"
Fixed newline in if statements Fixed if/else being ambiguous
This commit is contained in:
parent
fab7d8539c
commit
ab5a3604bf
1 changed files with 15 additions and 4 deletions
|
@ -28,6 +28,10 @@
|
|||
#include "./yyParser.hpp"
|
||||
#include "./yyLexer.h"
|
||||
|
||||
// the value was increased because some scripts have a lot of if/else statements
|
||||
// which ends up with an high depth
|
||||
#define YYINITDEPTH 500
|
||||
|
||||
int yyerror( const char *msg );
|
||||
|
||||
extern int prev_yylex;
|
||||
|
@ -47,7 +51,7 @@ int success_pos;
|
|||
%locations
|
||||
%define api.location.type { parse_pos_t }
|
||||
|
||||
%expect 131
|
||||
%expect 126
|
||||
|
||||
%precedence TOKEN_EOF 0 "end of file"
|
||||
%precedence TOKEN_EOL
|
||||
|
@ -59,7 +63,7 @@ int success_pos;
|
|||
%left TOKEN_COMMA
|
||||
|
||||
%precedence TOKEN_IF
|
||||
%right TOKEN_ELSE
|
||||
%right THEN TOKEN_ELSE
|
||||
%precedence TOKEN_WHILE TOKEN_FOR TOKEN_DO
|
||||
%precedence <s.val> TOKEN_IDENTIFIER
|
||||
|
||||
|
@ -115,6 +119,7 @@ int success_pos;
|
|||
%type <s.val> expr
|
||||
%type <s.val> func_prim_expr
|
||||
%type <s.val> prim_expr
|
||||
%type <s.val> listener_identifier
|
||||
%type <s.val> nonident_prim_expr
|
||||
%type <s.val> func_expr
|
||||
%type <s.val> const_array_list
|
||||
|
@ -176,7 +181,7 @@ compound_statement
|
|||
;
|
||||
|
||||
selection_statement
|
||||
: TOKEN_IF prim_expr[exp] statement[stmt] { $$ = node3(ENUM_if_statement, $exp, $stmt, TOKPOS(@1)); }
|
||||
: TOKEN_IF prim_expr[exp] statement[stmt] %prec THEN { $$ = node3(ENUM_if_statement, $exp, $stmt, TOKPOS(@1)); }
|
||||
| TOKEN_IF prim_expr[exp] statement[if_stmt] TOKEN_ELSE statement[else_stmt] { $$ = node4(ENUM_if_else_statement, $exp, $if_stmt, $else_stmt, TOKPOS(@1)); }
|
||||
| TOKEN_SWITCH prim_expr[exp] compound_statement[comp_stmt] { $$ = node3(ENUM_switch, $exp, $comp_stmt, TOKPOS(@1)); }
|
||||
;
|
||||
|
@ -279,8 +284,13 @@ identifier
|
|||
| TOKEN_STRING { $$ = $1; @$ = @1; }
|
||||
;
|
||||
|
||||
listener_identifier
|
||||
: identifier_prim { $$ = node2(ENUM_string, $1, TOKPOS(@1)); }
|
||||
| TOKEN_LEFT_BRACKET expr TOKEN_RIGHT_BRACKET { $$ = $2; }
|
||||
;
|
||||
|
||||
nonident_prim_expr
|
||||
: TOKEN_DOLLAR prim_expr { $$ = node3(ENUM_func1_expr, node1b(OP_UN_TARGETNAME), $2, TOKPOS(@1)); }
|
||||
: TOKEN_DOLLAR listener_identifier { $$ = node3(ENUM_func1_expr, node1b(OP_UN_TARGETNAME), $2, TOKPOS(@1)); }
|
||||
| nonident_prim_expr TOKEN_PERIOD identifier { $$ = node3(ENUM_field, $1, $3, TOKPOS(@3)); }
|
||||
| nonident_prim_expr TOKEN_PERIOD TOKEN_SIZE { $$ = node3(ENUM_func1_expr, node1b(OP_UN_SIZE), $1, TOKPOS(@3)); }
|
||||
| nonident_prim_expr TOKEN_LEFT_SQUARE_BRACKET expr TOKEN_RIGHT_SQUARE_BRACKET { $$ = node3(ENUM_array_expr, $1, $3, TOKPOS(@2)); }
|
||||
|
@ -290,6 +300,7 @@ nonident_prim_expr
|
|||
| TOKEN_LEFT_BRACKET expr[exp1] expr[exp2] expr[exp3] TOKEN_RIGHT_BRACKET { $$ = node4(ENUM_vector, $exp1, $exp2, $exp3, TOKPOS(@1)); }
|
||||
| TOKEN_LISTENER { $$ = node2(ENUM_listener, $1, TOKPOS(@1)); }
|
||||
| TOKEN_LEFT_BRACKET expr TOKEN_RIGHT_BRACKET { $$ = $2; }
|
||||
| TOKEN_LEFT_BRACKET expr TOKEN_EOL TOKEN_RIGHT_BRACKET { $$ = $2; }
|
||||
| func_expr nonident_prim_expr { $$ = node3(ENUM_func1_expr, $1, $2, TOKPOS(@1)); }
|
||||
| TOKEN_NOT nonident_prim_expr { $$ = node2(ENUM_bool_not, $2, TOKPOS(@1)); }
|
||||
| TOKEN_NULL { $$ = node1(ENUM_NULL, TOKPOS(@1)); }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue