/** * 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 void assertPredicate(final String expectation, final String grammar) { try { EObject _model = this.getModel(grammar); final Grammar parsed = ((Grammar) _model); EList<AbstractRule> _rules = parsed.getRules(); AbstractRule _head = IterableExtensions.<AbstractRule>head(_rules); final AbstractElement body = _head.getAlternatives(); final AbstractElement predicate = AntlrGrammarGenUtil.getPredicatedElement(body); String _xtext = this.toXtext(predicate); Assert.assertEquals(expectation, _xtext); } catch (Throwable _e) { throw Exceptions.sneakyThrow(_e); } }