4 ms·
Python 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 s
by drhagen 6y ago
Python 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