COMPSCI 61A Lecture Notes - Lecture 26: Init, Generic Function, Eval
zogo39484755 and 6 others unlocked
22
COMPSCI 61A Full Course Notes
Verified Note
22 documents
Document Summary
A scheme list is written as elements in parenthesis ( ) Each element can be a combination or primitive. The task of parsing a language involves coercing a string repr of an expression to the expression itself. Taking in text input and turning it into expression. Text (lexical analysis) tokens (syntactical analysis) expressions. A predictive recursive descent parser inspects only k tokens to decide how to proceed, for some fixed k. Identifies hierarchical structure of an expression which may be nested. Each call to scheme_read consusmes the input tokens for exactly one expression. Walks through from left to write, if hits parenthesis, evaluates that expression. The pair class represents scheme pairs and lists. A list is a pair whose second element is either a list or nil. >>> s = pair (1, pair(2, pair(3, nil))) print(s) (1 2 3) Scheme expressions are represented as scheme lists: homoiconic means source code is data.