News for hackers. Stuff that matters.
Re:Regexes vs. Combinatorial Parsing (2019) by jakear on Wednesday May 27, 2020 @09:24PM (#23332313)
One approach I like for this sort of thing is Pratt parsing. A full Pratt parsing "library" can be implemented with barely any work (hour or two), and from there you get quick and easy expression parsing with full support for precedence levels, left/right associativity, infix operations, etc.

Doc I read for introduction to the area: http://journal.stuffwithstuff.com/2011/03/19/pratt-parsers-e...

Quick little TS implementation: https://github.com/JacksonKearl/PrattParse

Above used in a cute little D&D dice rolling discord app (basically implementing a language with random variables as literals & first-class values): https://github.com/JacksonKearl/RollDice-Discord/

Re:Regexes vs. Combinatorial Parsing (2019) by wwee on Wednesday May 27, 2020 @10:54PM (#23332891)
I found this article[1] to be a great introduction to Pratt Parsing as well, it even ties into how it's actually a Shunting Yard algorithm in disguise[2].

[1]https://matklad.github.io/2020/04/13/simple-but-powerful-pra...

[2]https://matklad.github.io/2020/04/15/from-pratt-to-dijkstra....