Reading Input Lexical Analysis (Lexer):Turning the input into a collection of tokens A token:single input of the input string,e.g.literals,names,keywords,delimiters Syntactic Analysis (Parser):Turning tokens into a representation of the expression in the implementing language The exact "representation"depends on the type of expression Types of Scheme Expressions:self-evaluating expressions,symbols,call expressions, special form expressions. Reader input tokens representation Lexer Parser string of the expression
representation of the expression Reading Input Lexical Analysis (Lexer): Turning the input into a collection of tokens ● A token: single input of the input string, e.g. literals, names, keywords, delimiters Syntactic Analysis (Parser): Turning tokens into a representation of the expression in the implementing language ● The exact “representation” depends on the type of expression ● Types of Scheme Expressions: self-evaluating expressions, symbols, call expressions, special form expressions. Reader Lexer Parser input string tokens
Representing Scheme Primitive Expressions Self-Evaluating expressions (booleans and numbers) Use Python booleans and Python numbers Symbols Use Python strings Read ‘#t Lexer [True] Parser True Read '5.2' Lexer [5.2] Parser 5.2 Read 'cons' Lexer ['cons'] Parser 'cons
Read Lexer Parser Representing Scheme Primitive Expressions Self-Evaluating expressions (booleans and numbers) Use Python booleans and Python numbers Symbols Use Python strings '#t' True Read '5.2' Lexer Parser 5.2 Read 'cons' Lexer Parser 'cons' [True] [5.2] ['cons']