Example #1
0
	private void eventDef()
	{
		EnterRule_eventDef();
		EnterRule("eventDef", 7);
		TraceIn("eventDef", 7);
		LSLAst ID6 = default(LSLAst);

		try { DebugEnterRule(GrammarFileName, "eventDef");
		DebugLocation(103, 1);
		try
		{
			// Def.g:104:2: ( ^( EVENT_DEF ID ( . )* ) )
			DebugEnterAlt(1);
			// Def.g:104:4: ^( EVENT_DEF ID ( . )* )
			{
			DebugLocation(104, 4);
			DebugLocation(104, 6);
			Match(input,EVENT_DEF,Follow._EVENT_DEF_in_eventDef224); if (state.failed) return;

			Match(input, TokenTypes.Down, null); if (state.failed) return;
			DebugLocation(104, 16);
			ID6=(LSLAst)Match(input,ID,Follow._ID_in_eventDef226); if (state.failed) return;
			DebugLocation(104, 19);
			// Def.g:104:19: ( . )*
			try { DebugEnterSubRule(5);
			while (true)
			{
				int alt5=2;
				try { DebugEnterDecision(5, false);
				int LA5_0 = input.LA(1);

				if (((LA5_0>=ASSIGN_EQ && LA5_0<=95)))
				{
					alt5 = 1;
				}
				else if ((LA5_0==UP))
				{
					alt5 = 2;
				}


				} finally { DebugExitDecision(5); }
				switch ( alt5 )
				{
				case 1:
					DebugEnterAlt(1);
					// Def.g:104:19: .
					{
					DebugLocation(104, 19);
					MatchAny(input); if (state.failed) return;

					}
					break;

				default:
					goto loop5;
				}
			}

			loop5:
				;

			} finally { DebugExitSubRule(5); }


			Match(input, TokenTypes.Up, null); if (state.failed) return;
			DebugLocation(105, 3);
			if (state.backtracking == 1)
			{

							EventSymbol evtSym = new EventSymbol((ID6!=null?ID6.Text:null), currentScope);
							evtSym.Def = ID6;            // track AST location of def's ID
				        		ID6.symbol = evtSym;         // track in AST
							symtab.Define(evtSym, currentScope);
							currentEvent = evtSym;
							currentMethod = null;
							currentScope = evtSym;
						
			}

			}

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("eventDef", 7);
			LeaveRule("eventDef", 7);
			LeaveRule_eventDef();
		}
		DebugLocation(114, 1);
		} finally { DebugExitRule(GrammarFileName, "eventDef"); }
		return;

	}
Example #2
0
	private void methodDef()
	{
		EnterRule_methodDef();
		EnterRule("methodDef", 6);
		TraceIn("methodDef", 6);
		LSLAst ID5 = default(LSLAst);
		ISymbolType type4 = default(ISymbolType);

		try { DebugEnterRule(GrammarFileName, "methodDef");
		DebugLocation(79, 1);
		try
		{
			// Def.g:80:2: ( ^( METHOD_DEF ( type )? ID ( . )* ) )
			DebugEnterAlt(1);
			// Def.g:80:4: ^( METHOD_DEF ( type )? ID ( . )* )
			{
			DebugLocation(80, 4);
			DebugLocation(80, 6);
			Match(input,METHOD_DEF,Follow._METHOD_DEF_in_methodDef199); if (state.failed) return;

			Match(input, TokenTypes.Down, null); if (state.failed) return;
			DebugLocation(80, 17);
			// Def.g:80:17: ( type )?
			int alt3=2;
			try { DebugEnterSubRule(3);
			try { DebugEnterDecision(3, false);
			int LA3_0 = input.LA(1);

			if ((LA3_0==TYPE))
			{
				alt3 = 1;
			}
			} finally { DebugExitDecision(3); }
			switch (alt3)
			{
			case 1:
				DebugEnterAlt(1);
				// Def.g:80:17: type
				{
				DebugLocation(80, 17);
				PushFollow(Follow._type_in_methodDef201);
				type4=type();
				PopFollow();
				if (state.failed) return;

				}
				break;

			}
			} finally { DebugExitSubRule(3); }

			DebugLocation(80, 23);
			ID5=(LSLAst)Match(input,ID,Follow._ID_in_methodDef204); if (state.failed) return;
			DebugLocation(80, 26);
			// Def.g:80:26: ( . )*
			try { DebugEnterSubRule(4);
			while (true)
			{
				int alt4=2;
				try { DebugEnterDecision(4, false);
				int LA4_0 = input.LA(1);

				if (((LA4_0>=ASSIGN_EQ && LA4_0<=95)))
				{
					alt4 = 1;
				}
				else if ((LA4_0==UP))
				{
					alt4 = 2;
				}


				} finally { DebugExitDecision(4); }
				switch ( alt4 )
				{
				case 1:
					DebugEnterAlt(1);
					// Def.g:80:26: .
					{
					DebugLocation(80, 26);
					MatchAny(input); if (state.failed) return;

					}
					break;

				default:
					goto loop4;
				}
			}

			loop4:
				;

			} finally { DebugExitSubRule(4); }


			Match(input, TokenTypes.Up, null); if (state.failed) return;
			DebugLocation(81, 3);
			if (state.backtracking == 1)
			{

							MethodSymbol methSym;
							if (type4 == null)
							{
								methSym = new MethodSymbol((ID5!=null?ID5.Text:null), SymbolTable.VOID, currentScope);
							}
							else
							{
								methSym = new MethodSymbol((ID5!=null?ID5.Text:null), type4, currentScope);
							}
							
							symtab.Define(methSym, currentScope);

							methSym.Def = ID5;            // track AST location of def's ID
							ID5.symbol = methSym;         // track in AST

							currentMethod = methSym;
							currentEvent = null;
							currentScope = methSym;
						
			}

			}

		}
		catch (RecognitionException re)
		{
			ReportError(re);
			Recover(input,re);
		}
		finally
		{
			TraceOut("methodDef", 6);
			LeaveRule("methodDef", 6);
			LeaveRule_methodDef();
		}
		DebugLocation(101, 1);
		} finally { DebugExitRule(GrammarFileName, "methodDef"); }
		return;

	}