Factor NEWLINE at statement level.

This commit is contained in:
Stefano Sanfilippo 2014-11-23 19:12:48 +01:00
parent 65b38e33c2
commit 573a94def6

View File

@ -63,14 +63,14 @@ main:
MAIN NEWLINE statements MAIN NEWLINE statements
; ;
statements: statements:
/* epsilon */ | statements statement NEWLINE | statements statement NEWLINE
; ;
statement: statement:
var_decl | assign_stmt | print_stmt | input_stmt | return_stmt | var_decl | assign_stmt | print_stmt | input_stmt | return_stmt |
loop_stmt | branch_stmt | fun_call | abort_stmt | assert_stmt loop_stmt | branch_stmt | fun_call | abort_stmt | assert_stmt
; ;
var_decl: var_decl:
VARDECL pointer ID COMMA TYPENAME var_init NEWLINE VARDECL pointer ID COMMA TYPENAME var_init
; ;
pointer: pointer:
/* epsilon */ | STAR /* epsilon */ | STAR
@ -85,7 +85,7 @@ variable:
ID | ARTICLE ID ID | ARTICLE ID
; ;
assign_stmt: assign_stmt:
ID ASSIGN expression NEWLINE ID ASSIGN expression
; ;
print_stmt: print_stmt:
expression PRINT expression PRINT
@ -94,7 +94,7 @@ input_stmt:
INPUT variable INPUT variable
; ;
return_stmt: return_stmt:
RETURN NEWLINE | RETURN expression NEWLINE; RETURN | RETURN expression
; ;
loop_stmt: loop_stmt:
LOOP_BEGIN statements LOOP_CONDITION expression LOOP_BEGIN statements LOOP_CONDITION expression
@ -106,19 +106,19 @@ branch_stmt:
; ;
branch_body: branch_body:
cases %prec LOWER_THAN_ELSE | cases %prec LOWER_THAN_ELSE |
cases BRANCH_ELSE COLON statements cases BRANCH_ELSE COLON NEWLINE statements
; ;
cases: cases:
case_stmt | case_stmt cases case_stmt | case_stmt cases
; ;
case_stmt: case_stmt:
case_hp COLON statements case_hp COLON NEWLINE statements
; ;
case_hp: case_hp:
numeric | variable numeric | variable
; ;
fun_call: fun_call:
FUNCALL ID args NEWLINE | FUNCALL ID NEWLINE FUNCALL ID args | FUNCALL ID
; ;
abort_stmt: abort_stmt:
ABORT { ABORT {