aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--builtin.cpp19
-rw-r--r--main.cpp5
-rw-r--r--types.cpp1
3 files changed, 14 insertions, 11 deletions
diff --git a/builtin.cpp b/builtin.cpp
index 1096d7a..760aa2a 100644
--- a/builtin.cpp
+++ b/builtin.cpp
@@ -9,8 +9,9 @@
#include "types.h"
using std::stringstream;
-extern EmptyList *empty_list;
+extern EmptyList *empty_list;
+extern UnspecObj *unspec_obj;
SpecialOptIf::SpecialOptIf() : SpecialOptObj("if") {}
@@ -72,7 +73,7 @@ Pair *SpecialOptIf::call(Pair *args, Environment * &envt,
}
else
{
- *top_ptr++ = new UnspecObj();
+ *top_ptr++ = unspec_obj;
return ret_addr->next;
}
}
@@ -232,7 +233,7 @@ Pair *SpecialOptDefine::call(Pair *args, Environment * &envt,
obj = new ProcObj(body, envt, params);
}
envt->add_binding(id, obj);
- *top_ptr++ = new UnspecObj();
+ *top_ptr++ = unspec_obj;
return ret_addr->next;
}
@@ -276,7 +277,7 @@ Pair *SpecialOptSet::call(Pair *args, Environment * &envt,
bool flag = envt->add_binding(id, TO_PAIR(args->cdr)->car, false);
if (!flag) throw TokenError(id->ext_repr(), RUN_ERR_UNBOUND_VAR);
- *top_ptr++ = new UnspecObj();
+ *top_ptr++ = unspec_obj;
return ret_addr->next;
}
@@ -804,7 +805,7 @@ BUILTIN_PROC_DEF(pair_set_car) {
if (!args->car->is_pair_obj())
throw TokenError("pair", RUN_ERR_WRONG_TYPE);
TO_PAIR(args->car)->car = TO_PAIR(args->cdr)->car;
- return new UnspecObj();
+ return unspec_obj;
}
BUILTIN_PROC_DEF(pair_set_cdr) {
@@ -812,7 +813,7 @@ BUILTIN_PROC_DEF(pair_set_cdr) {
if (!args->car->is_pair_obj())
throw TokenError("pair", RUN_ERR_WRONG_TYPE);
TO_PAIR(args->car)->cdr = TO_PAIR(args->cdr)->car;
- return new UnspecObj();
+ return unspec_obj;
}
BUILTIN_PROC_DEF(is_null) {
@@ -1282,7 +1283,7 @@ BUILTIN_PROC_DEF(make_vector) {
args = TO_PAIR(args->cdr);
if (args == empty_list)
- fill = new UnspecObj();
+ fill = unspec_obj;
else if (args->cdr == empty_list)
fill = args->car;
else
@@ -1317,7 +1318,7 @@ BUILTIN_PROC_DEF(vector_set) {
throw TokenError(name, RUN_ERR_WRONG_NUM_OF_ARGS);
vect->set(k, args->car);
- return new UnspecObj();
+ return unspec_obj;
}
BUILTIN_PROC_DEF(vector_ref) {
@@ -1356,5 +1357,5 @@ BUILTIN_PROC_DEF(vector_length) {
BUILTIN_PROC_DEF(display) {
ARGS_EXACTLY_ONE;
printf("%s", args->car->ext_repr().c_str());
- return new UnspecObj();
+ return unspec_obj;
}
diff --git a/main.cpp b/main.cpp
index e751dd3..78515a6 100644
--- a/main.cpp
+++ b/main.cpp
@@ -42,7 +42,7 @@ void print_help(const char *cmd) {
" FILE \t\tload Scheme source code from FILE, and exit\n"
"The above switches stop argument processing\n\n"
" -l FILE \tload Scheme source code from FILE\n"
- " -h display \tthis help and exit\n", cmd);
+ " -h, --help \tdisplay this help and exit\n", cmd);
exit(0);
}
@@ -62,7 +62,8 @@ int main(int argc, char **argv) {
print_help(*argv);
}
}
- else if (strcmp(argv[i], "-h") == 0)
+ else if (strcmp(argv[i], "-h") == 0 ||
+ strcmp(argv[i], "--help") == 0)
print_help(*argv);
else
{
diff --git a/types.cpp b/types.cpp
index de7ef66..c782433 100644
--- a/types.cpp
+++ b/types.cpp
@@ -12,6 +12,7 @@ const double EPS = 1e-16;
const int PREC = 16;
EmptyList *empty_list = new EmptyList();
+UnspecObj *unspec_obj = new UnspecObj();
Pair::Pair(EvalObj *_car, EvalObj *_cdr) :
EvalObj(CLS_PAIR_OBJ), car(_car), cdr(_cdr),