ln028 - Review: Language ONE Lets develop an operational...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon
Review: Language ONE Let’s develop an operational semantics for a simple programming language called ONE ; ONE : < exp >* ::= < exp > + < mulexp > | < mulexp > < mulexp > ::= < mulexp > * < rootexp > | < rootexp > < rootexp > ::= ( < exp > ) | < constant > < constant > ::= all valid integer constants Note: The grammar is unambiguous, both precedence and associativity rules of “standard” arithmetic are observed. Do the following sentences belong to L ( ONE )? Why? Why not? s = 1 + 2 * 3 s = (1 + 2) * 3 s = a + 3
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Review: Prolog Interpreter for ONE 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). A simple interpreter that computes a semantic value for syntactic constructs, the computation of this semantic value can be interpreted as the behavior: val1 / 2, AST input and semantic value as output.
Background image of page 2
Problems What is the value of a constant? Interpreter says
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 4
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 12

ln028 - Review: Language ONE Lets develop an operational...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online