diff options
| author | hachem <im@hachem.wtf> | 2026-09-19 10:49:33 +0200 |
|---|---|---|
| committer | hachem <im@hachem.wtf> | 2026-09-19 10:49:33 +0200 |
| commit | 05bf718e37efdc5201ad281e85da7850af31bd59 (patch) | |
| tree | c862c8fca6d5deb1422d81ee538f214050c2d81a /Makefile | |
| parent | 0393d0b61b44a2b4df77a36bc63d64c5842971f9 (diff) | |
feat: basic lexer with flex
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 37 |
1 files changed, 13 insertions, 24 deletions
@@ -1,8 +1,8 @@ CC = cc -YACC = bison -CFLAGS = -std=c99 -Wall -Wextra -Werror -Wpedantic -O2 -Ibin -SOURCES = ast.c ast.h eval.c eval.h lexer.c lexer.h main.c -OBJECTS = bin/parser.o bin/lexer.o bin/ast.o bin/eval.o bin/main.o +LEX = flex +CFLAGS = -std=c17 -Wall -Wextra -Werror -Wpedantic -O2 +SOURCES = lexer.h main.c +OBJECTS = bin/lexer.o bin/main.o SANITIZE = -g -O0 -fsanitize=address,undefined .PHONY: all debug check format lint clean @@ -15,42 +15,31 @@ bin: sfinae: $(OBJECTS) $(CC) $(CFLAGS) -o $@ $(OBJECTS) -bin/parser.c bin/parser.h: sfinae.y | bin - $(YACC) -d -o bin/parser.c sfinae.y +bin/lexer.c: sfinae.l | bin + $(LEX) -o bin/lexer.c sfinae.l -bin/parser.o: bin/parser.c - $(CC) -std=c99 -w -I. -c -o $@ bin/parser.c +bin/lexer.o: bin/lexer.c lexer.h + $(CC) -std=c17 -w -I. -c -o $@ bin/lexer.c bin/%.o: %.c | bin $(CC) $(CFLAGS) -c -o $@ $< -bin/lexer.o: bin/parser.h ast.h lexer.h -bin/main.o: ast.h eval.h lexer.h -bin/ast.o: ast.h lexer.h -bin/eval.o: eval.h ast.h +bin/main.o: lexer.h debug: CFLAGS += $(SANITIZE) debug: clean sfinae check: sfinae @for example in examples/*.sfinae; do \ - expected="$${example%.sfinae}.expected"; \ - if ./sfinae "$$example" | diff -u "$$expected" - >/dev/null; then \ - echo "ok $$example"; \ - else \ - echo "FAIL $$example"; ./sfinae "$$example" | diff -u "$$expected" -; exit 1; \ - fi; \ + echo "== $$example"; \ + ./sfinae "$$example" || exit 1; \ done format: clang-format -i $(SOURCES) -LINT_FILTER = '[{"name":"parser.h","lines":[[1,1]]}, \ - {"name":"ast.c"},{"name":"eval.c"},{"name":"lexer.c"},{"name":"main.c"}, \ - {"name":"ast.h"},{"name":"eval.h"},{"name":"lexer.h"}]' - -lint: bin/parser.h - clang-tidy --line-filter=$(LINT_FILTER) ast.c eval.c lexer.c main.c -- -std=c99 -Ibin +lint: + clang-tidy main.c -- -std=c17 clean: rm -rf bin sfinae |
