]> www.ljiriste.work Git - KyciFTA/commitdiff
Add Makefile, remove parsing_table
authorLukáš Jiřiště <redacted>
Sun, 28 Jun 2026 19:47:57 +0000 (21:47 +0200)
committerLukáš Jiřiště <redacted>
Mon, 29 Jun 2026 19:18:32 +0000 (21:18 +0200)
The Makefile contains rules for creating the parsing_table from grammar
using my generator. It also generates a source file from the grammar
and parsing_table files.

.gitignore [new file with mode: 0644]
Makefile [new file with mode: 0644]
parsing_table [deleted file]

diff --git a/.gitignore b/.gitignore
new file mode 100644 (file)
index 0000000..ab4eaa4
--- /dev/null
@@ -0,0 +1,5 @@
+src/grammar.c
+parsing_table
+*.o
+kycifta
+tags
diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..acc2174
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,85 @@
+CC := gcc
+CFLAGS = -std=gnu99 -Wall -Wextra -Werror -Wpedantic
+
+ifneq ("$(wildcard .debug)","")
+       CFLAGS += -g
+endif
+
+RM := rm -f
+
+
+SUBPROJECTS := Libft
+
+INCDIR := inc/
+INCDIR += $(addsuffix /inc, $(SUBPROJECTS))
+INCLUDE := $(addprefix -I, $(INCDIR))
+
+
+SRCDIR := src/
+
+SOURCES :=                       \
+                       main.c    \
+                       grammar.c \
+
+SOURCES := $(addprefix $(SRCDIR), $(SOURCES))
+
+OBJECTS := $(SOURCES:.c=.o)
+
+NAME := kycifta
+
+all : $(NAME)
+
+debug : .debug
+       $(MAKE) -C Libft debug
+       $(MAKE) all
+
+nodebug :
+       $(MAKE) -C Libft nodebug
+       $(RM) .debug
+       $(MAKE) shallow_re
+
+.% :
+       $(MAKE) shallow_fclean
+       touch $@
+
+$(NAME) : $(OBJECTS) Libft/libft.a
+       $(CC) $(CFLAGS) -o $@ $^
+
+FORCE: ;
+
+Libft/libft.a : FORCE | Libft/Makefile
+       $(MAKE) -C Libft
+
+%.o : %.c | Libft/Makefile
+       $(CC) $(CFLAGS) -o $@ -c $< $(INCLUDE)
+
+%/Makefile :
+       git submodule update --init $($@%/Makefile=%)
+
+# The parsing_table_generator is available at https://git.ljiriste.work/?p=parsing_table_generator or git://ljiriste.work/parsing_table_generator
+parsing_table: grammar
+       $(RM) $@
+       parsing_table_generator $<
+
+# Option -t of xxd available as of version 9.2.0205
+$(SRCDIR)grammar.c : grammar parsing_table
+       echo "#include \"grammar.h\"\n" >$@
+       xxd -i -t $(word 1, $^) >>$@
+       echo -n "\n" >>$@
+       xxd -i -t $(word 2, $^) >>$@
+
+clean :
+       $(RM) $(OBJECTS)
+
+fclean : clean
+       $(RM) $(NAME)
+       $(MAKE) -C Libft fclean
+
+re : fclean
+       $(MAKE) all
+
+shallow_fclean : clean
+       $(RM) $(NAME)
+
+shallow_re : shallow_fclean
+       $(MAKE) all
diff --git a/parsing_table b/parsing_table
deleted file mode 100644 (file)
index 729b01d..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-State;WORD;EXP;DOT;FROM;ATOM;COMMA;INT;N_OUT_OF_K;TIMES;PLUS;RIGHT_PARA;LEFT_PARA;SYSTEM;INSTANTIATE;$;fault_tree;statement;atom;system;instantiation;classname;objectname;system_def;fta_logic;fta_sum;fta_product;name;list;probability;function_name;dynamic_library;value;mantisa;exponent;path
-0;;;;;s1;;;;;;;;s25;s77;;82;83;85;86;87;;;;;;;;;;;;;;;
-1;s2;;;;;;;;;;;;;;;;;;;;3;;;;;;24;;;;;;;;
-2;;;;;;;;;;;;r32;;;;;;;;;;;;;;;;;;;;;;;
-3;;;;;;;;;;;;s4;;;;;;;;;;;;;;;;;;;;;;;
-4;s5;;;;;;s6;;;;;;;;;;;;;;;;;;;;9;;10;12;;19;20;;
-5;;;;r32;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-6;;r23;s7;;;;;;;;r23;;;;;;;;;;;;;;;;;;;;;;;;
-7;;;;;;;s8;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-8;;r24;;;;;;;;;r24;;;;;;;;;;;;;;;;;;;;;;;;
-9;;;;r28;;;;;;;;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