本文整理汇总了C#中Antlr.Runtime.Tree.RewriteRuleTokenStream类的典型用法代码示例。如果您正苦于以下问题:C# RewriteRuleTokenStream类的具体用法?C# RewriteRuleTokenStream怎么用?C# RewriteRuleTokenStream使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RewriteRuleTokenStream类属于Antlr.Runtime.Tree命名空间,在下文中一共展示了RewriteRuleTokenStream类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CheckRewriteRuleTokenStreamConstructors
public void CheckRewriteRuleTokenStreamConstructors() {
RewriteRuleTokenStream tokenTest1 = new RewriteRuleTokenStream(CreateTreeAdaptor(),
"RewriteRuleTokenStream test1");
RewriteRuleTokenStream tokenTest2 = new RewriteRuleTokenStream(CreateTreeAdaptor(),
"RewriteRuleTokenStream test2", CreateToken(1,
"test token without any real context"));
RewriteRuleTokenStream tokenTest3 = new RewriteRuleTokenStream(CreateTreeAdaptor(),
"RewriteRuleTokenStream test3", CreateTokenList(4));
}
开发者ID:nikola-v,项目名称:jaustoolset,代码行数:11,代码来源:RewriteRuleXxxxStreamFixture.cs
示例2: name
// $ANTLR start "name"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:92:1: name : x= ID -> NAME[$x] ;
public name_return name() // throws RecognitionException [1]
{
var retval = new name_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken x = null;
CommonTree x_tree = null;
var stream_ID = new RewriteRuleTokenStream( adaptor, "token ID" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:93:2: (x= ID -> NAME[$x] )
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:93:4: x= ID
{
x = (IToken)Match( input, ID, FOLLOW_ID_in_name371 );
stream_ID.Add( x );
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 93:9: -> NAME[$x]
{
adaptor.AddChild( root_0, adaptor.Create( NAME, x ) );
}
retval.Tree = root_0;
retval.Tree = root_0;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
catch ( RecognitionException re )
{
ReportError( re );
Recover( input, re );
// Conversion of the second argument necessary, but harmless
retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
}
finally {}
return retval;
}
开发者ID:ChrisEdwards,项目名称:CalcEngine,代码行数:58,代码来源:AntlrCalcEngineParser.cs
示例3: baseClassDeclaration
// $ANTLR start "baseClassDeclaration"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:82:1: baseClassDeclaration : ':' name 'where' expression -> ^( BASE_CLASS name ^( DISCRIMINATOR expression ) ) ;
public baseClassDeclaration_return baseClassDeclaration() // throws RecognitionException [1]
{
var retval = new baseClassDeclaration_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken char_literal8 = null;
IToken string_literal10 = null;
name_return name9 = default( name_return );
expression_return expression11 = default( expression_return );
CommonTree char_literal8_tree = null;
CommonTree string_literal10_tree = null;
var stream_59 = new RewriteRuleTokenStream( adaptor, "token 59" );
var stream_58 = new RewriteRuleTokenStream( adaptor, "token 58" );
var stream_expression = new RewriteRuleSubtreeStream( adaptor, "rule expression" );
var stream_name = new RewriteRuleSubtreeStream( adaptor, "rule name" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:83:2: ( ':' name 'where' expression -> ^( BASE_CLASS name ^( DISCRIMINATOR expression ) ) )
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:83:4: ':' name 'where' expression
{
char_literal8 = (IToken)Match( input, 58, FOLLOW_58_in_baseClassDeclaration294 );
stream_58.Add( char_literal8 );
PushFollow( FOLLOW_name_in_baseClassDeclaration296 );
name9 = name();
state.followingStackPointer--;
stream_name.Add( name9.Tree );
string_literal10 = (IToken)Match( input, 59, FOLLOW_59_in_baseClassDeclaration298 );
stream_59.Add( string_literal10 );
PushFollow( FOLLOW_expression_in_baseClassDeclaration300 );
expression11 = expression();
state.followingStackPointer--;
stream_expression.Add( expression11.Tree );
// AST REWRITE
// elements: name, expression
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 83:32: -> ^( BASE_CLASS name ^( DISCRIMINATOR expression ) )
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:83:35: ^( BASE_CLASS name ^( DISCRIMINATOR expression ) )
{
var root_1 = (CommonTree)adaptor.GetNilNode();
root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( BASE_CLASS, "BASE_CLASS" ), root_1 );
adaptor.AddChild( root_1, stream_name.NextTree() );
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:83:54: ^( DISCRIMINATOR expression )
{
var root_2 = (CommonTree)adaptor.GetNilNode();
root_2 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( DISCRIMINATOR, "DISCRIMINATOR" ), root_2 );
adaptor.AddChild( root_2, stream_expression.NextTree() );
adaptor.AddChild( root_1, root_2 );
}
adaptor.AddChild( root_0, root_1 );
}
}
retval.Tree = root_0;
retval.Tree = root_0;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
catch ( RecognitionException re )
{
ReportError( re );
Recover( input, re );
// Conversion of the second argument necessary, but harmless
retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
}
finally {}
return retval;
}
开发者ID:ChrisEdwards,项目名称:CalcEngine,代码行数:97,代码来源:AntlrCalcEngineParser.cs
示例4: identifier
// $ANTLR start "identifier"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:262:1: identifier : ID -> ^( IDENTIFIER ID ) ;
public identifier_return identifier() // throws RecognitionException [1]
{
var retval = new identifier_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken ID92 = null;
CommonTree ID92_tree = null;
var stream_ID = new RewriteRuleTokenStream( adaptor, "token ID" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:263:2: ( ID -> ^( IDENTIFIER ID ) )
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:263:4: ID
{
ID92 = (IToken)Match( input, ID, FOLLOW_ID_in_identifier1399 );
stream_ID.Add( ID92 );
// AST REWRITE
// elements: ID
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 263:7: -> ^( IDENTIFIER ID )
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:263:10: ^( IDENTIFIER ID )
{
var root_1 = (CommonTree)adaptor.GetNilNode();
root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( IDENTIFIER, "IDENTIFIER" ), root_1 );
adaptor.AddChild( root_1, stream_ID.NextNode() );
adaptor.AddChild( root_0, root_1 );
}
}
retval.Tree = root_0;
retval.Tree = root_0;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
catch ( RecognitionException re )
{
ReportError( re );
Recover( input, re );
// Conversion of the second argument necessary, but harmless
retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
}
finally {}
return retval;
}
开发者ID:ChrisEdwards,项目名称:CalcEngine,代码行数:66,代码来源:AntlrCalcEngineParser.cs
示例5: criteria
// $ANTLR start "criteria"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:248:1: criteria : '[' expression ']' -> ^( CRITERIA expression ) ;
public criteria_return criteria() // throws RecognitionException [1]
{
var retval = new criteria_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken char_literal84 = null;
IToken char_literal86 = null;
expression_return expression85 = default( expression_return );
CommonTree char_literal84_tree = null;
CommonTree char_literal86_tree = null;
var stream_93 = new RewriteRuleTokenStream( adaptor, "token 93" );
var stream_92 = new RewriteRuleTokenStream( adaptor, "token 92" );
var stream_expression = new RewriteRuleSubtreeStream( adaptor, "rule expression" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:249:2: ( '[' expression ']' -> ^( CRITERIA expression ) )
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:249:4: '[' expression ']'
{
char_literal84 = (IToken)Match( input, 92, FOLLOW_92_in_criteria1320 );
stream_92.Add( char_literal84 );
PushFollow( FOLLOW_expression_in_criteria1322 );
expression85 = expression();
state.followingStackPointer--;
stream_expression.Add( expression85.Tree );
char_literal86 = (IToken)Match( input, 93, FOLLOW_93_in_criteria1324 );
stream_93.Add( char_literal86 );
// AST REWRITE
// elements: expression
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 249:23: -> ^( CRITERIA expression )
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:249:26: ^( CRITERIA expression )
{
var root_1 = (CommonTree)adaptor.GetNilNode();
root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( CRITERIA, "CRITERIA" ), root_1 );
adaptor.AddChild( root_1, stream_expression.NextTree() );
adaptor.AddChild( root_0, root_1 );
}
}
retval.Tree = root_0;
retval.Tree = root_0;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
catch ( RecognitionException re )
{
ReportError( re );
Recover( input, re );
// Conversion of the second argument necessary, but harmless
retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
}
finally {}
return retval;
}
开发者ID:ChrisEdwards,项目名称:CalcEngine,代码行数:79,代码来源:AntlrCalcEngineParser.cs
示例6: assignmentOp
// $ANTLR start "assignmentOp"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:224:1: assignmentOp : x= '=' -> OP_ASSIGN[$x] ;
public assignmentOp_return assignmentOp() // throws RecognitionException [1]
{
var retval = new assignmentOp_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken x = null;
CommonTree x_tree = null;
var stream_68 = new RewriteRuleTokenStream( adaptor, "token 68" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:225:2: (x= '=' -> OP_ASSIGN[$x] )
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:225:4: x= '='
{
x = (IToken)Match( input, 68, FOLLOW_68_in_assignmentOp1201 );
stream_68.Add( x );
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 225:10: -> OP_ASSIGN[$x]
{
adaptor.AddChild( root_0, adaptor.Create( OP_ASSIGN, x ) );
}
retval.Tree = root_0;
retval.Tree = root_0;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
catch ( RecognitionException re )
{
ReportError( re );
Recover( input, re );
// Conversion of the second argument necessary, but harmless
retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
}
finally {}
return retval;
}
开发者ID:ChrisEdwards,项目名称:CalcEngine,代码行数:58,代码来源:AntlrCalcEngineParser.cs
示例7: equalsOp
// $ANTLR start "equalsOp"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:189:1: equalsOp : (x= '==' -> OP_EQ[$x] | x= '=' -> OP_EQ[$x] );
public equalsOp_return equalsOp() // throws RecognitionException [1]
{
var retval = new equalsOp_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken x = null;
CommonTree x_tree = null;
var stream_79 = new RewriteRuleTokenStream( adaptor, "token 79" );
var stream_68 = new RewriteRuleTokenStream( adaptor, "token 68" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:190:2: (x= '==' -> OP_EQ[$x] | x= '=' -> OP_EQ[$x] )
int alt26 = 2;
int LA26_0 = input.LA( 1 );
if ( ( LA26_0 == 79 ) )
alt26 = 1;
else if ( ( LA26_0 == 68 ) )
alt26 = 2;
else
{
var nvae_d26s0 =
new NoViableAltException( "", 26, 0, input );
throw nvae_d26s0;
}
switch ( alt26 )
{
case 1:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:190:4: x= '=='
{
x = (IToken)Match( input, 79, FOLLOW_79_in_equalsOp988 );
stream_79.Add( x );
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 190:11: -> OP_EQ[$x]
{
adaptor.AddChild( root_0, adaptor.Create( OP_EQ, x ) );
}
retval.Tree = root_0;
retval.Tree = root_0;
}
break;
case 2:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:191:4: x= '='
{
x = (IToken)Match( input, 68, FOLLOW_68_in_equalsOp1001 );
stream_68.Add( x );
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 191:11: -> OP_EQ[$x]
{
adaptor.AddChild( root_0, adaptor.Create( OP_EQ, x ) );
}
retval.Tree = root_0;
retval.Tree = root_0;
}
break;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
catch ( RecognitionException re )
{
ReportError( re );
Recover( input, re );
// Conversion of the second argument necessary, but harmless
retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
//.........这里部分代码省略.........
开发者ID:ChrisEdwards,项目名称:CalcEngine,代码行数:101,代码来源:AntlrCalcEngineParser.cs
示例8: andOp
// $ANTLR start "andOp"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:181:1: andOp : (x= 'and' -> OP_AND[$x] | x= '&&' -> OP_AND[$x] );
public andOp_return andOp() // throws RecognitionException [1]
{
var retval = new andOp_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken x = null;
CommonTree x_tree = null;
var stream_75 = new RewriteRuleTokenStream( adaptor, "token 75" );
var stream_76 = new RewriteRuleTokenStream( adaptor, "token 76" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:182:2: (x= 'and' -> OP_AND[$x] | x= '&&' -> OP_AND[$x] )
int alt24 = 2;
int LA24_0 = input.LA( 1 );
if ( ( LA24_0 == 75 ) )
alt24 = 1;
else if ( ( LA24_0 == 76 ) )
alt24 = 2;
else
{
var nvae_d24s0 =
new NoViableAltException( "", 24, 0, input );
throw nvae_d24s0;
}
switch ( alt24 )
{
case 1:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:182:4: x= 'and'
{
x = (IToken)Match( input, 75, FOLLOW_75_in_andOp927 );
stream_75.Add( x );
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 182:12: -> OP_AND[$x]
{
adaptor.AddChild( root_0, adaptor.Create( OP_AND, x ) );
}
retval.Tree = root_0;
retval.Tree = root_0;
}
break;
case 2:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:183:4: x= '&&'
{
x = (IToken)Match( input, 76, FOLLOW_76_in_andOp939 );
stream_76.Add( x );
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 183:12: -> OP_AND[$x]
{
adaptor.AddChild( root_0, adaptor.Create( OP_AND, x ) );
}
retval.Tree = root_0;
retval.Tree = root_0;
}
break;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
catch ( RecognitionException re )
{
ReportError( re );
Recover( input, re );
// Conversion of the second argument necessary, but harmless
retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
//.........这里部分代码省略.........
开发者ID:ChrisEdwards,项目名称:CalcEngine,代码行数:101,代码来源:AntlrCalcEngineParser.cs
示例9: modulusOp
// $ANTLR start "modulusOp"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:185:1: modulusOp : (x= 'mod' -> OP_MODULUS[$x] | x= '%' -> OP_MODULUS[$x] );
public modulusOp_return modulusOp() // throws RecognitionException [1]
{
var retval = new modulusOp_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken x = null;
CommonTree x_tree = null;
var stream_78 = new RewriteRuleTokenStream( adaptor, "token 78" );
var stream_77 = new RewriteRuleTokenStream( adaptor, "token 77" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:186:2: (x= 'mod' -> OP_MODULUS[$x] | x= '%' -> OP_MODULUS[$x] )
int alt25 = 2;
int LA25_0 = input.LA( 1 );
if ( ( LA25_0 == 77 ) )
alt25 = 1;
else if ( ( LA25_0 == 78 ) )
alt25 = 2;
else
{
var nvae_d25s0 =
new NoViableAltException( "", 25, 0, input );
throw nvae_d25s0;
}
switch ( alt25 )
{
case 1:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:186:4: x= 'mod'
{
x = (IToken)Match( input, 77, FOLLOW_77_in_modulusOp957 );
stream_77.Add( x );
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 186:12: -> OP_MODULUS[$x]
{
adaptor.AddChild( root_0, adaptor.Create( OP_MODULUS, x ) );
}
retval.Tree = root_0;
retval.Tree = root_0;
}
break;
case 2:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:187:4: x= '%'
{
x = (IToken)Match( input, 78, FOLLOW_78_in_modulusOp969 );
stream_78.Add( x );
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 187:12: -> OP_MODULUS[$x]
{
adaptor.AddChild( root_0, adaptor.Create( OP_MODULUS, x ) );
}
retval.Tree = root_0;
retval.Tree = root_0;
}
break;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
catch ( RecognitionException re )
{
ReportError( re );
Recover( input, re );
// Conversion of the second argument necessary, but harmless
retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
//.........这里部分代码省略.........
开发者ID:ChrisEdwards,项目名称:CalcEngine,代码行数:101,代码来源:AntlrCalcEngineParser.cs
示例10: notEqualsOp
// $ANTLR start "notEqualsOp"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:193:1: notEqualsOp : (x= '!=' -> OP_NE[$x] | x= '<>' -> OP_NE[$x] );
public notEqualsOp_return notEqualsOp() // throws RecognitionException [1]
{
var retval = new notEqualsOp_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken x = null;
CommonTree x_tree = null;
var stream_80 = new RewriteRuleTokenStream( adaptor, "token 80" );
var stream_81 = new RewriteRuleTokenStream( adaptor, "token 81" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:194:2: (x= '!=' -> OP_NE[$x] | x= '<>' -> OP_NE[$x] )
int alt27 = 2;
int LA27_0 = input.LA( 1 );
if ( ( LA27_0 == 80 ) )
alt27 = 1;
else if ( ( LA27_0 == 81 ) )
alt27 = 2;
else
{
var nvae_d27s0 =
new NoViableAltException( "", 27, 0, input );
throw nvae_d27s0;
}
switch ( alt27 )
{
case 1:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:194:4: x= '!='
{
x = (IToken)Match( input, 80, FOLLOW_80_in_notEqualsOp1019 );
stream_80.Add( x );
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 194:11: -> OP_NE[$x]
{
adaptor.AddChild( root_0, adaptor.Create( OP_NE, x ) );
}
retval.Tree = root_0;
retval.Tree = root_0;
}
break;
case 2:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:195:4: x= '<>'
{
x = (IToken)Match( input, 81, FOLLOW_81_in_notEqualsOp1031 );
stream_81.Add( x );
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 195:11: -> OP_NE[$x]
{
adaptor.AddChild( root_0, adaptor.Create( OP_NE, x ) );
}
retval.Tree = root_0;
retval.Tree = root_0;
}
break;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
catch ( RecognitionException re )
{
ReportError( re );
Recover( input, re );
// Conversion of the second argument necessary, but harmless
retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
//.........这里部分代码省略.........
开发者ID:ChrisEdwards,项目名称:CalcEngine,代码行数:101,代码来源:AntlrCalcEngineParser.cs
示例11: classDeclaration
// $ANTLR start "classDeclaration"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:79:1: classDeclaration : 'class' name ( baseClassDeclaration )? classStatementBlock -> ^( CLASS name ( baseClassDeclaration )? classStatementBlock ) ;
public classDeclaration_return classDeclaration() // throws RecognitionException [1]
{
var retval = new classDeclaration_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken string_literal4 = null;
name_return name5 = default( name_return );
baseClassDeclaration_return baseClassDeclaration6 = default( baseClassDeclaration_return );
classStatementBlock_return classStatementBlock7 = default( classStatementBlock_return );
CommonTree string_literal4_tree = null;
var stream_57 = new RewriteRuleTokenStream( adaptor, "token 57" );
var stream_classStatementBlock = new RewriteRuleSubtreeStream( adaptor, "rule classStatementBlock" );
var stream_name = new RewriteRuleSubtreeStream( adaptor, "rule name" );
var stream_baseClassDeclaration = new RewriteRuleSubtreeStream( adaptor, "rule baseClassDeclaration" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:2: ( 'class' name ( baseClassDeclaration )? classStatementBlock -> ^( CLASS name ( baseClassDeclaration )? classStatementBlock ) )
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:4: 'class' name ( baseClassDeclaration )? classStatementBlock
{
string_literal4 = (IToken)Match( input, 57, FOLLOW_57_in_classDeclaration262 );
stream_57.Add( string_literal4 );
PushFollow( FOLLOW_name_in_classDeclaration264 );
name5 = name();
state.followingStackPointer--;
stream_name.Add( name5.Tree );
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:17: ( baseClassDeclaration )?
int alt3 = 2;
int LA3_0 = input.LA( 1 );
if ( ( LA3_0 == 58 ) )
alt3 = 1;
switch ( alt3 )
{
case 1:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:17: baseClassDeclaration
{
PushFollow( FOLLOW_baseClassDeclaration_in_classDeclaration266 );
baseClassDeclaration6 = baseClassDeclaration();
state.followingStackPointer--;
stream_baseClassDeclaration.Add( baseClassDeclaration6.Tree );
}
break;
}
PushFollow( FOLLOW_classStatementBlock_in_classDeclaration269 );
classStatementBlock7 = classStatementBlock();
state.followingStackPointer--;
stream_classStatementBlock.Add( classStatementBlock7.Tree );
// AST REWRITE
// elements: name, classStatementBlock, baseClassDeclaration
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 80:59: -> ^( CLASS name ( baseClassDeclaration )? classStatementBlock )
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:62: ^( CLASS name ( baseClassDeclaration )? classStatementBlock )
{
var root_1 = (CommonTree)adaptor.GetNilNode();
root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( CLASS, "CLASS" ), root_1 );
adaptor.AddChild( root_1, stream_name.NextTree() );
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:80:76: ( baseClassDeclaration )?
if ( stream_baseClassDeclaration.HasNext() )
adaptor.AddChild( root_1, stream_baseClassDeclaration.NextTree() );
stream_baseClassDeclaration.Reset();
adaptor.AddChild( root_1, stream_classStatementBlock.NextTree() );
adaptor.AddChild( root_0, root_1 );
}
}
retval.Tree = root_0;
retval.Tree = root_0;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
//.........这里部分代码省略.........
开发者ID:ChrisEdwards,项目名称:CalcEngine,代码行数:101,代码来源:AntlrCalcEngineParser.cs
示例12: functionCall
// $ANTLR start "functionCall"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:255:1: functionCall : x= ID '(' ( expression ( ',' expression )* )? ')' -> ^( FUNCTION[$x] ( expression )* ) ;
public functionCall_return functionCall() // throws RecognitionException [1]
{
var retval = new functionCall_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken x = null;
IToken char_literal87 = null;
IToken char_literal89 = null;
IToken char_literal91 = null;
expression_return expression88 = default( expression_return );
expression_return expression90 = default( expression_return );
CommonTree x_tree = null;
CommonTree char_literal87_tree = null;
CommonTree char_literal89_tree = null;
CommonTree char_literal91_tree = null;
var stream_69 = new RewriteRuleTokenStream( adaptor, "token 69" );
var stream_94 = new RewriteRuleTokenStream( adaptor, "token 94" );
var stream_ID = new RewriteRuleTokenStream( adaptor, "token ID" );
var stream_70 = new RewriteRuleTokenStream( adaptor, "token 70" );
var stream_expression = new RewriteRuleSubtreeStream( adaptor, "rule expression" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:2: (x= ID '(' ( expression ( ',' expression )* )? ')' -> ^( FUNCTION[$x] ( expression )* ) )
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:4: x= ID '(' ( expression ( ',' expression )* )? ')'
{
x = (IToken)Match( input, ID, FOLLOW_ID_in_functionCall1352 );
stream_ID.Add( x );
char_literal87 = (IToken)Match( input, 69, FOLLOW_69_in_functionCall1354 );
stream_69.Add( char_literal87 );
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:13: ( expression ( ',' expression )* )?
int alt33 = 2;
int LA33_0 = input.LA( 1 );
if ( ( ( LA33_0 >= ID && LA33_0 <= FLOAT ) || LA33_0 == 69 || ( LA33_0 >= 71 && LA33_0 <= 72 ) || LA33_0 == 87 || LA33_0 == 91 || ( LA33_0 >= 95 && LA33_0 <= 96 ) ) )
alt33 = 1;
switch ( alt33 )
{
case 1:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:15: expression ( ',' expression )*
{
PushFollow( FOLLOW_expression_in_functionCall1358 );
expression88 = expression();
state.followingStackPointer--;
stream_expression.Add( expression88.Tree );
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:26: ( ',' expression )*
do
{
int alt32 = 2;
int LA32_0 = input.LA( 1 );
if ( ( LA32_0 == 94 ) )
alt32 = 1;
switch ( alt32 )
{
case 1:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:256:28: ',' expression
{
char_literal89 = (IToken)Match( input, 94, FOLLOW_94_in_functionCall1362 );
stream_94.Add( char_literal89 );
PushFollow( FOLLOW_expression_in_functionCall1364 );
expression90 = expression();
state.followingStackPointer--;
stream_expression.Add( expression90.Tree );
}
break;
default:
goto loop32;
}
} while ( true );
loop32:
; // Stops C# compiler whining that label 'loop32' has no statements
}
break;
}
char_literal91 = (IToken)Match( input, 70, FOLLOW_70_in_functionCall1372 );
stream_70.Add( char_literal91 );
// AST REWRITE
// elements: expression
// token labels:
// rule labels: retval
// token list labels:
//.........这里部分代码省略.........
开发者ID:ChrisEdwards,项目名称:CalcEngine,代码行数:101,代码来源:AntlrCalcEngineParser.cs
示例13: relationshipDeclaration
// $ANTLR start "relationshipDeclaration"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:113:1: relationshipDeclaration : 'relationship' name '=' relationshipJoinDeclaration ';' -> ^( RELATIONSHIP name relationshipJoinDeclaration ) ;
public relationshipDeclaration_return relationshipDeclaration() // throws RecognitionException [1]
{
var retval = new relationshipDeclaration_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken string_literal25 = null;
IToken char_literal27 = null;
IToken char_literal29 = null;
name_return name26 = default( name_return );
relationshipJoinDeclaration_return relationshipJoinDeclaration28 = default( relationshipJoinDeclaration_return );
CommonTree string_literal25_tree = null;
CommonTree char_literal27_tree = null;
CommonTree char_literal29_tree = null;
var stream_67 = new RewriteRuleTokenStream( adaptor, "token 67" );
var stream_68 = new RewriteRuleTokenStream( adaptor, "token 68" );
var stream_63 = new RewriteRuleTokenStream( adaptor, "token 63" );
var stream_name = new RewriteRuleSubtreeStream( adaptor, "rule name" );
var stream_relationshipJoinDeclaration = new RewriteRuleSubtreeStream( adaptor, "rule relationshipJoinDeclaration" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:114:2: ( 'relationship' name '=' relationshipJoinDeclaration ';' -> ^( RELATIONSHIP name relationshipJoinDeclaration ) )
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:114:4: 'relationship' name '=' relationshipJoinDeclaration ';'
{
string_literal25 = (IToken)Match( input, 67, FOLLOW_67_in_relationshipDeclaration484 );
stream_67.Add( string_literal25 );
PushFollow( FOLLOW_name_in_relationshipDeclaration486 );
name26 = name();
state.followingStackPointer--;
stream_name.Add( name26.Tree );
char_literal27 = (IToken)Match( input, 68, FOLLOW_68_in_relationshipDeclaration488 );
stream_68.Add( char_literal27 );
PushFollow( FOLLOW_relationshipJoinDeclaration_in_relationshipDeclaration490 );
relationshipJoinDeclaration28 = relationshipJoinDeclaration();
state.followingStackPointer--;
stream_relationshipJoinDeclaration.Add( relationshipJoinDeclaration28.Tree );
char_literal29 = (IToken)Match( input, 63, FOLLOW_63_in_relationshipDeclaration492 );
stream_63.Add( char_literal29 );
// AST REWRITE
// elements: name, relationshipJoinDeclaration
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 114:60: -> ^( RELATIONSHIP name relationshipJoinDeclaration )
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:114:63: ^( RELATIONSHIP name relationshipJoinDeclaration )
{
var root_1 = (CommonTree)adaptor.GetNilNode();
root_1 = (CommonTree)adaptor.BecomeRoot( adaptor.Create( RELATIONSHIP, "RELATIONSHIP" ), root_1 );
adaptor.AddChild( root_1, stream_name.NextTree() );
adaptor.AddChild( root_1, stream_relationshipJoinDeclaration.NextTree() );
adaptor.AddChild( root_0, root_1 );
}
}
retval.Tree = root_0;
retval.Tree = root_0;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
catch ( RecognitionException re )
{
ReportError( re );
Recover( input, re );
// Conversion of the second argument necessary, but harmless
retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
}
finally {}
return retval;
}
开发者ID:ChrisEdwards,项目名称:CalcEngine,代码行数:94,代码来源:AntlrCalcEngineParser.cs
示例14: booleanValue
// $ANTLR start "booleanValue"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:269:1: booleanValue : (x= 'true' -> TRUE[$x] | x= 'false' -> FALSE[$x] );
public booleanValue_return booleanValue() // throws RecognitionException [1]
{
var retval = new booleanValue_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken x = null;
CommonTree x_tree = null;
var stream_96 = new RewriteRuleTokenStream( adaptor, "token 96" );
var stream_95 = new RewriteRuleTokenStream( adaptor, "token 95" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:270:2: (x= 'true' -> TRUE[$x] | x= 'false' -> FALSE[$x] )
int alt34 = 2;
int LA34_0 = input.LA( 1 );
if ( ( LA34_0 == 95 ) )
alt34 = 1;
else if ( ( LA34_0 == 96 ) )
alt34 = 2;
else
{
var nvae_d34s0 =
new NoViableAltException( "", 34, 0, input );
throw nvae_d34s0;
}
switch ( alt34 )
{
case 1:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:270:4: x= 'true'
{
x = (IToken)Match( input, 95, FOLLOW_95_in_booleanValue1440 );
stream_95.Add( x );
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 270:13: -> TRUE[$x]
{
adaptor.AddChild( root_0, adaptor.Create( TRUE, x ) );
}
retval.Tree = root_0;
retval.Tree = root_0;
}
break;
case 2:
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:271:4: x= 'false'
{
x = (IToken)Match( input, 96, FOLLOW_96_in_booleanValue1452 );
stream_96.Add( x );
// AST REWRITE
// elements:
// token labels:
// rule labels: retval
// token list labels:
// rule list labels:
// wildcard labels:
retval.Tree = root_0;
var stream_retval = new RewriteRuleSubtreeStream( adaptor, "rule retval", retval != null ? retval.Tree : null );
root_0 = (CommonTree)adaptor.GetNilNode();
// 271:14: -> FALSE[$x]
{
adaptor.AddChild( root_0, adaptor.Create( FALSE, x ) );
}
retval.Tree = root_0;
retval.Tree = root_0;
}
break;
}
retval.Stop = input.LT( -1 );
retval.Tree = adaptor.RulePostProcessing( root_0 );
adaptor.SetTokenBoundaries( retval.Tree, (IToken)retval.Start, (IToken)retval.Stop );
}
catch ( RecognitionException re )
{
ReportError( re );
Recover( input, re );
// Conversion of the second argument necessary, but harmless
retval.Tree = adaptor.ErrorNode( input, (IToken)retval.Start, input.LT( -1 ), re );
//.........这里部分代码省略.........
开发者ID:ChrisEdwards,项目名称:CalcEngine,代码行数:101,代码来源:AntlrCalcEngineParser.cs
示例15: relationshipJoinDeclaration
// $ANTLR start "relationshipJoinDeclaration"
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:116:1: relationshipJoinDeclaration : name 'where' expression -> ^( JOIN ^( TARGET name ) ^( CRITERIA expression ) ) ;
public relationshipJoinDeclaration_return relationshipJoinDeclaration() // throws RecognitionException [1]
{
var retval = new relationshipJoinDeclaration_return();
retval.Start = input.LT( 1 );
CommonTree root_0 = null;
IToken string_literal31 = null;
name_return name30 = default( name_return );
expression_return expression32 = default( expression_return );
CommonTree string_literal31_tree = null;
var stream_59 = new RewriteRuleTokenStream( adaptor, "token 59" );
var stream_expression = new RewriteRuleSubtreeStream( adaptor, "rule expression" );
var stream_name = new RewriteRuleSubtreeStream( adaptor, "rule name" );
try
{
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:117:2: ( name 'where' expression -> ^( JOIN ^( TARGET name ) ^( CRITERIA expression ) ) )
// C:\\Projects\\CalcEngine\\src\\CalcEngine\\Parsers\\Antlr\\AntlrCalcEngine.g:117:4: name 'where' expression
{
PushFollow( FOLLOW_name_in_relationshipJoinDeclaration514 );
name30 = name();
state.followingStackPointer--;
stream_name.Add( name30.Tree )
|
请发表评论