feat: add extended language validators and fix tokenizer crash bugs
Expand nimcheck with validators and tokenizers for C, C++, C#, Go, Rust, Ruby, CSS, SQL, Markdown, Dockerfile, Makefile, Kotlin, Lua, Swift, TypeScript, and XML. Register all flavors in the validator factory and improve auto-detection scoring for the new languages. Fix infinite tokenizer loops that caused OOM kills: closeBracket now advances position, finishTokenizeStep guards stalled tokenization, and Jinja/JS tokenizers no longer double-advance on brackets. Fix block-balance false positives in Lua (for/do) and Ruby (postfix unless), SQL trailing-comma detection across whitespace, and Makefile tab literals in test fixtures.
This commit is contained in:
+15
@@ -0,0 +1,15 @@
|
||||
.PHONY: all clean
|
||||
|
||||
CC := gcc
|
||||
CFLAGS := -O2 -Wall
|
||||
|
||||
all: program
|
||||
|
||||
program: main.o util.o
|
||||
$(CC) $(CFLAGS) -o $@ $^
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
clean:
|
||||
rm -f program *.o
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
.PHONY: all clean
|
||||
|
||||
CC := gcc
|
||||
CFLAGS := -O2 -Wall
|
||||
|
||||
all: program
|
||||
|
||||
program: main.o util.o
|
||||
$(CC) $(CFLAGS) -o $@
|
||||
|
||||
%.o: %.c
|
||||
$(CC) $(CFLAGS) -c -o $<
|
||||
echo "unclosed
|
||||
|
||||
clean:
|
||||
rm -f program *.o
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
.PHONY: all build release debug clean test coverage lint install uninstall
|
||||
|
||||
NIM := nim
|
||||
NIM_FLAGS := --hints:off --warnings:off
|
||||
SRC_DIR := src
|
||||
BIN_DIR := bin
|
||||
TEST_DIR := tests
|
||||
BUILD_DIR := build
|
||||
|
||||
SOURCES := $(shell find $(SRC_DIR) -name '*.nim')
|
||||
TESTS := $(shell find $(TEST_DIR) -name '*.nim')
|
||||
OBJECTS := $(patsubst $(SRC_DIR)/%.nim,$(BUILD_DIR)/%.o,$(SOURCES))
|
||||
|
||||
BINARY := $(BIN_DIR)/nimcheck
|
||||
|
||||
all: build
|
||||
|
||||
$(BIN_DIR):
|
||||
mkdir -p $(BIN_DIR)
|
||||
|
||||
$(BUILD_DIR):
|
||||
mkdir -p $(BUILD_DIR)
|
||||
|
||||
$(BUILD_DIR)/%.o: $(SRC_DIR)/%.nim | $(BUILD_DIR)
|
||||
$(NIM) compile --compileOnly -d:release -o:$@ $<
|
||||
|
||||
$(BINARY): $(OBJECTS) | $(BIN_DIR)
|
||||
$(NIM) compile -d:release --out:$(BINARY) $(SRC_DIR)/nimcheck.nim
|
||||
|
||||
build: $(BINARY)
|
||||
|
||||
release:
|
||||
$(NIM) compile -d:release --opt:speed --passC:-flto --passL:-flto \
|
||||
--out:$(BINARY) $(SRC_DIR)/nimcheck.nim
|
||||
|
||||
debug:
|
||||
$(NIM) compile -d:debug --lineDir:on --stacktrace:on \
|
||||
--out:$(BINARY) $(SRC_DIR)/nimcheck.nim
|
||||
|
||||
test: build
|
||||
$(NIM) compile --run $(TEST_DIR)/test_all.nim
|
||||
|
||||
coverage:
|
||||
$(NIM) compile --run -d:coverage $(TEST_DIR)/test_all.nim
|
||||
|
||||
lint:
|
||||
$(NIM) check $(SRC_DIR)/nimcheck.nim
|
||||
|
||||
clean:
|
||||
rm -rf $(BIN_DIR) $(BUILD_DIR)
|
||||
find . -name 'nimcache' -type d -exec rm -rf {} + 2>/dev/null || true
|
||||
|
||||
install: release
|
||||
install -m 755 $(BINARY) /usr/local/bin/nimcheck
|
||||
|
||||
uninstall:
|
||||
rm -f /usr/local/bin/nimcheck
|
||||
Reference in New Issue
Block a user