[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: code generator generators



Paul Cockshott wrote:
> > >I would need a compiler front end to use it. Are such available already
> > >for C written using sable.

I do not know if somebody has yet written an ANSI C grammar for SableCC,
but this is a feasible task, as C is quite suitable to parse with
LALR(1) parsers.  A few twists are required, mainly:
(1) You need a separate "preprocessor".  You can also write it using
SableCC, or hand code it.
(2) You need a customized lexer to resolve the "typedef" ambiguity.

You should probably start from a LEX/BISON grammar and rewrite it to
SableCC.  The longest part will be to write explicit grammar rules to
express operator precedence.

Have fun!

Etienne
PS:  It would be a nice contribution to the SableCC distribution
examples if somebody already has such a grammar:-)
-- 
----------------------------------------------------------------------
Etienne M. Gagnon, M.Sc.                     e-mail: egagnon@j-meg.com
Author of SableCC:                 http://www.sable.mcgill.ca/sablecc/
----------------------------------------------------------------------