LW - Grammatica CF - PowerPoint PPT Presentation

About This Presentation
Title:

LW - Grammatica CF

Description:

Funzioni di Semantica Statica Funzioni di Semantica Denotazionale Regole della Sem. Denot. per Decs 1 Regole della Sem. Denot. per Decs ed Exps LW ... – PowerPoint PPT presentation

Number of Views:38
Avg rating:3.0/5.0
Slides: 9
Provided by: MauraC4
Category:

less

Transcript and Presenter's Notes

Title: LW - Grammatica CF


1
LW - Grammatica CF
Prog Decs main() Stats. Decs Dec Dec
Decs. Dec VDec FDec. VDec PDec Type
Id Exp PDec Type Id FDec Type
Id(PDecs) with Decs do Stats result Exp
void Id(PDecs) with Decs do Stats PDecs PD
ec PDec PDecs. Type int
bool. Stats Stat Stat Stats. Stat Exp
while (Exp) Stats if (Exp) Stats else
Stats ?Id !Exp. Exp Id Id Exp
Id(Exps) Exp Exp Exps Exp Exp Exps.
2
Funzioni di Semantica Statica
_sProg LProg(LW) ?P _sDecs LDecs(LW)
? Envs ? Envs ?P Envs _sDec LDec(LW) ?
Envs ? Envs ?P Envs _sDec(d,r,rl)
_sDecs(d,r,rl) _sVDec LVDec(LW) ? Envs ?
Envs ?P Envs _sVDec(d,r,rl) _sDecs(d,r,rl)
_sPDecs LPDecs(LW) ? Envs ? Envs ?P Envs
_sPDecs(d,r,rl) _sDecs(d,r,rl)
_sPDec LPDec(LW) ? Envs ? Envs ?P Envs
_sPDec(d,r,rl) _sDecs(d,r,rl)
_sFDec LFDec(LW) ? Envs ? Envs ?P Envs
_sFDec(d,r,rl) _sDecs(d,r,rl)
_sStats LStats(LW) ? Envs ?P
_sStat LStat(LW) ? Envs ?P
_sStat(st,r) _sStats(st,r) _sExp LExp(LW
) ? Envs ?P Types _sExp(e,r)
_sExps(e,r) _sExps LExps(LW) ? Envs ?P
Types
Envs LId(LW) ?PTypesFin, dove Types BTypes
? (BTypes ? RTypes), dove BTypes int, bool
e RTypes BTypes ? void Notazione per funzioni
parziali a dominio finito f?X ?PAFin se f è ,
Dom(f) Ø se f è a1/x1,, an/xn con tutte le
xi distinte, Dom(f) x1,,xn e f(xi)(ai ) se
f è ga/x, Dom(f) Dom(g)? x e f(x) g(x) se
x ? x, altrimenti f(x)a se f è gh, Dom(f)
Dom(g)?Dom(h) e f(x) h(x) se x? Dom(h),
altrimenti f(x) g(x) se f è g\X, Dom(f)
Dom(g)\X e f(x) g(x)
3
Regole della Sem. Statica per Decs
ds(r, rl) rloc dss(r, rloc)
r0 _______________________________________________
______ d dss(r, rl) r0
es(rrl)t __________________________
_______ id ? Dom(rl) t id es(r,rl)
rlt/id
______________________________ id ? Dom(rl)
t ids(r,rl) rlt/id
pl(rrl,(lt,void)/f) rloc sts(rrl
rloc) lttypes(pl) ________________________
__________________________________________ f ?
Dom(rl) void f(pl) sts(r,rl)
rl(lt,void)/f
pl(rrl,(lt,t)/f) rloc sts(rrl
rloc) e(rrl rloc)
t lttypes(pl) ___________________________________
__________________________________________________
f ? Dom(rl) t f(pl) sts
result e(r,rl) rl(lt,t)/f t ? void
pl(rrl,(lt,void)/f) rloc ds(rrl,
rloc) rloc sts(r) lttypes(pl) _________
__________________________________________________
_____________________ f ? Dom(rl) void
f(pl) with ds do sts(r,rl)
rl(lt,void)/f r rrl rloc
pl(rrl,(lt,t)/f) rloc ds(rrl, rloc)
rloc sts(r) e(r) t
lttypes(pl) _____________________________________
__________________________________________________
___ f ? Dom(rl) t f(pl) with
ds do sts result e(r,rl) rl(lt,t)/f r
rrl rloc t ? void
4
Regole della Sem. Statica per Exps, Stats e Prog
es(r) t ess(r)
lt ____________________________________
e ess(r) t lt
________________________ id ? Dom(r) ids
(r) r(id) r(id)? BTypes
es(r) t __________________________
r(id) t id es (r) t
es(r) lt _____________________ r(id)
(lt,t) id(es)(r) t
e1(r) int e2(r) int __________________
__________________ e1 e2(r) int
etc...
es(r) t ________________ es (r)
es(r) bool stss (r)
_________________________________________
while (e) sts s (r)
es(r) t ________________ !es (r)
____________________ r(id) ? BTypes
?ids (r)
es(r) bool sts1s (r) sts2s
(r) __________________________________________
____________________ if (e) sts1
else sts2 s (r)
ds(,) r stss(r)
________________________________________________
ds main() stss (r)
5
Funzioni di Semantica Denotazionale
_Prog LProg(LW) ? Input ?P
Output _Decs LDecs(LW) ? Env ? States ?P Env
? States _Dec LDec(LW) ? Env ? States ?P
Env ? States _Dec(d,r,s) _Decs(d,r,s)
_VDec LVDec(LW) ? Env ? States ?P Env ?
States _VDec(d,r,s) _Decs(d,r,s)
_PDecs LPDecs(LW) ? Env ? States ?P Env ?
States _PDecs(d,r,s) _Decs(d,r,s)
_PDec LPDec(LW) ? Env ? States ?P Env ?
States _PDec(d,r,s) _Decs(d,r,s)
_FDec LFDec(LW) ? Env ? States ?P Env ?
States _FDec(d,r,s) _Decs(d,r,s)
_TypeLType(LW) ? Set _Stats LStats(LW) ?
Env ? States ?P States _Stat LStat(LW) ?
Env ? States ?P States _Stat(st,r,s)
_Stats(st,r,s) _Exp LExp(LW) ? Env ? States
?P Value ? States _Exp(e,r,s)
_Exps(e,r,s) _Exps LExps(LW) ? Env ? States
?P Value ? States
Env LId(LW) ?p Fun?Loc Fin, dove Loc
?T?BTypes LocT Fun Arg ?p Res, Arg Z B
? States e Res Z B ? States States
Input ? Output ? Loc ?p ValueFin, dove Value
?T?BTypes T e int Z, bool B, void
Input Output Value Nuova ? Loc ? Env ?
States definito da Nuova(l,r,s) sse l ?(Im(r) ?
Dom(s))
6
Regole della Sem. Denot. per Decs 1
F è definita induttivamente da tutte le regole
della semantica più le seguenti 2 A Aw se cè il
with e B, per leggibilità riportate nel riquadro
______________________________________ void f(T
x) with ds dosts(r,s) (rF/f,s)
sts (r?/f,lx/x,scv/lx ) s A
_____________________________________
Nuova(lx,r,sc) F(v,sc) (,s\lx)
e(r0?/f,s0) (u ,s) F(u,s)
(,s) B ________________________________________
__________ f(e) (r0?/f,s0)
(,s)
ds(r?/f,lx/x,scv/lx ) r1,s1 sts
(r1,s1) s Aw _________________________________
_______________________ Nuova(lx,r,sc)
F(v,sc) (,s\lx)
F è definita induttivamente da tutte le regole
della semantica più le seguenti 2 A Aw se cè il
with e B, per leggibilità riportate nel riquadro
____________________________________________ RT
f(T x) with ds dosts return e(r,s)
(rF/f,s)
sts (r?/f,lx/x,scv/lx ) s1 e(r
?/f,lx/x,s1) (u ,s) A _____________________
___________________________________
Nuova(lx,r,sc)
F(v,sc) (u,s\lx)
ds(r?/f,lx/x,scv/lx ) r1,s1 sts
(r1,s1) s2 e(r1,s2) (u ,s) Aw
__________________________________________________
___________________________ Nuova(lx,r,sc)
F(v,sc)
(u,s\lx)
e(r0?/f,s0) (v ,s) F(v,s)
(u,s) B ________________________________________
__________ f(e) (r0?/f,s0)
(u,s)
7
Regole della Sem. Denot. per Decs ed Exps
d(r,s) (r,s) ds (r,s)
(r,s) __________________________________________
_________ d ds (r,s) (r,s)
e(r,s) (v,s) _______________________________
_______ Nuova(l,r,s) t x e(r,s)
(rl/x,sv/l) l?LocT
________________________________ Nuova(l,r,s)
t x(r,s) (rl/x,s?/l) l?LocT
e (r,s) (v,s) es (r,s)
(lv,s) __________________________________________
_________ e es (r,s) (v lv,s)
e(r,s) (v,s) ___________________
___________________ x e(r,s)
(v,sv/r(x))
es(r,s) (lv ,s) _________________________
_____ f(es)(r,s) r(f)(lv,s)
___________________________ r(x) ?Loc
x(r,s) (s(r(x)),s)
e (r,s) (v,s) e (r,s)
(v,s) __________________________________________
________ v v a e e
(r,s) (a,s)
etc...
8
Regole della Sem. Denot. per Stats e Prog
st (r,s) s sts (r,s)
s __________________________________________
st sts (r,s) s
e(r,s) (v ,s) _______________________
e(r,s) s
e(r,s) (tt ,s) sts (r,s)
s ____________________________________________
if (e) sts else sts(r,s) s
e(r,s) (ff ,s) sts (r,s)
s ____________________________________________
if (e) sts else sts(r,s) s
e(r,s) (ff ,s) ______________________
_____________ while (e) sts(r,s) s
e(r,s) (tt ,s) sts (r,s) s
while (e) sts(r,s) s0 _____________________
__________________________________________________
____________ while (e)
sts(r,s) s0
ds(,(i,l,)) (r ,s) sts (r,s)
(i,o,m) _________________________________________
_________________ ds main() sts(i)
o
Write a Comment
User Comments (0)
About PowerShow.com