Add missing BAD_SYMBOL error
This commit is contained in:
parent
a145b436c9
commit
9b6b80f204
|
@ -122,6 +122,7 @@ static const char* errorText[] = {
|
||||||
"NULL_MAP_ARGS",
|
"NULL_MAP_ARGS",
|
||||||
"LAMBDA_ARGS_NOT_LIST",
|
"LAMBDA_ARGS_NOT_LIST",
|
||||||
"DID_NOT_FIND_SYMBOL",
|
"DID_NOT_FIND_SYMBOL",
|
||||||
|
"BAD_SYMBOL",
|
||||||
"BAD_TYPE",
|
"BAD_TYPE",
|
||||||
"BAD_PARAMS",
|
"BAD_PARAMS",
|
||||||
"BAD_NUMBER",
|
"BAD_NUMBER",
|
||||||
|
|
|
@ -22,7 +22,13 @@
|
||||||
#ifdef RELEASE
|
#ifdef RELEASE
|
||||||
#define assert(...) do { } while (0)
|
#define assert(...) do { } while (0)
|
||||||
#else
|
#else
|
||||||
#define assert(...) do {if (!(__VA_ARGS__)) {eprintf("\n[31;1massertion '" # __VA_ARGS__ "' at %s:%d failed!\nBailing![0m\n", __FILE__, __LINE__); int* X = NULL; unused int Y = *X;}} while (0)
|
#define assert(...) do { \
|
||||||
|
if (!(__VA_ARGS__)) { \
|
||||||
|
eprintf("\n[31;1massertion '" # __VA_ARGS__ "' at %s:%d failed!\nBailing![0m\n", __FILE__, __LINE__); \
|
||||||
|
int* X = NULL; \
|
||||||
|
unused int Y = *X; \
|
||||||
|
}\
|
||||||
|
} while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define MAX_TOK_CNT 2048
|
#define MAX_TOK_CNT 2048
|
||||||
|
@ -94,6 +100,7 @@ enum errorCode {
|
||||||
NULL_MAP_ARGS,
|
NULL_MAP_ARGS,
|
||||||
LAMBDA_ARGS_NOT_LIST,
|
LAMBDA_ARGS_NOT_LIST,
|
||||||
DID_NOT_FIND_SYMBOL,
|
DID_NOT_FIND_SYMBOL,
|
||||||
|
BAD_SYMBOL,
|
||||||
BAD_TYPE,
|
BAD_TYPE,
|
||||||
BAD_PARAMS,
|
BAD_PARAMS,
|
||||||
BAD_NUMBER,
|
BAD_NUMBER,
|
||||||
|
|
|
@ -54,15 +54,17 @@ Object listDef(Object* nameList, Object* valueList, struct Environment* env)
|
||||||
* @param env The environment to add the new definition to
|
* @param env The environment to add the new definition to
|
||||||
* @return The symbol(s) defined
|
* @return The symbol(s) defined
|
||||||
*/
|
*/
|
||||||
Object def(Object* params, unused int length, struct Environment* env)
|
Object def(Object* params, int length, struct Environment* env)
|
||||||
{
|
{
|
||||||
|
if (length == 2) {
|
||||||
if (isStringy(params[0])) {
|
if (isStringy(params[0])) {
|
||||||
return singleDef(params[0].string, ¶ms[1], env);
|
return singleDef(params[0].string, ¶ms[1], env);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (length == 2 && isListy(params[0]) && isListy(params[1])) {
|
if (isListy(params[0]) && isListy(params[1])) {
|
||||||
return listDef(¶ms[0], ¶ms[1], env);
|
return listDef(¶ms[0], ¶ms[1], env);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
throw(BAD_TYPE, "Poorly constructed (def)");
|
throw(BAD_TYPE, "Poorly constructed (def)");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue