3 ms·
Parser combinators [0] are great for quick parsing, usage from typescript is very neat. You can collapse tokenisation, parsing and some evaluation for simple gr
by mirekrusin 5y ago
Parser combinators [0] are great for quick parsing, usage from typescript is very neat. You can collapse tokenisation, parsing and some evaluation for simple grammars (they appear in production from time to time) into single parser combinator phase (there’s nothing else) where you get desired, typed result from your parser. It’s really fun to play with and imho one of the best ways to grasp monads really - when you write parser combinator by yourself it really clicks in.
[0] https://github.com/appliedblockchain/parser-combinators https://github.com/appliedblockchain/parser-combinators
- svachalek 5y agoHi, I've written recursive descent in JS similar to Brandon's examples. Do you have any examples of what usage of this library (or parser combinators in general) would look like? I found a few docs about the idea and it makes sense at a high level but I haven't been able to turn that into a clear idea of what such a parser looks like in practice.
- DylanSp 5y agoIt's Haskell, not Typescript, but http://dev.stephendiehl.com/fun/002_parsers.html http://dev.stephendiehl.com/fun/002_parsers.html goes over how parser combinators work and how to use them. I've also got a simple example on my github, https://github.com/DylanSp/three-pass-compiler https://github.com/DylanSp/three-pass-compiler.
- mirekrusin 5y agorfc4180 looks like this [0] [0] https://github.com/preludejs/parser/blob/master/rfc4180.ts https://github.com/preludejs/parser/blob/master/rfc4180.ts