} // NT_StatSeq private static void NT_Stat() { for (;;) { switch (Syn.Interpret()) { case 0: return; case 1: Lex.GETidentAttr(out identStr); break; case 2: NT_Expr(); break; case 3: Lex.GETidentAttr(out identStr); break; case 4: NT_Expr(); break; } // switch } // for } // NT_Stat
public static void StartSem() { //-----------------------------------|---------------------------------------- for (;;) { switch (Syn.Interpret()) { case 0: return; case 1: NT_MiniC(); break; } // switch } // for } // StartSem
} // NT_VarDecl private static void NT_StatSeq() { for (;;) { switch (Syn.Interpret()) { case 0: return; case 1: NT_Stat(); break; case 2: NT_Stat(); break; } // switch } // for } // NT_StatSeq
} // Abort private static int CompileFile(String srcFileName) { FileStream srcFs = null; try { srcFs = new FileStream(srcFileName, FileMode.Open); } catch (Exception) { Console.WriteLine("*** file \"{0}\" not found", srcFileName); return(Utils.EXIT_FAILURE); } // try/catch try { Lex.src = new StreamReader(srcFs); Console.WriteLine("parsing ..."); Syn.Parse(); Lex.src.Close(); Lex.src.Dispose(); Lex.src = null; if (Errors.NumOfErrors() > 0) { Console.WriteLine("listing ..."); String lstFileName = Path.ChangeExtension(srcFileName, ".lst"); FileStream lstFs = null; try { lstFs = new FileStream(lstFileName, FileMode.Create); } catch (Exception) { Utils.FatalError(NAME, "CompileFile", "file \"{0}\" not created", lstFileName); return(Utils.EXIT_FAILURE); } // try/catch StreamWriter lstWriter = null; try { lstWriter = new StreamWriter(lstFs); StreamReader srcFsReader = null; try { // open the source file a second time to generate the error listing srcFsReader = new StreamReader(new FileStream(srcFileName, FileMode.Open)); lstWriter.WriteLine(NAME + " (file: \"{0}\")", srcFileName); Errors.GenerateListing(srcFsReader, lstWriter, Errors.ListingShape.longListing); } finally { srcFsReader.Close(); srcFsReader.Dispose(); } // try/finally Console.WriteLine("{0} error(s) detected", Errors.NumOfErrors()); } finally { lstWriter.Close(); lstWriter.Dispose(); } // try/finally } else { Console.WriteLine("no errors detected"); } } finally { if (Lex.src != null) { Lex.src.Close(); Lex.src.Dispose(); Lex.src = null; } // if Utils.Modules(Utils.ModuleAction.resetModule); } // try/finally to make sure srcFs and srcReader are closed return(Utils.EXIT_SUCCESS); } // CompileFile