Re: lex question

Alejandro Dobniewski <>
28 Mar 1999 17:04:22 -0500

          From comp.compilers

Related articles
lex question (Mina Doroudi) (2005-12-02)
Re: lex question (Nathan Moore) (2005-12-08)
Re: lex question (toby) (2005-12-08)
lex question (Antonio Linares) (1999-03-23)
Re: lex question (Alejandro Dobniewski) (1999-03-28)
Re: lex question (1999-04-01)
Re: lex question (Chris F Clark) (1999-04-03)
| List of all articles for this month |

From: Alejandro Dobniewski <>
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.