diff options
-rw-r--r-- | .gitignore | 6 | ||||
-rw-r--r-- | attocc.c | 9 | ||||
-rw-r--r-- | makefile | 15 |
3 files changed, 28 insertions, 2 deletions
@@ -1,2 +1,4 @@ -/attocc -/test*.c +/* +!/attocc.c +!/makefile +!/.gitignore @@ -39,6 +39,8 @@ static char *OPERATORS[] = { ">=", "||", "&&", "+", "-", "*", "/", "%", "<", ">", "~", "&", "|", "^", "!", "&", "*", "=", }; + +#ifdef DEBUG static char *OPERATOR_NAMES[] = { "OP_SIZEOF", "OP_SHIFT_LEFT", @@ -90,6 +92,7 @@ static char *SEPERATOR_NAMES[] = { "SEP_LPAREN", "SEP_RPAREN", "SEP_LSQUARE", "SEP_RSQUARE", "SEP_LCURLY", "SEP_RCURLY", "SEP_SEMICOLON", "SEP_COMMA", "SEP_DOT", "SEP_COLOR", }; +#endif enum keyword { KW_AUTO, @@ -396,6 +399,7 @@ struct token *tokenize(char *source) { return tokens; } +#ifdef DEBUG void debug_tokens(struct token *tokens) { for (int i = 0; tokens[i].kind != TOK_END; i++) { switch (tokens[i].kind) { @@ -420,6 +424,7 @@ void debug_tokens(struct token *tokens) { } printf("TOK_END\n"); } +#endif int main(int argc, char **argv) { if (argc < 3) { @@ -467,7 +472,11 @@ int main(int argc, char **argv) { struct token *tokens = tokenize(source); if (!tokens) return 1; + +#ifdef DEBUG debug_tokens(tokens); +#endif + free(tokens); return 0; diff --git a/makefile b/makefile new file mode 100644 index 0000000..ffd9c32 --- /dev/null +++ b/makefile @@ -0,0 +1,15 @@ +.PHONY: all clean +ALL = attocc attocc-small attocc-debug +all: $(ALL) +clean: + rm $(ALL) + +attocc: attocc.c + gcc -O3 -o $@ $< + +attocc-debug: attocc.c + gcc -DDEBUG -Wall -Wextra -Wpedantic -o $@ $< + +attocc-small: attocc.c + gcc -Wl,--gc-sections -flto -ffunction-sections -fdata-sections -fPIC -s -Os -o $@ $< + strip -x $@ |