-
+ 546D8D1AC8F29F4CEF32DFDA953790663CE53016C8F63024BE2802CF0C60D0C9D899896ABEA4896DF637AD2FC11610F54CD7B1C89CA32E1195094416F41A5DC8adalisp/src/evaler.ads(0 . 0)(1 . 83)
1075 -- Basic LispM evaluator, based on the following rules:
1076 --
1077 -- - LispM constants, i.e. booleans, numbers, characters, builtins and
1078 -- closures are returned as they are.
1079 --
1080 -- - Symbols have their values looked up in the current (lexical) Env
1081 -- or, if not found, in the (dynamic) Global_Env; the first value found
1082 -- is returned; if no bindings are found, an error message is returned.
1083 --
1084 -- - Cons objects are interpreted as function applications, i.e. for any
1085 -- list L, car(L) is evaluated and applied upon cdr(L); if car(L) is
1086 -- not a closure or a builtin, then an error message is returned.
1087 --
1088 -- A large subset of this module is dedicated to the implementation of
1089 -- builtin functions and keywords. An explicit distinction between
1090 -- keywords and functions is not made at this point, i.e. the
1091 -- distinction is implicit in e.g. the way arguments are evaluated.
1092
1093 with LispM; use LispM;
1094
1095 package Evaler is
1096
1097 -- Arithmetic and logic functions
1098 type ALUFunc is (ALU_Add, ALU_Sub, ALU_Mul, ALU_Div);
1099 -- Unary predicates
1100 type UPred is (UPred_Pair, UPred_Bool, UPred_Num, UPred_Sym,
1101 UPred_Nil, UPred_List);
1102 -- And/or conditional forms
1103 type AndOr is (AndOr_And, AndOr_Or);
1104
1105 -- Application routines for builtin functions. These should be
1106 -- self-explanatory.
1107 procedure Apply_ALU_Func(Func : in ALUFunc;
1108 Args : in MemPtr;
1109 Env : in MemPtr; OutP : out MemPtr);
1110 procedure Apply_UPred(Pred : in UPred;
1111 Args : in MemPtr;
1112 Env : in MemPtr;
1113 OutP : out MemPtr);
1114 procedure Apply_AndOr(Cond : in AndOr;
1115 Args : in MemPtr;
1116 Env : in MemPtr;
1117 OutP : out MemPtr);
1118
1119 procedure Apply_QuoteB(Args : in MemPtr; OutP : out MemPtr);
1120 procedure Apply_EvalB(Args, Env : in MemPtr; OutP : out MemPtr);
1121 procedure Apply_IfB(Args, Env : in MemPtr; OutP : out MemPtr);
1122 procedure Apply_ConsB(Args, Env : in MemPtr; OutP : out MemPtr);
1123 procedure Apply_CarB(Args, Env : in MemPtr; OutP : out MemPtr);
1124 procedure Apply_CdrB(Args, Env : in MemPtr; OutP : out MemPtr);
1125 procedure Apply_ListB(Args, Env : in MemPtr; OutP : out MemPtr);
1126 procedure Apply_ApplyB(Args, Env : in MemPtr; OutP : out MemPtr);
1127 procedure Apply_DefineB(Args, Env : in MemPtr; OutP : out MemPtr);
1128 procedure Apply_SetB(Args, Env : in MemPtr; OutP : out MemPtr);
1129 procedure Apply_EqnB(Args, Env : in MemPtr; OutP : out MemPtr);
1130 procedure Apply_EqB(Args, Env : in MemPtr; OutP : out MemPtr);
1131 procedure Apply_EqvB(Args, Env : in MemPtr; OutP : out MemPtr);
1132 procedure Apply_NotB(Args, Env : in MemPtr; OutP : out MemPtr);
1133 procedure Apply_LambdaB(Args, Env : in MemPtr; OutP : out MemPtr);
1134 procedure Apply_LetB(Args, Env : in MemPtr; OutP : out MemPtr);
1135 procedure Apply_ReverseB(Args, Env : in MemPtr; OutP : out MemPtr);
1136 procedure Apply_AppendB(Args, Env : in MemPtr; OutP : out MemPtr);
1137
1138 -- Application routine for closures
1139 procedure Apply_Closure(Op, Args, Env : in MemPtr; OutP : out MemPtr);
1140
1141 -- Apply function with name identified by Op, on Args.
1142 procedure Apply_Func(Op, Args, Env : in MemPtr;
1143 Meta : in Boolean;
1144 OutP : out MemPtr);
1145
1146 -- Evaluate a list element by element.
1147 procedure Eval_List(List, Env : in MemPtr; OutP : out MemPtr);
1148
1149 -- Eval S-expression
1150 procedure Eval(InP, Env : in MemPtr; OutP : out MemPtr);
1151
1152 -- Other usefuls: reverse append, reverse in place, boolean
1153 -- value. XXX: move these somewhere else.
1154 procedure Rev_Append(A, B : in MemPtr; OutP : out MemPtr);
1155 procedure Rev_In_Place(List, Default : in MemPtr; OutP : out MemPtr);
1156 function Boolean_Value(P : MemPtr) return Boolean;
1157 end Evaler;