Java Code Examples for org.antlr.v4.runtime.Vocabulary#getMaxTokenType()
The following examples show how to use
org.antlr.v4.runtime.Vocabulary#getMaxTokenType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Identifiers.java From crate with Apache License 2.0 | 6 votes |
private static Set<Keyword> identifierCandidates() { HashSet<Keyword> candidates = new HashSet<>(); Vocabulary vocabulary = SqlBaseLexer.VOCABULARY; for (int i = 0; i < vocabulary.getMaxTokenType(); i++) { String literal = vocabulary.getLiteralName(i); if (literal == null) { continue; } literal = literal.replace("'", ""); Matcher matcher = IDENTIFIER.matcher(literal.toLowerCase(Locale.ENGLISH)); if (matcher.matches()) { candidates.add(new Keyword(literal, reserved(literal))); } } return candidates; }
Example 2
Source File: ReservedIdentifiers.java From presto with Apache License 2.0 | 5 votes |
public static Set<String> sqlKeywords() { ImmutableSet.Builder<String> names = ImmutableSet.builder(); Vocabulary vocabulary = SqlBaseLexer.VOCABULARY; for (int i = 0; i <= vocabulary.getMaxTokenType(); i++) { String name = nullToEmpty(vocabulary.getLiteralName(i)); Matcher matcher = IDENTIFIER.matcher(name); if (matcher.matches()) { names.add(matcher.group(1)); } } return names.build(); }
Example 3
Source File: ReservedIdentifiers.java From rainbow with Apache License 2.0 | 5 votes |
private static Set<String> possibleIdentifiers() { ImmutableSet.Builder<String> names = ImmutableSet.builder(); Vocabulary vocabulary = SqlBaseLexer.VOCABULARY; for (int i = 0; i <= vocabulary.getMaxTokenType(); i++) { String name = nullToEmpty(vocabulary.getLiteralName(i)); Matcher matcher = IDENTIFIER.matcher(name); if (matcher.matches()) { names.add(matcher.group(1)); } } return names.build(); }