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

Skip generating Lexer state transitions that go to the same state

This saves a switch case for every non-transitioning state in a token's
state list. If a token has no state transitions at all (only a list of
allowed states), this eliminates the entire state transition switch.
parent 72848701
No related branches found
No related tags found
No related merge requests found
Pipeline #135415 passed
...@@ -73,13 +73,17 @@ public class Transitions extends DepthFirstAdapter ...@@ -73,13 +73,17 @@ public class Transitions extends DepthFirstAdapter
@Override @Override
public void outAStateList(AStateList node) public void outAStateList(AStateList node)
{ {
map.put(state, transition); if (!state.equals(transition)) {
map.put(state, transition);
}
} }
@Override @Override
public void outAStateListTail(AStateListTail node) public void outAStateListTail(AStateListTail node)
{ {
map.put(state, transition); if (!state.equals(transition)) {
map.put(state, transition);
}
} }
@Override @Override
......
...@@ -183,10 +183,6 @@ public class Lexer ...@@ -183,10 +183,6 @@ public class Lexer
case 0: case 0:
tok = new TPkgId(getText(acceptLength), startLine + 1, startPos + 1); tok = new TPkgId(getText(acceptLength), startLine + 1, startPos + 1);
switch(state.ordinal())
{
case 1: state = State.PACKAGE; break;
}
break; break;
case 1: case 1:
...@@ -257,7 +253,6 @@ public class Lexer ...@@ -257,7 +253,6 @@ public class Lexer
tok = new TSemicolon(startLine + 1, startPos + 1); tok = new TSemicolon(startLine + 1, startPos + 1);
switch(state.ordinal()) switch(state.ordinal())
{ {
case 0: state = State.NORMAL; break;
case 1: state = State.NORMAL; break; case 1: state = State.NORMAL; break;
} }
break; break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment