+ 1
How to remove ambiguity from a grammar
Hello everyone Maybe this question not proper here but at least it related with the programming languages Anyway , if a grammar has an ambiguity how can removed is there any formal way for removing (like removing the left recursion in a grammar)?! Thanks
4 Antworten
+ 5
ambiguity come due to associativity or precedency
so to remove ambiguity
use left recursion for left associativity or right recursion for right associativity
and also take care of precedency
+ 1
Don't understand your question.
What is "left recursion"?
Do you have some examples?
0
consider this grammar wich written in CFG
E = E + T
T = 0 | 1 | .. | 9
the E is keep looping (infinite) , there is a formal rule to solve this problem
but I am just giving an example
what I want is how can I solve the ambiguity
0
I think you need the first to be able to terminate.
E: E + T | T
Or
E: T + E | T
Depending if you want left or right recursive.
Are you using a parser generator tool to build a compiler?