예제 #1
0
파일: Emitter.cs 프로젝트: BooMWax/ifmo
 private static void EmitStdProc(ILGenerator il, StdProc std)
 {
     switch (std.Type)
     {
         case StdProcType.Writeln:
             il.Emit(OpCodes.Call, typeof(Console).GetMethod("WriteLine", new []{ typeof(string) }));
             break;
         case StdProcType.Readln:
             il.Emit(OpCodes.Call, typeof(Console).GetMethod("ReadLine", BindingFlags.Public | BindingFlags.Static, null, new Type[] { }, null));
             break;
     }
 }
예제 #2
0
 private static void EmitStdProc(StdProc std)
 {
     switch (std.Type)
     {
         case StdProcType.Read:
             Source += "System.Console.Read( " + MakeString(std.Args) + " );\n";
             break;
         case StdProcType.Readln:
             Source += "System.Console.ReadLine( " + MakeString(std.Args) + " );\n";
             break;
         case StdProcType.Write:
             Source += "System.Console.Write( " + MakeString(std.Args) + " );\n";
             break;
         case StdProcType.Writeln:
             Source += "System.Console.WriteLine( " + MakeString(std.Args) + " );\n";
             break;
     }
 }
예제 #3
0
	public StdProc stdProc()
	{
		EnterRule_stdProc();
		EnterRule("stdProc", 24);
		TraceIn("stdProc", 24);
		StdProc st = default(StdProc);


		IToken READPROC46 = default(IToken);
		IToken READLNPROC48 = default(IToken);
		IToken WRITEPROC50 = default(IToken);
		IToken WRITELNPROC52 = default(IToken);
		List<List<IToken>> identifierListParam47 = default(List<List<IToken>>);
		List<List<IToken>> identifierListParam49 = default(List<List<IToken>>);
		List<List<IToken>> identifierListParam51 = default(List<List<IToken>>);
		List<List<IToken>> identifierListParam53 = default(List<List<IToken>>);


				st = new StdProc();
			
		try { DebugEnterRule(GrammarFileName, "stdProc");
		DebugLocation(484, 1);
		try
		{
			// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:489:2: ( READPROC LPAREN ( identifierListParam )? RPAREN | READLNPROC LPAREN ( identifierListParam )? RPAREN | WRITEPROC LPAREN ( identifierListParam )? RPAREN | WRITELNPROC LPAREN ( identifierListParam )? RPAREN )
			int alt26=4;
			try { DebugEnterDecision(26, false);
			switch (input.LA(1))
			{
			case READPROC:
				{
				alt26 = 1;
				}
				break;
			case READLNPROC:
				{
				alt26 = 2;
				}
				break;
			case WRITEPROC:
				{
				alt26 = 3;
				}
				break;
			case WRITELNPROC:
				{
				alt26 = 4;
				}
				break;
			default:
				{
					NoViableAltException nvae = new NoViableAltException("", 26, 0, input);
					DebugRecognitionException(nvae);
					throw nvae;
				}
			}

			} finally { DebugExitDecision(26); }
			switch (alt26)
			{
			case 1:
				DebugEnterAlt(1);
				// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:489:4: READPROC LPAREN ( identifierListParam )? RPAREN
				{
				DebugLocation(489, 4);
				READPROC46=(IToken)Match(input,READPROC,Follow._READPROC_in_stdProc1705); 
				DebugLocation(489, 13);
				 st.SetName(READPROC46); st.SetStdProcType(); 
				DebugLocation(489, 63);
				Match(input,LPAREN,Follow._LPAREN_in_stdProc1709); 
				DebugLocation(489, 70);
				// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:489:70: ( identifierListParam )?
				int alt22=2;
				try { DebugEnterSubRule(22);
				try { DebugEnterDecision(22, false);
				int LA22_0 = input.LA(1);

				if ((LA22_0==ID))
				{
					alt22 = 1;
				}
				} finally { DebugExitDecision(22); }
				switch (alt22)
				{
				case 1:
					DebugEnterAlt(1);
					// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:489:72: identifierListParam
					{
					DebugLocation(489, 72);
					PushFollow(Follow._identifierListParam_in_stdProc1713);
					identifierListParam47=identifierListParam();
					PopFollow();

					DebugLocation(489, 92);
					 st.SetArgs(identifierListParam47); 

					}
					break;

				}
				} finally { DebugExitSubRule(22); }

				DebugLocation(489, 139);
				Match(input,RPAREN,Follow._RPAREN_in_stdProc1719); 

				}
				break;
			case 2:
				DebugEnterAlt(2);
				// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:490:4: READLNPROC LPAREN ( identifierListParam )? RPAREN
				{
				DebugLocation(490, 4);
				READLNPROC48=(IToken)Match(input,READLNPROC,Follow._READLNPROC_in_stdProc1724); 
				DebugLocation(490, 15);
				 st.SetName(READLNPROC48); st.SetStdProcType(); 
				DebugLocation(490, 67);
				Match(input,LPAREN,Follow._LPAREN_in_stdProc1728); 
				DebugLocation(490, 74);
				// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:490:74: ( identifierListParam )?
				int alt23=2;
				try { DebugEnterSubRule(23);
				try { DebugEnterDecision(23, false);
				int LA23_0 = input.LA(1);

				if ((LA23_0==ID))
				{
					alt23 = 1;
				}
				} finally { DebugExitDecision(23); }
				switch (alt23)
				{
				case 1:
					DebugEnterAlt(1);
					// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:490:76: identifierListParam
					{
					DebugLocation(490, 76);
					PushFollow(Follow._identifierListParam_in_stdProc1732);
					identifierListParam49=identifierListParam();
					PopFollow();

					DebugLocation(490, 96);
					 st.SetArgs(identifierListParam49); 

					}
					break;

				}
				} finally { DebugExitSubRule(23); }

				DebugLocation(490, 143);
				Match(input,RPAREN,Follow._RPAREN_in_stdProc1738); 

				}
				break;
			case 3:
				DebugEnterAlt(3);
				// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:491:4: WRITEPROC LPAREN ( identifierListParam )? RPAREN
				{
				DebugLocation(491, 4);
				WRITEPROC50=(IToken)Match(input,WRITEPROC,Follow._WRITEPROC_in_stdProc1743); 
				DebugLocation(491, 14);
				 st.SetName(WRITEPROC50); st.SetStdProcType(); 
				DebugLocation(491, 65);
				Match(input,LPAREN,Follow._LPAREN_in_stdProc1747); 
				DebugLocation(491, 72);
				// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:491:72: ( identifierListParam )?
				int alt24=2;
				try { DebugEnterSubRule(24);
				try { DebugEnterDecision(24, false);
				int LA24_0 = input.LA(1);

				if ((LA24_0==ID))
				{
					alt24 = 1;
				}
				} finally { DebugExitDecision(24); }
				switch (alt24)
				{
				case 1:
					DebugEnterAlt(1);
					// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:491:74: identifierListParam
					{
					DebugLocation(491, 74);
					PushFollow(Follow._identifierListParam_in_stdProc1751);
					identifierListParam51=identifierListParam();
					PopFollow();

					DebugLocation(491, 94);
					 st.SetArgs(identifierListParam51); 

					}
					break;

				}
				} finally { DebugExitSubRule(24); }

				DebugLocation(491, 195);
				Match(input,RPAREN,Follow._RPAREN_in_stdProc1759); 

				}
				break;
			case 4:
				DebugEnterAlt(4);
				// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:492:4: WRITELNPROC LPAREN ( identifierListParam )? RPAREN
				{
				DebugLocation(492, 4);
				WRITELNPROC52=(IToken)Match(input,WRITELNPROC,Follow._WRITELNPROC_in_stdProc1764); 
				DebugLocation(492, 16);
				 st.SetName(WRITELNPROC52); st.SetStdProcType(); 
				DebugLocation(492, 69);
				Match(input,LPAREN,Follow._LPAREN_in_stdProc1768); 
				DebugLocation(492, 76);
				// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:492:76: ( identifierListParam )?
				int alt25=2;
				try { DebugEnterSubRule(25);
				try { DebugEnterDecision(25, false);
				int LA25_0 = input.LA(1);

				if ((LA25_0==ID))
				{
					alt25 = 1;
				}
				} finally { DebugExitDecision(25); }
				switch (alt25)
				{
				case 1:
					DebugEnterAlt(1);
					// D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:492:78: identifierListParam
					{
					DebugLocation(492, 78);
					PushFollow(Follow._identifierListParam_in_stdProc1772);
					identifierListParam53=identifierListParam();
					PopFollow();

					DebugLocation(492, 98);
					 st.SetArgs(identifierListParam53); 

					}
					break;

				}
				} finally { DebugExitSubRule(25); }

				DebugLocation(492, 199);
				Match(input,RPAREN,Follow._RPAREN_in_stdProc1780); 

				}
				break;

			}
		}

			catch (RecognitionException e)
			{
		        	throw e;
		    	}

		finally
		{
			TraceOut("stdProc", 24);
			LeaveRule("stdProc", 24);
			LeaveRule_stdProc();
		}
		DebugLocation(493, 1);
		} finally { DebugExitRule(GrammarFileName, "stdProc"); }
		return st;

	}