Customizable Parsing Test Repository

Global

Members

constant

escapeRegExp

Escape all characters in the given string so that it can be used as a regular expression that will match only the literal string given. For example, if the input is "[x]", this function will escape it to "\[x\]", so that if a regular expression is constructed from the result, it will match only the original string "[x]", rather than the string "x".

Source

constant

notationStringToArray

The Earley parsing library used in this repository expects grammar rules to be defined by an array containing a mixture of strings and regular expressions. A string is used to represent a non-terminal symbol, and a regular expression is used to represent a terminal symbol. But it is typically more convenient to write a rule as a single string. For example, a standard summation of two variables is more convenient to write as "x+y" instead of as ["x",/\+/,"y"]. This function converts strings in the simpler form to arrays of strings and regular expressions in the more complex form. It treats any identifier mentioned in the variables array as a nonterminal, and represents it as a string, and any other sequence of non-space characters as a terminal, and represents it as a regular expression.

Source

constant

putdownLeaves

A putdown expression represents a syntax tree in a straightforward way. The leaves of that tree are the symbols appearing in it, because they have no children. This function extracts the list of leaves (as an array, not a set, so they are ordered and may repeat) from the given putdown expression.

It does so via a trivial string processing operation that does not involve parsing the putdown code into a string. Consequently, this function can accept partial putdown code that is not a fully syntactically correct expression (such as (+ 1 2 for example) and will still return the leaves (in that case, the array ["+", "1", "2"]]).

Source