Re: YYLess equivalent in JLex

Gerwin Klein <lsf@gmx.net>
14 Jun 1999 23:01:27 -0400

          From comp.compilers

Related articles
YYLess equivalent in JLex binesh@hex21.com (Binesh Bannerjee) (1999-06-12)
Re: YYLess equivalent in JLex lsf@gmx.net (Gerwin Klein) (1999-06-14)
Re: YYLess equivalent in JLex binesh@hex21.com (Binesh Bannerjee) (1999-06-19)
Re: YYLess equivalent in JLex lsf@gmx.net (Gerwin Klein) (1999-06-27)
| List of all articles for this month |
From: Gerwin Klein <lsf@gmx.net>
Newsgroups: comp.compilers
Date: 14 Jun 1999 23:01:27 -0400
Organization: Technische Universitaet Muenchen, Germany
References: 99-06-046
Keywords: lex, Java

Binesh Bannerjee wrote:
> I don't want to do this: (extreme pseudocode)
> (I admit tho, that I don't want to do this because of my experience w/
> lex/flex... and overflowing buffers etc.


> ([^<]|[\ \t\r\n\f])* { return(TEXT); }
> "<" { yybegin(TAGSTATE); return(open_angle); }


There should be no problem with overflowing buffers in JLex, because the
input buffer is dynamically resized when necessary (although I would
recommend [^\<]+ as the first pattern). It should also be more efficient
than using an own additional input buffer.


For the yyless-thing (if you still like it better):
AFAIK there is no yyless in JLex, but with JFlex (http://www.jflex.de)
you could use the void yypushback(int) method like this (analogous to
yyless):


<YYINITIAL> "<" {
                yybegin(TAG_CONTEXT);
                yypushback(1);
                returnvalue = _internal_buffer;
                return(TEXT);
}
<YYINITIAL> (.|[\ \t\r\n\f]) { _internal_buffer += yytext(); }
<TAG_CONTEXT> "<" { return(open_angle); }


Regards,
Gerwin


Post a followup to this message

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