Difference between revisions of "Itty Bitty Programming Language Interpreter Assignment"
Jump to navigation
Jump to search
(Created page with "In a series of assignments, we will build the Itty Bitty Programming Language (IBPL). The inspiration for these assignments is MUPL by Dan Grossman and his team at UW. One c...") |
|||
Line 21: | Line 21: | ||
==Values== | ==Values== | ||
===int=== | ===int=== | ||
+ | * [https://docs.racket-lang.org/reference/number-types.html#%28def._%28%28quote._~23~25kernel%29._exact-integer~3f%29%29 exact-integer?] | ||
+ | ===the empty list=== | ||
+ | * [https://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._null%29%29 null] | ||
+ | * [https://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._null~3f%29%29 null?] | ||
===the mighty cons cell=== | ===the mighty cons cell=== | ||
− | + | * [https://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._cons%29%29 cons] | |
+ | * [https://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._car%29%29 car] | ||
+ | * [https://docs.racket-lang.org/reference/pairs.html#%28def._%28%28quote._~23~25kernel%29._cdr%29%29 cdr] | ||
===closure=== | ===closure=== | ||
<syntaxhighlight lang="racket"> | <syntaxhighlight lang="racket"> | ||
Line 30: | Line 36: | ||
==Utility== | ==Utility== | ||
===entry=== | ===entry=== | ||
+ | Environments in IBPL will be stored as a list of entries. An entry is comprised of a name of type string and a value which is a value. | ||
+ | |||
+ | * [https://docs.racket-lang.org/reference/strings.html#%28def._%28%28quote._~23~25kernel%29._string~3f%29%29 string?] | ||
+ | * value? | ||
+ | |||
<syntaxhighlight lang="racket"> | <syntaxhighlight lang="racket"> | ||
(struct entry (name value) #:transparent) | (struct entry (name value) #:transparent) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=Code To Implement= | =Code To Implement= |
Revision as of 13:27, 2 November 2023
In a series of assignments, we will build the Itty Bitty Programming Language (IBPL). The inspiration for these assignments is MUPL by Dan Grossman and his team at UW.
One can build an IBPL Abstract Syntax Tree (AST) with the following expressions:
Contents
Expressions
(struct IdentifierExp (name) #:transparent)
(struct IntExp (value) #:transparent)
(struct AddExp (left_exp right_exp) #:transparent)
(struct IfGreaterExp (left_exp right_exp then_body_exp else_body_exp) #:transparent)
(struct NilExp () #:transparent)
(struct IsNilExp (exp) #:transparent)
(struct ConsExp (car_exp cdr_exp) #:transparent)
(struct CarOfConsExp (cons_exp) #:transparent)
(struct CdrOfConsExp (cons_exp) #:transparent)
(struct LetExp (binding_name binding_exp body_exp) #:transparent)
(struct FunctionExp (name_option parameter_name body_exp) #:transparent)
(struct CallExp (function_exp argument_exp) #:transparent)
Values
int
the empty list
the mighty cons cell
closure
(struct closure (env function) #:transparent)
Utility
entry
Environments in IBPL will be stored as a list of entries. An entry is comprised of a name of type string and a value which is a value.
- string?
- value?
(struct entry (name value) #:transparent)
Code To Implement
file: | src/main/racket/ibpl/interpreter/interpreter.rkt | |
functions: | value? expand-environment evaluate |
value?
(define (value? v)
(error 'not-yet-implemented))
expand-environment
(define (expand-environment name value env)
(error 'not-yet-implemented))
evaluate
(define (evaluate exp env)
(if (expression? exp)
(if (list? env)
(ensure-value?
(error 'not-yet-implemented))
(raise-argument-error 'env "list?" env))
(raise-argument-error 'exp "expression?" exp)))
Test
file: | test_interpreter.rkt | Test |
source folder: | src/test/racket/ibpl/interpreter |
note: ensure that you have removed all printing to receive credit for any assignment.