15.08.2013 Views

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

General Computer Science 320201 GenCS I & II Lecture ... - Kwarc

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

A SW program (see the next slide for an example) first declares a set of variables (type declaration),<br />

executes a statement (type sta), and finally returns an expression (type exp). Expressions of SW<br />

can read the values of variables, but cannot change them. The statements of SW can read and<br />

change the values of variables, but do not return values (as usual in imperative languages). Note<br />

that SW follows common practice in imperative languages and models the conditional as a statement.<br />

Concrete vs. Abstract Syntax of a SW Program<br />

Example 469 (Abstract SW Syntax) We apply the abstract syntax to the SW program<br />

from Example 467:<br />

var n:= 12; var a:= 1;<br />

while 2 wln(x)+y) 0 xs<br />

fun wln(con _)=2 | wln(add)=1 | wln(sub)=1 | wln(mul)=1 | wln(leq)=1<br />

| wln(jp _)=2 | wln(cjp _)=2<br />

| wln(peek _)=2 | wln(poke _)=2 | wln(halt)=1<br />

c○: Michael Kohlhase 299<br />

Before we can come to the implementation of the compiler, we will need an infrastructure for<br />

environments.<br />

166

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!