Interpreting the D grammar

Jacob Carlborg via Digitalmars-d digitalmars-d at puremagic.com
Sun Aug 2 10:33:34 PDT 2015


On 02/08/15 18:37, MakersF wrote:

> Of course it's recursive! Do you want the grammar to be able to only
> define a finite number of programs?

I don't know how this work, that's why I'm asking. But I read something 
about left recursion needs to be removed to be able to parse a grammar, 
at least for some parsers.

> But in this case you could write the original grammar rule as
> mul |
> cat |
> (mul|cat)((+|-) (mul|cat))* (+|-) (mul|cat)
>
> but you lose the precedence of the operation as it is a flat list and
> not a tree

I don't think that's important for syntax highlighting.

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list