CSCI0170
An Integrated Introduction to Computer Science
- Prof. John Hughes
Today’s topics Racket review A little more arithmetic The “string” data type Tokenizing a program Describing “legal” programs
CSCI0170 An Integrated Introduction to Computer Science Prof. John - - PowerPoint PPT Presentation
CSCI0170 An Integrated Introduction to Computer Science Prof. John Hughes Todays topics Racket review A little more arithmetic The string data type Tokenizing a program Describing legal programs Announcements Register via
An Integrated Introduction to Computer Science
Today’s topics Racket review A little more arithmetic The “string” data type Tokenizing a program Describing “legal” programs
followed by a zero or one expressions
17
(define width 11) height
17
(define width 11) height
number
Definitio n
Keyword Nam e
Expression; number expression; number
Expression; name expression; name
Expression ???
17
Expression; number expression; number
Definitio n
Keyword Nam e
Expression; number expression; number
All these labels can be determined by just looking at the text of the program itself!
text and to name their parts
go in those places, not what you actually type.
must type (almost) exactly as shown
language?
them?
marks in a human language: they're the building blocks
"keywords", numbers, names
expert
instance.
punctuation marks in a human language: they're the building blocks
"keywords", numbers, names, strings,
empty, true, false
the “empty string”
number 17.
produce those!
… (let ([alon1 (list 1 2)] [alon2 (map (lambda (x) (/ x 4.0)) (list 2 14))]) (map + alon1 alon2)) …
whitespace or special characters)
that’s called “semantics”
pretty limited: individual numbers, things like (+ 3 5)
<definition> := ( define <name> <num>)
characters
need it wherever it helps separate things, but can skip it where separation is obvious (e.g., a left-paren is a single token, whether there’s white space around it or not)
(one number token)
<definition> := ( define <name> <num>)
characters
keyword “define”, a name, a number, and a right-paren”
think that they are “definitions” according to this rule
was nice and compact and self-contained.
<definition> := ( define <name> <expression>)
<expression> actually means.
<defn> := ( define <name> <expr>)
including zero”
zero or one of these).
followed by a zero or one expressions
<prog> := <defn>* [<expr>]
done
Form,”
have pattern-oriented structures
structure of (physical) trees!