MUPL and Friends Notes | EduRev

: MUPL and Friends Notes | EduRev

 Page 1


MUPL and Friends 
CSE 413 Spring 2011 
Credit: CSE341 notes by Dan Grossman 
Page 2


MUPL and Friends 
CSE 413 Spring 2011 
Credit: CSE341 notes by Dan Grossman 
Implementing Languages 
? At a very high level there are 2 ways to 
implement a language A 
?Write an interpreter in language B that reads, 
analyzes, and immediately evaluates 
programs written in language A 
?Write a compiler in language B that translates 
a program written in language A into some 
other language C (and have an 
implementation of C available) 
Page 3


MUPL and Friends 
CSE 413 Spring 2011 
Credit: CSE341 notes by Dan Grossman 
Implementing Languages 
? At a very high level there are 2 ways to 
implement a language A 
?Write an interpreter in language B that reads, 
analyzes, and immediately evaluates 
programs written in language A 
?Write a compiler in language B that translates 
a program written in language A into some 
other language C (and have an 
implementation of C available) 
Homework 4: Implement MUPL 
? MUPL – “Made-Up Programming 
Language” 
?Basically a small subset of Scheme 
?Most interesting feature: higher-order 
functions 
? HW4 is to write an interpreter for this 
language 
Page 4


MUPL and Friends 
CSE 413 Spring 2011 
Credit: CSE341 notes by Dan Grossman 
Implementing Languages 
? At a very high level there are 2 ways to 
implement a language A 
?Write an interpreter in language B that reads, 
analyzes, and immediately evaluates 
programs written in language A 
?Write a compiler in language B that translates 
a program written in language A into some 
other language C (and have an 
implementation of C available) 
Homework 4: Implement MUPL 
? MUPL – “Made-Up Programming 
Language” 
?Basically a small subset of Scheme 
?Most interesting feature: higher-order 
functions 
? HW4 is to write an interpreter for this 
language 
Encoding A Language 
? Suppose we want to process “-(2+2)” 
? Compilers and interpreters both read (parse) 
linear program text and produce an abstract 
syntax tree representation 
? For this example using a made-up AST syntax:  
(make-negate (make-add (make-const 2) (make-
const 2))) 
? A parser turns the linear input into an AST 
? For hw4 we’ll write ASTs directly – no parser 
needed 
Page 5


MUPL and Friends 
CSE 413 Spring 2011 
Credit: CSE341 notes by Dan Grossman 
Implementing Languages 
? At a very high level there are 2 ways to 
implement a language A 
?Write an interpreter in language B that reads, 
analyzes, and immediately evaluates 
programs written in language A 
?Write a compiler in language B that translates 
a program written in language A into some 
other language C (and have an 
implementation of C available) 
Homework 4: Implement MUPL 
? MUPL – “Made-Up Programming 
Language” 
?Basically a small subset of Scheme 
?Most interesting feature: higher-order 
functions 
? HW4 is to write an interpreter for this 
language 
Encoding A Language 
? Suppose we want to process “-(2+2)” 
? Compilers and interpreters both read (parse) 
linear program text and produce an abstract 
syntax tree representation 
? For this example using a made-up AST syntax:  
(make-negate (make-add (make-const 2) (make-
const 2))) 
? A parser turns the linear input into an AST 
? For hw4 we’ll write ASTs directly – no parser 
needed 
An Interpreter 
? An interpreter: a “direct” implementation 
created by writing out the evaluation rules 
for the language in another language 
? For HW4: 
?MUPL programs encoded in Scheme data 
structures (use define-struct definitions in 
starter code) 
?Interpreter written in Scheme 
Read More
Offer running on EduRev: Apply code STAYHOME200 to get INR 200 off on our premium plan EduRev Infinity!