示例#1
0
        public TREE_NODE Run(IEnumerable <ITokenMatch <SYMBOL_ENUM> > tokens, IEnumerable <Command <SYMBOL_ENUM, TREE_NODE> > commands)
        {
            this.commands = new LinkedList <Command <SYMBOL_ENUM, TREE_NODE> >(commands);
            this.tokens   = new ArraySlice <ITokenMatch <SYMBOL_ENUM> >(tokens.ToArray());
            this.stack    = new List <StackElement <SYMBOL_ENUM, TREE_NODE> >();

            while (this.commands.Any())
            {
                if (!process())
                {
                    return(null);
                }
            }

            if (isSuccessfulParse())
            {
                return((TREE_NODE)(stack.Single().UserObject.Value));
            }
            return
                (null);
        }
示例#2
0
 public StackMaster(IEnumerable <ITokenMatch <SYMBOL_ENUM> > input, int lookaheadWidth)
 {
     this.lookaheadWidth = lookaheadWidth;
     stackLeaves         = new Queue <StackElement <SYMBOL_ENUM, TREE_NODE> >();
     this.input          = new ArraySlice <ITokenMatch <SYMBOL_ENUM> >(input.ToArray());
 }