mdaines / grammophone

A tool for analyzing and transforming context-free grammars.
https://mdaines.github.io/grammophone
MIT License
200 stars 23 forks source link

Langcc support #29

Closed modulovalue closed 11 months ago

modulovalue commented 1 year ago

Hello @mdaines,

I hope you are doing well. (and thank you, again, for the copy link feature!)

On my quest to find out what it would take to make predictive parsing more practical, I've found the following project: langcc. It is based on some very cool research by the same author.

It claims not only to significantly expand the amount of grammars that LR(k)-style parsers are able to handle, but it also implements a fast and practical LR(k) parser generator.

I think it would be amazing if grammophone could support langcc in some shape or form. I'm not entirely sure what that would look like. Since C++ can compile to wasm, in theory, a lot should be possible here. (the least that I think of is to show whether a grammar is LR(k), or not, for some k > 1).

(I plan to use his research to expand my own parser generator, but I'm still working on that. Maybe I'll have to learn a bit of C++ which would make everything easier.)

I just wanted to hear your thoughts. What do you think?

mdaines commented 1 year ago

It sounds interesting. Maybe that project has some API for getting diagnostic information about the input?

In general I'm hesitant to expand the scope of this project very much, since I really haven't done much with context-free grammars specifically since completing the first version (and the compilers course it's related to) several years ago. When revisiting the project recently, my main concern was to update the "web app" part and not break the grammar part. Maybe something with LR(k) parsing with k > 1 would be in scope, though...

I'm also curious about the idea of Grammophone acting as a kind of frontend for different parser generator tools, like that project, or Lezer, which Grammophone uses for its parser.

modulovalue commented 1 year ago

Maybe that project has some API for getting diagnostic information about the input?

I've been experimenting with getting a simple LR(1) grammar to work with langcc, but, unless I'm doing something wrong, it can't handle it. (I just wanted to warn you, I'm still trying to find out whether it actually does what it promises. However, there are other projects besides langcc that are interesting such as LPG which supports LALR(k))

and not break the grammar part.

I completely agree.

I'm also curious about the idea of Grammophone acting as a kind of frontend for different parser generator tools,

Are you thinking of something like unifying the following projects? lezer playground, tree-sitter playground and ohmjs editor (that is, showing parse trees and allowing users to parse, not just to analyze grammars)?

modulovalue commented 11 months ago

langcc appears to be abandoned, so I'm going to close this issue. It doesn't seem like it would make sense to depend on an abandoned project.