L6AST - Abstract Syntax cs784 (Prasad) L6AST 1 Language of...

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

View Full Document Right Arrow Icon
cs784 (Prasad) L6AST 1 Abstract Syntax
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) L6AST 2 Language of λ -expressions <exp>  ::=   <identifier>         |  (lambda   <identifier>   ) <exp> )         |  ( <exp> <exp> )   E.g.,   concrete syntax Scheme S-expressions ( lambda (x) ( f ( f x ) ) )
Background image of page 2
cs784 (Prasad) L6AST 3 Abstract Syntax ( vs Concrete Syntax ) lambda-exp app-exp var-exp var-exp var-exp id id id id body rand rand app-exp rator rator
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) L6AST 4 Overview Parse-expression Unparse-expression Interpreter Concrete Syntax Abstract Syntax Results
Background image of page 4
cs784 (Prasad) L6AST 5 Representing Abstract Syntax with Records (define-datatype expression expression?     (var-exp     (id symbol?))    (lambda-exp      (id symbol?)      (body expression?))    (app-exp      (rator expression?)     (rand expression?)))
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) L6AST 6 (define parse-expression   (lambda (datum)     (cond       ((symbol? datum)  (var-exp datum) )       ((pair? datum)        (if (eqv? (car datum) 'lambda)          (lambda-exp (caadr datum) (lambda-exp (caadr datum)                         (parse-expression (caddr datum))) (parse-expression (caddr datum)))                     (app-exp (app-exp                         (parse-expression (car datum))
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 17

L6AST - Abstract Syntax cs784 (Prasad) L6AST 1 Language of...

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

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