| Re: [9fans] Replacements for lex |
|
 |
|
 |
|
 |
|
 |
Group: comp.os.plan9 · Group Profile
Author: erik quanstromerik quanstrom Date: Jan 19, 2007 13:08
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.
|