Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!samsung!brutus.cs.uiuc.edu!ux1.cso.uiuc.edu!ux1.cso.uiuc.edu!m.cs.uiuc.edu!sunb6!voss From: voss@sunb6.cs.uiuc.edu Newsgroups: comp.lang.c++ Subject: Re: zortech problem with lex Message-ID: <24800002@sunb6> Date: 28 Feb 90 17:39:23 GMT References: <6300008@ux1.cso.uiuc.edu> Lines: 52 Nf-ID: #R:ux1.cso.uiuc.edu:6300008:sunb6:24800002:000:2589 Nf-From: sunb6.cs.uiuc.edu!voss Feb 27 20:30:00 1990 > maxsmith@athena.mit.edu writes: > Lex generated scanners are slower than hand crafted ones. Doubly so for > yacc and its output and yacc it self can't produce a C++ parser, something > to do with the language not conforming to LALR(1) and all that. I saw that comment about C++ not being LALR(1) in the g++ distribution, and at the time believed it. However, my biggest thrill at OOPSLA '89 was sitting at the same table as Bjarne Stroustrup for a few hours drinking free beer. He said that he IS USING A LALR(1) GRAMMER for C++ 2.0. He appeared sober & honest, therefore I assume that C++ is LALR(1), but non-trivial. ============================================================================= First, let me make it clear that I am by no means an expert at writing compilers ( yet). I am a graduate student in CS, currently taking my first (much overdue) compiler course. We are using the text _Compilers_Principles_Techniques_and_Tools_ by Aho, Sethi, and Ullman. The programming portion of the class involves using lex/flex and yacc/byacc/bison to implement a subset of Pascal. Now my questions: > meissner@osf.org > Second of all, lex-ing is fairly simple. It took me a day or so, to > write from scratch the lexer for Data General C. It would have taken > more time to come up to speed with lex (ignoring the problem that we > didn't have lex at the time) than to just write the code. IMHO if you > think writing a lexer is too hard, you have no business writing > compilers. No, I don't think writing a lexer is hard. I did it many times before I even heard of lex (though I didn't know I was writing "lexers.") However, I can now write and debug a lexical analyzer in half a day max using flex, and anyone knowing lex/flex could easily maintain my code. Therefore I doubt I will ever write another "lexer" by hand. I think the surprise is that a "commercial compiler writer" would not be familiar with flex/lex. If you don't mind my asking, when did you study compilers, and what text did you use? ============================================================================== > schmidt@zola.ics.uci.edu writes: > Actually, GNU C uses a reserved word recognizer function generated > automatically by my GPERF program. But I understand your general > point. then goes on to give performance figures showing GPERF is much faster than flex/lex. I am not familiar with GPERF. What did you give up to get the speed advantage? Is GPERF available via anonymous ftp? Where? thanks, Bill Voss Email: billvoss@uiuc.edu or voss@cs.uiuc.edu