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); }
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); }