[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A Query on FLEX
From: |
John W. Millaway |
Subject: |
Re: A Query on FLEX |
Date: |
Mon, 21 May 2001 21:35:16 -0700 (PDT) |
> %%
> LETTER [A-Z]
> %%
> {LETTER} { if( strcmp(yytext, "C") == 0 )
> return CHAR;
> if( strcmp(yytext, "L") == 0 )
> return LEN;
> }
> {LETTER}+ { return SYMB;
> }
> %%
>
> In the above case, how can I ensure that when I get the input as "CL" flex
> returs
> 2 tokens CHAR and LEN
> and not one token i.e. SYMB.
Will this work?
%%
C { return CHAR;}
L { return LEN;}
{LETTER}+ { return SYMB;}
%%
You can't return two tokens, obviously. You can either match "CL" and set a
flag
that says "return LEN on the next call to yylex", or you can use yyunput() to
pushback the L and match that. Either way, it's a trick.
-John
__________________________________________________
Do You Yahoo!?
Yahoo! Auctions - buy the things you want at great prices
http://auctions.yahoo.com/
- A Query on FLEX, Gopalsingh Baran, 2001/05/22
- Re: A Query on FLEX,
John W. Millaway <=