3 ms·
Python has pyparsing: https://pypi.org/project/pyparsing/ https://pypi.org/project/pyparsing/ Maybe it's because non-FP languages typically don't support opera
by rbonvall 6y ago
Python has pyparsing: https://pypi.org/project/pyparsing/ https://pypi.org/project/pyparsing/
Maybe it's because non-FP languages typically don't support operator overloading, so you'd end up with verbose grammars like:
new Literal("true").or(new Literal("false"))
and then you'll probably use a parser generator like ANTLR.
- drhagen 6y agoPython is no Scala when it comes to operator overloading, but it has enough to make parser combinators work cleanly. funcparserlib [1] and Parsita [2] are two such libraries. For example, this does what you probably expect in Parsita: real = reg(r'[+-]?\d+\.\d+(e[+-]?\d+)?') | 'nan' | 'inf' > float (Full disclosure: I wrote Parsita.) [1]: https://github.com/vlasovskikh/funcparserlib https://github.com/vlasovskikh/funcparserlib [2]: https://github.com/drhagen/parsita https://github.com/drhagen/parsita