Last active
December 28, 2015 23:39
-
-
Save kowey/7580466 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import funcparserlib.parser as fp | |
| const = lambda x: lambda _: x | |
| unarg = lambda f: lambda x: f(*x) | |
| _any = fp.some(const(True)) | |
| def cons((x,xs)): | |
| return [x] + xs | |
| def _skipto(p): | |
| def smoosh(xs): | |
| if type(xs) == type(''): # str type | |
| return [xs] | |
| else: | |
| return cons(xs) | |
| def _core(): | |
| nxt = fp.with_forward_decls(lambda: _any + _core() >> smoosh) | |
| return (p | nxt) | |
| return _core() >> (lambda x:"".join(x)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment