diff options
author | Bad Diode <bd@badd10de.dev> | 2024-06-16 15:00:19 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2024-06-16 15:00:19 +0200 |
commit | 2e7f414c65d89ebe52570b0b0fb9b7ff2585bf96 (patch) | |
tree | 61a0178c877e69f674daff465fba30af76b379ab /Makefile | |
parent | c2c8796511c90930c41700f5fcd2043a5c4405c9 (diff) | |
download | bdl-2e7f414c65d89ebe52570b0b0fb9b7ff2585bf96.tar.gz bdl-2e7f414c65d89ebe52570b0b0fb9b7ff2585bf96.zip |
Add graphviz visualization for the parse tree
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 29 |
1 files changed, 20 insertions, 9 deletions
@@ -5,10 +5,17 @@ | |||
5 | SRC_DIR := src | 5 | SRC_DIR := src |
6 | BUILD_DIR := build | 6 | BUILD_DIR := build |
7 | SRC_MAIN := $(SRC_DIR)/main.c | 7 | SRC_MAIN := $(SRC_DIR)/main.c |
8 | SRC_BAD := tests/expressions.bad | ||
8 | WATCH_SRC := $(shell find $(SRC_DIR) -name "*.c" -or -name "*.s" -or -name "*.h") | 9 | WATCH_SRC := $(shell find $(SRC_DIR) -name "*.c" -or -name "*.s" -or -name "*.h") |
9 | INC_DIRS := $(shell find $(SRC_DIR) -type d) | 10 | INC_DIRS := $(shell find $(SRC_DIR) -type d) |
10 | INC_FLAGS := $(addprefix -I,$(INC_DIRS)) | 11 | INC_FLAGS := $(addprefix -I,$(INC_DIRS)) |
11 | 12 | ||
13 | # Graphviz viz command. | ||
14 | DOT := dot -Gmargin=0.7 -Gcolor=white -Gfontcolor=white \ | ||
15 | -Ncolor=white -Nfontcolor=white -Ecolor=white \ | ||
16 | -Nfontname="Iosevka Nerd Font" -Nfontsize=15 \ | ||
17 | -T png | kitty +kitten icat | ||
18 | |||
12 | # Output executable. | 19 | # Output executable. |
13 | TARGET := bdl | 20 | TARGET := bdl |
14 | BIN := $(BUILD_DIR)/$(TARGET) | 21 | BIN := $(BUILD_DIR)/$(TARGET) |
@@ -44,19 +51,23 @@ $(BUILD_DIR): | |||
44 | mkdir -p $(BUILD_DIR) | 51 | mkdir -p $(BUILD_DIR) |
45 | 52 | ||
46 | run: $(BIN) | 53 | run: $(BIN) |
47 | $(BIN) tests/expressions.bad | 54 | $(BIN) $(SRC_BAD) |
48 | 55 | ||
49 | viz_lex: $(BIN) | 56 | graph-tokens: $(BIN) |
50 | $(BIN) -pl example.bdl | 57 | # TODO: ... |
58 | $(BIN) -pl $(SRC_BAD) | ||
51 | 59 | ||
52 | viz_par: $(BIN) | 60 | graph-parse: $(BIN) |
53 | $(BIN) -pp example.bdl | idot | 61 | @echo "parsing tree for: '$(SRC_BAD)'" |
62 | @$(BIN) -pp $(SRC_BAD) | $(DOT) | ||
54 | 63 | ||
55 | viz_sem: $(BIN) | 64 | graph-semantic: $(BIN) |
56 | $(BIN) -ps example.bdl | idot | 65 | @echo "semantic tree for: '$(SRC_BAD)'" |
66 | @$(BIN) -ps $(SRC_BAD) | $(DOT) | ||
57 | 67 | ||
58 | viz_sym: $(BIN) | 68 | graph-symbols: $(BIN) |
59 | $(BIN) -pt example.bdl | idot | 69 | @echo "symbol table for: '$(SRC_BAD)'" |
70 | @$(BIN) -pt $(SRC_BAD) | $(DOT) | ||
60 | 71 | ||
61 | # Remove build directory. | 72 | # Remove build directory. |
62 | clean: | 73 | clean: |