/**
  * Answers {@code true} if the given terminal rule is synthetic. That is, the tokens for this rule
  * will not be produced by the generated Antlr lexer but manually in a custom token source.
  */
 public boolean isSyntheticTerminalRule(final TerminalRule rule) {
   AbstractElement _alternatives = rule.getAlternatives();
   if ((_alternatives instanceof Keyword)) {
     AbstractElement _alternatives_1 = rule.getAlternatives();
     String value = ((Keyword) _alternatives_1).getValue();
     TerminalRule _originalElement = AntlrGrammarGenUtil.<TerminalRule>getOriginalElement(rule);
     String _name = _originalElement.getName();
     String _plus = ("synthetic:" + _name);
     return Objects.equal(_plus, value);
   }
   return false;
 }
 public LookAheadTerminal createLookAheadTerminal(Token token) {
   Grammar grammar = getGrammar();
   String tokenName = getTokenNames()[token.getType()];
   tokenName = getValueForTokenName(tokenName);
   if (tokenName.charAt(0) == '\'') {
     LookaheadKeyword result = new LookaheadKeyword();
     result.setKeyword(tokenName.substring(1, tokenName.length() - 1));
     result.setToken(token);
     return result;
   }
   LookAheadTerminalRuleCall result = new LookAheadTerminalRuleCall();
   result.setToken(token);
   String ruleName = TokenTool.getLexerRuleName(tokenName);
   if (terminalRules == null) terminalRules = GrammarUtil.allTerminalRules(grammar);
   for (TerminalRule rule : terminalRules) {
     if (rule.getName().equalsIgnoreCase(ruleName)) {
       result.setRule(rule);
       return result;
     }
   }
   throw new IllegalArgumentException("tokenType " + token.getType() + " seems to be invalid.");
 }
 protected String _ruleName(final TerminalRule it) {
   String _name = it.getName();
   String _upperCase = _name.toUpperCase();
   return ("RULE_" + _upperCase);
 }