L7Interp - Interpreters Study Semantics of Programming...

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

View Full Document Right Arrow Icon
cs784(Prasad) L7Interp 1 Interpreters Study Semantics of Programming Languages through interpreters ( Executable Specifications )
Background image of page 1

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

View Full DocumentRight Arrow Icon
cs784(Prasad) L7Interp 2 Interpreters Input : Representation of a program (AST) Output : “Meaning” of the program s Interpreter vs Compiler Interpreter carries out the meaning of a program, while a compiler transforms a program in one language into a program in a lower-level language preserving the
Background image of page 2
cs784(Prasad) L7Interp 3 Simple Expression Language <program> ::= <expression>   <expression>::=  <number>                | <identifier>               | <primitive> <operands>              <operands> ::=  ()                 |  ( <expression>  { , <expression>}* )  <primitive> ::=   +  |  -  |  *  |  add1  |  sub1 E.g., 5 add1(+(3,j))                      
Background image of page 3

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

View Full DocumentRight Arrow Icon
cs784(Prasad) L7Interp 4 Informal Semanics Number same as what Scheme associates with numerals. ( internal to the entity ) Symbolic names value bound to it in the environment ( external to the entity ) Application expression recursively evaluate operator and operands. primitive operators interpreted by Scheme.
Background image of page 4
cs784(Prasad) L7Interp 5 Example (Petite Scheme) > (just-scan "add1(+(1,3))")  ((literal-string28 "add1" 1)  (literal-string28 "(" 1)  (literal-string28 "+" 1)  (literal-string28 "(" 1)  (number 1 1)  (literal-string28 "," 1)  (number 3 1)  (literal-string28 ")" 1)  (literal-string28 ")" 1))  
Background image of page 5

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

View Full DocumentRight Arrow Icon
cs784(Prasad) L7Interp 6 Example (a-program   (primapp-exp     (incr-prim)     ((primapp-exp (add-prim)                     ((lit-exp 1)                    (lit-exp 3)))))) > (eval-program 5
Background image of page 6
cs784(Prasad) L7Interp 7 The Abstract Syntax (define-datatype  program  program?    (a-program (exp expression?))) (define-datatype expression expression?    (lit-exp (datum number?))
Background image of page 7

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

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

This note was uploaded on 06/02/2011 for the course CS cs784 taught by Professor Tkprasad during the Spring '11 term at New York Institute of Technology-Westbury.

Page1 / 25

L7Interp - Interpreters Study Semantics of Programming...

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

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