Module: Script

This module implements a server function for node.js to script the practice page model, i.e., to run the examples from the command line.

Version:
  • 2024-02-13
Author:
Source:

Methods


<async, inner> script()

The server function. Blank-separated words, read from standard input, have the effects described below. Any other word is interpreted as a path from which an example is merged into the global strings.

word effect
model resets all flags and variables.
load resets global strings.
ebnf, stack, bnf clear all flags and set a mode.
actions, build, deep, error, follow, greedy,
noargs, lookahead, parser, sets, shallow, states
toggle flags.
new calls model.doNew().
scan calls model.doScan().
parse calls model.doParse().
run calls model.doRun().
1 calls model.doStep(1).
10 calls model.doStep(10).
100 calls model.doStep(100).
exit terminates the script
Source:
Example

Load an example, compile and run with each parser, overwrite parts, and repeat.

$ node script.js << 'end'
  model eg/06/06.eg      new parse run   stack new parse run
  ebnf  test/06-06a.eg   new parse run   stack new parse run
end