A personal scheme interpreter
- Double precision numbers ::=
AE
- Strings ::=
STR
- Boolean ::=
BE
- Symbols ::=
SE
define
::=(define SE E) -> None
-- Binds the result of the expressionE
to the symbolic expressionSE
. Ex:(define a 5)
if
::=(if BE E E) -> E
-- evaluates to the firstE
(the consequent) if the condition istrue
, otherwise evaluates to the secondE
(the alternate). Ex:(if true 5 4)
import
::=(import STR) -> None
-- imports and interprets the given filename into the current environment line by line.(import "arithmetic")
+
::=(+ AE AE) -> AE
-
::=(- AE AE) -> AE
*
::=(* AE AE) -> AE
/
::=(/ AE AE) -> AE
and
::=(and BE BE) -> BE
or
::=(or BE BE) -> BE
not
::=(not BE) -> BE
<
::=(< AE AE) -> BE
<=
::=(<= AE AE) -> BE
==
::=(== AE AE) -> BE
>=
::=(>= AE AE) -> BE
>
::=(> AE AE) -> BE
expr ::= sexpr | literal
sexpr ::= "(" SYMBOL expr* ")"
literal ::= NUMBER | SYMBOL | BOOLEAN | STRING | CHARACTER
SYMBOL ::= /[A-Za-z_][0-9A-Za-z_]*/
NUMBER ::= /[-+]?([0-9]*\.?[0-9]+|[0-9]+)/
BOOLEAN ::= /true/ | /false/
STRING ::= <traditional c-string syntax, including escapes>
CHARACTER ::= /'\c'/
- Number
- Boolean
- String
- Character
- Pair
- Closure
- bind ::=
- (bind SYMBOL expr) -> binds the value of the given sexpr to the given SYMBOL in the env
- (bind sexpr expr) -> creates a function whose named binding is the first SYMBOL of the sexpr given.
- lambda
- print ::=
- (print expr) -> prints the value of the given expression
- import
- true
- false
- and
- or
- not
- if
- cons
- car
- cdr
- null