Re: Getting rid of backups in flex.

Esmond Pitt <esmond.pitt@bigpond.com>
18 Jan 2002 21:12:49 -0500

          From comp.compilers

Related articles
Getting rid of backups in flex. robertminsk@yahoo.com (2002-01-17)
Re: Getting rid of backups in flex. esmond.pitt@bigpond.com (Esmond Pitt) (2002-01-18)
Re: Getting rid of backups in flex. casse@netcourrier.com (=?ISO-8859-15?q?=22Cass=E9=.Hugues@free.fr,@free.f) (2002-02-06)
Re: Getting rid of backups in flex. dube@dino04.iro.umontreal.ca (Danny Dube) (2002-02-16)
Re: Getting rid of backups in flex. esmond.pitt@bigpond.com (Esmond Pitt) (2002-02-28)
Re: Getting rid of backups in flex. clint@0lsen.net (2002-03-17)
Re: Getting rid of backups in flex. fjh@cs.mu.OZ.AU (2002-03-19)
| List of all articles for this month |
From: Esmond Pitt <esmond.pitt@bigpond.com>
Newsgroups: comp.compilers
Date: 18 Jan 2002 21:12:49 -0500
Organization: Melbourne Software Company Pty Ltd
References: 02-01-070
Keywords: lex
Posted-Date: 18 Jan 2002 21:12:49 EST

It may or may not solve your immediate problem, but you are overdoing
this specification. I would get rid of the tError production
altogether. You can take care of this & all lexical errors with the
parser, with a final rule


.. return yytext[0];


at the bottom of the grammar. This rule also takes care of all single
special characters as well, which is nice: you can get rid of


"+" return '+';
"-" return '-';
";" return ';';
"." return '.';


etc, and use '+' etc literally in the grammar (I'm assuming you're using
yacc).


Esmond Pitt


Robert Minsk wrote:
>
> Given the following rules I am still getting 1 backup I'm trying to
> get rid of.
>
> DIGIT [[:digit:]]
> EXP [Ee][+-]?{DIGIT}+
> EXPERR [Ee][+-]?
> %%
> [-+]?{DIGIT}+ { return tInt; }
>
> [-+]?{DIGIT}*"."{DIGIT}+{EXP}? |
> [-+]?{DIGIT}+"."{DIGIT}*{EXP}? |
> [-+]?{DIGIT}+{EXP} { return tFloat }
>
> [-+]?{DIGIT}*"."{DIGIT}+{EXPERR}? |
> [-+]?{DIGIT}+"."{DIGIT}*{EXPERR}? |
> [-+]?{DIGIT}+{EXPERR}
> . { return tError }
>
> I get:
> State #9 is non-accepting -
> associated rule line numbers:
> 7 11
> out-transitions: [ 0-9 ]
> jam-transitions: EOF [ \000-/ :-\377 ]
>
> 1 backing up (non-accepting) states.


Post a followup to this message

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