Re: [dev] lex and yacc

From: <k0ga_AT_shike2.com>
Date: Mon, 11 Mar 2019 07:04:49 +0000

> 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.

I think it depends what you want to do. If you want a compiler, go for
a recursive parser. If you want a DSL (like for example pic(1)), then go
with yacc. Mpu wrote a very good and small yacc implementation that you can
find in his page.
Received on Mon Mar 11 2019 - 08:04:49 CET

This archive was generated by hypermail 2.3.0 : Mon Mar 11 2019 - 08:12:07 CET