Property: ast
The apgExp object retains a copy of the APG parser's Abstract Syntax Tree (AST) object. The AST object is especially useful for making complex translations of the matched phrase. The use and details of the AST are beyond the scope of this guide.
Example
var pattern, exp, str, result; pattern = 'word = alpha *(alpha / num)\n'; pattern += 'alpha = %d65-90 / %d97-122\n'; pattern += 'num = %d48-57\n'; exp = new apgExp(pattern); str = "ab12"; result = exp.exec(str); console.log("exp.ast in XML format:"); console.log(exp.ast.toXml()); /* result */ exp.ast in XML format: <?xml version="1.0" encoding="utf-8"?> <root nodes="5" characters="4"> <!-- input string, decimal integer character codes --> 97,98,49,50 <node name="word" index="0" length="4"> 97,98,49,50 <node name="alpha" index="0" length="1"> 97 </node><!-- name="alpha" --> <node name="alpha" index="1" length="1"> 98 </node><!-- name="alpha" --> <node name="num" index="2" length="1"> 49 </node><!-- name="num" --> <node name="num" index="3" length="1"> 50 </node><!-- name="num" --> </node><!-- name="word" --> </root>