Re: YYLess equivalent in JLex

"Binesh Bannerjee" <binesh@hex21.com>
19 Jun 1999 17:53:45 -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: "Binesh Bannerjee" <binesh@hex21.com>
Newsgroups: comp.compilers
Date: 19 Jun 1999 17:53:45 -0400
Organization: Hex21 Inc.
References: 99-06-046 99-06-061
Keywords: lex, Java

Gerwin Klein <lsf@gmx.net> wrote:
: 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):


Cool... I read the docs on JFlex, and am sold... Just one thing tho...


When I converted my program to jflex, one of the things I decided to do
was use %unicode, since it's supported by JFlex... After doing this,
JFlex choked on input that worked with the input that was accepted by
JLex... I decided to dig a little, and came up with this test scanner...


JFlex seems to choke on %unicode or %full... Which isn't too encouraging...
%7bit seems to work fine... What am I doing wrong? I'm including the
lexer spec, the input I fed the lexer, and the output from both
JLex and JFlex generated scanners...


Thanks in advance...
Binesh Bannerjee


--- BEGIN SCANNER
%%
identifier=([a-zA-Z_][a-zA-Z0-9_]*)
digits=([0-9]+)
whitespace=([\ \t\r\n\f]+)
%class JFlexScanner
%integer
%full
%{
public static void main(String argv[]) {
try {
JFlexScanner y = new JFlexScanner(System.in);
y.yylex();
}
catch (Exception e) {
e.printStackTrace();
}
}
%}
%%
{identifier} { System.out.println("Identifier:`" + yytext() + "'"); }
{digits} { System.out.println(" Digits:`" + yytext() + "'"); }
{whitespace} { System.out.println("Whitespace:`" + yytext() + "'"); }
(.|[\ \t\r\n\f]) { System.out.println("Unknown:`" + yytext() + "'"); }
--- END SCANNER


-- BEGIN INPUT
HTML
"Something"
Whatever=17
43
blah balh
-- END INPUT


-- BEGIN OUTPUT FROM JLEX (Correct)
Identifier:`HTML'
Whitespace:`
'
Unknown:`"'
Identifier:`Something'
Unknown:`"'
Whitespace:`
'
Identifier:`Whatever'
Unknown:`='
        Digits:`17'
Whitespace:`
'
        Digits:`43'
Whitespace:`
'
Identifier:`blah'
Whitespace:` '
Identifier:`balh'
Whitespace:`
'
-- END OUTPUT FROM JLEX (Correct)


-- BEGIN OUTPUT FROM JFLEX (Incorrect)
Identifier:`HTML'
Whitespace:`
'
Identifier:`"Something"'
Whitespace:`
'
Identifier:`Whatever=17'
Whitespace:`
'
Identifier:`43'
Whitespace:`
'
Identifier:`blah'
Whitespace:` '
Identifier:`balh'
Whitespace:`
'
-- END OUTPUT FROM JFLEX (Incorrect)


Post a followup to this message

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