diff --git a/src/main/java/org/sablecc/sablecc/parser/Parser.java b/src/main/java/org/sablecc/sablecc/parser/Parser.java index 1f17b9a1d837c17584c47365d80d63e39d145dfa..939999117e023a9bd968ce4567c06ec404a0a5bd 100644 --- a/src/main/java/org/sablecc/sablecc/parser/Parser.java +++ b/src/main/java/org/sablecc/sablecc/parser/Parser.java @@ -178,11 +178,9 @@ public class Parser implements IParser switch(action) { case SHIFT: - { - List<?> list = Collections.singletonList(this.lexer.next()); - push(destination, list); - } - break; + push(destination, Collections.singletonList(this.lexer.next())); + break; + case REDUCE: switch(destination) { @@ -1804,13 +1802,12 @@ public class Parser implements IParser throw new ParserException(lastToken, "[" + lastToken.getLine() + "," + lastToken.getPos() + "] Internal parser error: invalid action table REDUCE destination " + destination + ", current state " + state()); } break; + case ACCEPT: - { - EOF node2 = (EOF) this.lexer.next(); - PGrammar node1 = (PGrammar) pop().get(0); - Start node = new Start(node1, node2); - return node; - } + EOF eof = (EOF) this.lexer.next(); + PGrammar top = (PGrammar) pop().get(0); + return new Start(top, eof); + case ERROR: throw new ParserException(lastToken, "[" + lastToken.getLine() + "," + lastToken.getPos() + "] " , diff --git a/src/main/resources/org/sablecc/sablecc/parser.txt b/src/main/resources/org/sablecc/sablecc/parser.txt index 3d28b807dc5ac120e6ccbebb77c61aba7595c26f..1c23fcf47490a7758e6b01aa2d06b6891820f508 100644 --- a/src/main/resources/org/sablecc/sablecc/parser.txt +++ b/src/main/resources/org/sablecc/sablecc/parser.txt @@ -186,11 +186,9 @@ public class Parser implements IParser switch(action) { case SHIFT: - { - List<?> list = Collections.singletonList(this.lexer.next()); - push(destination, list); - } - break; + push(destination, Collections.singletonList(this.lexer.next())); + break; + case REDUCE: switch(destination) { @@ -212,13 +210,12 @@ Macro:ParserParseTail throw new ParserException(lastToken, "[" + lastToken.getLine() + "," + lastToken.getPos() + "] Internal parser error: invalid action table REDUCE destination " + destination + ", current state " + state()); } break; + case ACCEPT: - { - EOF node2 = (EOF) this.lexer.next(); - $0$ node1 = ($0$) pop().get(0); - Start node = new Start(node1, node2); - return node; - } + EOF eof = (EOF) this.lexer.next(); + $0$ top = ($0$) pop().get(0); + return new Start(top, eof); + case ERROR: throw new ParserException(lastToken, "[" + lastToken.getLine() + "," + lastToken.getPos() + "] " ,