Skip to content

Instantly share code, notes, and snippets.

@matwey
Created January 23, 2014 07:44
Show Gist options
  • Save matwey/8574558 to your computer and use it in GitHub Desktop.
Save matwey/8574558 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
s=r"void LIBNOVA_EXPORT ln_get_equ_from_ecl (struct ln_lnlat_posn *object, double JD, struct ln_equ_posn *position)"
def parse_typed_name(x):
tokens = x.rsplit()
n = tokens.pop(-1)
t = " ".join(tokens)
return (t.strip(), n.strip())
def parse_args(x):
x = x.rstrip(')')
return x.split(',')
def parse_line(x):
[fun_text, args_text] = x.split('(', 2)
fun = parse_typed_name(fun_text)
args = map( parse_typed_name, parse_args(args_text) )
print fun, args
tree = parse_line(s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment