Re: [dev] lex and yacc

From: <>
Date: Sun, 10 Mar 2019 13:45:48 +0000

On Sun, Mar 10, 2019 at 06:17:16AM +0100, Markus Wichmann wrote:
> Well, other people have made that point before: Why use a regex to
> identify a token when a simple loop will do?
> So for lexing, usually a simple token parser in C will do the job
> better. And for parsing, you get the problem that yacc will create an
> LALR parser, which is a bottom-up parser. Which may be faster but
> doesn't allow for good error messages on faulty input ("error: expected
> this, that, or the other token before this one"). That's why top-down
> recursive-descent parsers (or LL(1) parsers) are superior. Maybe
> supplemented with a shunting-yard algorithm to get the binary
> expressions right without having to call layer after layer of functions.

This is exactly what I am experiencing while coding this little/simple custom
language parser.
Yep, I guess lex/yacc (then GNU flex/GNU bison) are inappropriate, I even would
generalize to they do not belong in "suckless".

Received on Sun Mar 10 2019 - 14:45:48 CET

This archive was generated by hypermail 2.3.0 : Sun Mar 10 2019 - 14:48:08 CET