Added ability to use labels in nested expressions
Merge remote-tracking branch 'remotes/asterick/master' into scoped_labels
PEG.js grammar: Add missing semicolon

Fixes the following JSHint error:

  lib/parser.js: line 108, col 54, Missing semicolon.
PEG.js grammar: Fix line continuation handling in character classes

Before this commit, line continuations in character classes contributed
an empty string to the list of characters and character ranges matched
by a class. While this didn't lead to a buggy behavior with the current
code generator, the AST was wrong and the problem could have caused bugs
later.

This commit fixes the problem.
PEG.js grammar: Improve the |Code| rule a bit

Instead of matching segments between blocks character by character,
match them as a whole. Also align the style with other similar rules
(e.g. the comment ones).
JavaScript example: Fix parsing of statements

Fixes a problem where statements starting with a reserved word produced
errors like this:

  Reserved word "return" can't be used as an identifier.

The problem was in a wrong ordering of choices in the |Statement| rule
together with aggressive reserved word detection in the |Identifier|
rule.
JavaScript example: Fix automatic semicolon insertion

Fix parsing of inputs like this:

  foo() // comment
  bar()
Add support for collecting all errors, warnings and notes in one pass of compilation.
Add to |options| new parameter: |collector|, that is object with following functions:
- emitFatalError(...)
- emitError(...)
- emitWarning(...)
- emitInfo(...)

By default, |emitFatalError| and |emitError| throws |GrammarError| with all arguments, passed to them; |emitWarning| and |emitInfo| do nothing.
Fix some errors.
Now errors collected by the compilation stage (check, transform, generate etc.)
Also incorporate #208.
|GrammarError| captures stack in v8.
Fix small error and allow user pass they problem collector.
Fix usage function name from |options.collector| instead of function itself.
Add error message to |GrammarError|.
JavaScript example: Remove reserved word detection

Reserved word detection as it was implemented in the JavaScript example
grammar had two big downsides:

  1. It required changes in ordering of choices in some rules in order
     not to trigger the detection prematurely. One of the changes was
     already implemented (in the |Statement| rule, see the diff), but
     apparently more were needed (the grammar didn't parse inputs like
     |true| or |function f() {}|). And I'm not 100% sure that would be
     the end of it (maybe deeper structural changes would be needed).

  2. It made error messages confusing. Consider the following example:

       var a = @;

     Instead of reporting:

       Expected ... but "@" found.

     the generated parser reported:

       Reserved word "var" can't be used as an identifier.

     This was because the parser parsed the statement first as
     |VariableStatement| and when this failed, it tried to parse it as
     |ExpressionStatement|, triggering the reserved word detection.

Because of these, I decided to remove reserved word detection from the
JavaScript example grammar.
PEG.js grammar: Remove reserved word detection

This is mostly done for consistency with the JavaScript example grammar,
from which the |Identifier| rule is taken from. See the previous commit
for details.
Mark |parse| and |SyntaxError| as internal identifiers

The |parse| function and the |SyntaxError| exception were meant as
internal, so let's mark them as such.
Expose the parser object in action/predicate code

The action/predicate code didn't have access to the parser object. This
was mostly a side effect actions/predicates being implemented as nested
functions, in which |this| is a reference to the global object (an ugly
JavaScript quirk). The initializer, being implemented differently, had
access to the parser object via |this|, but this was not documented.

Because having access to the parser object can be useful, this commits
introduces a new |parser| variable which holds a reference to it, is
visible in action/predicate/initializer code, and is properly
documented.

See also:

  https://groups.google.com/forum/#!topic/pegjs/Na7YWnz6Bmg
Clarify initializer documentation

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.
Update example arithmetics.pegjs, make it work
Merge pull request #252 from chunpu/patch-1

Update example arithmetics.pegjs, make it work
Wrap initializer code in generated parsers into |{...}|

Initializer code is usually indented and this indentation is carried
over to generated code. This resulted in a piece of indented code in the
middle of the parser.

This commit wraps initializer code in |{...}|, which makes indentation
in generated parsers look a bit more natural.