Пример #1
0
        public void ImportStatement(string _name, out IStatement _statements)
        {
            var text   = File.ReadAllText(_name);
            var lexer  = new Lexer(text);
            var parser = new ASTMaker(lexer);

            _statements = parser.ParseTokens();
        }
Пример #2
0
        private static void Main(string[] args)
        {
            if (args.Length == 0)
            {
                return;
            }
            var lexer      = new Lexer(new StreamReader(args[0]).ReadToEnd());
            var parser     = new ASTMaker(lexer);
            var statements = parser.ParseTokens();

            if (parser.ParseErrors.Count > 0)
            {
                foreach (var error in parser.ParseErrors)
                {
                    Console.WriteLine(error.Message);
                }
            }
            SetOutput(out var writer);
            ((IStatement)statements).Execute();
            Restore(writer);
        }