Re: lex question

Alejandro Dobniewski <adobni@itron.com.ar>
28 Mar 1999 17:04:22 -0500

          From comp.compilers

Related articles
lex question dormina@winnipeg-lnx.cc.gatech.edu (Mina Doroudi) (2005-12-02)
Re: lex question nathan.moore@cox.net (Nathan Moore) (2005-12-08)
Re: lex question toby@telegraphics.com.au (toby) (2005-12-08)
lex question alinares@fivetech.com (Antonio Linares) (1999-03-23)
Re: lex question adobni@itron.com.ar (Alejandro Dobniewski) (1999-03-28)
Re: lex question rkrayhawk@aol.com (1999-04-01)
Re: lex question cfc@world.std.com (Chris F Clark) (1999-04-03)
| List of all articles for this month |

From: Alejandro Dobniewski <adobni@itron.com.ar>
Newsgroups: comp.compilers
Date: 28 Mar 1999 17:04:22 -0500
Organization: ITRON
References: 99-03-077
Keywords: lex

You can do this with just Lex. I don't remember exactly what we did
but it was something like using states to match idfunction and
exp. Then you can do the macro expansion programaticaly in the
rule. You can use Yacc if you want but it may be more problematic
because this is a macro-substitution so you don't really need a
gramatic for exp.


Antonio Linares wrote:
>
> We are looking for a way to implement C language #define directive for
> expressions:
>
> #define <idFunction>([<arg list>]) [<exp>]
>
> example:
>
> #define Max( x, y ) ( x > y)? x: y
>
> Do you know how to do this using standard lex & yacc ? Any samples ?
>
> regards,
>
> A.L.
> [There's nothing in lex or yacc that makes it automatic, but macro
> expansion is pretty easy, you keep a stack of sources with the real
> input at the bottom and the macros you're expanding on top of that.
> -John]
--
Alejandro Dobniewski





Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.