From edf56e3444d5333d4362277ee97a5cdf0c2f52af Mon Sep 17 00:00:00 2001 From: Kimplul Date: Sat, 9 Mar 2024 20:27:37 +0200 Subject: phase 2 checked against examples --- gen/gen_parser.c | 311 +++++++++++++++++++++++++++++-------------------------- src/parser.y | 14 ++- 2 files changed, 174 insertions(+), 151 deletions(-) diff --git a/gen/gen_parser.c b/gen/gen_parser.c index 7375732..a1632fd 100644 --- a/gen/gen_parser.c +++ b/gen/gen_parser.c @@ -278,37 +278,38 @@ enum yysymbol_kind_t YYSYMBOL_YYACCEPT = 37, /* $accept */ YYSYMBOL_statement_list = 38, /* statement_list */ YYSYMBOL_definitions = 39, /* definitions */ - YYSYMBOL_variable_definition = 40, /* variable_definition */ - YYSYMBOL_variable_definitions = 41, /* variable_definitions */ - YYSYMBOL_opt_variable_definitions = 42, /* opt_variable_definitions */ - YYSYMBOL_return = 43, /* return */ - YYSYMBOL_opt_return = 44, /* opt_return */ - YYSYMBOL_function_definition = 45, /* function_definition */ - YYSYMBOL_procedure_definition = 46, /* procedure_definition */ - YYSYMBOL_formals = 47, /* formals */ - YYSYMBOL_opt_formals = 48, /* opt_formals */ - YYSYMBOL_formal_arg = 49, /* formal_arg */ - YYSYMBOL_procedure_call = 50, /* procedure_call */ - YYSYMBOL_arguments = 51, /* arguments */ - YYSYMBOL_opt_arguments = 52, /* opt_arguments */ - YYSYMBOL_assignment = 53, /* assignment */ - YYSYMBOL_lvalue = 54, /* lvalue */ - YYSYMBOL_rvalue = 55, /* rvalue */ - YYSYMBOL_print_statement = 56, /* print_statement */ - YYSYMBOL_print_items = 57, /* print_items */ - YYSYMBOL_print_item = 58, /* print_item */ - YYSYMBOL_statement = 59, /* statement */ - YYSYMBOL_until_statement = 60, /* until_statement */ - YYSYMBOL_unless_statement = 61, /* unless_statement */ - YYSYMBOL_expression = 62, /* expression */ - YYSYMBOL_simple_expr = 63, /* simple_expr */ - YYSYMBOL_term = 64, /* term */ - YYSYMBOL_factor = 65, /* factor */ - YYSYMBOL_atom = 66, /* atom */ - YYSYMBOL_function_call = 67, /* function_call */ - YYSYMBOL_unless_expression = 68, /* unless_expression */ - YYSYMBOL_opt_definitions = 69, /* opt_definitions */ - YYSYMBOL_program = 70 /* program */ + YYSYMBOL_definition = 40, /* definition */ + YYSYMBOL_variable_definition = 41, /* variable_definition */ + YYSYMBOL_variable_definitions = 42, /* variable_definitions */ + YYSYMBOL_opt_variable_definitions = 43, /* opt_variable_definitions */ + YYSYMBOL_return = 44, /* return */ + YYSYMBOL_opt_return = 45, /* opt_return */ + YYSYMBOL_function_definition = 46, /* function_definition */ + YYSYMBOL_procedure_definition = 47, /* procedure_definition */ + YYSYMBOL_formals = 48, /* formals */ + YYSYMBOL_opt_formals = 49, /* opt_formals */ + YYSYMBOL_formal_arg = 50, /* formal_arg */ + YYSYMBOL_procedure_call = 51, /* procedure_call */ + YYSYMBOL_arguments = 52, /* arguments */ + YYSYMBOL_opt_arguments = 53, /* opt_arguments */ + YYSYMBOL_assignment = 54, /* assignment */ + YYSYMBOL_lvalue = 55, /* lvalue */ + YYSYMBOL_rvalue = 56, /* rvalue */ + YYSYMBOL_print_statement = 57, /* print_statement */ + YYSYMBOL_print_items = 58, /* print_items */ + YYSYMBOL_print_item = 59, /* print_item */ + YYSYMBOL_statement = 60, /* statement */ + YYSYMBOL_until_statement = 61, /* until_statement */ + YYSYMBOL_unless_statement = 62, /* unless_statement */ + YYSYMBOL_expression = 63, /* expression */ + YYSYMBOL_simple_expr = 64, /* simple_expr */ + YYSYMBOL_term = 65, /* term */ + YYSYMBOL_factor = 66, /* factor */ + YYSYMBOL_atom = 67, /* atom */ + YYSYMBOL_function_call = 68, /* function_call */ + YYSYMBOL_unless_expression = 69, /* unless_expression */ + YYSYMBOL_opt_definitions = 70, /* opt_definitions */ + YYSYMBOL_program = 71 /* program */ }; typedef enum yysymbol_kind_t yysymbol_kind_t; @@ -354,7 +355,7 @@ static void yyerror(YYLTYPE *yylloc, void *lexer, struct parser *parser, const char *msg); -#line 358 "gen/gen_parser.c" +#line 359 "gen/gen_parser.c" #ifdef short @@ -679,18 +680,18 @@ union yyalloc #endif /* !YYCOPY_NEEDED */ /* YYFINAL -- State number of the termination state. */ -#define YYFINAL 26 +#define YYFINAL 29 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 140 +#define YYLAST 156 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 37 /* YYNNTS -- Number of nonterminals. */ -#define YYNNTS 34 +#define YYNNTS 35 /* YYNRULES -- Number of rules. */ -#define YYNRULES 69 +#define YYNRULES 72 /* YYNSTATES -- Number of states. */ -#define YYNSTATES 132 +#define YYNSTATES 136 /* YYMAXUTOK -- Last valid token kind. */ #define YYMAXUTOK 291 @@ -743,13 +744,14 @@ static const yytype_int8 yytranslate[] = /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_int16 yyrline[] = { - 0, 148, 148, 149, 152, 153, 154, 157, 160, 161, - 164, 165, 168, 171, 172, 175, 179, 184, 185, 188, - 189, 192, 195, 198, 199, 202, 203, 206, 209, 210, - 213, 214, 217, 220, 221, 224, 225, 228, 229, 230, - 231, 232, 233, 236, 239, 240, 243, 244, 245, 248, - 249, 250, 253, 254, 255, 258, 259, 260, 263, 264, - 265, 266, 267, 268, 269, 272, 275, 278, 279, 282 + 0, 148, 148, 149, 152, 153, 156, 157, 158, 161, + 164, 165, 168, 169, 172, 175, 176, 179, 183, 188, + 189, 192, 193, 196, 199, 202, 203, 206, 207, 210, + 213, 214, 217, 218, 221, 224, 225, 228, 229, 232, + 233, 234, 235, 236, 237, 240, 243, 244, 247, 248, + 249, 252, 253, 254, 257, 258, 259, 262, 263, 264, + 267, 268, 269, 270, 271, 272, 273, 276, 279, 282, + 283, 286, 287 }; #endif @@ -772,7 +774,7 @@ static const char *const yytname[] = "\"var\"", "\"is\"", "\"unless\"", "\"otherwise\"", "\"until\"", "\"do\"", "\"done\"", "\"procedure\"", "\"function\"", "\"return\"", "\"print\"", "\"end\"", "$accept", "statement_list", "definitions", - "variable_definition", "variable_definitions", + "definition", "variable_definition", "variable_definitions", "opt_variable_definitions", "return", "opt_return", "function_definition", "procedure_definition", "formals", "opt_formals", "formal_arg", "procedure_call", "arguments", "opt_arguments", @@ -789,12 +791,12 @@ yysymbol_name (yysymbol_kind_t yysymbol) } #endif -#define YYPACT_NINF (-17) +#define YYPACT_NINF (-21) #define yypact_value_is_default(Yyn) \ ((Yyn) == YYPACT_NINF) -#define YYTABLE_NINF (-1) +#define YYTABLE_NINF (-71) #define yytable_value_is_error(Yyn) \ 0 @@ -803,20 +805,20 @@ yysymbol_name (yysymbol_kind_t yysymbol) STATE-NUM. */ static const yytype_int8 yypact[] = { - 1, -4, 27, -1, -17, -17, -17, -17, -3, 47, - 31, 62, 60, 61, 84, -3, 83, 77, -17, -17, - -17, 75, -17, 79, -17, -17, -17, 83, 95, 95, - 96, 83, -16, -17, -17, 88, 98, 83, 59, 59, - -17, 5, 17, 22, -17, -17, -17, -17, -17, 94, - 5, 48, -3, 5, 100, -17, 99, 97, 101, -17, - -17, 106, 23, 83, 83, 111, 83, -2, -17, -17, - 83, 83, 83, 83, 83, 83, 77, 83, -17, 5, - -17, -17, 112, 85, 95, 85, -17, 83, -5, 5, - -17, 110, -17, 17, 17, 22, 22, -17, -17, -17, - 10, 109, 116, -17, 102, -17, 102, 5, -3, -17, - 83, -17, -17, 102, -17, 103, 104, 92, 0, -17, - -3, 48, -17, 83, 89, 90, -10, 105, 91, -17, - -17, -17 + 5, -21, 4, 51, 56, -21, 32, -21, -21, -21, + -3, 83, 81, 89, 95, -21, 97, 104, -3, 66, + 47, -21, -21, -21, 98, -21, 99, -21, -21, -21, + 66, 112, 112, 113, 66, -20, -21, -21, 105, 114, + 66, 86, 86, -21, 9, 3, 20, -21, -21, -21, + -21, -21, 106, 9, 12, -3, 9, 110, -21, 111, + 107, 115, -21, -21, 116, 65, 66, 66, 121, 66, + 57, -21, -21, 66, 66, 66, 66, 66, 66, 47, + 66, -21, 9, -21, -21, 122, 96, 112, 96, -21, + 66, -5, 9, -21, 123, -21, 3, 3, 20, 20, + -21, -21, -21, 59, 119, 126, -21, 109, -21, 109, + -21, -3, -21, -21, 66, -21, -21, 109, -21, 117, + 118, 108, 61, -21, -3, 12, -21, 66, 100, 101, + 27, 103, 120, -21, -21, -21 }; /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. @@ -824,123 +826,127 @@ static const yytype_int8 yypact[] = means the default is an error. */ static const yytype_int8 yydefact[] = { - 68, 0, 0, 0, 67, 6, 4, 5, 0, 0, - 0, 0, 0, 28, 0, 0, 0, 0, 69, 37, - 38, 0, 39, 3, 40, 41, 1, 0, 20, 20, - 0, 26, 0, 61, 60, 58, 0, 0, 0, 0, - 63, 42, 46, 49, 52, 57, 62, 35, 32, 34, - 36, 0, 0, 7, 0, 19, 0, 18, 0, 29, - 25, 0, 24, 0, 0, 0, 26, 0, 55, 56, - 0, 0, 0, 0, 0, 0, 0, 0, 27, 30, - 31, 2, 0, 14, 0, 0, 22, 0, 44, 43, - 59, 0, 64, 47, 48, 50, 51, 53, 54, 33, - 0, 0, 0, 13, 11, 17, 11, 23, 0, 65, - 0, 21, 12, 9, 10, 0, 0, 0, 0, 8, - 0, 0, 45, 0, 0, 0, 0, 0, 0, 66, - 16, 15 + 0, 72, 0, 0, 0, 69, 5, 8, 6, 7, + 0, 0, 0, 0, 0, 4, 30, 0, 0, 0, + 0, 71, 39, 40, 0, 41, 3, 42, 43, 1, + 0, 22, 22, 0, 28, 0, 63, 62, 60, 0, + 0, 0, 0, 65, 44, 48, 51, 54, 59, 64, + 37, 34, 36, 38, 0, 0, 9, 0, 21, 0, + 20, 0, 31, 27, 0, 26, 0, 0, 0, 28, + 0, 57, 58, 0, 0, 0, 0, 0, 0, 0, + 0, 29, 32, 33, 2, 0, 16, 0, 0, 24, + 0, 0, 45, 61, 0, 66, 49, 50, 52, 53, + 55, 56, 35, 0, 0, 0, 15, 13, 19, 13, + 25, 0, 46, 67, 0, 23, 14, 11, 12, 0, + 0, 0, 0, 10, 0, 0, 47, 0, 0, 0, + 0, 0, 0, 68, 18, 17 }; /* YYPGOTO[NTERM-NUM]. */ static const yytype_int16 yypgoto[] = { - -17, -11, -17, 128, 18, 26, 49, -17, -17, -17, - -17, 107, 51, -8, -17, 67, -17, -17, 19, -17, - 63, -17, -17, -17, -17, -15, -12, 2, -14, 38, - -17, -17, -17, -17 + -21, -14, 132, -21, 60, 23, 33, 53, -21, -21, + -21, -21, 124, 58, -10, 62, 77, -21, -21, 22, + -21, 69, -21, -21, -21, -21, -18, 25, 28, 34, + 64, -21, -21, -21, -21 }; /* YYDEFGOTO[NTERM-NUM]. */ static const yytype_int8 yydefgoto[] = { - 0, 18, 4, 113, 114, 115, 103, 104, 6, 7, - 55, 56, 57, 40, 60, 61, 20, 21, 78, 22, - 48, 49, 23, 24, 25, 50, 42, 43, 44, 45, - 46, 80, 8, 9 + 0, 21, 5, 6, 117, 118, 119, 106, 107, 8, + 9, 58, 59, 60, 43, 63, 64, 23, 24, 81, + 25, 51, 52, 26, 27, 28, 65, 45, 46, 47, + 48, 49, 83, 10, 11 }; /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If positive, shift that token. If negative, reduce the rule whose number is the opposite. If YYTABLE_NINF, syntax error. */ -static const yytype_uint8 yytable[] = +static const yytype_int16 yytable[] = { - 19, 41, 10, 13, 32, 14, 12, 19, 92, 70, - 71, 63, 53, 64, 70, 71, 62, 70, 71, 70, - 71, 129, 67, 108, 70, 71, 1, 15, 123, 70, - 71, 16, 17, 2, 3, 11, 79, 110, 72, 73, - 87, 81, 70, 71, 19, 74, 75, 26, 88, 89, - 27, 62, 33, 34, 35, 36, 14, 37, 93, 94, - 97, 98, 100, 33, 34, 35, 36, 14, 37, 38, - 39, 28, 107, 29, 95, 96, 68, 69, 77, 30, - 47, 33, 34, 35, 36, 14, 37, 33, 34, 35, - 36, 14, 37, 31, 51, 118, 52, 117, 38, 39, - 19, 54, 59, 65, 38, 39, 79, 66, 126, 124, - 76, 82, 19, 83, 84, 85, 86, 90, 101, 102, - 109, 111, 112, 122, 131, 127, 128, 1, 5, 120, - 121, 119, 116, 91, 106, 105, 58, 130, 0, 99, - 125 + 22, 44, 53, 16, 35, 17, 1, 66, 22, 67, + 12, -70, 56, -70, 73, 74, 36, 37, 38, 39, + 17, 40, 70, 111, 75, 76, 112, 18, 73, 74, + 2, 19, 20, 41, 42, -70, 82, 3, 4, -70, + -70, 84, 80, 77, 78, 22, 73, 74, 91, 92, + 50, 36, 37, 38, 39, 17, 40, 2, 133, 13, + 7, 53, 103, 14, 3, 4, 7, 95, 41, 42, + 36, 37, 38, 39, 17, 40, 73, 74, 73, 74, + 73, 74, 90, 29, 73, 74, 114, 41, 42, 127, + 36, 37, 38, 39, 17, 40, 122, 121, 96, 97, + 30, 22, 31, 98, 99, 71, 72, 82, 32, 130, + 128, 100, 101, 34, 22, 33, 55, 54, 57, 62, + 68, 85, 79, 69, 87, 86, 89, 93, 104, 88, + 105, 115, 116, 113, 2, 134, 131, 132, 15, 126, + 123, 109, 120, 124, 125, 108, 94, 129, 102, 0, + 0, 0, 110, 135, 0, 0, 61 }; static const yytype_int8 yycheck[] = { - 8, 16, 6, 6, 15, 8, 7, 15, 10, 19, - 20, 27, 27, 29, 19, 20, 31, 19, 20, 19, - 20, 31, 37, 28, 19, 20, 25, 30, 28, 19, - 20, 34, 35, 32, 33, 8, 51, 27, 21, 22, - 17, 52, 19, 20, 52, 23, 24, 0, 63, 64, - 19, 66, 4, 5, 6, 7, 8, 9, 70, 71, - 74, 75, 77, 4, 5, 6, 7, 8, 9, 21, - 22, 9, 87, 13, 72, 73, 38, 39, 30, 18, - 3, 4, 5, 6, 7, 8, 9, 4, 5, 6, - 7, 8, 9, 9, 19, 110, 17, 108, 21, 22, - 108, 6, 6, 15, 21, 22, 121, 9, 123, 120, - 16, 11, 120, 14, 17, 14, 10, 6, 6, 34, - 10, 12, 6, 31, 33, 36, 36, 25, 0, 26, - 26, 113, 106, 66, 85, 84, 29, 32, -1, 76, - 121 + 10, 19, 20, 6, 18, 8, 1, 27, 18, 29, + 6, 6, 30, 8, 19, 20, 4, 5, 6, 7, + 8, 9, 40, 28, 21, 22, 31, 30, 19, 20, + 25, 34, 35, 21, 22, 30, 54, 32, 33, 34, + 35, 55, 30, 23, 24, 55, 19, 20, 66, 67, + 3, 4, 5, 6, 7, 8, 9, 25, 31, 8, + 0, 79, 80, 7, 32, 33, 6, 10, 21, 22, + 4, 5, 6, 7, 8, 9, 19, 20, 19, 20, + 19, 20, 17, 0, 19, 20, 27, 21, 22, 28, + 4, 5, 6, 7, 8, 9, 114, 111, 73, 74, + 19, 111, 13, 75, 76, 41, 42, 125, 13, 127, + 124, 77, 78, 9, 124, 18, 17, 19, 6, 6, + 15, 11, 16, 9, 17, 14, 10, 6, 6, 14, + 34, 12, 6, 10, 25, 32, 36, 36, 6, 31, + 117, 88, 109, 26, 26, 87, 69, 125, 79, -1, + -1, -1, 90, 33, -1, -1, 32 }; /* YYSTOS[STATE-NUM] -- The symbol kind of the accessing symbol of state STATE-NUM. */ static const yytype_int8 yystos[] = { - 0, 25, 32, 33, 39, 40, 45, 46, 69, 70, - 6, 8, 7, 6, 8, 30, 34, 35, 38, 50, - 53, 54, 56, 59, 60, 61, 0, 19, 9, 13, - 18, 9, 38, 4, 5, 6, 7, 9, 21, 22, - 50, 62, 63, 64, 65, 66, 67, 3, 57, 58, - 62, 19, 17, 62, 6, 47, 48, 49, 48, 6, - 51, 52, 62, 27, 29, 15, 9, 62, 66, 66, - 19, 20, 21, 22, 23, 24, 16, 30, 55, 62, - 68, 38, 11, 14, 17, 14, 10, 17, 62, 62, - 6, 52, 10, 63, 63, 64, 64, 65, 65, 57, - 62, 6, 34, 43, 44, 49, 43, 62, 28, 10, - 27, 12, 6, 40, 41, 42, 42, 38, 62, 41, - 26, 26, 31, 28, 38, 55, 62, 36, 36, 31, - 32, 33 + 0, 1, 25, 32, 33, 39, 40, 41, 46, 47, + 70, 71, 6, 8, 7, 39, 6, 8, 30, 34, + 35, 38, 51, 54, 55, 57, 60, 61, 62, 0, + 19, 13, 13, 18, 9, 38, 4, 5, 6, 7, + 9, 21, 22, 51, 63, 64, 65, 66, 67, 68, + 3, 58, 59, 63, 19, 17, 63, 6, 48, 49, + 50, 49, 6, 52, 53, 63, 27, 29, 15, 9, + 63, 67, 67, 19, 20, 21, 22, 23, 24, 16, + 30, 56, 63, 69, 38, 11, 14, 17, 14, 10, + 17, 63, 63, 6, 53, 10, 64, 64, 65, 65, + 66, 66, 58, 63, 6, 34, 44, 45, 50, 44, + 52, 28, 31, 10, 27, 12, 6, 41, 42, 43, + 43, 38, 63, 42, 26, 26, 31, 28, 38, 56, + 63, 36, 36, 31, 32, 33 }; /* YYR1[RULE-NUM] -- Symbol kind of the left-hand side of rule RULE-NUM. */ static const yytype_int8 yyr1[] = { - 0, 37, 38, 38, 39, 39, 39, 40, 41, 41, - 42, 42, 43, 44, 44, 45, 46, 47, 47, 48, - 48, 49, 50, 51, 51, 52, 52, 53, 54, 54, - 55, 55, 56, 57, 57, 58, 58, 59, 59, 59, - 59, 59, 59, 60, 61, 61, 62, 62, 62, 63, - 63, 63, 64, 64, 64, 65, 65, 65, 66, 66, - 66, 66, 66, 66, 66, 67, 68, 69, 69, 70 + 0, 37, 38, 38, 39, 39, 40, 40, 40, 41, + 42, 42, 43, 43, 44, 45, 45, 46, 47, 48, + 48, 49, 49, 50, 51, 52, 52, 53, 53, 54, + 55, 55, 56, 56, 57, 58, 58, 59, 59, 60, + 60, 60, 60, 60, 60, 61, 62, 62, 63, 63, + 63, 64, 64, 64, 65, 65, 65, 66, 66, 66, + 67, 67, 67, 67, 67, 67, 67, 68, 69, 70, + 70, 71, 71 }; /* YYR2[RULE-NUM] -- Number of symbols on the right-hand side of rule RULE-NUM. */ static const yytype_int8 yyr2[] = { - 0, 2, 3, 1, 1, 1, 1, 4, 2, 1, - 1, 0, 2, 1, 0, 11, 11, 3, 1, 1, - 0, 4, 4, 3, 1, 1, 0, 3, 1, 3, - 1, 1, 2, 3, 1, 1, 1, 1, 1, 1, - 1, 1, 2, 4, 4, 7, 1, 3, 3, 1, - 3, 3, 1, 3, 3, 2, 2, 1, 1, 3, - 1, 1, 1, 1, 3, 4, 7, 1, 0, 2 + 0, 2, 3, 1, 2, 1, 1, 1, 1, 4, + 2, 1, 1, 0, 2, 1, 0, 11, 11, 3, + 1, 1, 0, 4, 4, 3, 1, 1, 0, 3, + 1, 3, 1, 1, 2, 3, 1, 1, 1, 1, + 1, 1, 1, 1, 2, 4, 5, 7, 1, 3, + 3, 1, 3, 3, 1, 3, 3, 2, 2, 1, + 1, 3, 1, 1, 1, 1, 3, 4, 7, 1, + 0, 2, 1 }; @@ -1799,14 +1805,23 @@ yyreduce: YY_REDUCE_PRINT (yyn); switch (yyn) { - case 68: /* opt_definitions: %empty */ -#line 279 "src/parser.y" + case 70: /* opt_definitions: %empty */ +#line 283 "src/parser.y" {} -#line 1806 "gen/gen_parser.c" +#line 1812 "gen/gen_parser.c" + break; + + case 72: /* program: error */ +#line 287 "src/parser.y" + { + /* make sure to catch parse errors */ + parser->failed = true; + } +#line 1821 "gen/gen_parser.c" break; -#line 1810 "gen/gen_parser.c" +#line 1825 "gen/gen_parser.c" default: break; } @@ -2035,7 +2050,7 @@ yyreturnlab: return yyresult; } -#line 284 "src/parser.y" +#line 292 "src/parser.y" #include "gen_lexer.inc" @@ -2127,7 +2142,7 @@ void parse(struct parser *p, const char *fname, const char *buf) // debugging, remember to reset yy_scan_string once the actual parser // runs - dump_lex(p); + //dump_lex(p); yy_scan_string(buf, p->lexer); yyparse(p->lexer, p); diff --git a/src/parser.y b/src/parser.y index ee1a026..3b69b06 100644 --- a/src/parser.y +++ b/src/parser.y @@ -149,6 +149,10 @@ statement_list | statement definitions + : definition definitions + | definition + +definition : function_definition | procedure_definition | variable_definition @@ -176,7 +180,7 @@ function_definition return opt_variable_definitions "is" rvalue "end" "function" procedure_definition - : "procedure" PROC_IDENT "(" opt_formals "}" + : "procedure" PROC_IDENT "{" opt_formals "}" opt_return opt_variable_definitions "is" statement_list "end" "procedure" @@ -195,7 +199,7 @@ procedure_call : PROC_IDENT "(" opt_arguments ")" arguments - : expression "," expression + : expression "," arguments | expression opt_arguments @@ -236,7 +240,7 @@ until_statement : "do" statement_list "until" expression unless_statement - : "do" statement_list "unless" expression + : "do" statement_list "unless" expression "done" | "do" statement_list "unless" expression "otherwise" statement_list "done" expression @@ -280,6 +284,10 @@ opt_definitions program : opt_definitions statement_list + | error { + /* make sure to catch parse errors */ + parser->failed = true; + } %% -- cgit v1.2.3