Skip to content

Changes: 2.0.x 2.1.x

Francis Galiegue edited this page Apr 3, 2016 · 4 revisions

Java 8 required; Java 8 bytecode emitted

This is 2016!

However: due to limitations in code generation, lambdas cannot be used as actions... Currently, an attempt at doing so will generate an IllegalAccessError. This is due to the fact that invokedynamic is not visited -- yet.

ParseResult declares success if and only if all the input is matched

Prior to this version, a run would be declared a success even if the input was only partially matched. For instance, if you had a parser which matched, say, a sequence of as, then running against input aaab would return a success.

Not anymore. In this situation, the run is now declared a failure. There are two reasons for this:

  • the theory says so: if the chosen rule of your grammar doesn't match the whole input, then it is said that the input does not satisfy the grammar;
  • this behaviour is more logical to the end user.

InputBuffer now implements CharSequence -- to the letter

This has the important consequence that .charAt() now throws an IndexOutOfBoundsException on an invalid index (therefore, Context's .getCurrentChar() as well).

Historically, Parboiled, and up to grappa 2.0.x, had a .charAt() method which confusingly returned 0xffff if ever the index specified was greater than (or equal to) the underlying text length.

Not anymore. This method now obeys the CharSequence contract, and specifying an invalid index will throw an exception.

This decision has been made because 0xffff, in spite of being a "non character", is a legal character in a CharSequence and possibly in an input which Grappa may parse. It also has the advantage to greatly simplify the character matchers construction.

If you wish to detect the end of input, you can use the new .atEnd() method available in Context and BaseParser (returns true if... Well... You've guessed it.) The .getCurrentCodePoint() still returns -1 if the end of input is reached, so you can also use that.

Add the ability to generate parsers on custom classloaders (IN DEVELOPMENT)

This was prompted by grappa-formal.

In this package, the source code of a parser is generated from a formal grammar, then compiled. However, this compilation generated a class which is not in the classloaders available at runtime.

Code now exists to be able to add one classloader (or more) to the parser generation process, and obtain a valid instance of a parser generated at runtime from one such classloader.

API changes

  • There is no more ListeningParser nor ValueBuilder. All of these have been replaced with a much more simple EventBusParser.
  • There is no more ListeningParseRunner. The base ParseRunner has everything that ListeningParseRunner had.
  • ParseRunnerListener has been renamed to ParseEventListener.