GerHobbelt / jison

bison / YACC / LEX in JavaScript (LALR(1), SLR(1), etc. lexer/parser generator)
https://gerhobbelt.github.io/jison/
MIT License
117 stars 20 forks source link

arrow notation barfs on comments #51

Open ericprud opened 4 years ago

ericprud commented 4 years ago

zaaaach/jison parses

expr: 'foo' -> 1 // comment
;

jison-gho 0.6.1-216 and master fail if there's a comment following the semantic action.

(zaaaaach also parses extra ';'s

expr: 'foo' -> 1; // comment
;

but I think that's a bug.)

GerHobbelt commented 4 years ago

I would consider the latter variant a grammar bug as

expr: 'foo' -> 1 // comment
;

SHOULD be parsed by the machine as semantic action 1 // comment, i.e. a action including comment, while

expr: 'foo' -> 1; // comment

(note the edit) SHOULD be parsed by the machine as semantic action 1 in a jison grammar rule, which itself is now followed by the comment comment, which is summarily ignored.

Good catch, by the way. Must find out where this went wrong. Without looking, my bet is that it's the -> semaction coding style parse section that doesn't properly consider comments as part of such ~single-line~ single-expression actions.

That hunch suggest you might also try this, which I expect should also fix the issue:

ericprud commented 4 years ago

For now, I continued all of my comments on the following line a la:

nonLiteralKind:
      IT_IRI    -> { nodeKind: "iri" }
// CONT  t: 1iriPattern
    | IT_NONLITERAL -> { nodeKind: "nonliteral" }
// CONT  t: 1nonliteralLength
    ;

It's reversible so I can make my way back when the parser's happy with arrows with comments.

Tx for being so attentive!

ericprud commented 3 years ago

Can I help with this? I'm typically pingable on gitter 9:00-19:00, 21:30-24:00 CEST.

GerHobbelt commented 3 years ago

Will be available Saturday. Might have a look at it then, see if we can fix this easily (haven't built jison-gho in a while, but we'll see how it goes :-)

On Fri, Nov 6, 2020, 11:15 ericprud notifications@github.com wrote:

Can I help with this? I'm typically pingable on gitter 9:00-19:00, 21:30-24:00 CEST.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/GerHobbelt/jison/issues/51#issuecomment-722998350, or unsubscribe https://github.com/notifications/unsubscribe-auth/AADCIHU4YKD4RX4BCO7QM3LSOPEFLANCNFSM4I52KEBQ .

ericprud commented 3 years ago

I'll be around. Not much leaving the house these days.

GerHobbelt commented 3 years ago

Ok. This took a lot longer than intended. Had the overestimated confidence that I would be able to run a few jison-gho tests in a few hours. That turned out into a big fight with the bleeding edge codebase which didn't want to cooperate after a long bout of inattentiveness, so I had to try a few spots, ending up with having to roll the last release forward in micro steps as the dev box node env has changed over the months (year-plus!) since it got a good workout last.

Currently I have (should push this by now 🤔 [Edit: done] ) a bleeding edge which is halfway there (latest lexer grammar working, latest BNF parser grammar failing badly and therefor rolled back to bnf parser from last release plus some minimal changes) and compiling grammars again.

The good news -- though most of it unrelated to your problem yet

The bad news

Ergo: this issue will need some more work before I'ld call it anywhere near "done".


Meanwhile, thank you VERY MUCH for your patience-in-the-extreme. Wow. Sticking around for a year while I'm silent is impressive (for lack of better words). I cannot guarantee better performance in the future but I don't know how else I can convey to you that I am humbled. I can only hope jison-gho is still useful to you despite the chaotic bits.


If you feel extremely daring, the bleeding edge I'll push in a few minutes today will be in the t3 branch -- master still is a total b0rk b0rk b0rk today -- but when you go in there and run make to build a jison-gho of your own, be VERY aware that jison bootstraps itself by using the jison installed by npm in node_modules/jison-gho/ and that will FAIL with horrid errors unless some very nasty patching is done until the next official release of jison-gho (which will be a 0.7.0-something; too much has changed since 0.6.x) -- that patching action has to be documented in CONTRIBUTING.md tonight!


That's the current state of affairs; things are moving, possibly a glacial pace, but at least now you know a bit about what going on.

HTH

GerHobbelt commented 3 years ago

In case you feel extremely daring as mentioned above, you'll need this for hints on that /node_modules/jison-gho/dist/ bootstrapping process you will need while riding the very edge of the bleeding edge: https://github.com/GerHobbelt/jison/blob/t3/CONTRIBUTING.md

ericprud commented 3 years ago

and I applaud your persistence in picking up a cold project. I'll try to fiddle around with the grammar in the bleeding edge and maybe even add its build products into a branch of shex.js in order to see how those hacks fares there.