0% found this document useful (0 votes)
72 views11 pages

Unit 5 Assignment: Dissecting Syntax

5th aasment

Uploaded by

bhattdev7777
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
72 views11 pages

Unit 5 Assignment: Dissecting Syntax

5th aasment

Uploaded by

bhattdev7777
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Chaptes-05 S yuto Disecte d Trams labim

AssiaNMeNT -04
:o Congtructhe pasetee amd
txee for the eapresaiom CCa)+cb)
to
accovding
(a) Sya-tar diected detinition
Pecoduelion )+o)) Bemamtic Rules
E>Et+ T C + e ) E np#y= mtnode '%[Link],
E npiyiz mknode (-Engtzjn
E>T [Link]=T:nptr
T’(E) [Link]= Enp*7
T>i) [Link] mkleafCid,id tnt)
T nptri= mklea Cnum,num Vau)
V

Ans:ol
Translatuen scheme
RI:= T. npt

mtnode '+Ri,Inpto

(a) Ca))
R R-s: R s

) 1 . npty: .npt 3
raga No 6C
Date

T’ id ELnpti mkleat Cid, identdi


Pasue tre
Input((a+Cb)):
C-npt (Ca)rch))
T. npt
(Ca)+ C6)
Enpii
+ (b)

E- hpk : (b)
[Link] := (a) T' npti= (b)

E-npeai
T
chaaiAbondcd

Contuct Sytax kee-o input


2-)shonn e)(6))

istq.3icsq.}
T. npt
¬;npi T)

E-npts Tinpts
S Jnpt |+| E-npt
CJE-npt

[Link] id
do eutyfoe b
id)

Rue:o2Fos tths fupt ex presg ie (4Pt)*2


Conslzuct annotated parse tee
to the gtax disecte d
accondng
deesniie qinen belocu
tiguse
Peiocucton Bemamtic Rules
Point (E. val)
6. Val: E.v al+ [Link]
[Link]:- [Link]
T: Va:=7. ValtE:val
T. Va:= E val
F’digit
T
F Val dqit lek Val
T. Va: = F val
Prgo No
Data
63

Ans:o2
L:=Pnt (54

T.Val59
T| va=24

duit ler val

diqit. leval )
.va'-4 dugit -Lerval
gugt evat

ue:03 Constct Ahe dag amd


hum beis identity
suber pASion
the value
the
expessien
a t at - a t ata+ (atat a+ a))
An:o3 t.

+
Pa
Date
N
69
idl
+
+ 2
+ 3
34
+ 2

:o4: Onstouct x ectedtmlauen


&cheme and
yut detiition that toans|ate
anith metic opesation fem inix to postfix
wWch Ope atoy appeans befoe
its opesiamd is a
positie notatÁn Give annonated
q-5+2 md
passe tceeg fo tee)nput
q- 5 2 ( Concatenatio)

Produc tions SDD tSDTS

[Link]"+"

enpyenpyl -texmenpy.t Bnp).t 11enpreupy l-tem


HomtL "pint ( - ")3

ep term enpy.i tem.t epy trm

ferm ’0 tegoiPit
Pege No
Date

term +enn

9
tey9
tenmt"9em9p
Annon ated panse tsee

emp

point t (123
{Point (ls' )}
2raltTbor

Ahnonacted Paseate koeinpus 39-5+


1C)tica7

enpriy *tezm:2Pnt

a fpint
to a wit
Rueio A 91obot is to be moved
COmmamd
dinectorn
30b0t
specitied
hoves
as a

directon Nosth South, East West


neceiving N,S E,wcovn mamd resp amd
the dinecHon No4a -Gayt Noy th
westt Sowtth Ga3* Sowta cwest
Conn man dLs
oe
ceitng
cuent position sf te
sp
?nitialined to Co, o) Castesian coordUn cteg

ecaivina
poductionn
84at

Poo dy cinq seuan


Cwite

amd gem amtic

knouoing Be uernce
obat
[Link] w
annotated pase toee pr tolloeoing dequen
gtast NNAACCN
rio
n:oG The PoDductian and Zennamticactton
Lqiven bafo cu t t ’ Ccmmmd
09rib
Commamd diecten Command
dnec Hon N|s|E|wlAla|c|D
move

S move sowtL
eat
mowe cuet
A rnove n o t - east
noth- coest
mowe So wte - est
South - Cuet
S-tat
Comnah

diyec tcn CommQnd

move disectHon comm and


nota
dËveckin
Hot
A move
noth
command
move
hoth
coet

diyectom
Covinmoveo
Comm0nd
8ou
eayt diyecton Cemmad
D. nore

cdécton cemmaind
99N
A9ton mov eA
not
Paga No. 3
Date

Synth esi2ed an d inhen ite d


Discuss
ottibtes usinq swtable gaqmma

Ang:0 SYNTHEsizeD ATTRIBUTES

Value Jynthesized attib cte at a node


cant be iCompted
attibtes can t4ee cildn node
inthe Pase
Jyntax directed degini tion that Wses
is Sadi to
Byothesized atti bute ceus ivel
be S- attibute depiniion
A pasSe tee a S-attibuted depii +i
Can aloa s be nnotaed by ew aluatng
8emamtic ulesQttibuche at
ea ce hode botto - up om t e Peaveg
5TUA9TTA7HAI
The syntex dinecteddegini ten
desonCalcul ator

Pro duucHÇn Semantic Rules


enhe
E’EI+T [Link] tlsvltT Val
E Tq
TTkF +otAnhval = Thvl * FvQl
3i Tvad F va i
F>(E)S 6Fi val E valt
F digjt o Fval = diqito leval
Luntax dusectdn
~inpla. dok caecueoto
Page No
Date

[Link] |9
A9TAY
Tval= 4
ksis9
[Link] l5

F Val>.54
Tval-3
b9+39i
ssig9
o [Link] 3
tydieto

duqitex val3
-Annototedr passetor 2* 5t un
INHERITE D ATTRIBUTG

An inheited: value ratyas nede in


IS deined tems
pasue
Qttibteg at
the
Pogzaiing
7ent the context
Jecontuct
appena.
They jinhesited attibute dsti budeg type
tee tivanious identitje
ru7 otmatien to
daclaLatien
Exowsplei
Data

Produucign Semantic Ruls

T. type tegea
’ eal I type = eal
. in =bin ,add teype
34 ntox divecte d
add tee Cid evy L'iin
dokuthie OH ?nheited attiblte
coith
attoibuta typc
QA2Oi ated
Tuseited

T type [Link] =veal


eal Lin eal id 3

L-in =7eal id

idl
inheited ottibcte

uos 6xplain appropate emple that


to
petom botlom up evaluatiom
inheite d t t ibutes .

You might also like