From 534f174303fdb928b923d8e8de098b768e8f42ed Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Sat, 7 May 2016 18:39:26 +0200 Subject: grammar: remove EBNF constructs I guess that this satisfies "A description of the grammar resulting from the transformation to remove EBNF constructs". It does not mention something about the left-associativity and priority rules, that is probably the next step. --- grammar.txt | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/grammar.txt b/grammar.txt index 0a7a66e..fe6b235 100644 --- a/grammar.txt +++ b/grammar.txt @@ -1,8 +1,12 @@ start-symbol PROGRAM context-free syntax - PROGRAM ::= "begin" DECLS "|" (STATEMENT ";")* "end" - DECLS ::= "declare" (ID ",")* + PROGRAM ::= "begin" DECLS "|" STATEMENTS "end" + DECLS ::= "declare" IDLIST + STATEMENTS ::= STATEMENT ";" + STATEMENTS ::= + IDLIST ::= ID "," + IDLIST ::= context-free syntax STATEMENT ::= ID ":=" EXP @@ -16,13 +20,20 @@ context-free syntax EXP ::= "(" EXP ")" lexical syntax - ID ::= [a-z][a-z0-9]* + ID ::= [a-z] ID' + ID' ::= [a-z0-9] ID' + ID' ::= lexical syntax - NAT ::= [0] | [1-9][0-9]* + NAT ::= [0] + NAT ::= [1-9] NAT' + NAT' ::= [0-9] NAT' + NAT' ::= lexical syntax - LAYOUT ::= [\ \n]* + LAYOUT ::= " " LAYOUT + LAYOUT ::= "\n" LAYOUT + LAYOUT ::= context-free priorities EXP ::= "-" EXP > -- cgit v1.2.1