Ejemplo n.º 1
0
 public void Save(Program program, string filename)
 {
     using (_writer = new Indenter(filename, System.Text.Encoding.UTF8))
     {
         program.Visit(this);
     }
     _writer = null;
 }
        public override object Visit(Program that, object value = null)
        {
            SymbolTable symbols = that.Symbols;

            /** \todo Register Braceless's runtime identifiers such as types, constants, and so on. */
            // symbols.Insert("Braceless", new ScopeStatement(...));

            // Create the standard classes known to all Braceless programs.
            #if USED
            symbols.EnterBlock(
                "Object",
                new ClassStatement(
                    that.Cursor,
                    new SymbolDefinition(that.Cursor, "Object", SymbolKind.Class),
                    new Reference[0],
                    new Definition[0]
                )
            );
            symbols.LeaveBlock("Object");

            symbols.EnterBlock(
                "data",
                new ClassStatement(
                    that.Cursor,
                    new SymbolDefinition(that.Cursor, "data", SymbolKind.Class),
                    new Reference[0],
                    new Definition[0]
                )
            );
            symbols.LeaveBlock("data");

            symbols.EnterBlock(
                "text",
                new ClassStatement(
                    that.Cursor,
                    new SymbolDefinition(that.Cursor, "text", SymbolKind.Class),
                    new Reference[0],
                    new Definition[0]
                )
            );
            symbols.LeaveBlock("text");
            #endif
            #if false
            symbols.Insert("Stream", new ObjectStatement(that.Cursor));
            symbols.Insert("System", new ObjectStatement(that.Cursor));
            #endif
            return that;
        }
Ejemplo n.º 3
0
 public override object Visit(Program that, object value = null)
 {
     _symbols = that.Symbols;
     foreach (Module module in that.Modules)
         module.Visit(this);
     _symbols = null;
     return that;
 }
Ejemplo n.º 4
0
 public override object Visit(Program that, object value)
 {
     foreach (Module module in that.Modules)
         module.Visit(this);
     return null;
 }
        /** Walks the \c Module nodes defined inside the \c Program node. */
        public override object Visit(Program that, object value = null)
        {
            /** Assign the value of the "class global variable" \c _symbols as the remaining methods make use of it. */
            /** \note We \b could pass in the symbol table as the \c value parameter, but this is easier and just as fast. */
            _symbols = that.Symbols;

            // Process each module in input order.
            foreach (Module module in that.Modules)
                module.Visit(this);

            /** Clear the "class global variable" \c _symbols after use. */
            _symbols = null;

            return that;
        }
        public override object Visit(Program that, object value = null)
        {
            using (_writer = new Org.Braceless.Version0.Toolbox.Indenter(_filename, System.Text.Encoding.UTF8))
            {
                _writer.WriteLine("Braceless0 AST Dump - {0}:", _title);
                _writer.WriteLine();

                _writer.WriteLine("SYMBOLS:");
                _writer.Indent();
                that.Symbols.Print(_writer);
                _writer.Dedent();
                _writer.WriteLine();

                _writer.WriteLine("NODES:");
                _writer.Indent();
                PrintPrologue(that);
                PrintSequence("Modules", that.Modules);
                PrintEpilogue(that);

                foreach (Module module in that.Modules)
                    module.Visit(this);

                _writer.Dedent();
                _writer.WriteLine();
            }

            return that;
        }
Ejemplo n.º 7
0
        public override object Visit(Program that, object value)
        {
            _writer.WriteLine("; WARNING: DO NOT EDIT THIS FILE; IT WAS GENERATED AUTOMATICALLY BY BRACELESS v0.x!");
            _writer.WriteLine();

            foreach (Module module in that.Modules)
                module.Visit(this);

            /** \todo Generate the final main() function. */

            return null;
        }
Ejemplo n.º 8
0
 public void Save(Program program, string filename)
 {
     /** \todo Generate a separate D source folder for each name space. */
     using (_writer = new Indenter(filename, System.Text.Encoding.ASCII))
     {
         program.Visit(this);
     }
     _writer = null;
 }