From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: From: erik quanstrom Date: Fri, 19 Jan 2007 16:06:14 -0500 To: 9fans@cse.psu.edu Subject: Re: [9fans] Replacements for lex In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 065a4f34-ead2-11e9-9d60-3106f5b1d025 i think the ken c lexer is a very good example. it shows how goto, well applied, can be a very useful tool for an ad hoc problem. it also shows that in practice lexers and parsers are seldom as separate as they appear in textbooks. on the other hand, rc has a very hairy lexer. hoc has a small, elegant one. i believe the _practice of programming_ goes into detail about it. - erik On Fri Jan 19 15:37:42 EST 2007, forsyth@vitanuova.com wrote: > >I expect the lexer in /sys/src/cmd/cc/ will be a good example. > > it's a little more elaborate than some (not gcc!) because it takes on limited C preprocessing > duties as well. you might also observe that the author enjoys his gotos, but since it is essentially > a finite state machine that seems fair enough, and furthermore he's allowed to take advantage of his > `licence to GOTO' awarded after a killer early paper. (Since that was about automata, it should probably > be an Earley paper, except that it's slightly earlier than that.) anyway, he meant no harm.