From 7694728a2104abfdd6fd10ed86667fc92bd13d71 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 13 Nov 2024 17:49:38 -0800 Subject: [PATCH] 11 13 24 5 49 --- lab-4/parser.bison | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/lab-4/parser.bison b/lab-4/parser.bison index 9b42942..62b7693 100644 --- a/lab-4/parser.bison +++ b/lab-4/parser.bison @@ -108,14 +108,16 @@ op_parm : mathmaticalexpr | booleanexpr | type_expr ; -term : mathmaticalexpr +term : mathmaticalexpr + ; +math_op : TOKEN_ADD + | TOKEN_SUB + | TOKEN_MULTIPLY + | TOKEN_DIVIDE + | TOKEN_EXPONENTIAL ; mathmaticalexpr : type_expr - | mathmaticalexpr TOKEN_ADD term - | mathmaticalexpr TOKEN_SUB term - | mathmaticalexpr TOKEN_MULTIPLY term - | mathmaticalexpr TOKEN_DIVIDE term - | mathmaticalexpr TOKEN_EXPONENTIAL term + | mathmaticalexpr math_op term | container_expr | type_expr container_expr ; @@ -139,8 +141,8 @@ cbl_function : TOKEN_DISPLAY ; if_branch : TOKEN_IF booleanexpr ; -else_parts : TOKEN_ELSE_IF booleanexpr statements - | TOKEN_ELSE statements +else_parts : TOKEN_ELSE_IF booleanexpr simple_stmt + | TOKEN_ELSE simple_stmt | 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