DFA

zell@curtiss.SEAS.UCLA.EDU (Adam W. Zell)
Tue, 15 Dec 1992 20:02:40 GMT

          From comp.compilers

Related articles
DFA zell@curtiss.SEAS.UCLA.EDU (1992-12-15)
| List of all articles for this month |
Newsgroups: comp.compilers
From: zell@curtiss.SEAS.UCLA.EDU (Adam W. Zell)
Organization: Compilers Central
Date: Tue, 15 Dec 1992 20:02:40 GMT
Keywords: lex, question, comment

Just a quick question. When I used flex a while back, I defined a
floating point number or integer as:


number [0-9]
exp [Ee][+-]?{number}+
numtype {number}*\.?{number}+{exp}?


While flipping through the 2nd edition of Lex and Yacc, they use the
following definition:


number [0-9]
exp [Ee][+-]?{number}+
numtype ({number}+|{number}*\.{number}+)({exp})?


Is there any advantage in using the Lex and Yacc definition? Does it use
fewer DFA states?
[I don't see any compelling advantage either way, except that the first
example works differently (worse) in AT&T lex because there's no parens
around the {exp}. We did it the way we did because we wanted an example
for the | operator and parenthesised patterns. Note that neither version
accepts "123." which I'd call a bug. -John]
--


Post a followup to this message

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