This commit is contained in:
IlyaShurupov 2024-03-05 19:40:38 +03:00 committed by Ilya Shurupov
parent 8dc73bc1d5
commit 505b77da3f
3 changed files with 1177 additions and 878 deletions

View file

@ -158,27 +158,10 @@ void bind(LalrParser& parser) {
BIND(stm_var_def_assign);
BIND(stm_log);
BIND(stm_assign);
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)
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(tmp)

File diff suppressed because it is too large Load diff

View file

@ -7,6 +7,9 @@ oscript {
%left '*' '/';
%left '.' '=';
%left '==' '>' '<' '>=' '<=' '!=' '!';
%left ';';
script : stmts [tmp];
scope:
'{' stmts '}' [scope]
@ -22,8 +25,24 @@ oscript {
| stm_var_def_assign [tmp]
| stm_log [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_assign: 'var' id '=' expr [stm_var_def_assign];
stm_log: 'print' expr [stm_log];