only 13 shift/reduce

This commit is contained in:
Josh 2024-11-13 19:23:10 -08:00
parent 75e28de83c
commit f85d4c3599
1 changed files with 19 additions and 29 deletions

View File

@ -61,9 +61,6 @@ int yylex();
%token TOKEN_WORKING_STORAGE %token TOKEN_WORKING_STORAGE
%token TOKEN_EOF %token TOKEN_EOF
%left TOKEN_ADD TOKEN_SUB
%left TOKEN_MULTIPLY TOKEN_DIVIDE
%right TOKEN_EXPONENTIAL
%% %%
@ -95,47 +92,34 @@ simple_stmt : cbl_func_stmt
| else_parts | else_parts
| perform_stmt | perform_stmt
; ;
cbl_func_stmt : display_stmt cbl_func_stmt : cbl_function
| move_stmt | cbl_function op_parms
| compute_stmt | cbl_function assignment_stmt
| cbl_function op_parm assignment_stmt
; ;
display_stmt : TOKEN_DISPLAY op_parms_list assignment_stmt : TOKEN_EQUAL op_parms
| TOKEN_KEYWORD_TO op_parms
; ;
move_stmt : TOKEN_MOVE op_parms_list assignment_stmt op_parms : op_parm
; | op_parms op_parm
compute_stmt : TOKEN_KEYWORD_COMPUTE op_parms_list assignment_stmt
;
assignment_stmt : TOKEN_EQUAL ext_function
| TOKEN_EQUAL op_parms_list
| TOKEN_KEYWORD_TO op_parms_list
;
op_parms_list : op_parm
| op_parms_list op_parm
; ;
op_parm : mathmaticalexpr op_parm : mathmaticalexpr
| booleanexpr | booleanexpr
| type_expr
; ;
term : mathmaticalexpr term : mathmaticalexpr
; ;
math_op : TOKEN_ADD math_op : TOKEN_ADD
| TOKEN_SUB | TOKEN_SUB
| TOKEN_MULTIPLY | TOKEN_MULTIPLY
| TOKEN_DIVIDE | TOKEN_DIVIDE
| TOKEN_EXPONENTIAL | TOKEN_EXPONENTIAL
; ;
mathmaticalexpr : primary_expr mathmaticalexpr : type_expr
| mathmaticalexpr math_op term | mathmaticalexpr math_op term
| container_expr
| type_expr container_expr
; ;
full_contain : simple_contain container_expr : TOKEN_LEFT_PARENTHESIS mathmaticalexpr TOKEN_RIGHT_PARENTHESIS
| TOKEN_IDENT simple_contain
;
simple_contain : TOKEN_LEFT_PARENTHESIS mathmaticalexpr TOKEN_RIGHT_PARENTHESIS
;
primary_expr : type_expr
| full_contain
| TOKEN_SUB primary_expr
; ;
booleanexpr : mathmaticalexpr TOKEN_LESS_THAN term booleanexpr : mathmaticalexpr TOKEN_LESS_THAN term
| mathmaticalexpr TOKEN_GREATER_THAN term | mathmaticalexpr TOKEN_GREATER_THAN term
@ -145,16 +129,22 @@ type_expr : TOKEN_IDENT
| TOKEN_INTEGER | TOKEN_INTEGER
| TOKEN_STRING | TOKEN_STRING
| TOKEN_SPACE | TOKEN_SPACE
| TOKEN_SUB TOKEN_IDENT
| ext_function
; ;
ext_function : TOKEN_KEYWORD_FUNCTION TOKEN_IDENT TOKEN_LEFT_PARENTHESIS TOKEN_IDENT TOKEN_RIGHT_PARENTHESIS ext_function : TOKEN_KEYWORD_FUNCTION TOKEN_IDENT TOKEN_LEFT_PARENTHESIS TOKEN_IDENT TOKEN_RIGHT_PARENTHESIS
; ;
cbl_function : TOKEN_DISPLAY
| TOKEN_MOVE
| TOKEN_KEYWORD_COMPUTE
;
if_branch : TOKEN_IF booleanexpr if_branch : TOKEN_IF booleanexpr
; ;
else_parts : TOKEN_ELSE_IF booleanexpr simple_stmt else_parts : TOKEN_ELSE_IF booleanexpr simple_stmt
| TOKEN_ELSE simple_stmt | TOKEN_ELSE simple_stmt
| TOKEN_END_IF | TOKEN_END_IF
; ;
perform_stmt : TOKEN_PERFORM TOKEN_VARYING TOKEN_IDENT TOKEN_KEYWORD_FROM TOKEN_INTEGER TOKEN_KEYWORD_BY TOKEN_INTEGER TOKEN_UNTIL op_parms_list perform_stmt : TOKEN_PERFORM TOKEN_VARYING TOKEN_IDENT TOKEN_KEYWORD_FROM TOKEN_INTEGER TOKEN_KEYWORD_BY TOKEN_INTEGER TOKEN_UNTIL op_parms
| TOKEN_END_PERFORM | TOKEN_END_PERFORM
; ;
data_space : TOKEN_WORKING_STORAGE TOKEN_KEYWORD_SECTION TOKEN_DOT data_space : TOKEN_WORKING_STORAGE TOKEN_KEYWORD_SECTION TOKEN_DOT