Exemplo n.º 1
-1
        internal void LoadCommandStack(string Script)
        {

            // Clear the current stack //
            this.Commands.Clear();
            this._CompileErrorMessages.Clear();

            // Create a token stream and do lexal analysis //
            AntlrInputStream TextStream = new AntlrInputStream(Script);
            HScriptLexer HorseLexer = new HScriptLexer(TextStream);

            // Parse the script //
            CommonTokenStream HorseTokenStream = new CommonTokenStream(HorseLexer);
            HScriptParser HorseParser = new HScriptParser(HorseTokenStream);
            HorseParser.RemoveErrorListeners();
            HorseParser.AddErrorListener(new ParserErrorListener());
            
            // Create an executer object //
            CommandVisitor processor = new CommandVisitor(this.Home);

            // Load the call stack //
            try
            {
                foreach (HScriptParser.CommandContext context in HorseParser.compile_unit().command_set().command())
                {
                    this.Commands.Add(context);
                }
            }
            catch (Exception e)
            {
                this._CompileErrorMessages.Add(e.Message);
            }

        }