本文整理汇总了C#中Antlr3.Tool.GrammarAST.HasSameTreeStructure方法的典型用法代码示例。如果您正苦于以下问题:C# GrammarAST.HasSameTreeStructure方法的具体用法?C# GrammarAST.HasSameTreeStructure怎么用?C# GrammarAST.HasSameTreeStructure使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Antlr3.Tool.GrammarAST
的用法示例。
在下文中一共展示了GrammarAST.HasSameTreeStructure方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TrackTokenRule
protected override void TrackTokenRule( GrammarAST t,
GrammarAST modifier,
GrammarAST block )
{
// imported token names might exist, only add if new
if ( grammar.type == GrammarType.Lexer || grammar.type == GrammarType.Combined )
{
if (Rule.GetRuleType(t.Text) == RuleType.Parser)
{
return;
}
if ( t.Text.Equals( Grammar.ArtificialTokensRuleName ) )
{
// don't add Tokens rule
return;
}
// track all lexer rules so we can look for token refs w/o
// associated lexer rules.
grammar.composite.LexerRules.Add( t.Text );
int existing = grammar.GetTokenType( t.Text );
if ( existing == Label.INVALID )
{
_tokens[t.Text] = Unassigned;
}
// look for "<TOKEN> : <literal> ;" pattern
// (can have optional action last)
if ( block.HasSameTreeStructure( charAlias ) ||
block.HasSameTreeStructure( stringAlias ) ||
block.HasSameTreeStructure( charAlias2 ) ||
block.HasSameTreeStructure( stringAlias2 ) )
{
tokenRuleDefs.Add( t.Text );
/*
Grammar parent = grammar.composite.getDelegator(grammar);
boolean importedByParserOrCombined =
parent!=null &&
(parent.type==GrammarType.Lexer||parent.type==GrammarType.Parser);
*/
if ( grammar.type == GrammarType.Combined || grammar.type == GrammarType.Lexer )
{
// only call this rule an alias if combined or lexer
Alias( t, (GrammarAST)block.GetChild( 0 ).GetChild( 0 ) );
}
}
}
// else error
}