chore: update c, h, md files
CI / build (push) Has been cancelled
CI / test (push) Has been cancelled
CI / valgrind (push) Has been cancelled
CI / coverage (push) Has been cancelled

This commit is contained in:
2026-01-04 01:58:43 +01:00
parent 3d9c4aa00b
commit 7f728a5284
26 changed files with 1967 additions and 513 deletions
+30 -11
View File
@@ -14,19 +14,20 @@ SRC_DIR = src
INC_DIR = include
BUILD_DIR = build
TEST_DIR = tests
COV_DIR = coverage
SRCS = $(SRC_DIR)/lexer.c $(SRC_DIR)/ast.c $(SRC_DIR)/parser.c \
$(SRC_DIR)/nfa.c $(SRC_DIR)/matcher.c $(SRC_DIR)/loreg.c \
$(SRC_DIR)/nfa.c $(SRC_DIR)/matcher.c $(SRC_DIR)/lorex.c \
$(SRC_DIR)/repl.c $(SRC_DIR)/main.c
LIB_SRCS = $(SRC_DIR)/lexer.c $(SRC_DIR)/ast.c $(SRC_DIR)/parser.c \
$(SRC_DIR)/nfa.c $(SRC_DIR)/matcher.c $(SRC_DIR)/loreg.c
$(SRC_DIR)/nfa.c $(SRC_DIR)/matcher.c $(SRC_DIR)/lorex.c
OBJS = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(SRCS))
LIB_OBJS = $(patsubst $(SRC_DIR)/%.c,$(BUILD_DIR)/%.o,$(LIB_SRCS))
TARGET = loreg
LIB_TARGET = libloreg.a
TARGET = lorex
LIB_TARGET = liblorex.a
TEST_SRCS = $(TEST_DIR)/test_lexer.c $(TEST_DIR)/test_parser.c \
$(TEST_DIR)/test_nfa.c $(TEST_DIR)/test_matcher.c \
@@ -36,7 +37,7 @@ TEST_BINS = $(BUILD_DIR)/test_lexer $(BUILD_DIR)/test_parser \
$(BUILD_DIR)/test_nfa $(BUILD_DIR)/test_matcher \
$(BUILD_DIR)/test_all $(BUILD_DIR)/test_integration
.PHONY: all clean test debug coverage profile valgrind help install
.PHONY: all clean test debug coverage lcov profile valgrind help install
all: $(BUILD_DIR) $(TARGET)
@@ -73,6 +74,9 @@ $(BUILD_DIR)/test_all: $(TEST_DIR)/test_all.c $(LIB_SRCS) | $(BUILD_DIR)
$(BUILD_DIR)/test_integration: $(TEST_DIR)/test_integration.c $(LIB_SRCS) | $(BUILD_DIR)
$(CC) $(CFLAGS_DEBUG) $(INCLUDES) $< $(LIB_SRCS) -o $@
$(BUILD_DIR)/benchmark: $(TEST_DIR)/benchmark.c $(LIB_SRCS) | $(BUILD_DIR)
$(CC) -O3 -march=native $(INCLUDES) $< $(LIB_SRCS) -o $@
test: $(TEST_BINS)
@echo "running lexer tests..."
@$(BUILD_DIR)/test_lexer
@@ -105,6 +109,17 @@ coverage: clean $(BUILD_DIR)
@mv *.gcda $(BUILD_DIR)/coverage/ 2>/dev/null || true
@mv *.gcno $(BUILD_DIR)/coverage/ 2>/dev/null || true
lcov: clean $(BUILD_DIR)
@mkdir -p $(COV_DIR)
$(CC) $(CFLAGS_COV) $(INCLUDES) $(TEST_DIR)/test_integration.c $(LIB_SRCS) -o $(BUILD_DIR)/test_lcov $(LDFLAGS_COV)
lcov --zerocounters --directory .
$(BUILD_DIR)/test_lcov
lcov --capture --directory . --output-file $(COV_DIR)/coverage.info
lcov --remove $(COV_DIR)/coverage.info '*/tests/*' --ignore-errors unused --output-file $(COV_DIR)/coverage.info
genhtml $(COV_DIR)/coverage.info --output-directory $(COV_DIR)/html
@echo ""
@echo "lcov html report: $(COV_DIR)/html/index.html"
profile: CFLAGS = $(CFLAGS_PROF)
profile: clean $(BUILD_DIR)
$(CC) $(CFLAGS_PROF) $(INCLUDES) $(TEST_DIR)/test_all.c $(LIB_SRCS) -o $(BUILD_DIR)/test_profile
@@ -123,8 +138,11 @@ valgrind-verbose: $(BUILD_DIR)/test_all
--verbose --log-file=$(BUILD_DIR)/valgrind.log $(BUILD_DIR)/test_all
@echo "valgrind log: $(BUILD_DIR)/valgrind.log"
benchmark: $(TARGET)
@echo "benchmarking..."
benchmark: $(BUILD_DIR)/benchmark
@./$(BUILD_DIR)/benchmark
benchmark-quick: $(TARGET)
@echo "quick benchmark..."
@echo "pattern: [a-z]+@[a-z]+\\.[a-z]+"
@time -p sh -c 'for i in $$(seq 1 1000); do ./$(TARGET) "[a-z]+@[a-z]+\\.[a-z]+" "test@example.com" > /dev/null; done'
@echo ""
@@ -139,18 +157,19 @@ uninstall:
rm -f $(DESTDIR)/usr/local/bin/$(TARGET)
clean:
rm -rf $(BUILD_DIR) $(TARGET) $(LIB_TARGET)
rm -rf $(BUILD_DIR) $(TARGET) $(LIB_TARGET) $(COV_DIR)
rm -f *.gcov *.gcda *.gcno gmon.out
help:
@echo "loreg makefile targets:"
@echo "lorex makefile targets:"
@echo " all build optimized release binary"
@echo " debug build with debug symbols"
@echo " test run all tests"
@echo " coverage run tests with coverage analysis"
@echo " coverage run tests with gcov coverage analysis"
@echo " lcov generate html coverage report with lcov"
@echo " profile run tests with profiling"
@echo " valgrind run tests under valgrind"
@echo " benchmark run simple benchmarks"
@echo " benchmark run performance benchmarks"
@echo " install install to /usr/local/bin"
@echo " uninstall remove from /usr/local/bin"
@echo " clean remove build artifacts"