Java Code Examples for org.eclipse.xtext.ParserRule#isDefinesHiddenTokens()
The following examples show how to use
org.eclipse.xtext.ParserRule#isDefinesHiddenTokens() .
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: WhitespaceAddingSequenceAcceptor.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected AbstractRule findWhitespaceRule(AbstractElement ele) { for (int i = ruleCalls.size() - 1; i >= 0; i--) { AbstractRule rule = ruleCalls.get(i).getRule(); if (rule instanceof ParserRule) { ParserRule pr = (ParserRule) rule; if (pr.isDefinesHiddenTokens()) { for (AbstractRule hidden : pr.getHiddenTokens()) if (isWhitespaceRule(hidden)) return hidden; return null; } } } if (ruleCalls.isEmpty()) return findWhitespaceRule(GrammarUtil.getGrammar(ele)); return findWhitespaceRule(GrammarUtil.getGrammar(ruleCalls.get(0))); }
Example 2
Source File: ContextPDAProvider.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected ParserRule getFilterableRule(ISerState state) { if (state.getType() == SerStateType.PUSH) { RuleCall rc = (RuleCall) state.getGrammarElement(); AbstractRule rule = rc.getRule(); if (rule instanceof ParserRule) { ParserRule pr = (ParserRule) rule; if (pr.isFragment()) { return null; } if (pr.isDefinesHiddenTokens()) { return null; } return pr; } } return null; }
Example 3
Source File: AbstractAntlrGrammarWithActionsGenerator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected CharSequence compileEntryInit(final ParserRule it, final AntlrOptions options) { StringConcatenation _builder = new StringConcatenation(); { if ((it.isDefinesHiddenTokens() || this._grammarAccessExtensions.definesUnorderedGroups(it, options))) { _builder.append("@init {"); _builder.newLine(); _builder.append("\t"); CharSequence _compileInitHiddenTokens = this.compileInitHiddenTokens(it, options); _builder.append(_compileInitHiddenTokens, "\t"); _builder.newLineIfNotEmpty(); _builder.append("\t"); CharSequence _compileInitUnorderedGroups = this.compileInitUnorderedGroups(it, options); _builder.append(_compileInitUnorderedGroups, "\t"); _builder.newLineIfNotEmpty(); _builder.append("}"); } } return _builder; }
Example 4
Source File: AbstractAntlrGrammarWithActionsGenerator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected CharSequence _compileInitHiddenTokens(final ParserRule it, final AntlrOptions options) { StringConcatenation _builder = new StringConcatenation(); { boolean _isDefinesHiddenTokens = it.isDefinesHiddenTokens(); if (_isDefinesHiddenTokens) { _builder.append("HiddenTokens myHiddenTokenState = ((XtextTokenStream)input).setHiddenTokens("); { EList<AbstractRule> _hiddenTokens = it.getHiddenTokens(); boolean _hasElements = false; for(final AbstractRule hidden : _hiddenTokens) { if (!_hasElements) { _hasElements = true; } else { _builder.appendImmediate(", ", ""); } _builder.append("\""); String _ruleName = this._grammarAccessExtensions.ruleName(hidden); _builder.append(_ruleName); _builder.append("\""); } } _builder.append(");"); } } return _builder; }
Example 5
Source File: AbstractAntlrGrammarWithActionsGenerator.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
protected CharSequence compileEntryFinally(final ParserRule it, final AntlrOptions options) { StringConcatenation _builder = new StringConcatenation(); { if ((it.isDefinesHiddenTokens() || this._grammarAccessExtensions.definesUnorderedGroups(it, options))) { _builder.append("finally {"); _builder.newLine(); _builder.append("\t"); CharSequence _compileRestoreHiddenTokens = this.compileRestoreHiddenTokens(it, options); _builder.append(_compileRestoreHiddenTokens, "\t"); _builder.newLineIfNotEmpty(); _builder.append("\t"); CharSequence _compileRestoreUnorderedGroups = this.compileRestoreUnorderedGroups(it, options); _builder.append(_compileRestoreUnorderedGroups, "\t"); _builder.newLineIfNotEmpty(); _builder.append("}"); } } return _builder; }
Example 6
Source File: UsedRulesFinder.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public Void caseParserRule(ParserRule object) { if (usedRules.add(object)) { if (object.getAlternatives() != null) doSwitch(object.getAlternatives()); if (object.isDefinesHiddenTokens()) for(AbstractRule rule: object.getHiddenTokens()) doSwitch(rule); } return null; }
Example 7
Source File: DefaultHiddenTokenHelper.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
@Override public AbstractRule getWhitespaceRuleFor(ParserRule context, String whitespace) { if (context == null || !context.isDefinesHiddenTokens()) return wsRule; if (context.getHiddenTokens().contains(wsRule)) return wsRule; return null; }
Example 8
Source File: AbstractAntlrGrammarWithActionsGenerator.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
protected CharSequence _compileRestoreHiddenTokens(final ParserRule it, final AntlrOptions options) { StringConcatenation _builder = new StringConcatenation(); { boolean _isDefinesHiddenTokens = it.isDefinesHiddenTokens(); if (_isDefinesHiddenTokens) { _builder.append("myHiddenTokenState.restore();"); } } return _builder; }
Example 9
Source File: XtextValidator.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
@Check public void checkHiddenTokenIsNotAFragment(ParserRule rule) { if (rule.isDefinesHiddenTokens()) { checkHiddenTokenIsNotAFragment(rule, rule.getHiddenTokens(), XtextPackage.Literals.PARSER_RULE__HIDDEN_TOKENS); } }