Skip to content

Commit

Permalink
new type error scheme
Browse files Browse the repository at this point in the history
  • Loading branch information
jweinst1 committed Jun 3, 2018
1 parent a9bf9d7 commit 8344558
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
4 changes: 1 addition & 3 deletions include/WindType.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ typedef enum
WindCommand_map
} WindCommand;

/*Literal String represenations for windtype*/
extern const char* WindType_STR_NONE;
extern const char* WindType_STR_BOOL;
const char* WindType_get_str(WindType type);

#endif
24 changes: 24 additions & 0 deletions src/code/WindType.c
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
#include "WindType.h"


/*Strings for type message formatting*/
static const char* WindType_STR_NONE = "None";
static const char* WindType_STR_BOOL = "Bool";
static const char* WindType_STR_NUMBER = "Number";
static const char* WindType_STR_ASSIGN = "Assign";
static const char* WindType_STR_NOT = "Not";
static const char* WindType_STR_PLUS = "Plus";
static const char* WindType_STR_SEP = "Separator";

const char* WindType_get_str(WindType type)
{
switch(type)
{
case WindType_None: return WindType_STR_NONE;
case WindType_Bool: return WindType_STR_BOOL;
case WindType_Not: return WindType_STR_NOT;
case WindType_Number: return WindType_STR_NUMBER;
case WindType_Assign: return WindType_STR_ASSIGN;
case WindType_Plus: return WindType_STR_PLUS;
case WindType_Sep: return WindType_STR_SEP;
}
}
4 changes: 2 additions & 2 deletions src/flow/WindComp.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ unsigned WindComp_apply_plus(unsigned char* args, const unsigned char* argsEnd)
{
if(WindComp_BUF[0] != WindType_Number)
{
WindState_write_err("Attempted to use + operator on type that is not number.");
WindState_write_err("Attempted to use + operator on type: '%s'", WindType_get_str(WindComp_BUF[0]));
return 0;
}
unsigned char* mover = args;
Expand All @@ -125,7 +125,7 @@ unsigned WindComp_apply_plus(unsigned char* args, const unsigned char* argsEnd)
case WindType_Sep:
return mover - args;
default:
WindState_write_err("Attempted to use + operator on arg with non-number type: %u", *mover);
WindState_write_err("Attempted to use + operator on arg with type: '%s'", WindType_get_str(*mover));
return 0;
}
}
Expand Down

0 comments on commit 8344558

Please sign in to comment.