-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
1 changed file
with
32 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,42 @@ | ||
from eval_def import * | ||
|
||
def make_a_list() -> A_List: | ||
raise NotImplementedError | ||
return [] | ||
|
||
|
||
def lookup(a_list: A_List, ast: str) -> S_Expression: | ||
for s, val in reversed(a_list): | ||
if s == ast: | ||
return val | ||
raise Undefined | ||
|
||
|
||
def normalize(ast: AST) -> AST: | ||
raise NotImplementedError | ||
if isinstance(ast, Atom): | ||
ast = ast.upper() | ||
if set(ast) - ALLOWED_CHARS: | ||
raise IllegalSymbol | ||
return ast | ||
else: | ||
return [normalize(x) for x in ast] | ||
|
||
def lookup(a_list: A_List, name: str) -> S_Expression: | ||
raise NotImplementedError | ||
|
||
def eval_cond(a_list: A_List, args: List[AST]) -> S_Expression: | ||
def eval_set(a_list: A_List, args: List[AST]) -> S_Expression: | ||
from eval import eval_rec | ||
raise NotImplementedError | ||
if len(args) != 2: | ||
raise WrongNumberOfArguments | ||
name = eval_rec(a_list, args[0]) | ||
if isinstance(name, S_Atom): | ||
value = eval_rec(a_list, args[1]) | ||
a_list.append((name.value, value)) | ||
return value | ||
else: | ||
raise NotASymbol | ||
|
||
def eval_set(a_list: A_List, args: List[AST]) -> S_Expression: | ||
|
||
def eval_cond(a_list: A_List, args: List[AST]) -> S_Expression: | ||
from eval import eval_rec | ||
raise NotImplementedError | ||
for t, v, *_ in args: | ||
if eval_rec(a_list, t) != NIL: | ||
return eval_rec(a_list, v) | ||
return NIL |