コード例 #1
0
ファイル: Checker.cs プロジェクト: bencz/Beryl
        public Checker(SymbolTable symbols, AST.Program program)
        {
            _symbols = symbols;
            _program = program;

            // create the standard set of predefined identifiers that Triangle defines
            CreateStandardEnvironment();

            // start walking the AST from the topmost node
            _program.visit(this);
        }
コード例 #2
0
ファイル: Checker.cs プロジェクト: bencz/Beryl
        public Checker(SymbolTable symbols, AST.Program program)
        {
            _symbols = symbols;
            _program = program;

            // create the standard set of predefined identifiers that Triangle defines
            CreateStandardEnvironment();

            // start walking the AST from the topmost node
            _program.visit(this);
        }
コード例 #3
0
 /* This is the first tree-walking method that is called! */
 public void visit(AST.Program that)
 {
     Console.WriteLine("namespace Foobar");
     that.Command.visit(this);
 }
コード例 #4
0
 public CodeGen(SymbolTable symbols, AST.Program program)
 {
     _symbols = symbols;
     _program = program;
     _program.visit(this);
 }
コード例 #5
0
ファイル: CodeGen.cs プロジェクト: bencz/Beryl
 public CodeGen(SymbolTable symbols, AST.Program program)
 {
     _symbols = symbols;
     _program = program;
     _program.visit(this);
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: bencz/Beryl
        static int Main(string[] args)
        {
            int result = 0;

            try
            {
#if false
                StreamReader sr      = new StreamReader(args[0]);
                Scanner      scanner = new Scanner(args[0], sr, 4);
                for (; ;)
                {
                    Token token = scanner.ReadToken();
                    Console.WriteLine(token.Position.ToString() + ":" + token.ToString());

                    if (token.Kind == TokenKind.EndOfFile)
                    {
                        break;
                    }
                }
                sr.Close();
                Console.ReadLine();
#else
                // expand wildcards
                string[] found = Toolbox.Find(args, false);

                // process each input file in turn
                foreach (string arg in found)
                {
                    SymbolTable  symbols  = new SymbolTable();
                    StreamReader reader   = new StreamReader(arg);
                    Scanner      scanner  = new Scanner(arg, reader, 4);
                    Parser       parser   = new Parser(symbols, scanner);
                    AST.Program  program  = parser.ParseProgram();
                    Checker      checker  = new Checker(symbols, program);
                    Indenter     indenter = new Indenter(arg + ".log", System.Text.Encoding.ASCII);
                    try
                    {
                        program.Dump(indenter);
                    }
                    finally
                    {
                        indenter.Close();
                    }
                    new CodeGen(symbols, program);
                    Console.WriteLine("Press ENTER");
                    Console.ReadLine();
                }
#endif
            }
            catch (BerylError that)
            {
                if (that.Position == null)
                {
                    Console.WriteLine("Error: {0}", that.Message);
                }
                else
                {
                    Console.WriteLine("{0} Error: {1}", that.Position.ToString(), that.Message);
                }
                result = 1;
            }
#if false
            catch (System.Exception that)
            {
                Console.WriteLine("Error: {0}", that.Message);
                result = 1;
            }
#endif

            return(result);
        }
コード例 #7
0
ファイル: Checker.cs プロジェクト: bencz/Beryl
 public void visit(AST.Program that)
 {
     that.Command.Declarations = CreateStandardEnvironment();
     that.Command.visit(this);
 }