protected boolean hasSyntheticTerminalRule() { final Function1<TerminalRule, Boolean> _function = (TerminalRule it) -> { return Boolean.valueOf(this._syntheticTerminalDetector.isSyntheticTerminalRule(it)); }; return IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(this.getGrammar()), _function); }
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 = tokenName.substring(5); 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."); }
@Override 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."); }
/** * @since 2.4 * @nooverride This method is not intended to be re-implemented or extended by clients. * @noreference This method is not intended to be referenced by clients. */ protected void registerEFactoryConverters(Map<String, IValueConverter<Object>> converters) { for (ParserRule parserRule : allParserRules(getGrammar())) { if (isDatatypeRule(parserRule) && !converters.containsKey(parserRule.getName())) { EDataType datatype = (EDataType) parserRule.getType().getClassifier(); converters.put(parserRule.getName(), new EFactoryValueConverter(datatype)); } } for (TerminalRule terminalRule : allTerminalRules(getGrammar())) { if (!terminalRule.isFragment()) { String terminalRuleName = terminalRule.getName(); if (!converters.containsKey(terminalRuleName)) { converters.put(terminalRuleName, defaultTerminalConverterFactory.create(terminalRule)); } } } }
return Boolean.valueOf(Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("BEGIN", "INDENT", "OPEN")).contains(it.getName().toUpperCase())); }; final Iterable<TerminalRule> open = IterableExtensions.<TerminalRule>filter(GrammarUtil.allTerminalRules(this.getGrammar()), _function); final Function1<TerminalRule, Boolean> _function_1 = (TerminalRule it) -> { return Boolean.valueOf(Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("END", "DEDENT", "CLOSE")).contains(it.getName().toUpperCase())); }; final Iterable<TerminalRule> close = IterableExtensions.<TerminalRule>filter(GrammarUtil.allTerminalRules(this.getGrammar()), _function_1); StringConcatenationClient _client = new StringConcatenationClient() { @Override
public void inspectKeywordHidesTerminalRule(Keyword keyword) { AbstractRule container = GrammarUtil.containingRule(keyword); if (container instanceof TerminalRule) return; Grammar grammar = GrammarUtil.getGrammar(container); List<TerminalRule> rules = GrammarUtil.allTerminalRules(grammar); for(TerminalRule rule: rules) { AbstractElement element = rule.getAlternatives(); if (element instanceof Keyword && Strings.isEmpty(element.getCardinality())) { String value = ((Keyword) element).getValue(); if (value.equals(keyword.getValue())) acceptor.acceptError("The keyword '" + value + "' hides the terminal rule " + rule.getName()+ ".", keyword, XtextPackage.Literals.KEYWORD__VALUE, ValidationMessageAcceptor.INSIGNIFICANT_INDEX, null); } } }
return Boolean.valueOf(Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("BEGIN", "INDENT", "OPEN")).contains(it.getName().toUpperCase())); }; final Iterable<TerminalRule> open = IterableExtensions.<TerminalRule>filter(GrammarUtil.allTerminalRules(this.getGrammar()), _function); final Function1<TerminalRule, Boolean> _function_1 = (TerminalRule it) -> { return Boolean.valueOf(Collections.<String>unmodifiableSet(CollectionLiterals.<String>newHashSet("END", "DEDENT", "CLOSE")).contains(it.getName().toUpperCase())); }; final Iterable<TerminalRule> close = IterableExtensions.<TerminalRule>filter(GrammarUtil.allTerminalRules(this.getGrammar()), _function_1); StringConcatenationClient _client = new StringConcatenationClient() { @Override
protected CharSequence compileTerminalRules(final Grammar it, final AntlrOptions options) { StringConcatenation _builder = new StringConcatenation(); { boolean _isBacktrackLexer = options.isBacktrackLexer(); if (_isBacktrackLexer) { _builder.newLine(); _builder.append("// Rules duplicated to allow inter-rule references"); _builder.newLine(); } } { List<TerminalRule> _allTerminalRules = GrammarUtil.allTerminalRules(it); for(final TerminalRule rule : _allTerminalRules) { _builder.newLine(); CharSequence _compileRule = this.compileRule(rule, it, options); _builder.append(_compileRule); _builder.newLineIfNotEmpty(); } } return _builder; }
List<TerminalRule> _allTerminalRules = GrammarUtil.allTerminalRules(it); for(final TerminalRule rule : _allTerminalRules) { _builder.append("\t");
return Boolean.valueOf(Objects.equal(_name, "WS")); }; boolean _exists = IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(grammar), _function); if (_exists) { _builder.append("\t"); if ((IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(grammar), ((Function1<TerminalRule, Boolean>) (TerminalRule it) -> { String _name = it.getName(); return Boolean.valueOf(Objects.equal(_name, "SL_COMMENT")); })) && IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(grammar), ((Function1<TerminalRule, Boolean>) (TerminalRule it) -> { String _name = it.getName(); return Boolean.valueOf(Objects.equal(_name, "ML_COMMENT")); return Boolean.valueOf(Objects.equal(_name, "SL_COMMENT")); }; boolean _exists_1 = IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(grammar), _function_1); if (_exists_1) { _builder.append("\t"); return Boolean.valueOf(Objects.equal(_name, "ML_COMMENT")); }; boolean _exists_2 = IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(grammar), _function_2); if (_exists_2) { _builder.append("\t"); return Boolean.valueOf(Objects.equal(_name, "STRING")); }; boolean _exists_3 = IterableExtensions.<TerminalRule>exists(GrammarUtil.allTerminalRules(grammar), _function_3); if (_exists_3) {
final List<TerminalRule> allTerminalRules = GrammarUtil.allTerminalRules(it); final ArrayList<String> synthetic_kw_alternatives = CollectionLiterals.<String>newArrayList(); final Function1<Pair<Integer, String>, String> _function = (Pair<Integer, String> it_1) -> {