Created
January 23, 2014 07:44
-
-
Save matwey/8574558 to your computer and use it in GitHub Desktop.
This file contains 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
#!/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