PetitParser has various tools for debugging, all based on parser
transformations:

- "debug(Parser)":
https://github.com/renggli/PetitParserDart/blob/master/lib/src/core/reflection.dart#L127
  Prints each parser on activation, and the parser result on deactivation
(probably "trace(Parser)" would be a better name).

- "progress(Parser)":
https://github.com/renggli/PetitParserDart/blob/master/lib/src/core/reflection.dart#L152
  Prints the position in the stream on each parser activation.

- "profile(Parce)":
https://github.com/renggli/PetitParserDart/blob/master/lib/src/core/reflection.dart#L164
  Measures and prints the activation count and time spent in each parser.

The links above shows the implementation of the Dart version. The Smalltalk
version also has some UI tools for the same functionality, see Section 3.5
in http://scg.unibe.ch/archive/papers/Reng10cDynamicGrammars.pdf.

Lukas



On 21 November 2013 21:36, Juancarlo Añez <apal...@gmail.com> wrote:

> Hi,
>
> This is what I did in Grako both for grammar parsing, and for generated
> parsers:
>
>    - Keep a stack of the invoked rules, and print it when the --trace
>    option is used.
>    - Implement a "cut" operator, so errors can be reported as close to
>    the input token that triggered them as possible, even in deeply nested
>    syntactical blocks.
>
> I just thought that it is still far from perfect, because "cut" makes the
> errors be reported against the relevant position in the input, but I still
> have to go back in the trace to find the failing rule. I think that the
> solution may be to memorize the rule stack whenever a rule fails to parse.
>
> Cheers,
>
>
> On Wed, Nov 20, 2013 at 7:45 PM, Henri Tuhola <henri.tuh...@gmail.com>wrote:
>
>> Hello
>>
>> How could I extend my simple parser generator such that parsers provide
>> error reports that show precisely what went wrong?
>>
>> I thought it was a nice idea to write myself a parser generator,
>> specifically tailored for the language I'm going to parse:
>> https://github.com/cheery/kickrat
>>
>> It was quite fun, clean and exciting to create such library but now I've
>> been prototyping my language for few hours. It was enough for noticing that
>> when I do an error in describing the grammar it is really hard to figure
>> out what's wrong with just plain 'syntax error' -message. Overall it would
>> be nice to get detailed syntax errors for language, even if it's a
>> prototype.
>>
>> _______________________________________________
>> PEG mailing list
>> PEG@lists.csail.mit.edu
>> https://lists.csail.mit.edu/mailman/listinfo/peg
>>
>>
>
>
> --
> Juancarlo *Añez*
>
> _______________________________________________
> PEG mailing list
> PEG@lists.csail.mit.edu
> https://lists.csail.mit.edu/mailman/listinfo/peg
>
>


-- 
Lukas Renggli
www.lukas-renggli.ch
_______________________________________________
PEG mailing list
PEG@lists.csail.mit.edu
https://lists.csail.mit.edu/mailman/listinfo/peg

Reply via email to