aboutsummaryrefslogtreecommitdiff
path: root/2015/23
diff options
context:
space:
mode:
authorThomas Voss <mail@thomasvoss.com> 2022-11-30 12:23:17 +0100
committerThomas Voss <mail@thomasvoss.com> 2022-11-30 12:23:17 +0100
commitf3e3e3e354b87f4ce27bd74bf14cec05d06974b6 (patch)
tree112352e9c3ba5d5d924036def2b5f853d3f8dc28 /2015/23
parent4742dd73046c53cff7fe54deee58358c3b193206 (diff)
Lots of cleanup and stuff
Diffstat (limited to '2015/23')
-rw-r--r--2015/23/Makefile10
-rw-r--r--2015/23/puzzles.l23
2 files changed, 13 insertions, 20 deletions
diff --git a/2015/23/Makefile b/2015/23/Makefile
index 8779ec0..b65503c 100644
--- a/2015/23/Makefile
+++ b/2015/23/Makefile
@@ -1,9 +1,3 @@
-all:
- flex -f -DYY_NO_INPUT --nounput puzzles.l
- ${CC} ${CFLAGS} -lfl -DPROGLEN=`wc -l <input` -o puzzle-1 lex.yy.c
- ${CC} ${CFLAGS} -lfl -DPROGLEN=`wc -l <input` -DPART2 -o puzzle-2 lex.yy.c
- rm lex.yy.c
+CPPFLAGS = -DPROGLEN=`wc -l <input`
-.PHONY: clean
-clean:
- rm -f puzzle-[12]
+include ../../Makefiles/lex.mk
diff --git a/2015/23/puzzles.l b/2015/23/puzzles.l
index 7d654e1..6793126 100644
--- a/2015/23/puzzles.l
+++ b/2015/23/puzzles.l
@@ -1,5 +1,4 @@
%{
-#define _POSIX_C_SOURCE
#include <err.h>
#include <stdbool.h>
#include <stdio.h>
@@ -38,17 +37,17 @@ unsigned long long registers[2];
%%
-hlf { program[i].type = HLF; BEGIN(ARGS); }
-inc { program[i].type = INC; BEGIN(ARGS); }
-jie { program[i].type = JIE; BEGIN(ARGS); }
-jio { program[i].type = JIO; BEGIN(ARGS); }
-jmp { program[i].type = JMP; BEGIN(ARGS); }
-tpl { program[i].type = TPL; BEGIN(ARGS); }
-
-<ARGS>[ab] { program[i].reg = *yytext - 'a'; }
-<ARGS>[+\-][0-9]+ { program[i].imm = atoi(yytext); }
-<ARGS>[ ,]+ { ; }
-<ARGS>\n { i++; BEGIN(INITIAL); }
+hlf { program[i].type = HLF; BEGIN(ARGS); }
+inc { program[i].type = INC; BEGIN(ARGS); }
+jie { program[i].type = JIE; BEGIN(ARGS); }
+jio { program[i].type = JIO; BEGIN(ARGS); }
+jmp { program[i].type = JMP; BEGIN(ARGS); }
+tpl { program[i].type = TPL; BEGIN(ARGS); }
+
+<ARGS>[ab] { program[i].reg = *yytext - 'a'; }
+<ARGS>[+\-][0-9]+ { program[i].imm = atoi(yytext); }
+<ARGS>[ ,]+ { ; }
+<ARGS>\n { i++; BEGIN(INITIAL); }
%%