Exemple #1
0
        public Parser(Tokenizer tokenizer)
        {
            Debug.Assert(tokenizer != null);

            this.tokenizer = tokenizer;
            this.ReadNextToken();
        }
        // turn the expression into an AST each time it changes (not each time our Convert methods are called)
        private void EnsureExpressionNode()
        {
            if (this.expressionNode != null || string.IsNullOrEmpty(this.expression))
            {
                return;
            }

            using (var stringReader = new StringReader(this.expression))
            using (var tokenizer = new Tokenizer(stringReader))
            using (var parser = new Parser(tokenizer))
            {
                this.expressionNode = parser.ParseExpression();
            }
        }