World's most popular travel blog for travel bloggers.

operator precendence grammar

, , No Comments
Problem Detail: 

According to this post http://stackoverflow.com/questions/28397767/computing-leading-and-trailing-sets-for-context-free-grammar while constructing operator precendence parser we have to create tabel with operator. Actually i dont understand the rules which tells how to build such table. For example take last production term -> '(' expr ')' do we use rule terminal nonterminal because of ( expr or do we use rule nonterminal terminal because of expr ) or do we use rule terminal nonterminal terminal shoudl we divide production or treat as whole? Then is there any other rule applicable in example from link then terminal nonterminal terminal ?

Asked By : whd
Answered By : rici

I think that answer is clear (although of course I would do, because I wrote it).

What it says is:

if you find

$$nonterminal\; TERMINAL$$

in any production, then you add the precedence relations $TRAIL \gtrdot TERMINAL$ for every $TRAIL$ in $Trailing(nonterminal)$. Similarly, every occurrence of

$$TERMINAL\; nonterminal$$

generates the relationships $TERMINAL \lessdot LEAD$ for every $LEAD$ in $Leading(nonterminal)$.

So in $'(' expr ')'$, you have both an instance of $TERMINAL\; nonterminal$ and an instance of $nonterminal\; TERMINAL$, and you need to deal with both of them independently.

Best Answer from StackOverflow

Question Source : http://cs.stackexchange.com/questions/58102

3200 people like this

 Download Related Notes/Documents

0 comments:

Post a Comment

Let us know your responses and feedback