From b42098ef8cc477459d1926bf08bd8400c6ecbfea Mon Sep 17 00:00:00 2001
From: Peter Wu
Date: Sat, 7 May 2016 20:04:10 +0200
Subject: Attempt to convert grammar to LL(1)
Needs more verification, but the idea is that the expressions with
lowest precedence (+) should be the first one in the parse tree
(implying that nonterminals with highest precedence should be just
above a terminal).
Leftassociativity is achieved by the trick in section 2.3.1 of
Intro2CD which results in the left operand being recursed instead of the
right one.

grammarll1.txt  19 ++++++++
1 file changed, 8 insertions(+), 11 deletions()
diff git a/grammarll1.txt b/grammarll1.txt
index 9487bd1..23c1abf 100644
 a/grammarll1.txt
+++ b/grammarll1.txt
@@ 12,12 +12,14 @@ contextfree syntax
STATEMENT ::= ID ":=" EXP
contextfree syntax
 EXP ::= ID
 EXP ::= NAT
 EXP ::= EXP "+" EXP {left}
 EXP ::= EXP "*" EXP {left}
 EXP ::= "" EXP
 EXP ::= "(" EXP ")"
+ EXP ::= EXP "+" PRODEXP
+ EXP ::= PRODEXP
+ PRODEXP ::= EXP "*" SINGLEEXP
+ PRODEXP ::= SINGLEEXP
+ SINGLEEXP ::= "" EXP
+ SINGLEEXP ::= ID
+ SINGLEEXP ::= NAT
+ SINGLEEXP ::= "(" EXP ")"
lexical syntax
ID ::= [az] ID'
@@ 34,8 +36,3 @@ lexical syntax
LAYOUT ::= " " LAYOUT
LAYOUT ::= "\n" LAYOUT
LAYOUT ::=

contextfree priorities
 EXP ::= "" EXP >
 EXP ::= EXP "*" EXP >
 EXP ::= EXP "+" EXP

cgit v1.2.1