Computer Science, asked by jayagedar2368, 1 year ago

Consider the following grammar E \rightarrow E+T  |T, T\rightarrow T*F |F, F\rightarrow  id Construct the operator precedence relation table and find the precedence functions.

Answers

Answered by maralsarthak1834
0

Answer:

grammar that is used to define mathematical operators is called an operator grammar or operator precedence grammar. Such grammars have the restriction that no production has either an empty right-hand side (null productions) or two adjacent non-terminals in its right-hand side.

Examples –

This is an example of operator grammar:

E->E+E/E*E/id

However, the grammar given below is not an operator grammar because two non-terminals are adjacent to each other:

S->SAS/a

A->bSb/b

We can convert it into an operator grammar, though:

S->SbSbS/SbS/a

A->bSb/b

Operator precedence parser –

An operator precedence parser is a bottom-up parser that interprets an operator grammar. This parser is only used for operator grammars. Ambiguous grammars are not allowed in any parser except operator precedence parser.

There are two methods for determining what precedence relations should hold between a pair of terminals:

Similar questions