Esempio n. 1
0
        public static void Main(string[] args)
        {
            if (args.Length == 1)
            {
                string fullpath;
                if (Path.IsPathRooted(args[0]))
                {
                    fullpath = args[0];
                }
                else
                {
                    fullpath = Path.Combine(Environment.CurrentDirectory, args[0]);
                }

                Console.Out.WriteLine("Processing file: {0}", fullpath);
                ICharStream       input  = new ANTLRFileStream(fullpath);
                SimpleCLexer      lex    = new SimpleCLexer(input);
                CommonTokenStream tokens = new CommonTokenStream(lex);
                //System.out.println("tokens="+tokens);
                SimpleCParser parser = new SimpleCParser(tokens);
                parser.program();
                Console.Out.WriteLine("Finished processing file: {0}", fullpath);
            }
            else
            {
                Console.Error.WriteLine("Usage: llstar <input-filename>");
            }
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            if (args.Length == 1)
            {
                string fullpath;
                if ( Path.IsPathRooted(args[0]) )
                    fullpath = args[0];
                else
                    fullpath = Path.Combine(Environment.CurrentDirectory, args[0]);

                Console.Out.WriteLine("Processing file: {0}", fullpath);
                ICharStream input = new ANTLRFileStream(fullpath);
                SimpleCLexer lex = new SimpleCLexer(input);
                CommonTokenStream tokens = new CommonTokenStream(lex);
                SimpleCParser parser = new SimpleCParser(tokens);
                SimpleCParser.program_return r = parser.program();
                Console.Out.WriteLine("tree="+((ITree)r.Tree).ToStringTree());

                if ( parser.NumberOfSyntaxErrors > 0 ) {
                    // don't tree parse if has errors
                    return;
                }

                CommonTreeNodeStream nodes = new CommonTreeNodeStream((ITree)r.Tree);
                nodes.TokenStream = tokens;
                SimpleCWalker walker = new SimpleCWalker(nodes);

                walker.program();
            }
            else
                Console.Error.WriteLine("Usage: SimpleC <input-file>");
        }
Esempio n. 3
0
        public static void Main(string[] args)
        {
            if (args.Length == 1)
            {
                string fullpath;
                if (Path.IsPathRooted(args[0]))
                {
                    fullpath = args[0];
                }
                else
                {
                    fullpath = Path.Combine(Environment.CurrentDirectory, args[0]);
                }

                Console.Out.WriteLine("Processing file: {0}", fullpath);
                ICharStream                  input  = new ANTLRFileStream(fullpath);
                SimpleCLexer                 lex    = new SimpleCLexer(input);
                CommonTokenStream            tokens = new CommonTokenStream(lex);
                SimpleCParser                parser = new SimpleCParser(tokens);
                SimpleCParser.program_return r      = parser.program();
                Console.Out.WriteLine("tree=" + ((ITree)r.Tree).ToStringTree());

                if (parser.NumberOfSyntaxErrors > 0)
                {
                    // don't tree parse if has errors
                    return;
                }

                CommonTreeNodeStream nodes = new CommonTreeNodeStream((ITree)r.Tree);
                nodes.TokenStream = tokens;
                SimpleCWalker walker = new SimpleCWalker(nodes);

                walker.program();
            }
            else
            {
                Console.Error.WriteLine("Usage: SimpleC <input-file>");
            }
        }
Esempio n. 4
0
        public static void Main(string[] args)
        {
            if (args.Length == 1)
            {
                string fullpath;
                if ( Path.IsPathRooted(args[0]) )
                    fullpath = args[0];
                else
                    fullpath = Path.Combine(Environment.CurrentDirectory, args[0]);

                Console.Out.WriteLine("Processing file: {0}", fullpath);
                ICharStream input = new ANTLRFileStream(fullpath);
                SimpleCLexer lex = new SimpleCLexer(input);
                CommonTokenStream tokens = new CommonTokenStream(lex);
                //System.out.println("tokens="+tokens);
                SimpleCParser parser = new SimpleCParser(tokens);
                parser.program();
                Console.Out.WriteLine("Finished processing file: {0}", fullpath);
            }
            else
                Console.Error.WriteLine("Usage: llstar <input-filename>");
        }