Skip to content

Instantly share code, notes, and snippets.

@kowey
Last active December 28, 2015 23:39
Show Gist options
  • Select an option

  • Save kowey/7580466 to your computer and use it in GitHub Desktop.

Select an option

Save kowey/7580466 to your computer and use it in GitHub Desktop.
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