Skip to content

Commit

Permalink
Clarify initializer documentation
Browse files Browse the repository at this point in the history
Make it clear that there is only one initializer in the whole grammar.
The previous formulation could have been understood to mean that there
can be an initializer for every rule in the grammar.

Fixes #82.
  • Loading branch information
dmajda committed Apr 20, 2014
1 parent 3908449 commit 5a02bca
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions README.md
Expand Up @@ -182,14 +182,14 @@ written as a JavaScript string between the name and separating equality sign.
Rules need to be separated only by whitespace (their beginning is easily
recognizable), but a semicolon (“;”) after the parsing expression is allowed.

Rules can be preceded by an *initializer* — a piece of JavaScript code in curly
braces (“{” and “}”). This code is executed before the generated parser starts
parsing. All variables and functions defined in the initializer are accessible
in rule actions and semantic predicates. The code inside the initializer can
access the parser object using the `parser` variable and options passed to the
parser using the `options` variable. Curly braces in the initializer code must
be balanced. Let's look at the example grammar from above using a simple
initializer.
The first rule can be preceded by an *initializer* — a piece of JavaScript code
in curly braces (“{” and “}”). This code is executed before the generated parser
starts parsing. All variables and functions defined in the initializer are
accessible in rule actions and semantic predicates. The code inside the
initializer can access the parser object using the `parser` variable and options
passed to the parser using the `options` variable. Curly braces in the
initializer code must be balanced. Let's look at the example grammar from above
using a simple initializer.

{
function makeInteger(o) {
Expand Down

0 comments on commit 5a02bca

Please sign in to comment.