コード例 #1
0
    MStatementGroup BuildStatementGroup(MContent x, VirtualIdentifierTable t)
    {
        var res = new MStatementGroup();

        res.statements = x.subs.Map((h) => BuildStatement(h, t));
        res.captures   = new CaptureTable().Fold(res.statements, (h, v) => h.Merge(v.captures));
        return(res);
    }
コード例 #2
0
 public override MValue Eval(IdentifierTable t)
 {
     return(new MFunc()
     {
         formalParams = formalParams,
         statements = statements,
         captures = captures.Map((x) => (x, t.Search(x)))
     });
コード例 #3
0
    public void Compile(string filePath, bool output = false)
    {
        string source = "";

        try
        {
            source = Compile(filePath, compilerPath);
            string   json  = Compile(filePath, compilerPath);
            MContent croot = JsonConvert.DeserializeObject <MContent>(json);
            program = BuildStatementGroup(croot, new VirtualIdentifierTable()
            {
                // builtin identifiers.
                "ReadChar",
                "ReadInt",
                "ReadFloat",
                "Write",
                "ToChar",
                "ToInt",
                "ToFloat",
            });
            if (output)
            {
                WriteLine("Compile Finished!");
            }
        }
        catch (CompileErrorException e) { WriteLine(e.Message); }
        catch (Exception e)
        {
            #if BACK_TRACE
            WriteLine(e.Message + "\n" + e.StackTrace);
            #else
            WriteLine(e.Message);
            #endif
        }
        return;
    }