Search in sources :

Example 6 with RuleFilter

use of org.eclipse.xtext.xtext.RuleFilter in project xtext-core by eclipse.

the class AbstractAntlrGrammarGenerator method generate.

public void generate(final Grammar it, final AntlrOptions options, final IXtextGeneratorFileSystemAccess fsa) {
    this.keywordHelper = KeywordHelper.getHelper(it);
    this.originalGrammar = it;
    final RuleFilter filter = new RuleFilter();
    filter.setDiscardUnreachableRules(options.isSkipUnusedRules());
    final RuleNames ruleNames = RuleNames.getRuleNames(it, true);
    final Grammar flattened = new FlattenedGrammarAccess(ruleNames, filter).getFlattenedGrammar();
    boolean _isCombinedGrammar = this.isCombinedGrammar();
    new CombinedGrammarMarker(_isCombinedGrammar).attachToEmfObject(flattened);
    fsa.generateFile(this.getGrammarNaming().getParserGrammar(it).getGrammarFileName(), this.compileParser(flattened, options));
    boolean _isCombinedGrammar_1 = this.isCombinedGrammar();
    boolean _not = (!_isCombinedGrammar_1);
    if (_not) {
        fsa.generateFile(this.getGrammarNaming().getLexerGrammar(it).getGrammarFileName(), this.compileLexer(flattened, options));
    }
}
Also used : RuleNames(org.eclipse.xtext.xtext.RuleNames) RuleFilter(org.eclipse.xtext.xtext.RuleFilter) Grammar(org.eclipse.xtext.Grammar) FlattenedGrammarAccess(org.eclipse.xtext.xtext.FlattenedGrammarAccess)

Aggregations

Grammar (org.eclipse.xtext.Grammar)6 FlattenedGrammarAccess (org.eclipse.xtext.xtext.FlattenedGrammarAccess)6 RuleFilter (org.eclipse.xtext.xtext.RuleFilter)6 RuleNames (org.eclipse.xtext.xtext.RuleNames)6 Collection (java.util.Collection)3 List (java.util.List)3 Map (java.util.Map)3 Set (java.util.Set)3 AbstractElement (org.eclipse.xtext.AbstractElement)3 Lists (com.google.common.collect.Lists)2 Sets (com.google.common.collect.Sets)2 Injector (com.google.inject.Injector)2 Method (java.lang.reflect.Method)2 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 ReflectExtensions (org.eclipse.xtext.xbase.lib.util.ReflectExtensions)2 Assert (org.junit.Assert)2 Test (org.junit.Test)2 RunWith (org.junit.runner.RunWith)2 Parameterized (org.junit.runners.Parameterized)2