The Gateway to Computer Science Excellence
First time here? Checkout the FAQ!
x
0 votes
63 views
Rewrite the following SDT:

A->A {a} B | AB {b} | 0

B->B {c} A | BA {d} | 1

so that the underlying grammar becomes non-left-recursive. Here a, b, c and d are actions, and 0 and 1 are terminals

 

is my solution correct?

A→ 0A’

A’→ {a} BA’ | B {b} A’ | ε

B→ 1B’

B’→ {c} AB’ | A {d} B’ | ε
asked in Compiler Design by Active (3.7k points) | 63 views
0
what 2nd bracket thing actually representing here

Is it printing statement or nonterminal?
0
they're actions(semantic). it's mentioned in the question
0
action means it can be printf statement, +,-, or any arithmetic or logical operations

right?
0
yes!
0
yes, u r correct. position of actions cannot be changed
0

where u got action always done at last?

See here also printing done in middle https://gateoverflow.in/194481/sdt-compiler

0

@srestha that's not my question

when semantic action is performed in the middle and semantic action is done on a left-recursive variable then how to you eliminate left-recursion?

+1
Suppose

$E\rightarrow E+T|T$

then

$E\rightarrow TE'$

$E'\rightarrow +TE'|\epsilon$

So, actions are in place

right?
0
yeah.. got it now 👍

Please log in or register to answer this question.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true
49,540 questions
54,099 answers
187,269 comments
71,006 users