Skip to content
Snippets Groups Projects
Commit db582cda authored by dgelessus's avatar dgelessus
Browse files

Inline a few local variables in generated Parser

parent 22f56113
Branches
Tags
No related merge requests found
...@@ -178,11 +178,9 @@ public class Parser implements IParser ...@@ -178,11 +178,9 @@ public class Parser implements IParser
switch(action) switch(action)
{ {
case SHIFT: case SHIFT:
{ push(destination, Collections.singletonList(this.lexer.next()));
List<?> list = Collections.singletonList(this.lexer.next());
push(destination, list);
}
break; break;
case REDUCE: case REDUCE:
switch(destination) switch(destination)
{ {
...@@ -1804,13 +1802,12 @@ public class Parser implements IParser ...@@ -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()); throw new ParserException(lastToken, "[" + lastToken.getLine() + "," + lastToken.getPos() + "] Internal parser error: invalid action table REDUCE destination " + destination + ", current state " + state());
} }
break; break;
case ACCEPT: case ACCEPT:
{ EOF eof = (EOF) this.lexer.next();
EOF node2 = (EOF) this.lexer.next(); PGrammar top = (PGrammar) pop().get(0);
PGrammar node1 = (PGrammar) pop().get(0); return new Start(top, eof);
Start node = new Start(node1, node2);
return node;
}
case ERROR: case ERROR:
throw new ParserException(lastToken, throw new ParserException(lastToken,
"[" + lastToken.getLine() + "," + lastToken.getPos() + "] " , "[" + lastToken.getLine() + "," + lastToken.getPos() + "] " ,
......
...@@ -186,11 +186,9 @@ public class Parser implements IParser ...@@ -186,11 +186,9 @@ public class Parser implements IParser
switch(action) switch(action)
{ {
case SHIFT: case SHIFT:
{ push(destination, Collections.singletonList(this.lexer.next()));
List<?> list = Collections.singletonList(this.lexer.next());
push(destination, list);
}
break; break;
case REDUCE: case REDUCE:
switch(destination) switch(destination)
{ {
...@@ -212,13 +210,12 @@ Macro:ParserParseTail ...@@ -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()); throw new ParserException(lastToken, "[" + lastToken.getLine() + "," + lastToken.getPos() + "] Internal parser error: invalid action table REDUCE destination " + destination + ", current state " + state());
} }
break; break;
case ACCEPT: case ACCEPT:
{ EOF eof = (EOF) this.lexer.next();
EOF node2 = (EOF) this.lexer.next(); $0$ top = ($0$) pop().get(0);
$0$ node1 = ($0$) pop().get(0); return new Start(top, eof);
Start node = new Start(node1, node2);
return node;
}
case ERROR: case ERROR:
throw new ParserException(lastToken, throw new ParserException(lastToken,
"[" + lastToken.getLine() + "," + lastToken.getPos() + "] " , "[" + lastToken.getLine() + "," + lastToken.getPos() + "] " ,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment