List of usage examples for org.antlr.v4.runtime.misc Pair Pair
public Pair(A a, B b)
From source file:com.sample.JavaErrorStrategy.java
License:BSD License
/** * Conjure up a missing token during error recovery. * * The recognizer attempts to recover from single missing symbols. But, * actions might refer to that missing symbol. For example, x=ID {f($x);}. * The action clearly assumes that there has been an identifier matched * previously and that $x points at that token. If that token is missing, * but the next token in the stream is what we want we assume that this * token is missing and we keep going. Because we have to return some token * to replace the missing token, we have to conjure one up. This method * gives the user control over the tokens returned for missing tokens. * Mostly, you will want to create something special for identifier tokens. * For literals such as '{' and ',', the default action in the parser or * tree parser works. It simply creates a CommonToken of the appropriate * type. The text will be the token. If you change what tokens must be * created by the lexer, override this method to create the appropriate * tokens.// www . j av a 2s . c om */ @NotNull protected Token getMissingSymbol(@NotNull Parser recognizer) { Token currentSymbol = recognizer.getCurrentToken(); IntervalSet expecting = getExpectedTokens(recognizer); int expectedTokenType = expecting.getMinElement(); // get any element String tokenText; if (expectedTokenType == Token.EOF) tokenText = "<missing EOF>"; else tokenText = "<missing " + recognizer.getTokenNames()[expectedTokenType] + ">"; Token current = currentSymbol; Token lookback = recognizer.getInputStream().LT(-1); if (current.getType() == Token.EOF && lookback != null) { current = lookback; } return recognizer.getTokenFactory() .create(new Pair<TokenSource, CharStream>(current.getTokenSource(), current.getTokenSource().getInputStream()), expectedTokenType, tokenText, Token.DEFAULT_CHANNEL, -1, -1, current.getLine(), current.getCharPositionInLine()); }
From source file:de.vandermeer.skb.commons.collections.FlatMultiTable.java
License:Apache License
@Override public boolean columnValue(Object row, Object column, E value) { String key = Table.tableJoiner.transform(new Pair<Object, Object>(row, column)).toString(); if (this.sval.containsKey(key)) { if (this.sval.get(key) != null) { this.sval.get(key).add(value); } else {/* w ww . j ava 2s . c om*/ ComCollection<E> coll = new ComCollection<E>(); coll.add(value); this.sval.put(key, coll); } return true; } return false; }
From source file:de.vandermeer.skb.commons.collections.FlatMultiTable.java
License:Apache License
@Override public boolean contains(Object row) { return this.sval.containsKey(Table.tableJoiner.transform(new Pair<Object, Object>(null, row)).toString()); }
From source file:de.vandermeer.skb.commons.collections.FlatMultiTable.java
License:Apache License
@Override public boolean contains(Object row, Object column) { return this.sval.containsKey(Table.tableJoiner.transform(new Pair<Object, Object>(row, column)).toString()); }
From source file:de.vandermeer.skb.commons.collections.FlatMultiTable.java
License:Apache License
@Override public Map<String, E> get(Object row) { Map<String, E> ret = new HashMap<String, E>(); Collection<String> columns = IsPath.GET_SUB_PATHS(Table.defaulSeparator, Table.tableJoiner.transform(new Pair<Object, Object>(null, row)), this.sval.keySet()); for (String s : columns) { if (this.sval.get(s) == null) { ret.put(s, null);/*w ww .ja va 2 s .c om*/ } else { ret.put(s, this.sval.get(s).getFirst()); } } return ret; }
From source file:de.vandermeer.skb.commons.collections.FlatMultiTable.java
License:Apache License
@Override public E get(Object row, Object column) { ComCollection<E> coll = this.sval .get(Table.tableJoiner.transform(new Pair<Object, Object>(row, column)).toString()); if (coll != null) { return coll.getFirst(); }/*from w w w . j a v a 2s .c o m*/ return null; }
From source file:de.vandermeer.skb.commons.collections.FlatMultiTable.java
License:Apache License
/** * Returns the values of a cell identified by row and column * @param row row of the cell/*w ww. j av a2 s. co m*/ * @param column column of the cell * @return collection of values of the cell */ public Collection<E> getMulti(Object row, Object column) { return this.sval.get(Table.tableJoiner.transform(new Pair<Object, Object>(row, column)).toString()); }
From source file:de.vandermeer.skb.commons.collections.FlatMultiTable.java
License:Apache License
/** * Returns a complete row will all columns and asociated values. * @param row row identifier//from www .j ava 2 s.co m * @return complete row */ public Map<String, ComCollection<E>> getRow(Object row) { Map<String, ComCollection<E>> ret = new HashMap<String, ComCollection<E>>(); Collection<String> columns = IsPath.GET_SUB_PATHS(Table.defaulSeparator, Table.tableJoiner.transform(new Pair<Object, Object>(null, row)), this.sval.keySet()); for (String s : columns) { ret.put(s, this.sval.get(s)); } return ret; }
From source file:de.vandermeer.skb.commons.collections.FlatMultiTree.java
License:Apache License
@Override public boolean containsNode(Object fqpn) { return this.sval.containsKey(Tree.treeJoiner.transform(new Pair<Object, Object>(null, fqpn)).toString()); }
From source file:de.vandermeer.skb.commons.collections.FlatMultiTree.java
License:Apache License
@Override public boolean containsNode(Object path, Object name) { return this.sval.containsKey(Tree.treeJoiner.transform(new Pair<Object, Object>(path, name)).toString()); }