-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
194 lines (144 loc) · 7.44 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
CXX = g++
CXXFLAGS = -std=c++11
GRAMMAR_OBJS = build/grammar.o build/nonterminal.o build/token.o \
build/production.o
TABLE_OBJS = build/table.o build/lr_table.o build/lalr_table.o \
build/item_set.o build/item.o build/state.o build/item_core.o build/lalr_state.o
CODEGEN_OBJS = build/json_generator.o
all : bin/asparserations
install : all
cp bin/asparserations ~/local/bin
clean :
rm build/*
rm bin/*
build :
mkdir -p build
bin :
mkdir -p bin
autogen autogen/include autogen/src :
mkdir -p autogen && cd autogen && mkdir -p include src
grammar/include/grammar.hpp : grammar/include/nonterminal.hpp \
grammar/include/token.hpp
grammar/include/symbol.hpp : grammar/include/production.hpp
grammar/include/nonterminal.hpp : grammar/include/production.hpp \
grammar/include/symbol.hpp
grammar/include/token.hpp : grammar/include/production.hpp \
grammar/include/symbol.hpp
table/include/table.hpp: table/include/state.hpp table/include/item.hpp
table/include/lr_table.hpp : table/include/state.hpp table/include/table.hpp
table/include/lalr_table.hpp : table/include/state.hpp table/include/table.hpp
table/include/item_set.hpp : table/include/item.hpp
table/include/lalr_state.hpp : table/include/item_set.hpp
codegen/include/json_generator.hpp : codegen/include/code_generator.hpp
bootstrap/include/lexer.hpp : autogen/include/Parser.hpp
bootstrap/include/callback.hpp : grammar/include/grammar.hpp \
grammar/include/nonterminal.hpp grammar/include/production.hpp
#Grammar
build/grammar.o: grammar/src/grammar.cpp grammar/include/grammar.hpp \
grammar/include/production.hpp| build
$(CXX) $(CXXFLAGS) -c -o build/grammar.o grammar/src/grammar.cpp
build/nonterminal.o: grammar/src/nonterminal.cpp \
grammar/include/nonterminal.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/nonterminal.o grammar/src/nonterminal.cpp
build/token.o : grammar/src/token.cpp grammar/include/token.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/token.o grammar/src/token.cpp
build/production.o : grammar/src/production.cpp grammar/include/production.hpp \
| build
$(CXX) $(CXXFLAGS) -c -o build/production.o grammar/src/production.cpp
#Table
build/table.o : table/src/table.cpp table/include/table.hpp \
table/include/item_set.hpp grammar/include/token.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/table.o table/src/table.cpp
build/lr_table.o : table/src/lr_table.cpp grammar/include/grammar.hpp \
grammar/include/nonterminal.hpp grammar/include/token.hpp \
table/include/lr_table.hpp table/include/state.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/lr_table.o table/src/lr_table.cpp
build/lalr_table.o : table/src/lalr_table.cpp \
table/include/lalr_table.hpp table/include/item_core.hpp \
table/include/item_set.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/lalr_table.o table/src/lalr_table.cpp
build/item.o : table/src/item.cpp table/include/item.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/item.o table/src/item.cpp
build/item_set.o : table/src/item_set.cpp table/include/item_set.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/item_set.o table/src/item_set.cpp
build/state.o : table/src/state.cpp table/include/state.hpp \
grammar/include/production.hpp grammar/include/symbol.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/state.o table/src/state.cpp
build/item_core.o : table/src/item_core.cpp table/include/item_core.hpp \
grammar/include/production.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/item_core.o table/src/item_core.cpp
build/lalr_state.o : table/src/lalr_state.cpp table/include/lalr_state.hpp \
| build
$(CXX) $(CXXFLAGS) -c -o build/lalr_state.o table/src/lalr_state.cpp
#Codegen
build/json_generator.o : codegen/src/json_generator.cpp | build
$(CXX) $(CXXFLAGS) -c -o build/json_generator.o \
codegen/src/json_generator.cpp
#Miscellaneous
build/grammar_syntax.o : bootstrap/src/grammar_syntax.cpp \
bootstrap/include/grammar_syntax.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/grammar_syntax.o \
bootstrap/src/grammar_syntax.cpp
build/first_set1.o : tests/src/first_set1.cpp \
bootstrap/include/grammar_syntax.hpp grammar/include/grammar.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/first_set1.o tests/src/first_set1.cpp
build/print_states.o : tests/src/print_states.cpp \
tests/include/print_states.hpp table/include/state.hpp table/include/table.hpp \
| build
$(CXX) $(CXXFLAGS) -c -o build/print_states.o tests/src/print_states.cpp
build/lr_table1.o : tests/src/lr_table1.cpp | build
$(CXX) $(CXXFLAGS) -c -o build/lr_table1.o tests/src/lr_table1.cpp
build/lalr_table1.o : tests/src/lalr_table1.cpp | build
$(CXX) $(CXXFLAGS) -c -o build/lalr_table1.o tests/src/lalr_table1.cpp
build/json_test1.o : build tests/src/json_test1.cpp \
codegen/include/json_generator.hpp \
grammar/include/grammar.hpp grammar/include/nonterminal.hpp \
grammar/include/token.hpp table/include/lr_table.hpp
$(CXX) $(CXXFLAGS) -c -o build/json_test1.o tests/src/json_test1.cpp
build/gen_json.o : bootstrap/src/gen_json.cpp \
codegen/include/json_generator.hpp grammar/include/grammar.hpp \
table/include/lr_table.hpp bootstrap/include/grammar_syntax.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/gen_json.o bootstrap/src/gen_json.cpp
build/lexer.o : bootstrap/src/lexer.cpp bootstrap/include/lexer.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/lexer.o bootstrap/src/lexer.cpp
build/parser.o : autogen/src/Parser.cpp autogen/include/Parser.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/parser.o autogen/src/Parser.cpp
build/callback.o : bootstrap/src/callback.cpp bootstrap/include/callback.hpp \
autogen/include/Parser.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/callback.o bootstrap/src/callback.cpp
build/main.o : main.cpp autogen/include/Parser.hpp bootstrap/include/lexer.hpp \
bootstrap/include/callback.hpp codegen/include/json_generator.hpp \
grammar/include/grammar.hpp table/include/lr_table.hpp | build
$(CXX) $(CXXFLAGS) -c -o build/main.o main.cpp
#Executables
bin/first_set1.out : build/first_set1.o build/grammar_syntax.o $(GRAMMAR_OBJS) \
| bin
$(CXX) -std=c++11 -o bin/first_set1.out build/first_set1.o \
build/grammar_syntax.o $(GRAMMAR_OBJS)
bin/lr_table1.out : build/lr_table1.o build/print_states.o $(GRAMMAR_OBJS) \
$(TABLE_OBJS) | bin
$(CXX) -std=c++11 -o bin/lr_table1.out build/lr_table1.o \
build/print_states.o $(GRAMMAR_OBJS) $(TABLE_OBJS)
bin/lalr_table1.out : build/lalr_table1.o build/print_states.o $(GRAMMAR_OBJS) \
$(TABLE_OBJS) | bin
$(CXX) -std=c++11 -o bin/lalr_table1.out build/lalr_table1.o \
build/print_states.o $(GRAMMAR_OBJS) $(TABLE_OBJS)
bin/json_test1.out : build/json_test1.o $(GRAMMAR_OBJS) $(TABLE_OBJS) \
$(CODEGEN_OBJS) | bin
$(CXX) -std=c++11 -o bin/json_test1.out build/json_test1.o \
$(GRAMMAR_OBJS) $(TABLE_OBJS) $(CODEGEN_OBJS)
bin/gen_json.out : build/gen_json.o $(GRAMMAR_OBJS) $(TABLE_OBJS) \
$(CODEGEN_OBJS) build/grammar_syntax.o | bin
$(CXX) -std=c++11 -o bin/gen_json.out build/gen_json.o $(GRAMMAR_OBJS) \
$(TABLE_OBJS) $(CODEGEN_OBJS) build/grammar_syntax.o
bin/asparserations : build/main.o $(GRAMMAR_OBJS) $(TABLE_OBJS) $(CODEGEN_OBJS)\
build/parser.o build/lexer.o build/callback.o | bin
$(CXX) -std=c++11 -o bin/asparserations build/main.o $(GRAMMAR_OBJS) \
$(TABLE_OBJS) $(CODEGEN_OBJS) build/parser.o build/lexer.o build/callback.o
#Bootstrap
bootstrap/output_json.json : bin/gen_json.out
bin/gen_json.out > bootstrap/output_json.json
autogen/include/Parser.hpp autogen/src/Parser.cpp : bootstrap/parser_gen.py \
bootstrap/output_json.json bootstrap/config.json | autogen/include autogen/src
python3 bootstrap/parser_gen.py bootstrap/output_json.json \
bootstrap/config.json autogen