[lug] parsing tool for linux

Bear Giles bgiles at coyotesong.com
Sun Apr 7 16:15:03 MDT 2002


> Hi folks!  I am looking for a tool that already knows C syntax, and can
> output the results of a parsed C source file, one token per line.

This is a tokenizer, easily written with a tool such as lex/flex.  Almost
as easily coded by hand.

> Separated by spaces is fine, too, so long as the function names are
> preserved as functions ( so that func(x) comes out func(, or func (x)
> comes out func( )

That's a problem.  func(x) is actually four tokens - 'func', '(', 'x'
and ')'.  While it's possible to write the tokenizer rules so that
'func(' is a single token, you'll rarely see this done in practice.
It's also not really correct to call 'func' the function - what's the
"function" in this C snippet:

   ((*((struct foobar *) x)).y(2))->z() 

Bear



More information about the LUG mailing list