home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / compiler / 2041 < prev    next >
Encoding:
Text File  |  1992-12-15  |  1.3 KB  |  38 lines

  1. Newsgroups: comp.compilers
  2. Path: sparky!uunet!world!iecc!compilers-sender
  3. From: zell@curtiss.SEAS.UCLA.EDU (Adam W. Zell)
  4. Subject: DFA
  5. Reply-To: zell@curtiss.SEAS.UCLA.EDU (Adam W. Zell)
  6. Organization: Compilers Central
  7. Date: Tue, 15 Dec 1992 20:02:40 GMT
  8. Approved: compilers@iecc.cambridge.ma.us
  9. Message-ID: <92-12-073@comp.compilers>
  10. Keywords: lex, question, comment
  11. Sender: compilers-sender@iecc.cambridge.ma.us
  12. Lines: 24
  13.  
  14. Just a quick question.  When I used flex a while back, I defined a
  15. floating point number or integer as: 
  16.  
  17. number   [0-9]
  18. exp         [Ee][+-]?{number}+
  19. numtype {number}*\.?{number}+{exp}?
  20.  
  21. While flipping through the 2nd edition of Lex and Yacc, they use the
  22. following definition:
  23.  
  24. number  [0-9]
  25. exp        [Ee][+-]?{number}+
  26. numtype ({number}+|{number}*\.{number}+)({exp})?
  27.  
  28. Is there any advantage in using the Lex and Yacc definition?  Does it use
  29. fewer DFA states?
  30. [I don't see any compelling advantage either way, except that the first
  31. example works differently (worse) in AT&T lex because there's no parens
  32. around the {exp}.  We did it the way we did because we wanted an example
  33. for the | operator and parenthesised patterns.  Note that neither version
  34. accepts "123." which I'd call a bug. -John]
  35. -- 
  36. Send compilers articles to compilers@iecc.cambridge.ma.us or
  37. {ima | spdcc | world}!iecc!compilers.  Meta-mail to compilers-request.
  38.