
Pasukon – The easy JavaScript parser generator - gosukiwi
https://pasukon.rocks/
======
eckza
I like this a lot!

A small critique: it might be useful to include a small explainer of why
parsers / ADTs are useful - maybe in the context of decoding JSON.

(Learning about ADTs shifted the way that I think about data modelling and
application development, so I am a huge fan.)

~~~
gosukiwi
Great point. I'll ellaborate on it in the readme and/or website :D Thanks for
the feedback!

------
chrisbrandow
This looks cool but the “easy to learn” intro statement set a disappointing
expectation. Building up some simple examples would _really_ help.

I mean this as constructive criticize, apologies if it feels too harsh.

~~~
gosukiwi
Yeah I really need to work on the docs. I want to write a "Getting Started"
guide for someone with absolutely zero background on the topic and put it in
the repo's Wiki.

Did you see the GitHub repo's README? I do ellaborate a bit over there. Do you
think I should explain the basics in the website too? Or maybe just link to
the wiki once I have that "Getting Started" guide up?

------
aarchi
This looks like a nice simplification of yacc/bison and lex/flex. The `then`
keyword seems superfluous though; what was the motivation for `then` as
opposed to just juxtaposition?

~~~
gosukiwi
Thanks :) The reason it looks like that is because I need a way to distinguish
binary calls from unary calls: `a b` would call the combinator `a` with the
parser `b` as input. `a b c` will call the combinator b with a and c as input.

I certainly could have chosen another syntax, but I settled for that one.
Because the user can define their own combinators I can't just hard-code all
combinators into the syntax.

For example `*:A` is alias for `(many0 (token A))` but if the user defines
his/her own unary combinator, I need a way to let him/her call it without
changing the syntax.

------
galaxyLogic
Good stuff. I have 2 questions:

1\. Is there a Pasukon grammar for JavaScript/ES6?

2\. Is there a Pasukon grammar for Pasukon grammars?

~~~
gosukiwi
1\. Nope, I still need to make some more example grammars :)

2\. Yup:
[https://github.com/gosukiwi/Pasukon/blob/master/lib/grammar....](https://github.com/gosukiwi/Pasukon/blob/master/lib/grammar.pasukon)

~~~
galaxyLogic
I find (2.) rather interesting. A parser than can parse its own grammar
definitions. A language that can define itself.

~~~
gosukiwi
Yeah it's pretty cool, if I say so myself :) It parses itself (using a pre-
compiled AST) to parse other user-defined grammars.

Initially I started using PEGjs, and then swapped once it was ready.

------
jessaustin
Does the term "substraction" mean anything in particular? It's kind of funny
to have the same typo four times on the main page... I guess it compiles
either way. b^)

It looks like a great package. I have loved parser combinators forever.

~~~
gosukiwi
It's a typo I have, Spanish being my native language, I always get confused
with that one :) Just pushed a new version with a fix

------
pastoreerrante
Similar tool:
[https://github.com/DmitrySoshnikov/syntax](https://github.com/DmitrySoshnikov/syntax)

It can emit parser in many languages.

There are also a couple of udemy courses from the author, about parsing and
language creation. They are quite good imho.

~~~
gosukiwi
Impressive!

------
renke1
Having written my own CommonMark parser, I often wonder if I should have used
some kind of parser generator. Can I use this to parse CommonMark (in 100%
compliant way)? – And, can I parse it such that I can recreate the original
Markdown based on the resulting model?

~~~
gosukiwi
I think Pasukon should perform similarly to a hand-written recursive descent
parser. If you already have something going, I don't see much benefit in
porting it, besides ease of creating and maintaining the parser.

It can parse any context-free language, so it should have no problem parsing
CommonMark.

------
erjiang
Awesome! I've been wanting to add a proper parser to my Scheme interpreter for
a long time now, and this might lower the barrier enough to motivate me to
actually do it.

~~~
gosukiwi
Awesome, do it! Making languages is always fun :)

------
sAbakumoff
I am pretty happy with the parser from MS: [https://github.com/microsoft/ts-
parsec#readme](https://github.com/microsoft/ts-parsec#readme) the API is
pretty intuitive and it the package is reliable Can't imagine why I would want
to switch to PASUKON(what an odd name by the way).

~~~
moogly
I believe the name is a play on

a) romanization of the Japanese pronunciation of PC ("personal computer" ->
"PersCom" Japanese abbreviations of English tend to concatenate the initial
syllable of every word, and "n" and "m" end up sounding very similar).

b) "parser combinator" would have the same abbreviation in Japanese

~~~
gosukiwi
Exactly that :) Glad someone got it! Heh.

