public override JsonIr ToJSON() { return(new JsonIr(GetType()) .AppendChild(JsonIr.ListToJSON(body)) .AppendChild(JsonIr.ListToJSON(handlers)) .AppendChild(JsonIr.ListToJSON(else_part))); }
public override JsonIr ToJSON() { return(new JsonIr(GetType()) //.AppendChild(JsonIr.ListToJSON(uses)) .AppendChild(JsonIr.ListToJSON(units_and_standalones)) .AppendChild(ToJSON(anonymous))); }
public static JsonIr ToJSON(ENTITY e) { if (e == null) { return(JsonIr.GetIrNull()); } return(e.ToJSON()); }
public override JsonIr ToJSON() { return(new JsonIr(GetType(), prefix.ToString()) .AppendChild(ToJSON(loop_counter)) .AppendChild(ToJSON(while_clause)) .AppendChild(JsonIr.ListToJSON(invariants)) .AppendChild(ToJSON(body)) .AppendChild(JsonIr.ListToJSON(variants))); }
public override JsonIr ToJSON() { return(base.ToJSON() //.AppendChild(ToJSON(alias)) //.AppendChild(new JsonIr("PURE_SAFE_SPEC", isPure ? "pure" : isSafe ? "safe" : null)) //.AppendChild(new JsonIr("ABSTRACT_SPEC", isAbstract ? "abstract" : null)) .AppendChild(isForeign ? new JsonIr("FOREIGN_SPEC") : null) //.AppendChild(new JsonIr("OVERRIDE_SPEC", isOverride ? "override" : null)) //.AppendChild(JsonIr.ListToJSON(genericParameters)) .AppendChild(JsonIr.ListToJSON(parameters)) .AppendChild(ToJSON(type)) .AppendChild( new JsonIr("PRECONDITION", requireElse ? "require else" : null) .AppendChild(JsonIr.ListToJSON(preconditions)) ) .AppendChild(ToJSON(routineBody)) .AppendChild( new JsonIr("POSTCONDITION", ensureThen ? "ensure then" : null) .AppendChild(JsonIr.ListToJSON(postconditions)) )); }
static void Main(string[] args) { if (args.Length == 0) { // Output the quick guide Options.QuickGuide(); goto NoActions; } // Parsing command line arguments Dictionary <string, string> opts = CommandLineArgs.parse(args); // The first queue element should be the source file name/path string fileName = opts["file-name"]; // Setting compilation options Options options = new Options(opts); // Opening message pool Message messagePool = new Message(options); // Output compiler title & version if (options.optPrintVersion) { messagePool.info("compiler-title", "0.0.0.1 prototype"); } // Opening the source file if (fileName == "") { messagePool.error(null, "empty-path"); goto Finish; } if (!System.IO.File.Exists(fileName)) { messagePool.error(null, "no-file", fileName); goto Finish; } // Initializing parsing process Reader reader = new Reader((Message)null, fileName); Tokenizer tokenizer = new Tokenizer(reader, options, messagePool); ENTITY.init(tokenizer, 0, messagePool, options); if (messagePool.numErrors > 0) { goto Finish; } // Phase 1: parsing // ================ COMPILATION compilation = null; try { try { compilation = COMPILATION.parse(); if (options.optDumpAST) { compilation.report(4); } } catch (Exception) { throw new TerminateSLangCompiler(ENTITY.current); } } catch (TerminateSLangCompiler exc) { Position pos = (exc == null) ? null : exc.position; messagePool.error(pos, "system-bug"); goto Finish; } // TODO: semantic analysis call? // Phase 2: code generation // =============================== if (options.optDumpJSON) { JsonIr json = compilation.ToJSON(); System.IO.File.WriteAllText(fileName + ".json", json.Serialize(false)); } if (!options.optGenerate) { goto Finish; } Finish: messagePool.info("end-compilation"); NoActions: ; }
public override JsonIr ToJSON() { return(new JsonIr(GetType()) .AppendChild(JsonIr.ListToJSON(types))); }
public override JsonIr ToJSON() { return(base.ToJSON() .AppendChild(JsonIr.ListToJSON(expressions))); }
public override JsonIr ToJSON() { return(base.ToJSON() .AppendChild(JsonIr.ListToJSON(ifThenParts)) .AppendChild(ToJSON(elsePart))); }
public override JsonIr ToJSON() { return(base.ToJSON() .AppendChild(ToJSON(secondary)) .AppendChild(JsonIr.ListToJSON(actuals))); }
public override JsonIr ToJSON() { return(new JsonIr(GetType()) // do not use base.ToJSON(), no need .AppendChild(JsonIr.ListToJSON(constants))); }