public void SetForStruct(ForStruct fs) { Fs = fs; }
private static string MakeString(ForStruct fs, string id) { string appendix; if (fs.To) appendix = id + "<=" + MakeString(fs.FinalExpr) + "; ++" + id; else { appendix = id + ">=" + MakeString(fs.FinalExpr) + "; --" + id; } return id +"=" + MakeString(fs.InitExpr) + ";" + appendix; }
public ForStruct forList() { EnterRule_forList(); EnterRule("forList", 20); TraceIn("forList", 20); ForStruct fs = default(ForStruct); Expression s = default(Expression); Expression f = default(Expression); fs = new ForStruct(); try { DebugEnterRule(GrammarFileName, "forList"); DebugLocation(418, 5); try { // D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:423:6: (s= expression ( TO | DOWNTO ) f= expression ) DebugEnterAlt(1); // D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:423:8: s= expression ( TO | DOWNTO ) f= expression { DebugLocation(423, 10); PushFollow(Follow._expression_in_forList1444); s=expression(); PopFollow(); DebugLocation(424, 7); fs.SetInitExpr(s); DebugLocation(427, 7); // D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:427:7: ( TO | DOWNTO ) int alt18=2; try { DebugEnterSubRule(18); try { DebugEnterDecision(18, false); int LA18_0 = input.LA(1); if ((LA18_0==TO)) { alt18 = 1; } else if ((LA18_0==DOWNTO)) { alt18 = 2; } else { NoViableAltException nvae = new NoViableAltException("", 18, 0, input); DebugRecognitionException(nvae); throw nvae; } } finally { DebugExitDecision(18); } switch (alt18) { case 1: DebugEnterAlt(1); // D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:427:9: TO { DebugLocation(427, 9); Match(input,TO,Follow._TO_in_forList1462); DebugLocation(427, 12); fs.To = true; } break; case 2: DebugEnterAlt(2); // D:\\projects\\repository\\ifmo\\Компиляторы\\PascalCompiler\\PascalCompiler\\Grammar\\Pascal.g:427:32: DOWNTO { DebugLocation(427, 32); Match(input,DOWNTO,Follow._DOWNTO_in_forList1468); DebugLocation(427, 39); fs.To = false; } break; } } finally { DebugExitSubRule(18); } DebugLocation(428, 9); PushFollow(Follow._expression_in_forList1484); f=expression(); PopFollow(); DebugLocation(429, 7); fs.SetFinalExpr(f); } } catch (RecognitionException e) { throw e; } finally { TraceOut("forList", 20); LeaveRule("forList", 20); LeaveRule_forList(); } DebugLocation(432, 5); } finally { DebugExitRule(GrammarFileName, "forList"); } return fs; }