INF 3110/ INF INF Oppgave 6.7 Grammar RuleSemantic Rule decl → var-list : type var-list 1 → var-list 2 ; id var-list → id type → int type → bool
INF 3110/ INF INF 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
INF 3110/ INF INF 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
INF 3110/ INF INF Grammar RuleSemantic Rule call → id ()call.ok = (lookup(id.name).has_parameter=no) call → id 1 (id 2 )call.ok =
INF 3110/ INF INF 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
INF 3110/ INF INF Grammar RuleSemantic Rule exp → idexp.type = lookup(id.name) exp → id 1 + id 2 exp → trueexp.type = Boolean exp → falseexp.type = Boolean