Ejemplo n.º 1
0
    public int Compile(string[] inputs, string[] argv)
    {
        checkArg(inputs, "inputs");
        compilation_unitList asts = new compilation_unitList();

        compile(inputs, asts);
        if (Msg.Count == 0 && asts.Count > 0)
        {
            visit(argv, asts, Console.Out);
        }
        return(Msg.Count);
    }
Ejemplo n.º 2
0
    void visit(string[] argv, compilation_unitList asts, TextWriter w)
    {
        compilation ast = new compilation(argv, asts, imports.global);

        ast.link(null);
        for (int i = 0; i < visitors.Count && ast != null; i++)
        {
            VisitorDelegate visitor = visitors[i];
            string[]        args    = (string[])visitorArgs[i];

            ast = visitor(ast, w, args, Msg);
        }
    }
Ejemplo n.º 3
0
    public int Compile(string[] inputs, string output, string[] argv)
    {
        checkArg(inputs, "inputs");
        checkArg(output, "output");
        compilation_unitList asts = new compilation_unitList();

        compile(inputs, asts);
        if (Msg.Count == 0 && asts.Count > 0)
        {
            TextWriter w;
            try {
                w = new StreamWriter(output);
            } catch (Exception e) {
                Msg.Error("can't write \"{0}\": {1}", output, e.Message);
                return(Msg.Count);
            }
            visit(argv, asts, w);
            w.Close();
        }
        return(Msg.Count);
    }
Ejemplo n.º 4
0
 void compile(string[] inputs, compilation_unitList asts)
 {
     foreach (string f in inputs)
     {
         try {
             TextReader r    = new StreamReader(f);
             long       time = Debug.Clock;
             object     ast  = Parser.parse(f, r);
             if (ast != null)
             {
                 asts.Add((compilation_unit)ast);
             }
             else
             {
                 Msg.Count++;
             }
             r.Close();
         } catch (Exception e) {
             Msg.Error("can't read \"{0}\": {1}", f, e.Message);
         }
     }
 }