diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-03-09 20:27:37 +0200 | 
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-03-09 20:27:37 +0200 | 
| commit | edf56e3444d5333d4362277ee97a5cdf0c2f52af (patch) | |
| tree | 48c2dd4120025a573b4d0fee6a4a9042e3d6ab95 /src | |
| parent | 8ee9c16bfb4090cab4a330915a373047d82bc459 (diff) | |
| download | posthaste-edf56e3444d5333d4362277ee97a5cdf0c2f52af.tar.gz posthaste-edf56e3444d5333d4362277ee97a5cdf0c2f52af.zip | |
phase 2 checked against examples
Diffstat (limited to 'src')
| -rw-r--r-- | src/parser.y | 14 | 
1 files changed, 11 insertions, 3 deletions
| 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; +	}  %% | 
