Skip to content

Instantly share code, notes, and snippets.

@Moligaloo
Last active May 7, 2018 03:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Moligaloo/566a694db978318f8eb8c27f6b9417db to your computer and use it in GitHub Desktop.
Save Moligaloo/566a694db978318f8eb8c27f6b9417db to your computer and use it in GitHub Desktop.
Directly parse C function declaration
#!/usr/bin/env io
CFunction := Object clone do(
returnType ::= nil
name ::= nil
paramTypes ::= nil
curlyBrackets := method(
msg_list := list()
msg := call argAt(0)
while(msg,
if(msg name != ";",
msg_list push(msg)
)
msg = msg next
)
Range 0 to (msg_list size / 2 - 1) map(i,
self clone setReturnType(msg_list at(i*2) name) setName(msg_list at(i*2+1) name) setParamTypes(msg_list at(i*2+1) arguments map(name))
)
)
)
CFunction {
int strcmp(string, string);
int strlen(string);
void exit();
} println
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment