예제 #1
0
	// $ANTLR end "ANY"

	public override void mTokens()
	{
		// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:1:8: ( T__16 | T__17 | T__18 | T__19 | T__20 | T__21 | USING | ID | NEWLINE | WHITESPACE | ANY )
		int alt4=11;
		try { DebugEnterDecision(4, false);
		int LA4_0 = input.LA(1);

		if ((LA4_0=='.'))
		{
			alt4 = 1;
		}
		else if ((LA4_0==':'))
		{
			alt4 = 2;
		}
		else if ((LA4_0=='?'))
		{
			alt4 = 3;
		}
		else if ((LA4_0=='@'))
		{
			alt4 = 4;
		}
		else if ((LA4_0=='['))
		{
			alt4 = 5;
		}
		else if ((LA4_0==']'))
		{
			alt4 = 6;
		}
		else if ((LA4_0=='U'||LA4_0=='u'))
		{
			int LA4_7 = input.LA(2);

			if ((LA4_7=='S'||LA4_7=='s'))
			{
				int LA4_19 = input.LA(3);

				if ((LA4_19=='I'||LA4_19=='i'))
				{
					int LA4_23 = input.LA(4);

					if ((LA4_23=='N'||LA4_23=='n'))
					{
						int LA4_24 = input.LA(5);

						if ((LA4_24=='G'||LA4_24=='g'))
						{
							int LA4_25 = input.LA(6);

							if (((LA4_25>='0' && LA4_25<='9')||(LA4_25>='A' && LA4_25<='Z')||LA4_25=='_'||(LA4_25>='a' && LA4_25<='z')))
							{
								alt4 = 8;
							}
							else
							{
								alt4 = 7;
							}
						}
						else
						{
							alt4 = 8;
						}
					}
					else
					{
						alt4 = 8;
					}
				}
				else
				{
					alt4 = 8;
				}
			}
			else
			{
				alt4 = 8;
			}
		}
		else if (((LA4_0>='A' && LA4_0<='T')||(LA4_0>='V' && LA4_0<='Z')||LA4_0=='_'||(LA4_0>='a' && LA4_0<='t')||(LA4_0>='v' && LA4_0<='z')))
		{
			alt4 = 8;
		}
		else if ((LA4_0=='\r'))
		{
			int LA4_9 = input.LA(2);

			if ((LA4_9=='\n'))
			{
				alt4 = 9;
			}
			else
			{
				alt4 = 11;
			}
		}
		else if ((LA4_0=='\n'))
		{
			alt4 = 9;
		}
		else if ((LA4_0=='\t'||LA4_0==' '))
		{
			alt4 = 10;
		}
		else if (((LA4_0>='\u0000' && LA4_0<='\b')||(LA4_0>='\u000B' && LA4_0<='\f')||(LA4_0>='\u000E' && LA4_0<='\u001F')||(LA4_0>='!' && LA4_0<='-')||(LA4_0>='/' && LA4_0<='9')||(LA4_0>=';' && LA4_0<='>')||LA4_0=='\\'||LA4_0=='^'||LA4_0=='`'||(LA4_0>='{' && LA4_0<='\uFFFF')))
		{
			alt4 = 11;
		}
		else
		{
			NoViableAltException nvae = new NoViableAltException("", 4, 0, input);
			DebugRecognitionException(nvae);
			throw nvae;
		}
		} finally { DebugExitDecision(4); }
		switch (alt4)
		{
		case 1:
			DebugEnterAlt(1);
			// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:1:10: T__16
			{
			DebugLocation(1, 10);
			mT__16(); 

			}
			break;
		case 2:
			DebugEnterAlt(2);
			// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:1:16: T__17
			{
			DebugLocation(1, 16);
			mT__17(); 

			}
			break;
		case 3:
			DebugEnterAlt(3);
			// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:1:22: T__18
			{
			DebugLocation(1, 22);
			mT__18(); 

			}
			break;
		case 4:
			DebugEnterAlt(4);
			// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:1:28: T__19
			{
			DebugLocation(1, 28);
			mT__19(); 

			}
			break;
		case 5:
			DebugEnterAlt(5);
			// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:1:34: T__20
			{
			DebugLocation(1, 34);
			mT__20(); 

			}
			break;
		case 6:
			DebugEnterAlt(6);
			// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:1:40: T__21
			{
			DebugLocation(1, 40);
			mT__21(); 

			}
			break;
		case 7:
			DebugEnterAlt(7);
			// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:1:46: USING
			{
			DebugLocation(1, 46);
			mUSING(); 

			}
			break;
		case 8:
			DebugEnterAlt(8);
			// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:1:52: ID
			{
			DebugLocation(1, 52);
			mID(); 

			}
			break;
		case 9:
			DebugEnterAlt(9);
			// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:1:55: NEWLINE
			{
			DebugLocation(1, 55);
			mNEWLINE(); 

			}
			break;
		case 10:
			DebugEnterAlt(10);
			// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:1:63: WHITESPACE
			{
			DebugLocation(1, 63);
			mWHITESPACE(); 

			}
			break;
		case 11:
			DebugEnterAlt(11);
			// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:1:74: ANY
			{
			DebugLocation(1, 74);
			mANY(); 

			}
			break;

		}

	}
예제 #2
0
	private AstParserRuleReturnScope<object, IToken> outputToken()
	{
		EnterRule_outputToken();
		EnterRule("outputToken", 6);
		TraceIn("outputToken", 6);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);

		object root_0 = default(object);

		IToken id = default(IToken);
		IToken char_literal12 = default(IToken);
		IToken char_literal14 = default(IToken);
		IToken char_literal15 = default(IToken);
		IToken char_literal16 = default(IToken);
		AstParserRuleReturnScope<object, IToken> type13 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> type17 = default(AstParserRuleReturnScope<object, IToken>);

		object id_tree = default(object);
		object char_literal12_tree = default(object);
		object char_literal14_tree = default(object);
		object char_literal15_tree = default(object);
		object char_literal16_tree = default(object);
		RewriteRuleITokenStream stream_21=new RewriteRuleITokenStream(adaptor,"token 21");
		RewriteRuleITokenStream stream_20=new RewriteRuleITokenStream(adaptor,"token 20");
		RewriteRuleITokenStream stream_ID=new RewriteRuleITokenStream(adaptor,"token ID");
		RewriteRuleITokenStream stream_17=new RewriteRuleITokenStream(adaptor,"token 17");
		RewriteRuleSubtreeStream stream_type=new RewriteRuleSubtreeStream(adaptor,"rule type");
		try { DebugEnterRule(GrammarFileName, "outputToken");
		DebugLocation(39, 1);
		try
		{
			// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:40:2: ( ( ID ':' )=>id= ID ':' type -> ^( OUTPUT_TOKEN $id type ) | ( '[' ID ']' )=> '[' id= ID ']' ':' type -> ^( OUTPUT_TOKEN $id type ) )
			int alt5=2;
			try { DebugEnterDecision(5, false);
			int LA5_0 = input.LA(1);

			if ((LA5_0==ID) && (EvaluatePredicate(synpred2_TypeSql_fragment)))
			{
				alt5 = 1;
			}
			else if ((LA5_0==20) && (EvaluatePredicate(synpred3_TypeSql_fragment)))
			{
				alt5 = 2;
			}
			else
			{
				if (state.backtracking>0) {state.failed=true; return retval;}
				NoViableAltException nvae = new NoViableAltException("", 5, 0, input);
				DebugRecognitionException(nvae);
				throw nvae;
			}
			} finally { DebugExitDecision(5); }
			switch (alt5)
			{
			case 1:
				DebugEnterAlt(1);
				// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:40:4: ( ID ':' )=>id= ID ':' type
				{
				DebugLocation(40, 17);
				id=(IToken)Match(input,ID,Follow._ID_in_outputToken228); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_ID.Add(id);

				DebugLocation(40, 21);
				char_literal12=(IToken)Match(input,17,Follow._17_in_outputToken230); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_17.Add(char_literal12);

				DebugLocation(40, 25);
				PushFollow(Follow._type_in_outputToken232);
				type13=type();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_type.Add(type13.Tree);


				{
				// AST REWRITE
				// elements: type, id
				// token labels: id
				// rule labels: retval
				// token list labels: 
				// rule list labels: 
				// wildcard labels: 
				if (state.backtracking == 0) {
				retval.Tree = root_0;
				RewriteRuleITokenStream stream_id=new RewriteRuleITokenStream(adaptor,"token id",id);
				RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

				root_0 = (object)adaptor.Nil();
				// 40:30: -> ^( OUTPUT_TOKEN $id type )
				{
					DebugLocation(40, 33);
					// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:40:33: ^( OUTPUT_TOKEN $id type )
					{
					object root_1 = (object)adaptor.Nil();
					DebugLocation(40, 35);
					root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(OUTPUT_TOKEN, "OUTPUT_TOKEN"), root_1);

					DebugLocation(40, 49);
					adaptor.AddChild(root_1, stream_id.NextNode());
					DebugLocation(40, 52);
					adaptor.AddChild(root_1, stream_type.NextTree());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:41:4: ( '[' ID ']' )=> '[' id= ID ']' ':' type
				{
				DebugLocation(41, 18);
				char_literal14=(IToken)Match(input,20,Follow._20_in_outputToken256); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_20.Add(char_literal14);

				DebugLocation(41, 24);
				id=(IToken)Match(input,ID,Follow._ID_in_outputToken260); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_ID.Add(id);

				DebugLocation(41, 28);
				char_literal15=(IToken)Match(input,21,Follow._21_in_outputToken262); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_21.Add(char_literal15);

				DebugLocation(41, 32);
				char_literal16=(IToken)Match(input,17,Follow._17_in_outputToken264); if (state.failed) return retval; 
				if (state.backtracking == 0) stream_17.Add(char_literal16);

				DebugLocation(41, 36);
				PushFollow(Follow._type_in_outputToken266);
				type17=type();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) stream_type.Add(type17.Tree);


				{
				// AST REWRITE
				// elements: id, type
				// token labels: id
				// rule labels: retval
				// token list labels: 
				// rule list labels: 
				// wildcard labels: 
				if (state.backtracking == 0) {
				retval.Tree = root_0;
				RewriteRuleITokenStream stream_id=new RewriteRuleITokenStream(adaptor,"token id",id);
				RewriteRuleSubtreeStream stream_retval=new RewriteRuleSubtreeStream(adaptor,"rule retval",retval!=null?retval.Tree:null);

				root_0 = (object)adaptor.Nil();
				// 41:41: -> ^( OUTPUT_TOKEN $id type )
				{
					DebugLocation(41, 44);
					// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:41:44: ^( OUTPUT_TOKEN $id type )
					{
					object root_1 = (object)adaptor.Nil();
					DebugLocation(41, 46);
					root_1 = (object)adaptor.BecomeRoot((object)adaptor.Create(OUTPUT_TOKEN, "OUTPUT_TOKEN"), root_1);

					DebugLocation(41, 60);
					adaptor.AddChild(root_1, stream_id.NextNode());
					DebugLocation(41, 63);
					adaptor.AddChild(root_1, stream_type.NextTree());

					adaptor.AddChild(root_0, root_1);
					}

				}

				retval.Tree = root_0;
				}
				}

				}
				break;

			}
			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("outputToken", 6);
			LeaveRule("outputToken", 6);
			LeaveRule_outputToken();
		}
		DebugLocation(42, 1);
		} finally { DebugExitRule(GrammarFileName, "outputToken"); }
		return retval;

	}
예제 #3
0
파일: DFA.cs 프로젝트: benpriebe/TypeSql
 protected virtual void NoViableAlt( int s, IIntStream input )
 {
     if ( recognizer.state.backtracking > 0 )
     {
         recognizer.state.failed = true;
         return;
     }
     NoViableAltException nvae =
         new NoViableAltException( Description,
                                  decisionNumber,
                                  s,
                                  input );
     Error( nvae );
     throw nvae;
 }
예제 #4
0
	private AstParserRuleReturnScope<object, IToken> token()
	{
		EnterRule_token();
		EnterRule("token", 5);
		TraceIn("token", 5);
		AstParserRuleReturnScope<object, IToken> retval = new AstParserRuleReturnScope<object, IToken>();
		retval.Start = (IToken)input.LT(1);

		object root_0 = default(object);

		IToken wildcard11 = default(IToken);
		AstParserRuleReturnScope<object, IToken> outputToken9 = default(AstParserRuleReturnScope<object, IToken>);
		AstParserRuleReturnScope<object, IToken> inputToken10 = default(AstParserRuleReturnScope<object, IToken>);

		object wildcard11_tree = default(object);
		try { DebugEnterRule(GrammarFileName, "token");
		DebugLocation(34, 1);
		try
		{
			// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:34:8: ( outputToken | ( '@' ID ':' )=> inputToken | . )
			int alt4=3;
			try { DebugEnterDecision(4, false);
			switch (input.LA(1))
			{
			case ID:
				{
				int LA4_1 = input.LA(2);

				if ((LA4_1==17))
				{
					int LA4_5 = input.LA(3);

					if ((LA4_5==ID))
					{
						alt4 = 1;
					}
					else if ((LA4_5==EOF||(LA4_5>=ANY && LA4_5<=DIGIT)||(LA4_5>=INPUT_TOKEN && LA4_5<=21)))
					{
						alt4 = 3;
					}
					else
					{
						if (state.backtracking>0) {state.failed=true; return retval;}
						NoViableAltException nvae = new NoViableAltException("", 4, 5, input);
						DebugRecognitionException(nvae);
						throw nvae;
					}
				}
				else if ((LA4_1==EOF||(LA4_1>=ANY && LA4_1<=16)||(LA4_1>=18 && LA4_1<=21)))
				{
					alt4 = 3;
				}
				else
				{
					if (state.backtracking>0) {state.failed=true; return retval;}
					NoViableAltException nvae = new NoViableAltException("", 4, 1, input);
					DebugRecognitionException(nvae);
					throw nvae;
				}
				}
				break;
			case 20:
				{
				int LA4_2 = input.LA(2);

				if ((LA4_2==ID))
				{
					int LA4_6 = input.LA(3);

					if ((LA4_6==21))
					{
						int LA4_9 = input.LA(4);

						if ((LA4_9==17))
						{
							int LA4_11 = input.LA(5);

							if ((LA4_11==ID))
							{
								alt4 = 1;
							}
							else if ((LA4_11==EOF||(LA4_11>=ANY && LA4_11<=DIGIT)||(LA4_11>=INPUT_TOKEN && LA4_11<=21)))
							{
								alt4 = 3;
							}
							else
							{
								if (state.backtracking>0) {state.failed=true; return retval;}
								NoViableAltException nvae = new NoViableAltException("", 4, 11, input);
								DebugRecognitionException(nvae);
								throw nvae;
							}
						}
						else if ((LA4_9==EOF||(LA4_9>=ANY && LA4_9<=16)||(LA4_9>=18 && LA4_9<=21)))
						{
							alt4 = 3;
						}
						else
						{
							if (state.backtracking>0) {state.failed=true; return retval;}
							NoViableAltException nvae = new NoViableAltException("", 4, 9, input);
							DebugRecognitionException(nvae);
							throw nvae;
						}
					}
					else if ((LA4_6==EOF||(LA4_6>=ANY && LA4_6<=20)))
					{
						alt4 = 3;
					}
					else
					{
						if (state.backtracking>0) {state.failed=true; return retval;}
						NoViableAltException nvae = new NoViableAltException("", 4, 6, input);
						DebugRecognitionException(nvae);
						throw nvae;
					}
				}
				else if ((LA4_2==EOF||(LA4_2>=ANY && LA4_2<=DIGIT)||(LA4_2>=INPUT_TOKEN && LA4_2<=21)))
				{
					alt4 = 3;
				}
				else
				{
					if (state.backtracking>0) {state.failed=true; return retval;}
					NoViableAltException nvae = new NoViableAltException("", 4, 2, input);
					DebugRecognitionException(nvae);
					throw nvae;
				}
				}
				break;
			case 19:
				{
				int LA4_3 = input.LA(2);

				if ((LA4_3==ID))
				{
					int LA4_7 = input.LA(3);

					if ((LA4_7==17))
					{
						int LA4_10 = input.LA(4);

						if ((LA4_10==ID))
						{
							int LA4_12 = input.LA(5);

							if ((EvaluatePredicate(synpred1_TypeSql_fragment)))
							{
								alt4 = 2;
							}
							else if ((true))
							{
								alt4 = 3;
							}
							else
							{
								if (state.backtracking>0) {state.failed=true; return retval;}
								NoViableAltException nvae = new NoViableAltException("", 4, 12, input);
								DebugRecognitionException(nvae);
								throw nvae;
							}
						}
						else if ((LA4_10==EOF||(LA4_10>=ANY && LA4_10<=DIGIT)||(LA4_10>=INPUT_TOKEN && LA4_10<=21)))
						{
							alt4 = 3;
						}
						else
						{
							if (state.backtracking>0) {state.failed=true; return retval;}
							NoViableAltException nvae = new NoViableAltException("", 4, 10, input);
							DebugRecognitionException(nvae);
							throw nvae;
						}
					}
					else if ((LA4_7==EOF||(LA4_7>=ANY && LA4_7<=16)||(LA4_7>=18 && LA4_7<=21)))
					{
						alt4 = 3;
					}
					else
					{
						if (state.backtracking>0) {state.failed=true; return retval;}
						NoViableAltException nvae = new NoViableAltException("", 4, 7, input);
						DebugRecognitionException(nvae);
						throw nvae;
					}
				}
				else if ((LA4_3==EOF||(LA4_3>=ANY && LA4_3<=DIGIT)||(LA4_3>=INPUT_TOKEN && LA4_3<=21)))
				{
					alt4 = 3;
				}
				else
				{
					if (state.backtracking>0) {state.failed=true; return retval;}
					NoViableAltException nvae = new NoViableAltException("", 4, 3, input);
					DebugRecognitionException(nvae);
					throw nvae;
				}
				}
				break;
			case ANY:
			case DIGIT:
			case INPUT_TOKEN:
			case NAMESPACE:
			case NEWLINE:
			case OUTPUT_TOKEN:
			case SQL:
			case TYPE:
			case TYPESQL:
			case USING:
			case WHITESPACE:
			case 16:
			case 17:
			case 18:
			case 21:
				{
				alt4 = 3;
				}
				break;
			default:
				{
					if (state.backtracking>0) {state.failed=true; return retval;}
					NoViableAltException nvae = new NoViableAltException("", 4, 0, input);
					DebugRecognitionException(nvae);
					throw nvae;
				}
			}

			} finally { DebugExitDecision(4); }
			switch (alt4)
			{
			case 1:
				DebugEnterAlt(1);
				// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:34:11: outputToken
				{
				root_0 = (object)adaptor.Nil();

				DebugLocation(34, 11);
				PushFollow(Follow._outputToken_in_token183);
				outputToken9=outputToken();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) adaptor.AddChild(root_0, outputToken9.Tree);

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:35:5: ( '@' ID ':' )=> inputToken
				{
				root_0 = (object)adaptor.Nil();

				DebugLocation(35, 21);
				PushFollow(Follow._inputToken_in_token199);
				inputToken10=inputToken();
				PopFollow();
				if (state.failed) return retval;
				if (state.backtracking == 0) adaptor.AddChild(root_0, inputToken10.Tree);

				}
				break;
			case 3:
				DebugEnterAlt(3);
				// C:\\Users\\mjr\\src\\TypeSql\\TypeSql\\Parsing\\TypeSql.g:36:5: .
				{
				root_0 = (object)adaptor.Nil();

				DebugLocation(36, 5);

				wildcard11=(IToken)input.LT(1);

				MatchAny(input); if (state.failed) return retval;
				if (state.backtracking == 0) {
				wildcard11_tree = (object)adaptor.Create(wildcard11);
				adaptor.AddChild(root_0, wildcard11_tree);
				}


				}
				break;

			}
			retval.Stop = (IToken)input.LT(-1);

			if (state.backtracking == 0) {
			retval.Tree = (object)adaptor.RulePostProcessing(root_0);
			adaptor.SetTokenBoundaries(retval.Tree, retval.Start, retval.Stop);
			}
		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		retval.Tree = (object)adaptor.ErrorNode(input, retval.Start, input.LT(-1), re);

		}
		finally
		{
			TraceOut("token", 5);
			LeaveRule("token", 5);
			LeaveRule_token();
		}
		DebugLocation(37, 1);
		} finally { DebugExitRule(GrammarFileName, "token"); }
		return retval;

	}
예제 #5
0
파일: DFA.cs 프로젝트: benpriebe/TypeSql
 /** <summary>A hook for debugging interface</summary> */
 public virtual void Error( NoViableAltException nvae )
 {
 }