














































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The key points are: Formal Semantics, Definitions of Syntax, Abstract Syntax Trees, Programming Language Semantics, Prolog Interpreters, Natural Semantics, Adding Functions, Adding Variables, Integer Expressions
Typology: Slides
1 / 54
This page cannot be seen from the preview
Don't miss anything!















































Chapter Twenty-Three Modern Programming Languages, 2nd ed. (^) Docsity.com 1
Chapter Twenty-Three Modern Programming Languages, 2nd ed. (^) Docsity.com 2
Chapter Twenty-Three Modern Programming Languages, 2nd ed. (^) Docsity.com 4
Chapter Twenty-Three Modern Programming Languages, 2nd ed. 5
< exp > ::= < exp > + < mulexp > | < mulexp > < mulexp > ::= < mulexp > ***** < rootexp > | < rootexp > < rootexp > ::= ( < exp > ) | < constant >
Docsity.com
Chapter Twenty-Three Modern Programming Languages, 2nd ed. 7
+
1
2
3 plus(const(1),times(const(2),const(3)))
Docsity.com
Chapter Twenty-Three Modern Programming Languages, 2nd ed. 8
< exp > ::= plus( < exp > , < exp > ) | times( < exp > , < exp > ) | const( < constant > )
Docsity.com
Chapter Twenty-Three Modern Programming Languages, 2nd ed. 10
?- val1(const(1),X). X = 1.
?- val1(plus(const(1),const(2)),X). X = 3.
?- val1(plus(const(1),times(const(2),const(3))),X). X = 7.
Docsity.com
Chapter Twenty-Three Modern Programming Languages, 2nd ed. (^) Docsity.com 11
Chapter Twenty-Three Modern Programming Languages, 2nd ed. 13
?- val(plus(const(2147483647),const(1)),X). X = 2.14748e+009.
?- val(plus(const(2147483647),const(1)),X). X = 2147483648.
Docsity.com
Chapter Twenty-Three Modern Programming Languages, 2nd ed. (^) Docsity.com 14
Chapter Twenty-Three Modern Programming Languages, 2nd ed. 16
1 1 2 2
val1(times(X,Y),Value) :- val1(X,XValue), val1(Y,YValue), Value is XValue * YValue.
Docsity.com
Chapter Twenty-Three Modern Programming Languages, 2nd ed. 17
1 1 2 2
1 1 2 2
val1(plus(X,Y),Value) :- val1(X,XValue), val1(Y,YValue), Value is XValue + YValue. val1(times(X,Y),Value) :- val1(X,XValue), val1(Y,YValue), Value is XValue * YValue. val1(const(X),X).
Docsity.com
Chapter Twenty-Three Modern Programming Languages, 2nd ed. (^) Docsity.com 19
Chapter Twenty-Three Modern Programming Languages, 2nd ed. (^) Docsity.com 20