Converting ambiguous to unambigous grammar for arithmetic expressions

558 Views Asked by At

I'm attempting to come up with a non-ambiguous grammar for arithmetic expressions to make an Earley parser faster but I seem to be having trouble. This is the given ambiguous grammar

S -> E | S,S
E -> E+E | E-E | E*E | (E) | -E | V
V -> a | b | c

this is my attempt at making it unambiguous

S -> S+E | S-E | E | (S+E) | (S-E) | (E)
E -> E*T | E
T -> -V | V
V -> a | b | c

It parses everything fine but there isn't any significant speedup as compared to using the ambiguous one.

0

There are 0 best solutions below