本文整理汇总了C#中Antlr4.Tool.Ast.GrammarAST类的典型用法代码示例。如果您正苦于以下问题:C# GrammarAST类的具体用法?C# GrammarAST怎么用?C# GrammarAST使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GrammarAST类属于Antlr4.Tool.Ast命名空间,在下文中一共展示了GrammarAST类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LabelElementPair
public LabelElementPair(Grammar g, GrammarAST label, GrammarAST element, int labelOp)
{
this.label = label;
this.element = element;
// compute general case for label type
if (element.GetFirstDescendantWithType(tokenTypeForTokens) != null)
{
if (labelOp == ANTLRParser.ASSIGN)
type = LabelType.TOKEN_LABEL;
else
type = LabelType.TOKEN_LIST_LABEL;
}
else if (element.GetFirstDescendantWithType(ANTLRParser.RULE_REF) != null)
{
if (labelOp == ANTLRParser.ASSIGN)
type = LabelType.RULE_LABEL;
else
type = LabelType.RULE_LIST_LABEL;
}
// now reset if lexer and string
if (g.IsLexer())
{
if (element.GetFirstDescendantWithType(ANTLRParser.STRING_LITERAL) != null)
{
if (labelOp == ANTLRParser.ASSIGN)
type = LabelType.LEXER_STRING_LABEL;
}
}
}
示例2: Choice
public Choice(OutputModelFactory factory,
GrammarAST blkOrEbnfRootAST,
IList<CodeBlockForAlt> alts)
: base(factory, blkOrEbnfRootAST)
{
this.alts = alts;
}
示例3: GrammarAST
public GrammarAST(GrammarAST node)
: base(node)
{
this.g = node.g;
this.atnState = node.atnState;
this.textOverride = node.textOverride;
}
示例4: Loop
public Loop(OutputModelFactory factory,
GrammarAST blkOrEbnfRootAST,
IList<CodeBlockForAlt> alts)
: base(factory, blkOrEbnfRootAST, alts)
{
bool nongreedy = (blkOrEbnfRootAST is QuantifierAST) && !((QuantifierAST)blkOrEbnfRootAST).GetGreedy();
exitAlt = nongreedy ? 1 : alts.Count + 1;
}
示例5: ReduceBlocksToSets
public virtual void ReduceBlocksToSets(GrammarAST root)
{
CommonTreeNodeStream nodes = new CommonTreeNodeStream(new GrammarASTAdaptor(), root);
GrammarASTAdaptor adaptor = new GrammarASTAdaptor();
BlockSetTransformer transformer = new BlockSetTransformer(nodes, g);
transformer.TreeAdaptor = adaptor;
transformer.Downup(root);
}
示例6: SrcOp
protected SrcOp(OutputModelFactory factory, GrammarAST ast)
: base(factory, ast)
{
if (ast != null)
uniqueID = ast.Token.TokenIndex;
enclosingBlock = factory.GetCurrentBlock();
enclosingRuleRunction = factory.GetCurrentRuleFunction();
}
示例7: AltBlock
// @ModelElement public ThrowNoViableAlt error;
public AltBlock(OutputModelFactory factory,
GrammarAST blkOrEbnfRootAST,
IList<CodeBlockForAlt> alts)
: base(factory, blkOrEbnfRootAST, alts)
{
decision = ((BlockStartState)blkOrEbnfRootAST.atnState).decision;
// interp.predict() throws exception
// this.error = new ThrowNoViableAlt(factory, blkOrEbnfRootAST, null);
}
示例8: TestSetInline
public TestSetInline(OutputModelFactory factory, GrammarAST ast, IntervalSet set, int wordSize)
: base(factory, ast)
{
bitsetWordSize = wordSize;
Bitset[] withZeroOffset = CreateBitsets(factory, set, wordSize, true);
Bitset[] withoutZeroOffset = CreateBitsets(factory, set, wordSize, false);
this.bitsets = withZeroOffset.Length <= withoutZeroOffset.Length ? withZeroOffset : withoutZeroOffset;
this.varName = "_la";
}
示例9: DiscoverRule
public override void DiscoverRule(RuleAST rule, GrammarAST ID,
IList<GrammarAST> modifiers, ActionAST arg,
ActionAST returns, GrammarAST thrws,
GrammarAST options, ActionAST locals,
IList<GrammarAST> actions,
GrammarAST block)
{
currentRule = g.GetRule(ID.Text);
}
示例10: RuleRef
public override IList<SrcOp> RuleRef(GrammarAST ID, GrammarAST label, GrammarAST args)
{
InvokeRule invokeOp = new InvokeRule(this, ID, label);
// If no manual label and action refs as token/rule not label, we need to define implicit label
if (controller.NeedsImplicitLabel(ID, invokeOp))
DefineImplicitLabel(ID, invokeOp);
AddToLabelList listLabelOp = GetAddToListOpIfListLabelPresent(invokeOp, label);
return List(invokeOp, listLabelOp);
}
示例11: MatchSet
public MatchSet(OutputModelFactory factory, GrammarAST ast)
: base(factory, ast)
{
SetTransition st = (SetTransition)ast.atnState.Transition(0);
int wordSize = factory.GetGenerator().GetTarget().GetInlineTestSetWordSize();
expr = new TestSetInline(factory, null, st.set, wordSize);
Decl.Decl d = new TokenTypeDecl(factory, expr.varName);
factory.GetCurrentRuleFunction().AddLocalDecl(d);
capture = new CaptureNextTokenType(factory, expr.varName);
}
示例12: ThrowRecognitionException
public ThrowRecognitionException(OutputModelFactory factory, GrammarAST ast, IntervalSet expecting)
: base(factory, ast)
{
//this.decision = ((BlockStartState)ast.ATNState).decision;
grammarLine = ast.Line;
grammarLine = ast.CharPositionInLine;
grammarFile = factory.GetGrammar().fileName;
//this.expecting = factory.createExpectingBitSet(ast, decision, expecting, "error");
// factory.defineBitSet(this.expecting);
}
示例13: StarBlock
public StarBlock(OutputModelFactory factory,
GrammarAST blkOrEbnfRootAST,
IList<CodeBlockForAlt> alts)
: base(factory, blkOrEbnfRootAST, alts)
{
loopLabel = factory.GetTarget().GetLoopLabel(blkOrEbnfRootAST);
StarLoopEntryState star = (StarLoopEntryState)blkOrEbnfRootAST.atnState;
loopBackStateNumber = star.loopBackState.stateNumber;
decision = star.decision;
}
示例14: Sync
// public BitSetDecl expecting;
public Sync(OutputModelFactory factory,
GrammarAST blkOrEbnfRootAST,
IntervalSet expecting,
int decision,
string position)
: base(factory, blkOrEbnfRootAST)
{
this.decision = decision;
// this.expecting = factory.createExpectingBitSet(ast, decision, expecting, position);
// factory.defineBitSet(this.expecting);
}
示例15: LL1AltBlock
public LL1AltBlock(OutputModelFactory factory, GrammarAST blkAST, IList<CodeBlockForAlt> alts)
: base(factory, blkAST, alts)
{
this.decision = ((DecisionState)blkAST.atnState).decision;
/* Lookahead for each alt 1..n */
IntervalSet[] altLookSets = factory.GetGrammar().decisionLOOK[decision];
altLook = GetAltLookaheadAsStringLists(altLookSets);
IntervalSet expecting = IntervalSet.Or(altLookSets); // combine alt sets
this.error = GetThrowNoViableAlt(factory, blkAST, expecting);
}