Thu Nov 4
First order of business
Let's discuss any of this week's homework you'd like to go over :
- 3_03.scm - local state with password bank accounts
- 3_09.scm - environment of fibonnaci functions
- 3_11.scm - environment of local state functions
- 3_12.scm - practice with set-car! , set-cdr!
- 3_13.scm - a cyclic list
- 3_14.scm - "mystery" function : reverse
- 3_21.scm - printing a queue data structure
Second order of business
New topic : start looking at "grammars" and "BNF notation" : how to define a programming language.
resources :
I'll go over some of these ideas in class, working through some of the examples in the materials above.
The next topic is "lexers" : how to turn a text string into `[(token-type, value), (token-type, value), ....] which is the first step in interpreting or compiling a computer program.
Please start reading through these materials. I'll choose some exercises before Monday which will be due next Thursday.
to think about
These are a bit open ended so far ... but some of these may turn into assignments. ;)
- What is the BNF grammar for the lisps described in Mary Rose's "Little Lisp" or the "python practice project?"
- Pick one of the math expression grammars described in the resources above. Write an arithmetic expression with at least a dozen terms. Trace through how the grammar rules could generate that expression.
- Using those same rules, generate the first few levels of the tree of all possible expressions.
- Create your own small, simple, minimal programming language syntax - first with some examples, then with a grammar syntax specification. How small but useable can you make it? The building blocks might be things like :
- math expressions : addition, multiplication, grouping
- assignment statements : bindings or "memory storage" ... variables
- function definitions
- conditionals ... boolean operations
- strings and operations on strings
- data structures (arrays or lists or whatever)
- looping syntax
- input & output
- any other built-in functions ?
related resources - compilers, interpreters, interesting languages