syntax icon indicating copy to clipboard operation
syntax copied to clipboard

source-map, or at least some comments, for generated code

Open namiwang opened this issue 7 years ago • 0 comments

it's pretty hard to debug the generated parser, when it contains more than 500 handlers.

I crudely added the following line to the template, so I could find the handler's corresponding grammar rule in seconds.

  buildSemanticAction(production) {
    ....

    // Verbose debug info
    action = action + `\n// raw production: ${production._rawLHS} -> ${production._rawRHS}\n`;

    ....
  },

It's not a fancy souce-mapping solution, but maybe that's enough for now. Maybe I could polish it a little and file a PR, what do you think?

namiwang avatar Nov 23 '18 12:11 namiwang