Presentation is loading. Please wait.

Presentation is loading. Please wait.

INF 3110/4110 - 2004 INF 5110 - 2013 INF5110 01.03.20131 Oppgave 6.7 Grammar RuleSemantic Rule decl → var-list : type var-list 1 → var-list 2 ; id var-list.

Similar presentations


Presentation on theme: "INF 3110/4110 - 2004 INF 5110 - 2013 INF5110 01.03.20131 Oppgave 6.7 Grammar RuleSemantic Rule decl → var-list : type var-list 1 → var-list 2 ; id var-list."— Presentation transcript:

1 INF 3110/4110 - 2004 INF 5110 - 2013 INF5110 01.03.20131 Oppgave 6.7 Grammar RuleSemantic Rule decl → var-list : type var-list 1 → var-list 2 ; id var-list → id type → int type → bool

2 INF 3110/4110 - 2004 INF 5110 - 2013 INF5110 01.03.20132 Grammar RuleSemantic Rule class → class name superclass { decls } decls 1 → decls 2 ; decl decls → decl decl → method-decl method-decl → type name ( params ) body type → int type → bool type → void superclass → name

3 INF 3110/4110 - 2004 INF 5110 - 2013 INF5110 01.03.20133 Grammar RuleSemantic Rule function-decl → type id ( ) body function-decl.has_parameter = no function-decl → type id ( parameter ) body function-decl.has_parameter = yes function-decl.param-kind = parameter.kind function-decl.param-type = parameter.type parameter → type id parameter → type func id type → inttype.type = integer type → booltype.type = boolean type → voidtype.type = void Eksamen 2007 – oppgave 2b

4 INF 3110/4110 - 2004 INF 5110 - 2013 INF5110 01.03.20134 Grammar RuleSemantic Rule call → id ()call.ok = (lookup(id.name).has_parameter=no) call → id 1 (id 2 )call.ok =

5 INF 3110/4110 - 2004 INF 5110 - 2013 INF5110 01.03.20135 Grammar RuleSemantic Rule func → type func id signature stmt-list type → inttype.type = Integer type → booltype.type = Boolean stmt-list 1 → stmt-list 2 stmt stmt-list → stmt stmt → return-stmt return-stmt → return expreturn-stmt.ok = (return-stmt.type = exp.type) Eksamen 2010 – oppgave 3a

6 INF 3110/4110 - 2004 INF 5110 - 2013 INF5110 01.03.20136 Grammar RuleSemantic Rule exp → idexp.type = lookup(id.name) exp → id 1 + id 2 exp → trueexp.type = Boolean exp → falseexp.type = Boolean


Download ppt "INF 3110/4110 - 2004 INF 5110 - 2013 INF5110 01.03.20131 Oppgave 6.7 Grammar RuleSemantic Rule decl → var-list : type var-list 1 → var-list 2 ; id var-list."

Similar presentations


Ads by Google