apg parsers provide an optional tracing facility which is essentially the “debugger”.
When something is going wrong with either the grammar or the string being parsed,
the trace gives a step-by-step picture of how the parser is operating.
Using the debug flag,
d, will make the trace also available to
apg-exp and a simple demonstration of that is given here.
This example assumes that you are already familiar with the trace object in
If not, check out the trace examples to get started.
We will use the floating point grammar and turn on the tracing facility to
have a look at how the parser operates.
var apgexp = require("apg-exp");
var apglib = require("apg-lib");
var writeHtml = require("../writeHtml.js");
var grammar, exp, flags, result, str, html, page, htmlName;
grammar = new (require("./grammars/float.js"))();
str = "";
str += '|||123.0e-10|||';
flags = "d";
exp = new apgexp(grammar, flags);