Interpreters
Def : a program that allows you to interact with the computer in a certain language
- This is what project 4 is all about !
- Involves 2 languages
1. language being implemented ( Scheme in Project 4 )
2. Underlying language implementing 1 ( Python in Project 4 )
REPL Process : Process that interpreters follow
Read
lexer : break up inputs into smaller 'tokens'
parser : 'organize' tokens into the form the implementing language can process ( in project 4, this is storing tokens as pairs )
Eval
- using the result of Read, obtain the value of the expression
- Done by mutual recursion of eval and apply
- eval rules :
1. #5 -> #5 ex. 5 -> 5
2. name -> value bounded ex. x = 5, x -> 5
3. call expression ex. ( + 1 2 )
1) The expression itself ex. ( + 1 2 )
2) Operator ex. +
3) Operands ex. 1, 2
4) call apply which computes and outputs 3
Print : displays the value
Loop : repeat the process until we get to the end
Be careful : special forms do not follow the regular call expression eval procedure
'University of California, Berkeley > ElectricalEngineering & ComputerSciences' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
Week 7 (0) | 2019.08.06 |
---|---|
Macros (0) | 2019.08.02 |
Interpreters (0) | 2019.08.01 |
More Scheme (0) | 2019.07.31 |
Scheme (0) | 2019.07.30 |