//* // * Analyzes a parse tree node by traversing all it's child nodes. // * The tree traversal is depth-first, and the appropriate // * callback methods will be called. If the node is a production // * node, a new production node will be created and children will // * be added by recursively processing the children of the // * specified production node. This method is used to process a // * parse tree after creation. // * // * @param node the parse tree node to process // * // * @return the resulting parse tree node // * // * @throws ParserLogException if the node analysis discovered // * errors // public Node Analyze(Node node) { ParserLogException log = new ParserLogException(); node = Analyze(node, log); if (log.Count > 0) { throw log; } return(node); }
internal ExpressionCompileException(ParserLogException parseException) : base(string.Empty, parseException) { MyReason = CompileExceptionReason.SyntaxError; }
//* // * Analyzes a parse tree node by traversing all it's child nodes. // * The tree traversal is depth-first, and the appropriate // * callback methods will be called. If the node is a production // * node, a new production node will be created and children will // * be added by recursively processing the children of the // * specified production node. This method is used to process a // * parse tree after creation. // * // * @param node the parse tree node to process // * @param log the parser error log // * // * @return the resulting parse tree node // private Node Analyze(Node node, ParserLogException log) { Production prod = default(Production); int errorCount = 0; errorCount = log.Count; if (node is Production) { prod = (Production)node; prod = new Production(prod.Pattern); try { Enter(prod); } catch (ParseException e) { log.AddError(e); } for (int i = 0; i <= node.Count - 1; i++) { try { Child(prod, Analyze(node[i], log)); } catch (ParseException e) { log.AddError(e); } } try { return(Exit(prod)); } catch (ParseException e) { if (errorCount == log.Count) { log.AddError(e); } } } else { node.Values.Clear(); try { Enter(node); } catch (ParseException e) { log.AddError(e); } try { return(Exit(node)); } catch (ParseException e) { if (errorCount == log.Count) { log.AddError(e); } } } return(null); }
//* // * Resets this parser. This method will clear all the internal // * state and error log in the parser, but will not reset the // * tokenizer. In order to parse multiple input streams with // * the same parser, the Tokenizer.reset() method must also be // * called. // * // * @see Tokenizer#Reset // * // * @since 1.5 // public void Reset() { this.tokens.Clear(); this.errorLog = new ParserLogException(); this.errorRecovery = -1; }