9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
* [9fans] stub function generator
@ 2008-06-05 14:18 Steve Simon
  2008-06-05 15:14 ` erik quanstrom
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Steve Simon @ 2008-06-05 14:18 UTC (permalink / raw)
  To: 9fans

Anyone know of some nice simple code to parse C prototype definitions
and split them into nicely awk'able bits so I can generate stub functions:

I have been playing with mkptypes | awk which works well
for simple stuff, say my source contains:

	void
	func(int a, char *b)


and I want to generate

	void
	stub_func(int a, char *b)
	{
		func(a, b);
	}

however when you get into

	int syspipe(int fd[2])

let alone

	int sysnotify(void (*func)(void*, char*))

it is starting to push at the limits of what awk is good for.

I guess I am looking for some yacc and lex which
parses C and spits out somthing like this:

	func#a|int a#b|char *b
	syspipe#fd|int fd[2]
	sysnotify#func|void (*func)(void*, char*)

I understand knowledge of types is harder but if I use just basic types
this sounds doable to me. Before I write it, does anyone seem such a beast?

-Steve



^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-06-09 11:56 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-06-05 14:18 [9fans] stub function generator Steve Simon
2008-06-05 15:14 ` erik quanstrom
2008-06-05 18:44 ` John Stalker
2008-06-09  9:02   ` Steve Simon
2008-06-09 11:56     ` Bruce Ellis
2008-06-06  1:39 ` Pietro Gagliardi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).