Go to the documentation of this file.
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
117 #define CHECK_MALLOC_PTR(P) \
119 printf("Out of memory!\n"); \
120 exit(EXIT_FAILURE); \
132 #define DECL_LIST_TYPE(NAME, ELEMTYPE) \
134 typedef struct NAME ## List { \
141 NAME ## List* NAME ## List_new (); \
144 void NAME ## List_add (NAME ## List* list, ELEMTYPE item); \
147 int NAME ## List_size (NAME ## List* list); \
150 bool NAME ## List_is_empty (NAME ## List* list); \
153 void NAME ## List_free (NAME ## List* list);
168 #define DEF_LIST_IMPL(NAME, ELEMTYPE, FREEFUNC) \
169 NAME ## List* NAME ## List_new () \
171 NAME ## List* list = (NAME ## List*)calloc(1, sizeof(NAME ## List)); \
172 CHECK_MALLOC_PTR(list); \
178 void NAME ## List_add (NAME ## List* list, ELEMTYPE item) \
180 if (list->head == NULL) { \
184 list->tail->next = item; \
189 int NAME ## List_size (NAME ## List* list) \
193 bool NAME ## List_is_empty (NAME ## List* list) \
195 return (list->size == 0); \
197 void NAME ## List_free (NAME ## List* list) \
199 ELEMTYPE next = list->head; \
200 while (next != NULL) { \
201 ELEMTYPE cur = next; \
214 #define FOR_EACH(TYPE, VARIABLE, CONTAINER) \
215 for (TYPE VARIABLE = (CONTAINER)->head; \
217 VARIABLE = VARIABLE->next)
DecafType
Valid Decaf types.
Definition: common.h:66
const char * DecafType_to_string(DecafType type)
Convert a Decaf type to a string for output.
Definition: common.c:3
void Error_throw_printf(const char *format,...)
Throw an exception with an error message using printf syntax.
Definition: main.c:24
void print_escaped_string(const char *string, FILE *output)
Print a Decaf string literal, inserting escape codes as necessary.
Definition: common.c:15
void print_doubly_escaped_string(const char *string, FILE *output)
Print a Decaf string literal, inserting double escape codes as necessary.
Definition: common.c:29