예제 #1
0
파일: Try.cs 프로젝트: Tubbz-alt/SLang-6
 public override JsonIr ToJSON()
 {
     return(new JsonIr(GetType())
            .AppendChild(JsonIr.ListToJSON(body))
            .AppendChild(JsonIr.ListToJSON(handlers))
            .AppendChild(JsonIr.ListToJSON(else_part)));
 }
예제 #2
0
 public override JsonIr ToJSON()
 {
     return(new JsonIr(GetType())
            //.AppendChild(JsonIr.ListToJSON(uses))
            .AppendChild(JsonIr.ListToJSON(units_and_standalones))
            .AppendChild(ToJSON(anonymous)));
 }
예제 #3
0
파일: Entity.cs 프로젝트: Tubbz-alt/SLang-6
 public static JsonIr ToJSON(ENTITY e)
 {
     if (e == null)
     {
         return(JsonIr.GetIrNull());
     }
     return(e.ToJSON());
 }
예제 #4
0
파일: Loop.cs 프로젝트: Tubbz-alt/SLang-6
 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)));
 }
예제 #5
0
 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))
                ));
 }
예제 #6
0
        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:
            ;
        }
예제 #7
0
파일: Type.cs 프로젝트: Tubbz-alt/SLang-6
 public override JsonIr ToJSON()
 {
     return(new JsonIr(GetType())
            .AppendChild(JsonIr.ListToJSON(types)));
 }
예제 #8
0
 public override JsonIr ToJSON()
 {
     return(base.ToJSON()
            .AppendChild(JsonIr.ListToJSON(expressions)));
 }
예제 #9
0
 public override JsonIr ToJSON()
 {
     return(base.ToJSON()
            .AppendChild(JsonIr.ListToJSON(ifThenParts))
            .AppendChild(ToJSON(elsePart)));
 }
예제 #10
0
 public override JsonIr ToJSON()
 {
     return(base.ToJSON()
            .AppendChild(ToJSON(secondary))
            .AppendChild(JsonIr.ListToJSON(actuals)));
 }
예제 #11
0
 public override JsonIr ToJSON()
 {
     return(new JsonIr(GetType())  // do not use base.ToJSON(), no need
            .AppendChild(JsonIr.ListToJSON(constants)));
 }