Java 类org.eclipse.xtext.parser.antlr.IUnorderedGroupHelper 实例源码

项目:xtext-extras    文件:XtextAntlrGeneratorFragment.java   
@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();
}
项目:xtext-extras    文件:AntlrGeneratorFragment.java   
@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();
}
项目:xtext-core    文件:BaseContentAssistParser.java   
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());
    }
}
项目:xtext-core    文件:EofListener.java   
@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;
    }
}
项目:bts    文件:AbstractContentAssistParser.java   
public Collection<FollowElement> getFollowElements(String input, boolean strict) {
    CharStream stream = new ANTLRStringStream(input);
    TokenSource tokenSource = createLexer(stream);
    AbstractInternalContentAssistParser parser = createParser();
    parser.setStrict(strict);
    ObservableXtextTokenStream tokens = new ObservableXtextTokenStream(tokenSource, parser);
    tokens.setInitialHiddenTokens(getInitialHiddenTokens());
    parser.setTokenStream(tokens);
    IUnorderedGroupHelper helper = getUnorderedGroupHelper().get();
    parser.setUnorderedGroupHelper(helper);
    helper.initializeWith(parser);
    tokens.setListener(parser);
    try {
        return Lists.newArrayList(getFollowElements(parser));
    } catch(InfiniteRecursion infinite) {
        return Lists.newArrayList(parser.getFollowElements());
    }
}
项目:n4js    文件:CustomN4JSParser.java   
/**
 * Initialize the parser properly with the given tokens and process it.
 */
private Collection<FollowElement> doGetFollowElements(AbstractInternalContentAssistParser parser,
        ObservableXtextTokenStream tokens) {
    tokens.setInitialHiddenTokens(getInitialHiddenTokens());
    parser.setTokenStream(tokens);
    IUnorderedGroupHelper helper = getUnorderedGroupHelper().get();
    parser.setUnorderedGroupHelper(helper);
    helper.initializeWith(parser);
    tokens.setListener(parser);
    Collection<FollowElement> followElements = getFollowElements(parser);
    return followElements;
}
项目:xtext-core    文件:BaseContentAssistParser.java   
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;
}
项目:xtext-core    文件:BaseContentAssistParser.java   
/**
 * @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;
}
项目:antlr4ide    文件:AntlrGeneratorFragmentWithCustomLexer.java   
@Override
public Set<Binding> getGuiceBindingsRt(final 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();
}
项目:n4js    文件:AbstractN4MFRuntimeModule.java   
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() {
    return UnorderedGroupHelper.class;
}
项目:lcdsl    文件:AbstractLcDslRuntimeModule.java   
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() {
    return UnorderedGroupHelper.class;
}
项目:xtext-core    文件:AbstractSimpleBeeLangTestLanguageRuntimeModule.java   
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() {
    return UnorderedGroupHelper.class;
}
项目:xtext-core    文件:AbstractBeeLangTestLanguageRuntimeModule.java   
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() {
    return UnorderedGroupHelper.class;
}
项目:xtext-core    文件:AbstractExBeeLangTestLanguageRuntimeModule.java   
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() {
    return UnorderedGroupHelper.class;
}
项目:xtext-core    文件:AbstractExBacktrackingBug325745TestLanguageRuntimeModule.java   
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() {
    return UnorderedGroupHelper.class;
}
项目:xtext-core    文件:AbstractBacktrackingBug325745TestLanguageRuntimeModule.java   
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() {
    return UnorderedGroupHelper.class;
}
项目:xtext-core    文件:AbstractExUnorderedGroupsTestLanguageRuntimeModule.java   
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() {
    return UnorderedGroupHelper.class;
}
项目:xtext-core    文件:AbstractSimpleBacktrackingBug325745TestLanguageRuntimeModule.java   
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() {
    return UnorderedGroupHelper.class;
}
项目:xtext-core    文件:AbstractUnorderedGroupsTestLanguageRuntimeModule.java   
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() {
    return UnorderedGroupHelper.class;
}
项目:xtext-core    文件:AbstractSimpleUnorderedGroupsTestLanguageRuntimeModule.java   
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() {
    return UnorderedGroupHelper.class;
}
项目:xtext-core    文件:AbstractSequencerTestLanguageRuntimeModule.java   
public Class<? extends IUnorderedGroupHelper> bindIUnorderedGroupHelper() {
    return UnorderedGroupHelper.class;
}
项目:xtext-core    文件:IgnoreFirstEntranceUnorderedGroupHelper.java   
protected IUnorderedGroupHelper getHelper() {
    return helper;
}
项目:xtext-core    文件:BaseContentAssistParser.java   
/**
 * Factory method for the {@link IgnoreFirstEntranceUnorderedGroupHelper}.
 */
protected IUnorderedGroupHelper ignoreFirstEntrance(final IUnorderedGroupHelper helper) {
    return new IgnoreFirstEntranceUnorderedGroupHelper(helper);
}
项目:xtext-core    文件:BaseContentAssistParser.java   
/**
 * Creates a new {@link IUnorderedGroupHelper} that is not yet initialized.
 */
protected IUnorderedGroupHelper createUnorderedGroupHelper() {
    return getUnorderedGroupHelper().get();
}
项目:xtext-core    文件:BaseContentAssistParser.java   
/**
 * Public for testing purpose.
 */
public void setUnorderedGroupHelper(Provider<IUnorderedGroupHelper> unorderedGroupHelper) {
    this.unorderedGroupHelper = unorderedGroupHelper;
}
项目:xtext-core    文件:BaseContentAssistParser.java   
/**
 * Public for testing purpose.
 */
public Provider<IUnorderedGroupHelper> getUnorderedGroupHelper() {
    return unorderedGroupHelper;
}
项目:xtext-core    文件:BaseInternalContentAssistParser.java   
public void setUnorderedGroupHelper(IUnorderedGroupHelper unorderedGroupHelper) {
    this.unorderedGroupHelper = unorderedGroupHelper;
}
项目:xtext-core    文件:BaseInternalContentAssistParser.java   
public IUnorderedGroupHelper getUnorderedGroupHelper() {
    return unorderedGroupHelper;
}
项目:xtext-core    文件:DFA.java   
protected IUnorderedGroupHelper getUnorderedGroupHelper() {
    return getRecognizer().getUnorderedGroupHelper();
}
项目:bts    文件:AbstractContentAssistParser.java   
public void setUnorderedGroupHelper(Provider<IUnorderedGroupHelper> unorderedGroupHelper) {
    this.unorderedGroupHelper = unorderedGroupHelper;
}
项目:bts    文件:AbstractContentAssistParser.java   
public Provider<IUnorderedGroupHelper> getUnorderedGroupHelper() {
    return unorderedGroupHelper;
}
项目:bts    文件:DFA.java   
/**
 * @since 2.4
 */
protected IUnorderedGroupHelper getUnorderedGroupHelper() {
    return getRecognizer().getUnorderedGroupHelper();
}
项目:bts    文件:AbstractInternalContentAssistParser.java   
public void setUnorderedGroupHelper(IUnorderedGroupHelper unorderedGroupHelper) {
    this.unorderedGroupHelper = unorderedGroupHelper;
}
项目:bts    文件:AbstractInternalContentAssistParser.java   
public IUnorderedGroupHelper getUnorderedGroupHelper() {
    return unorderedGroupHelper;
}
项目:xtext-core    文件:IgnoreFirstEntranceUnorderedGroupHelper.java   
/**
 * Protected contructor to allow to override this type. 
 * 
 * @see BaseContentAssistParser#ignoreFirstEntrance(IUnorderedGroupHelper)
 */
protected IgnoreFirstEntranceUnorderedGroupHelper(IUnorderedGroupHelper helper) {
    this.helper = Preconditions.checkNotNull(helper, "helper may not be null");
}