37 #define MAX_FILE_SIZE 65536
42 #define MAX_LINE_LEN 256
47 #define MAX_TOKEN_LEN 256
52 #define MAX_ERROR_LEN 256
57 #define MAX_ID_LEN 256
67 UNKNOWN, INT, BOOL, VOID, STR
107 #define CHECK_MALLOC_PTR(P) \
109 printf("Out of memory!\n"); \
110 exit(EXIT_FAILURE); \
122 #define DECL_LIST_TYPE(NAME, ELEMTYPE) \
124 typedef struct NAME ## List { \
131 NAME ## List* NAME ## List_new (); \
134 void NAME ## List_add (NAME ## List* list, ELEMTYPE item); \
137 int NAME ## List_size (NAME ## List* list); \
140 bool NAME ## List_is_empty (NAME ## List* list); \
143 void NAME ## List_free (NAME ## List* list);
158 #define DEF_LIST_IMPL(NAME, ELEMTYPE, FREEFUNC) \
159 NAME ## List* NAME ## List_new () \
161 NAME ## List* list = (NAME ## List*)calloc(1, sizeof(NAME ## List)); \
162 CHECK_MALLOC_PTR(list); \
168 void NAME ## List_add (NAME ## List* list, ELEMTYPE item) \
170 if (list->head == NULL) { \
174 list->tail->next = item; \
179 int NAME ## List_size (NAME ## List* list) \
183 bool NAME ## List_is_empty (NAME ## List* list) \
185 return (list->size == 0); \
187 void NAME ## List_free (NAME ## List* list) \
189 ELEMTYPE next = list->head; \
190 while (next != NULL) { \
191 ELEMTYPE cur = next; \
204 #define FOR_EACH(TYPE, VARIABLE, CONTAINER) \
205 for (TYPE VARIABLE = (CONTAINER)->head; \
207 VARIABLE = VARIABLE->next)
void Error_throw_printf(const char *format,...)
Throw an exception with an error message using printf syntax.
Definition: main.c:26
const char * DecafType_to_string(DecafType type)
Convert a Decaf type to a string for output.
Definition: common.c:3
void print_escaped_string(const char *string, FILE *output)
Print a Decaf string literal, inserting escape codes as necessary.
Definition: common.c:15
DecafType
Valid Decaf types.
Definition: common.h:66