ln027 - Formal Semantics The structure of a language...

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

View Full Document Right Arrow Icon
Formal Semantics The structure of a language defines its syntax, but what defines semantics or meaning? Behavior ! The most straight forward way to define semantics is to provide a simple interpreter for the programming language that highlights the behavior of the language, Operational Semantics
Background image of page 1

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

View Full Document Right Arrow Icon
Operational Semantics 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 2
Abstract Syntax Trees We want to define an operational semantics, i.e., an abstract interpreter for the language, but parse trees are not very convenient, too many non-terminal symbols
Background image of page 3

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

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

{[ snackBarMessage ]}

Page1 / 7

ln027 - Formal Semantics The structure of a language...

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