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) |
From: | Danny Dube <dube@dino04.iro.umontreal.ca> |
Newsgroups: | comp.compilers |
Date: | 16 Feb 2002 01:12:39 -0500 |
Organization: | Compilers Central |
References: | 02-01-070 02-02-017 |
Keywords: | lex |
Posted-Date: | 16 Feb 2002 01:12:39 EST |
(I'm responding late. Sorry if someone already gave similar explanations.)
" <casse@netcourrier.com>"@free.fr writes:
> "Robert Minsk" <robertminsk@yahoo.com> a écrit :
>
> > 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.
> >
> > I have not been able to fix this backup. Can you get rid of the one
> > backup? Is there a better way to code this?
State #9 is non-accepting because when the automaton has read
+.
or
-.
it is in a situation where it has to read at least a digit.
I suggest adding another error-catching regular expression, namely:
[-+]"."
Adding the following error-catching regular expression:
..
(as someone suggested previously) is not correct because this
expression would take precedence on the normal regular expressions
when the input would start with a single-digit integer. For example,
if the input starts with:
9),...
the automaton would do a match of length 2 and return `tError' instead
of matching the length 1 string "9" and returning `tInt'.
--
Danny Dubé
dube@IRO.UMontreal.CA
Return to the
comp.compilers page.
Search the
comp.compilers archives again.