org.eclipse.xtext.parser.antlr.IUnorderedGroupHelper Java Examples
The following examples show how to use
org.eclipse.xtext.parser.antlr.IUnorderedGroupHelper.
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: CustomN4JSParser.java From n4js with Eclipse Public License 1.0 | 6 votes |
private AbstractInternalContentAssistParser createParser(AbstractElement parseMe, FollowElement baseFollowElement) { AbstractInternalContentAssistParser parser = createParser(); parser.setUnorderedGroupHelper(getUnorderedGroupHelper().get()); parser.getUnorderedGroupHelper().initializeWith(parser); ObservableXtextTokenStream tokens = toTokenStream(baseFollowElement, parser); parser.setTokenStream(tokens); tokens.setListener(parser); parser.getGrammarElements().addAll(baseFollowElement.getTrace()); parser.getGrammarElements().add(parseMe); parser.getLocalTrace().addAll(baseFollowElement.getLocalTrace()); parser.getLocalTrace().add(parseMe); parser.getParamStack().addAll(baseFollowElement.getParamStack()); if (parseMe instanceof UnorderedGroup && baseFollowElement.getGrammarElement() == parseMe) { UnorderedGroup group = (UnorderedGroup) parseMe; final IUnorderedGroupHelper helper = parser.getUnorderedGroupHelper(); helper.enter(group); for (AbstractElement consumed : baseFollowElement.getHandledUnorderedGroupElements()) { parser.before(consumed); helper.select(group, group.getElements().indexOf(consumed)); helper.returnFromSelection(group); parser.after(consumed); } parser.setUnorderedGroupHelper(wrap(helper)); } return parser; }
Example #2
Source File: XtextAntlrGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public Set<Binding> getGuiceBindingsRt(Grammar grammar) { BindFactory factory = new BindFactory() .addTypeToType(IParser.class.getName(),getParserClassName(grammar, getNaming())) .addTypeToType(ITokenToStringConverter.class.getName(),AntlrTokenToStringConverter.class.getName()) .addTypeToType(IAntlrTokenFileProvider.class.getName(),getAntlrTokenFileProviderClassName(grammar, getNaming())) .addTypeToType(Lexer.class.getName(), getLexerClassName(grammar, getNaming())) .addTypeToProviderInstance(getLexerClassName(grammar, getNaming()), "org.eclipse.xtext.parser.antlr.LexerProvider.create(" + getLexerClassName(grammar, getNaming()) + ".class)") .addConfiguredBinding("RuntimeLexer", "binder.bind(" + Lexer.class.getName() + ".class)"+ ".annotatedWith(com.google.inject.name.Names.named(" + "org.eclipse.xtext.parser.antlr.LexerBindings.RUNTIME" + ")).to(" + getLexerClassName(grammar, getNaming()) +".class)") .addTypeToType(ITokenDefProvider.class.getName(), AntlrTokenDefProvider.class.getName()); if (containsUnorderedGroup(grammar)) factory = factory.addTypeToType(IUnorderedGroupHelper.class.getName(), UnorderedGroupHelper.class.getName()); return factory.getBindings(); }
Example #3
Source File: AntlrGeneratorFragment.java From xtext-extras with Eclipse Public License 2.0 | 6 votes |
@Override public Set<Binding> getGuiceBindingsRt(Grammar grammar) { BindFactory factory = new BindFactory() .addTypeToType(IParser.class.getName(),getFragmentHelper().getParserClassName(grammar)) .addTypeToType(ITokenToStringConverter.class.getName(),AntlrTokenToStringConverter.class.getName()) .addTypeToType(IAntlrTokenFileProvider.class.getName(),getFragmentHelper().getAntlrTokenFileProviderClassName(grammar)) .addTypeToType(Lexer.class.getName(), getFragmentHelper().getLexerClassName(grammar)) .addTypeToProviderInstance(getFragmentHelper().getLexerClassName(grammar), "org.eclipse.xtext.parser.antlr.LexerProvider.create(" + getFragmentHelper().getLexerClassName(grammar) + ".class)") .addConfiguredBinding("RuntimeLexer", "binder.bind(" + Lexer.class.getName() + ".class)"+ ".annotatedWith(com.google.inject.name.Names.named(" + "org.eclipse.xtext.parser.antlr.LexerBindings.RUNTIME" + ")).to(" + getFragmentHelper().getLexerClassName(grammar) +".class)") .addTypeToType(ITokenDefProvider.class.getName(),AntlrTokenDefProvider.class.getName()); if (containsUnorderedGroup(grammar)) factory = factory.addTypeToType(IUnorderedGroupHelper.class.getName(), UnorderedGroupHelper.class.getName()); if (getOptions().isIgnoreCase()) { factory = factory .addTypeToType(ITokenSerializer.IKeywordSerializer.class.getName(), IgnoreCaseKeywordSerializer.class.getName()) .addTypeToType(AbstractIDValueConverter.class.getName(), IgnoreCaseIDValueConverter.class.getName()); } return factory.getBindings(); }
Example #4
Source File: EofListener.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
@Override public void announceEof(int lookAhead) { if (!wasRecovering) { parser.announceEof(lookAhead); if (lookAhead > 1) announcedEofWithLA = true; } if (parser.isDFAPrediction()) { int lastGrammarElement = parser.getGrammarElements().size() - 1; if (elementToParse instanceof UnorderedGroup && parser.getGrammarElements().get(lastGrammarElement) == elementToParse) { IUnorderedGroupHelper helper = parser.getUnorderedGroupHelper(); if (!helper.canLeave((UnorderedGroup) elementToParse)) { wasEof = true; } } } else { wasEof = true; } }
Example #5
Source File: BaseContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 6 votes |
public Collection<FE> getFollowElements(String input, boolean strict) { TokenSource tokenSource = createTokenSource(input); InternalParser parser = createParser(); parser.setStrict(strict); ObservableXtextTokenStream tokens = new ObservableXtextTokenStream(tokenSource, parser); tokens.setInitialHiddenTokens(getInitialHiddenTokens()); parser.setTokenStream(tokens); IUnorderedGroupHelper helper = createUnorderedGroupHelper(); parser.setUnorderedGroupHelper(helper); helper.initializeWith(parser); tokens.setListener(parser); try { return Lists.newArrayList(getFollowElements(parser)); } catch (InfiniteRecursion infinite) { return Lists.newArrayList(parser.getFollowElements()); } }
Example #6
Source File: CustomN4JSParser.java From n4js with Eclipse Public License 1.0 | 5 votes |
/** * Initialize the parser properly with the given tokens and process it. */ private Collection<FollowElement> doGetFollowElements( AbstractInternalContentAssistParser parser, ObservableXtextTokenStream tokens, String ruleName) { tokens.setInitialHiddenTokens(getInitialHiddenTokens()); parser.setTokenStream(tokens); IUnorderedGroupHelper helper = getUnorderedGroupHelper().get(); parser.setUnorderedGroupHelper(helper); helper.initializeWith(parser); tokens.setListener(parser); Collection<FollowElement> followElements = getFollowElements(parser, ruleName); return followElements; }
Example #7
Source File: BaseContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
public Collection<FE> getFollowElements(FE element) { if (element.getLookAhead() <= 1) throw new IllegalArgumentException("lookahead may not be less than or equal to 1"); Collection<FE> result = new ArrayList<FE>(); for (AbstractElement elementToParse : getElementsToParse(element)) { elementToParse = unwrapSingleElementGroups(elementToParse); String ruleName = getRuleName(elementToParse); String[][] allRuleNames = getRequiredRuleNames(ruleName, element.getParamStack(), elementToParse); for (String[] ruleNames : allRuleNames) { for (int i = 0; i < ruleNames.length; i++) { InternalParser parser = createParser(); parser.setUnorderedGroupHelper(createUnorderedGroupHelper()); parser.getUnorderedGroupHelper().initializeWith(parser); ObservableXtextTokenStream tokens = setTokensFromFollowElement(parser, element); tokens.setListener(parser); parser.getGrammarElements().addAll(element.getTrace()); parser.getGrammarElements().add(elementToParse); parser.getLocalTrace().addAll(element.getLocalTrace()); parser.getLocalTrace().add(elementToParse); parser.getParamStack().addAll(element.getParamStack()); if (elementToParse instanceof UnorderedGroup && element.getGrammarElement() == elementToParse) { UnorderedGroup group = (UnorderedGroup) elementToParse; IUnorderedGroupHelper helper = getInitializedUnorderedGroupHelper(element, parser, group); parser.setUnorderedGroupHelper(ignoreFirstEntrance(helper)); } Collection<FE> elements = getFollowElements(parser, elementToParse, ruleNames, i); result.addAll(elements); } } } return result; }
Example #8
Source File: BaseContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 5 votes |
/** * @since 2.14 */ protected IUnorderedGroupHelper getInitializedUnorderedGroupHelper(FE element, InternalParser parser, UnorderedGroup group) { final IUnorderedGroupHelper helper = parser.getUnorderedGroupHelper(); helper.enter(group); for (AbstractElement consumed : element.getHandledUnorderedGroupElements()) { parser.before(consumed); helper.select(group, group.getElements().indexOf(consumed)); helper.returnFromSelection(group); parser.after(consumed); } return helper; }
Example #9
Source File: AbstractSequencerTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }
Example #10
Source File: AbstractSARLRuntimeModule.java From sarl with Apache License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }
Example #11
Source File: IgnoreFirstEntranceUnorderedGroupHelper.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected IUnorderedGroupHelper getHelper() { return helper; }
Example #12
Source File: BaseContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * Factory method for the {@link IgnoreFirstEntranceUnorderedGroupHelper}. */ protected IUnorderedGroupHelper ignoreFirstEntrance(final IUnorderedGroupHelper helper) { return new IgnoreFirstEntranceUnorderedGroupHelper(helper); }
Example #13
Source File: BaseContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * Creates a new {@link IUnorderedGroupHelper} that is not yet initialized. */ protected IUnorderedGroupHelper createUnorderedGroupHelper() { return getUnorderedGroupHelper().get(); }
Example #14
Source File: BaseContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * Public for testing purpose. */ public void setUnorderedGroupHelper(Provider<IUnorderedGroupHelper> unorderedGroupHelper) { this.unorderedGroupHelper = unorderedGroupHelper; }
Example #15
Source File: BaseContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
/** * Public for testing purpose. */ public Provider<IUnorderedGroupHelper> getUnorderedGroupHelper() { return unorderedGroupHelper; }
Example #16
Source File: BaseInternalContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public void setUnorderedGroupHelper(IUnorderedGroupHelper unorderedGroupHelper) { this.unorderedGroupHelper = unorderedGroupHelper; }
Example #17
Source File: BaseInternalContentAssistParser.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public IUnorderedGroupHelper getUnorderedGroupHelper() { return unorderedGroupHelper; }
Example #18
Source File: DFA.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
protected IUnorderedGroupHelper getUnorderedGroupHelper() { return getRecognizer().getUnorderedGroupHelper(); }
Example #19
Source File: AbstractSimpleUnorderedGroupsTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }
Example #20
Source File: AbstractUnorderedGroupsTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }
Example #21
Source File: AbstractSimpleBacktrackingBug325745TestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }
Example #22
Source File: AbstractExUnorderedGroupsTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }
Example #23
Source File: AbstractBacktrackingBug325745TestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }
Example #24
Source File: AbstractExBacktrackingBug325745TestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }
Example #25
Source File: AbstractExBeeLangTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }
Example #26
Source File: AbstractBeeLangTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }
Example #27
Source File: AbstractSimpleBeeLangTestLanguageRuntimeModule.java From xtext-core with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }
Example #28
Source File: AbstractBug381381TestLanguageRuntimeModule.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }
Example #29
Source File: AbstractBug360834TestLanguageRuntimeModule.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }
Example #30
Source File: AbstractUnorderedGroupsTestLanguageRuntimeModule.java From xtext-eclipse with Eclipse Public License 2.0 | 4 votes |
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() { return UnorderedGroupHelper.class; }