Exemple #1
0
        public bool IsValid(IParserImmutableContext context)
        {
            var stream = new MemoryStream().FromString(this.RulePattern);
            var lexer  = LexerBuilder.DefaultAstLexer;
            var tree   = new AstTree.AstTree(lexer.Parse(stream));

            this._tree = tree;

            return(this.TokenConvertionPattern.Childs.Values.Max() <= tree.NodeCount);
        }
Exemple #2
0
        public bool Check(Stream stream)
        {
            this.ChekedString = Empty;
            if (this._tree == null)
            {
                var ruleStream = new MemoryStream().FromString(this.RulePattern);
                this._tree = new AstTree.AstTree(LexerBuilder.DefaultAstLexer.Parse(ruleStream));
            }

            var result = false;

            try {
                result = this._tree.Check(stream);
            }
            catch {
                result = false;
            }

            this.ChekedString = this._tree.ParsedResult;
            return(result);
        }