This commit is contained in:
IlyaShurupov 2024-03-05 19:40:38 +03:00 committed by Ilusha
parent ed3421321c
commit ad543c304d
3 changed files with 1177 additions and 878 deletions

View file

@ -158,29 +158,12 @@ void bind(LalrParser& parser) {
BIND(stm_var_def_assign); BIND(stm_var_def_assign);
BIND(stm_log); BIND(stm_log);
BIND(stm_assign); BIND(stm_assign);
stm_while_loop stm_return stm_break BIND(expr_function) BIND(expr_method) BIND(expr_child) BIND(expr_bool_eq)
BIND(expr_bool_negate) BIND(expr_bool_neq) BIND(expr_bool_grater) BIND(expr_bool_lesser) BIND(expr_bool_grater_eq)
BIND(expr_bool_lesser_eq) BIND(expr_add) BIND(expr_subtract) BIND(expr_multiply) BIND(expr_divide)
BIND(expr_compound) BIND(expr_bool) BIND(expr_int) BIND(expr_float) BIND(expr_string) BIND(expr_id)
BIND(expr_function) BIND(tmp)
BIND(expr_method)
BIND(expr_child)
BIND(expr_bool_eq)
BIND(expr_bool_negate)
BIND(expr_bool_neq)
BIND(expr_bool_grater)
BIND(expr_bool_lesser)
BIND(expr_bool_grater_eq)
BIND(expr_bool_lesser_eq)
BIND(expr_add)
BIND(expr_subtract)
BIND(expr_multiply)
BIND(expr_divide)
BIND(expr_compound)
BIND(expr_bool)
BIND(expr_int)
BIND(expr_float)
BIND(expr_string)
BIND(expr_id)
BIND(tmp) parser.set_lexer_action_handler("string", &lalr::string_literal<IteratorType>);
parser.set_lexer_action_handler("string", &lalr::string_literal<IteratorType>);
} }

File diff suppressed because it is too large Load diff

View file

@ -7,6 +7,9 @@ oscript {
%left '*' '/'; %left '*' '/';
%left '.' '='; %left '.' '=';
%left '==' '>' '<' '>=' '<=' '!=' '!'; %left '==' '>' '<' '>=' '<=' '!=' '!';
%left ';';
script : stmts [tmp];
scope: scope:
'{' stmts '}' [scope] '{' stmts '}' [scope]
@ -22,8 +25,24 @@ oscript {
| stm_var_def_assign [tmp] | stm_var_def_assign [tmp]
| stm_log [tmp] | stm_log [tmp]
| stm_assign [tmp] | stm_assign [tmp]
| stm_while [tmp]
| stm_return [tmp]
| stm_break [tmp]
| stm_if [tmp]
| stm_def_class [tmp]
; ;
stm_def_method: 'class' id scope [stm_def_class];
stm_def_class: 'class' id scope [stm_def_class];
stm_if:
'if' '(' expr ')' scope [stm_if]
| 'if' '(' expr ')' scope 'else' scope [stm_if];
stm_break: 'break' [stm_break];
stm_return: 'return' expr [stm_return] | 'return' [stm_return];
stm_while: 'while' '(' expr ')' scope [stm_while_loop];
stm_var_def_new_type: 'var' id ':' id [stm_var_def_new_type]; stm_var_def_new_type: 'var' id ':' id [stm_var_def_new_type];
stm_var_def_assign: 'var' id '=' expr [stm_var_def_assign]; stm_var_def_assign: 'var' id '=' expr [stm_var_def_assign];
stm_log: 'print' expr [stm_log]; stm_log: 'print' expr [stm_log];