How do I write a "lexer or parser generators"
Timon Gehr
timon.gehr at gmx.ch
Thu Jan 23 02:07:56 PST 2014
On 01/23/2014 10:06 AM, Daniel Murphy wrote:
>> "OP" wrote in message news:qtjpbqxlabjerowdlkfo at forum.dlang.org... I
>> just looked at parse.c and I had no idea there is a precedence table.
>> Why is there one rather than it being embedded like a switch statement
>> which tries to handle all the higher precedence operations calling a
>> function running the next set of precedence? I guess that does sound
>> like a loop/table but I imagined it in switch statements.
>
> The precedence table is mostly just used for leaving off redundant
> parens when printing expressions, not for parsing.
Encoding precedence by function calls is unnecessarily wasteful though.
(e.g. "a.b" requires roughly 14 recursive function calls to be parsed by
such a scheme.)
More information about the Digitalmars-d
mailing list