Skip to content

Commit

Permalink
removed bison/flex, all tests pass
Browse files Browse the repository at this point in the history
  • Loading branch information
billhails committed Oct 5, 2024
1 parent d086363 commit 6696490
Show file tree
Hide file tree
Showing 14 changed files with 41 additions and 1,446 deletions.
30 changes: 6 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ MAIN=src/main.c
PREAMBLE=generated/preamble.c
CFILES=$(filter-out $(MAIN), $(wildcard src/*.c))
EXTRA_CFILES=$(EXTRA_C_TARGETS) $(EXTRA_DEBUG_C_TARGETS)
PARSER_CFILES=generated/lexer.c generated/parser.c
TEST_CFILES=$(wildcard tests/src/*.c)

TEST_TARGETS=$(patsubst tests/src/%.c,tests/%,$(TEST_CFILES))
Expand All @@ -75,18 +74,13 @@ DEP=$(patsubst obj/%,dep/%,$(patsubst %.o,%.d,$(OBJ)))
TEST_DEP=$(patsubst obj/%,dep/%,$(patsubst %.o,%.d,$(TEST_OBJ)))

EXTRA_OBJ=$(patsubst generated/%,obj/%,$(patsubst %.c,%.o,$(EXTRA_CFILES)))
PARSER_OBJ=$(patsubst generated/%,obj/%,$(patsubst %.c,%.o,$(PARSER_CFILES)))
EXTRA_DEP=$(patsubst obj/%,dep/%,$(patsubst %.o,%.d,$(EXTRA_OBJ)))
PARSER_DEP=$(patsubst obj/%,dep/%,$(patsubst %.o,%.d,$(PARSER_OBJ)))

ALL_OBJ=$(OBJ) $(EXTRA_OBJ) $(PARSER_OBJ) $(PREAMBLE_OBJ)
ALL_DEP=$(DEP) $(EXTRA_DEP) $(TEST_DEP) $(PARSER_DEP) $(MAIN_DEP) $(PREAMBLE_DEP)
ALL_OBJ=$(OBJ) $(EXTRA_OBJ) $(PREAMBLE_OBJ)
ALL_DEP=$(DEP) $(EXTRA_DEP) $(TEST_DEP) $(MAIN_DEP) $(PREAMBLE_DEP)

INCLUDE_PATHS=-I generated/ -I src/

TMP_H=generated/parser.h generated/lexer.h
TMP_C=generated/parser.c generated/lexer.c

all: $(TARGET) docs

$(TARGET): $(MAIN_OBJ) $(ALL_OBJ)
Expand Down Expand Up @@ -139,18 +133,15 @@ $(EXTRA_DEBUG_C_TARGETS): generated/%_debug.c: src/%.yaml tools/makeAST.py src/p
$(EXTRA_DOCS): docs/generated/%.md: src/%.yaml tools/makeAST.py src/primitives.yaml | docs/generated
$(MAKE_AST) $< md > $@ || (rm -f $@ ; exit 1)

.generated: $(EXTRA_TARGETS) $(TMP_H)
.generated: $(EXTRA_TARGETS)
touch $@

tags: src/* $(EXTRA_TARGETS) $(TMP_H) $(TMP_C)
ctags src/* $(EXTRA_TARGETS) $(TMP_H) $(TMP_C)
tags: src/* $(EXTRA_TARGETS)
ctags src/* $(EXTRA_TARGETS)

$(MAIN_OBJ) $(OBJ): obj/%.o: src/%.c | obj
$(CC) $(INCLUDE_PATHS) -c $< -o $@

$(PARSER_OBJ): obj/%.o: generated/%.c | obj
$(LAXCC) $(INCLUDE_PATHS) -c $< -o $@

$(EXTRA_OBJ) $(PREAMBLE_OBJ): obj/%.o: generated/%.c | obj
$(CC) $(INCLUDE_PATHS) -c $< -o $@

Expand All @@ -160,18 +151,12 @@ $(TEST_OBJ): obj/%.o: tests/src/%.c | obj
$(MAIN_DEP) $(DEP): dep/%.d: src/%.c .generated | dep
$(CC) $(INCLUDE_PATHS) -MM -MT $(patsubst dep/%,obj/%,$(patsubst %.d,%.o,$@)) -o $@ $<

$(PARSER_DEP) $(EXTRA_DEP) $(PREAMBLE_DEP): dep/%.d: generated/%.c .generated | dep
$(EXTRA_DEP) $(PREAMBLE_DEP): dep/%.d: generated/%.c .generated | dep
$(CC) $(INCLUDE_PATHS) -MM -MT $(patsubst dep/%,obj/%,$(patsubst %.d,%.o,$@)) -o $@ $<

$(TEST_DEP): dep/%.d: tests/src/%.c .generated | dep
$(CC) $(INCLUDE_PATHS) -MM -MT $(patsubst dep/%,obj/%,$(patsubst %.d,%.o,$@)) -o $@ $<

generated/lexer.c generated/lexer.h: src/lexer.l | generated
flex --header-file=generated/lexer.h -o generated/lexer.c $<

generated/parser.c generated/parser.h: src/parser.y | generated
bison -v -Werror -Wcounterexamples --header=generated/parser.h -o generated/parser.c $<

test: $(TEST_TARGETS) $(TARGET) unicode/unicode.db
for t in $(TEST_TARGETS) ; do echo '***' $$t '***' ; $$t || exit 1 ; done
for t in tests/fn/test_*.fn ; do echo '***' $$t '***' ; ./$(TARGET) --include=fn --assertions-accumulate $$t || exit 1 ; done
Expand Down Expand Up @@ -227,9 +212,6 @@ indent-generated: .typedefs .indent.pro

.typedefs: .generated

check-grammar:
bison -Wcex --feature=syntax-only src/parser.y

list-cores:
@ls -rt1 /var/lib/apport/coredump/* | tail -1

Expand Down
8 changes: 5 additions & 3 deletions docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@ More of a wish-list than a hard and fast plan.
* another special case: `a + b`, `b` would be bound to `0i` if the actual
argument is not complex.
* Much better error reporting.
* `--expression="..."` to execute a snippet from the command line.
* Error recovery.
* User definable operators.
* With precedence and associativity.
* `infix 55 left >>= fn(l, r) { ... }`
* `prefix 45 $ fn(a) { ... }`
* `suffix 60 ! factorial`
* `infix 55 left ">>=" fn(l, r) { ... }`
* `prefix 45 "$" fn(a) { ... }`
* `suffix 60 "!" factorial`
* `infix 40 "and" and` - where `and` would have to be a macro.
* precedence of prefix and postfix operators matters, i.e. `-2**2` is `-(2**2)` not `(-2)**2`.
* looks like this is a biggie and would involve replacing the existing parser (and probably lexer)
with a
Expand Down
254 changes: 0 additions & 254 deletions src/lexer.l

This file was deleted.

1 change: 0 additions & 1 deletion src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
#include "ast_debug.h"
#include "lambda_debug.h"
#include "lambda_conversion.h"
#include "module.h"
#include "annotate.h"
#include "anf.h"
#include "anf_normalize.h"
Expand Down
1 change: 0 additions & 1 deletion src/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "step.h"
#include "anf.h"
#include "cekf.h"
#include "module.h"
#include "symbol.h"
#include "arithmetic.h"
#include "opaque.h"
Expand Down
Loading

0 comments on commit 6696490

Please sign in to comment.