本文整理汇总了Java中org.eclipse.xtext.xtext.RuleFilter类的典型用法代码示例。如果您正苦于以下问题:Java RuleFilter类的具体用法?Java RuleFilter怎么用?Java RuleFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RuleFilter类属于org.eclipse.xtext.xtext包,在下文中一共展示了RuleFilter类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getGrammarPDAs
import org.eclipse.xtext.xtext.RuleFilter; //导入依赖的package包/类
@Override
public SerializationContextMap<Pda<ISerState, RuleCall>> getGrammarPDAs(Grammar grammar) {
RuleNames names = RuleNames.getRuleNames(grammar, true);
RuleFilter filter = new RuleFilter();
filter.setDiscardTerminalRules(true);
filter.setDiscardUnreachableRules(false);
filter.setDiscardRuleTypeRef(false);
Grammar flattened = new FlattenedGrammarAccess(names, filter).getFlattenedGrammar();
Builder<Pda<ISerState, RuleCall>> result = SerializationContextMap.<Pda<ISerState, RuleCall>>builder();
for (ParserRule rule : GrammarUtil.allParserRules(flattened)) {
RuleWithParameterValues withParams = RuleWithParameterValues.findInEmfObject(rule);
AbstractRule original = withParams.getOriginal();
if (original instanceof ParserRule && isValidRule((ParserRule) original)) {
ISerializationContext context = createContext((ParserRule) original, withParams.getParamValues());
try {
Pda<ISerState, RuleCall> pda = createPDA(grammar, rule);
result.put(context, pda);
} catch (Exception e) {
LOG.error("Error creating PDA for context '" + context + "': " + e.getMessage(), e);
}
}
}
return result.create();
}
示例2: FlattenedGrammarAccess
import org.eclipse.xtext.xtext.RuleFilter; //导入依赖的package包/类
public FlattenedGrammarAccess(final RuleNames names, final RuleFilter filter) {
final Grammar grammar = names.getContextGrammar();
Grammar flattenedGrammar = this.<Grammar>copy(grammar);
flattenedGrammar.setName(grammar.getName());
LinkedHashMap<RuleWithParameterValues, AbstractRule> origToCopy = Maps.<RuleWithParameterValues, AbstractRule>newLinkedHashMap();
final ArrayList<AbstractRule> copies = this.copyRuleStubs(names, origToCopy, filter.getRules(grammar), filter.isDiscardRuleTypeRef());
EList<AbstractRule> _rules = flattenedGrammar.getRules();
Iterables.<AbstractRule>addAll(_rules, copies);
Multimap<TerminalRule, AbstractRule> calledFrom = this.copyRuleBodies(copies, origToCopy);
this.setHiddenTokens(flattenedGrammar, grammar, origToCopy);
this.markAsFragment(calledFrom);
boolean _isDiscardUnreachableRules = filter.isDiscardUnreachableRules();
if (_isDiscardUnreachableRules) {
Set<AbstractRule> usedRules = CollectionLiterals.<AbstractRule>newHashSet();
boolean _isDiscardTerminalRules = filter.isDiscardTerminalRules();
boolean _not = (!_isDiscardTerminalRules);
if (_not) {
usedRules.addAll(GrammarUtil.allTerminalRules(flattenedGrammar));
}
UsedRulesFinder finder = new UsedRulesFinder(usedRules);
finder.compute(flattenedGrammar);
flattenedGrammar.getRules().retainAll(usedRules);
}
this.flattenedGrammar = flattenedGrammar;
new OriginalGrammar(grammar).attachToEmfObject(flattenedGrammar);
}
示例3: generate
import org.eclipse.xtext.xtext.RuleFilter; //导入依赖的package包/类
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));
}
}
示例4: generate
import org.eclipse.xtext.xtext.RuleFilter; //导入依赖的package包/类
@Override
public void generate(Grammar grammar, XpandExecutionContext ctx) {
checkGrammar(grammar);
RuleFilter filter = new RuleFilter();
filter.setDiscardUnreachableRules(getOptions().isSkipUnusedRules());
RuleNames ruleNames = RuleNames.getRuleNames(grammar, true);
Grammar flattened = new FlattenedGrammarAccess(ruleNames, filter).getFlattenedGrammar();
super.generate(flattened, ctx);
}
示例5: getModel
import org.eclipse.xtext.xtext.RuleFilter; //导入依赖的package包/类
public Grammar getModel(final String model, final boolean dropUnreachable) throws Exception {
EObject _model = super.getModel(model);
Grammar grammar = ((Grammar) _model);
RuleNames ruleNames = RuleNames.getRuleNames(grammar, false);
RuleFilter filter = new RuleFilter();
filter.setDiscardUnreachableRules(dropUnreachable);
Grammar result = new FlattenedGrammarAccess(ruleNames, filter).getFlattenedGrammar();
XtextResource resource = this.<XtextResource>get(XtextResource.class);
resource.getContents().add(result);
resource.setURI(URI.createURI("synthetic://flattened.xtext"));
return result;
}