Skip to content

Commit

Permalink
Used record Key as key of ActionGoToTable
Browse files Browse the repository at this point in the history
  • Loading branch information
GiacomoCau committed Jan 15, 2022
1 parent a381c89 commit 1b258b4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/util/LRParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,15 @@ public class StateList extends ArrayList<S> {
}
}

public class ActionGoToTable extends LinkedHashMap<String, Object> {
private record Key(Integer state, String token) {}

public class ActionGoToTable extends LinkedHashMap<Key, Object> {
private static final long serialVersionUID = 1L;
public <T> T put(int state, String symbol, T t) {
return (T) put(state + '\0' + symbol, t);
return (T) put(new Key(state, symbol), t);
}
public <T> T get(int state, String symbol) {
return (T) get(state + '\0' + symbol);
return (T) get(new Key(state, symbol));
}
private int value(int state, String symbol) {
return switch (get(state, symbol)) { case null, default-> 0; case Integer i-> i; case Action a-> a.operand; };
Expand Down

0 comments on commit 1b258b4

Please sign in to comment.