Discussion:
[9fans] Config File parsing
(too old to reply)
erik quanstrom
2012-02-27 13:18:34 UTC
Permalink
For this could someone please tell me how to write a lex and yacc
program.
you may wish to consult the dragon book. just google it.

- erik
Jack Norton
2012-02-27 14:06:00 UTC
Permalink
Post by erik quanstrom
For this could someone please tell me how to write a lex and yacc
program.
you may wish to consult the dragon book. just google it.
- erik
FYI I just bought my copy on Amazon used for $3.48 USD ($3.99
shipping....). It is a hardcopy in great shape too!

-Jack
a***@skeeve.com
2012-02-27 13:23:56 UTC
Permalink
O'Reilly's "lex & yacc" is somewhat more user-friendly a reference than
the dragon book, although the latter certainly has its value. :-)

Arnold
Nick LaForge
2012-02-28 04:03:01 UTC
Permalink
Are you certain you want to use Lex? If no, you may like this
fascinating and instructive lecture by Rob Pike, which solves a lexing
problem using Golang:


If you have "The Unix Programming Environment" handy, you will also
find a lucid tutorial of Lex and Yacc both (in the later chapters).

Nick
Post by a***@skeeve.com
O'Reilly's "lex & yacc" is somewhat more user-friendly a reference than
the dragon book, although the latter certainly has its value. :-)
Arnold
Aram Hăvărneanu
2012-02-28 14:57:39 UTC
Permalink
Post by Nick LaForge
If you have "The Unix Programming Environment" handy, you will also
find a lucid tutorial of Lex and Yacc both (in the later chapters).
A great complement to this great book is the yacc paper in tenth
edition's manual.
--
Aram Hăvărneanu
Bakul Shah
2012-02-28 16:46:33 UTC
Permalink
I have almost always used a handwritten lexer as it seemed about the same amount of work and the end result is much smaller and easier to understand and lexers for different languages are not all that different so once you've written one it is pretty easy to write another; and somehow lex or flex interface never felt quite right.
Post by Nick LaForge
Are you certain you want to use Lex? If no, you may like this
fascinating and instructive lecture by Rob Pike, which solves a lexing
problem using Golang: http://youtu.be/HxaD_trXwRE
If you have "The Unix Programming Environment" handy, you will also
find a lucid tutorial of Lex and Yacc both (in the later chapters).
Nick
Post by a***@skeeve.com
O'Reilly's "lex & yacc" is somewhat more user-friendly a reference than
the dragon book, although the latter certainly has its value. :-)
Arnold
erik quanstrom
2012-02-28 16:57:58 UTC
Permalink
Post by Bakul Shah
I have almost always used a handwritten lexer as it seemed about the
same amount of work and the end result is much smaller and easier to
understand and lexers for different languages are not all that
different so once you've written one it is pretty easy to write
another; and somehow lex or flex interface never felt quite right.
for an extreme example, see /sys/src/cmd/upas/smtp/smtpd.y.

imho, the trick in lexing is to do as little as possible. context rules
tend to sneak in in the lex phase. for example, rc's free carets and
willingness to eat newlines under rules that seem obvious until they
need explaining.

- erik

Continue reading on narkive:
Loading...