Each folder contains a complete example.
The GitHub & npm README page.
weblinks - the weblinks folder has copies of all of the bundled applications for web page use.
apg - demonstrate use of the parser generator.
package.jsonfor some example of running
apg, the parser generator.
apg.html - demonstrate use of the web page GUI parser generator.
apg-html/README.md- general instructions on testing the apg.html application.
apg-api - using the APG API.
apg-conv - using the data encoding conversion application.
apg-conv/README.md- instructions for running the examples.
apg-conv-api - examples of using the data encoding conversion API.
apg-exp - demonstrates APG Expressions - the new APG regex-like, pattern-matching engine.
apg-exp/grammarsfolder has all of the grammars used in the various demonstrations.
apg-exp/ast.js- demonstrates using the Abstract Syntax Tree of the matched pattern
apg-exp/csv.js- demonstrates dealing with Microsoft’s Comma Separated Values format
apg-exp/dangling-else.js- demonstrates translating the famous “dangling else” problem in the
apg-exp/display.js- demonstrates the many display options available for the source and results
apg-exp/flags.js- demonstrates the flags or options available
apg-exp/float.js- demonstrates a comparison to
regexfor floating point numbers
apg-exp/limits.js- demonstrates placing limits on a potentially run-away grammar
apg-exp/multiline-mode.js- demonstrates how to implement multiline mode
apg-exp/recursive.js- demonstrates the use of recursion to match opening and closing parenthesis pairs
apg-exp/replace.js- demonstrates the
apg-exp/rules.js- demonstrates how to deal with the named rules in a grammar
apg-exp/split.js- demonstrates the
apg-exp/test.js- demonstrates the
apg-exp/trace.js- demonstrates viewing the trace of the pattern-matching parse tree
apg-exp/udt.js- demonstrates how to insert user-written, phrase-matching code
apg-exp/unicode.js- demonstrates the Unicode mode and how to use it
apg-exp/word-boundaries.js- demonstrates defining and matching word boundaries
apg-exp/webpage/email.js- using apg-exp in a web page application.
ast- demonstrate translating and displaying the Abstract Syntax Tree.
back-reference- demonstrate use of the back reference operators.
back-reference/setup.js- the general setup for all of the other examples
back-reference/branch-fail.js- demonstrates that matched rules in a failed branch are not retained for back reference
back-reference/html.js- demonstrates using recursion with parent mode back referencing to match the names in opening and closing HTML tags
back-reference/parent.js- demonstrates back references in parent frame mode
back-reference/simple.js- a simple demonstration of case-sensitive and case-insensitive back references
back-reference/universal.js- demonstrates back references in universal mode
execute-rule- demonstrate the use of the parser’s functions
executeUdt()from user-written callback functions.
execute-rule/colors-app.js- the “colors” application demonstrating a rule name callback function executing a
UDTwith a call to
execute-rule/colors-callbacks.js- the “colors” application
execute-rule/more-app.js- the “more” application demonstrating a UDT callback function executing a rule with
execute-rule/more-setup.js- setting up a parser for a simple grammar with a UDT (more.bnf).
execute-rule/more-app.js- the “more” application demonstrating callback functions which call a rule name operator from a user-written UDT.
ini-file- a “real world” application. Demonstrates how an INI file might be defined, parsed and translated into usable information.
ini-file/setup.js- set up the parser for a the ini file grammar (ini-file.bnf).
ASTtranslating callback functions
ini-file/parser-callbacks.js- the syntax callback functions
ini-file/basic.js- parsing out the ini file parts
ini-file/bad-input.js- how it performs with a badly-formed ini file
ini-file/trace.js- generate a trace of the parser
look-ahead- a demonstration of grammars with look ahead operators (
!) and the
ASTbehavior with them.
look-ahead/setup.js- generalized set up of the parser for all of the demonstrations.
look-ahead/and.js- the classic non-context free grammar. Demonstrates the positive look-ahead
look-ahead/not.js- the C-style comment. Demonstrates the negative look-ahead
look-ahead/compound.js- a make-shift grammar to demonstrate nesting of positive and negative look-ahead operators.
look-behind- demonstrate use of the look-behind (
look-behind/setup.js- the basic setup for all of the examples
look-behind/boundaries.js- demonstrates using look behind to define word boundaries
look-behind/comment.js- demonstrates the problem of using rule/UDT names in look behind - they don’t always work right-to-left. Here a special rule is written to match a C-style comment in the right-to-left direction.
look-behind/negative.js- demonstrates the negative look behind operator
look-behind/positive.js- demonstrates the positive look behind operator
simple- a basic demonstration of how to set up a parser. Nothing fancy, just the basics.
simple/setup.js- set up a basic parser for a simple phone number grammar.
simple/minimal.js- just parse a phone number and print its parts
simple/stats.js- same, but generate and display the parsing statistics
simple/trace.js- same, but generate and display the parser trace
simple/webpage/setup.js- a web page application example
substrings- demonstrate the substring parsing option.
substrings/setup.js- setting up a basic parser for the sub-strings examples
substrings/simple.js- a simple demonstration of using the
substrings/lookaround.js- demonstrates that look ahead and look behind modes are allowed to look at the portions of the string ahead of and behind the defined sub-string being parsed
trace- a demonstration of how to manage the tracing facility.
trace/setup.js- generalized set up of the parser for all of the demonstrations.
trace/default.js- the tracing defaults - all named rules and
trace/all-operators.js- the whole enchilada. All operators, all parse tree nodes displayed.
trace/limited-lines.js- limits the display lines to less than the total number of nodes traced
trace/select-operators.js- only a select few of the operators are displayed
trace/select-rules.js- only a select few of the rule name operators are displayed
UDTdemonstration. Basically the same as the “simple” example, but with a
UDTin the grammar.