Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite Catharsis as a Pratt parser #54

Open
hegemonic opened this issue Jul 23, 2018 · 3 comments
Open

Rewrite Catharsis as a Pratt parser #54

hegemonic opened this issue Jul 23, 2018 · 3 comments

Comments

@hegemonic
Copy link
Owner

(Disclaimer: I'll probably never actually do this.)

Catharsis's parser is currently generated by PEG.js from a parsing expression grammar. That seemed like a good choice when I made it. Over time, though, as I've implemented more and more undocumented things that Closure Compiler supports, the grammar has become quite brittle and difficult to change.

In the unlikely event that I'm ever so inclined, it would be interesting to try to reimplement Catharsis as a Pratt parser, which should be more flexible while still being reasonably straightforward to implement by hand.

@brettz9
Copy link

brettz9 commented Jun 29, 2020

FWIW, I see there is https://www.npmjs.com/package/pratt-parser

Btw, also regarding the project future, until such time as you may move to such a parser, are you still accepting PRs here? I'd like to add a routine for having the Unicode rules be auto-generated from the https://github.com/mathiasbynens/node-unicode-data for the latest Unicode support, and also to make use of much more succinct regex-like ranges as PegJS supports.

Also would be interested to know if you'd accept PRs to add support for a TypeScript mode to parse TS expressions...

@simonseyock
Copy link

simonseyock commented Feb 10, 2021

@brettz9 because I saw this post and I was curious to learn more about pratt-parsers, I just wrote one that parses jsdoc types. I used the carthasis test suites to test my Parser and might use the jsdoctypeparser ones as well. So far it passes all catharsis tests but one in the main test/spec directory but not all of the subdirectories.

I looked at catharsis and at jsdoctypeparser for inspiration for the output. So far the results are pretty near to catharsis and I also wrote a catharsis compat mode - to be able to use the test suites directly. I might write one for jsdoctypeparser as well.

I uploaded the project to https://github.com/simonseyock/jsdoc-type-pratt-parser, but did not write any documentation yet. If this is interesting to you I am grateful for any input. Also I am willing to write some documentation XD

I did not think much about modes (closure, jsdoc, typescript) and any other functionality apart from parsing.

@brettz9
Copy link

brettz9 commented Feb 11, 2021

Excellent! I'd love to be able to use such an engine in eslint-plugin-jsdoc so that we can be compatible with jsdoc (or have a mode that is compatible), as well as support any closure-specific types and TypeScript types. (It does admittedly get hard to keep compatibility in some cases though, e.g., one doesn't want to hold back Unicode usage for the whole project if jsdoc won't be updating; but passing most or all of its tests should at least be a good sign).

So, yes, I'm very interested. Just have to give a warning that my health isn't great, so I can be flaky and unreliable at times, and at other times, if I have energy, may be able to plow forward for a time.

I've watched your repo, and if you get to adding some docs, hope you can file an alpha release or file an issue or something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants