1 |
commit: f3165d3aba092c6712943e1d41ffc5327a4d8ccc |
2 |
Author: Mu Qiao <qiaomuf <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Mar 30 02:04:01 2011 +0000 |
4 |
Commit: Petteri Räty <betelgeuse <AT> gentoo <DOT> org> |
5 |
CommitDate: Wed Mar 30 12:06:08 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/libbash.git;a=commit;h=f3165d3a |
7 |
|
8 |
Rename grammar files |
9 |
|
10 |
Grammar files are renamed for better consistency of the generated |
11 |
files. It also help automake differentiate the grammars for gUnit |
12 |
and C source files. |
13 |
|
14 |
--- |
15 |
.gitignore | 14 ++++++++------ |
16 |
Makefile.am | 28 +++++++++++++++------------- |
17 |
bashast/{bashwalker.g => libbashWalker.g} | 4 ++-- |
18 |
src/core/interpreter.h | 2 +- |
19 |
test/post_check.cpp | 6 +++--- |
20 |
test/walker_test.cpp | 20 ++++++++++---------- |
21 |
6 files changed, 39 insertions(+), 35 deletions(-) |
22 |
|
23 |
diff --git a/.gitignore b/.gitignore |
24 |
index 35588e4..4bf6402 100644 |
25 |
--- a/.gitignore |
26 |
+++ b/.gitignore |
27 |
@@ -18,7 +18,8 @@ missing |
28 |
Makefile |
29 |
autom4te.cache |
30 |
cppunittests |
31 |
-bashast.g |
32 |
+libbash.g |
33 |
+libbash.tokens |
34 |
bashast.tokens |
35 |
bashast/.DS_Store |
36 |
bashast/*.ebuild |
37 |
@@ -29,11 +30,12 @@ bashast/tmp/ |
38 |
bashast/tokens.png |
39 |
bashastLexer.* |
40 |
bashastParser.* |
41 |
-bashwalker.g |
42 |
-bashwalker.h |
43 |
-bashwalker.c |
44 |
-bashwalker.cpp |
45 |
-bashwalker.tokens |
46 |
+libbashLexer.* |
47 |
+libbashParser.* |
48 |
+libbashWalker.h |
49 |
+libbashWalker.c |
50 |
+libbashWalker.cpp |
51 |
+libbashWalker.tokens |
52 |
coding_standard/*.pdf |
53 |
coding_standard/*.log |
54 |
coding_standard/*.aux |
55 |
|
56 |
diff --git a/Makefile.am b/Makefile.am |
57 |
index faecc69..9207722 100644 |
58 |
--- a/Makefile.am |
59 |
+++ b/Makefile.am |
60 |
@@ -88,19 +88,19 @@ cppunittests_LDADD = libcppbash.la \ |
61 |
cppunittests_LDFLAGS = -static |
62 |
endif |
63 |
|
64 |
-GENERATED_PARSER_C = bashastLexer.c bashastParser.c |
65 |
-GENERATED_PARSER_H = bashastLexer.h bashastParser.h |
66 |
-GENERATED_WALKER_C = bashwalker.c |
67 |
-GENERATED_WALKER_H = bashwalker.h |
68 |
+GENERATED_PARSER_C = libbashLexer.c libbashParser.c |
69 |
+GENERATED_PARSER_H = libbashLexer.h libbashParser.h |
70 |
+GENERATED_WALKER_C = libbashWalker.c |
71 |
+GENERATED_WALKER_H = libbashWalker.h |
72 |
CLEANFILES = $(GENERATED_PARSER_C) \ |
73 |
$(GENERATED_PARSER_H) \ |
74 |
$(GENERATED_WALKER_C) \ |
75 |
$(GENERATED_WALKER_H) \ |
76 |
$(check_JAVA) \ |
77 |
- bashast.g \ |
78 |
- bashast.tokens \ |
79 |
+ libbash.g \ |
80 |
+ libbash.tokens \ |
81 |
bashast/bashast.tokens \ |
82 |
- bashwalker.tokens \ |
83 |
+ libbashWalker.tokens \ |
84 |
bashast/javagrammar.run \ |
85 |
cgrammar.run \ |
86 |
walker.run |
87 |
@@ -125,7 +125,7 @@ libcppbash_la_CXXFLAGS = $(AM_CXXFLAGS) $(HIDDEN_FLAGS) |
88 |
libcppbash_la_CFLAGS = $(AM_CFLAGS) $(HIDDEN_FLAGS) |
89 |
|
90 |
EXTRA_DIST = bashast/bashast.g \ |
91 |
- bashast/bashwalker.g \ |
92 |
+ bashast/libbashWalker.g \ |
93 |
$(GUNIT_TESTS) \ |
94 |
$(GUNIT_LOG_COMPILER) |
95 |
|
96 |
@@ -134,20 +134,22 @@ coding_standard.pdf: coding_standard/coding_standard.tex |
97 |
|
98 |
ANTLR = @JAVA@ -classpath @antlr_cp@ org.antlr.Tool |
99 |
|
100 |
-cgrammar.run: bashast.g |
101 |
+cgrammar.run: libbash.g |
102 |
$(AM_V_at)touch $@.tmp |
103 |
$(AM_V_GEN)$(ANTLR) -fo . $< |
104 |
$(AM_V_at)mv $@.tmp $@ |
105 |
|
106 |
-bashast.g: bashast/bashast.g |
107 |
- $(AM_V_at)sed -e 's/CommonTree/pANTLR3_BASE_TREE/g' -e 's/Java/C/g' $< > $@ |
108 |
+libbash.g: bashast/bashast.g |
109 |
+ $(AM_V_at)sed -e 's/ASTLabelType = CommonTree;/ASTLabelType = pANTLR3_BASE_TREE;/g' \ |
110 |
+ -e 's/language = Java;/language = C;/g' \ |
111 |
+ -e 's/grammar bashast;/grammar libbash;/g' $< > $@ |
112 |
|
113 |
# Avoid initializing C++ type to NULL by sed, variables whose name |
114 |
# starts with libbash_ will be stripped |
115 |
-walker.run: bashast/bashwalker.g cgrammar.run |
116 |
+walker.run: bashast/libbashWalker.g cgrammar.run |
117 |
$(AM_V_at)touch $@.tmp |
118 |
$(AM_V_GEN)$(ANTLR) -fo . $< |
119 |
- $(AM_V_at)sed -i -e 's/\(libbash_.*\) = NULL/\1/' bashwalker.c |
120 |
+ $(AM_V_at)sed -i -e 's/\(libbash_.*\) = NULL/\1/' libbashWalker.c |
121 |
$(AM_V_GEN)mv $@.tmp $@ |
122 |
|
123 |
$(GENERATED_PARSER_C): cgrammar.run |
124 |
|
125 |
diff --git a/bashast/bashwalker.g b/bashast/libbashWalker.g |
126 |
similarity index 98% |
127 |
rename from bashast/bashwalker.g |
128 |
rename to bashast/libbashWalker.g |
129 |
index d2c2438..6de281f 100644 |
130 |
--- a/bashast/bashwalker.g |
131 |
+++ b/bashast/libbashWalker.g |
132 |
@@ -16,12 +16,12 @@ |
133 |
You should have received a copy of the GNU General Public License |
134 |
along with libbash. If not, see <http://www.gnu.org/licenses/>. |
135 |
*/ |
136 |
-tree grammar bashwalker; |
137 |
+tree grammar libbashWalker; |
138 |
|
139 |
options |
140 |
{ |
141 |
language = C; |
142 |
- tokenVocab = bashast; |
143 |
+ tokenVocab = libbash; |
144 |
ASTLabelType = pANTLR3_BASE_TREE; |
145 |
} |
146 |
|
147 |
|
148 |
diff --git a/src/core/interpreter.h b/src/core/interpreter.h |
149 |
index 0833e02..1d6ced9 100644 |
150 |
--- a/src/core/interpreter.h |
151 |
+++ b/src/core/interpreter.h |
152 |
@@ -32,7 +32,7 @@ |
153 |
|
154 |
#include <antlr3basetree.h> |
155 |
|
156 |
-#include "bashastLexer.h" |
157 |
+#include "libbashLexer.h" |
158 |
#include "core/symbols.hpp" |
159 |
|
160 |
/// |
161 |
|
162 |
diff --git a/test/post_check.cpp b/test/post_check.cpp |
163 |
index 098b0f8..1385290 100644 |
164 |
--- a/test/post_check.cpp |
165 |
+++ b/test/post_check.cpp |
166 |
@@ -36,15 +36,15 @@ static void check_file_size(const char *path, uintmax_t size_max) |
167 |
|
168 |
TEST(post_check, lexer_size) |
169 |
{ |
170 |
- check_file_size("bashastLexer.c", 1024 * 1024); |
171 |
+ check_file_size("libbashLexer.c", 1024 * 1024); |
172 |
} |
173 |
|
174 |
TEST(post_check, parser_size) |
175 |
{ |
176 |
- check_file_size("bashastParser.c", 4096 * 1024); |
177 |
+ check_file_size("libbashParser.c", 4096 * 1024); |
178 |
} |
179 |
|
180 |
TEST(post_check, walker_size) |
181 |
{ |
182 |
- check_file_size("bashwalker.c", 4096 * 1024); |
183 |
+ check_file_size("libbashWalker.c", 4096 * 1024); |
184 |
} |
185 |
|
186 |
diff --git a/test/walker_test.cpp b/test/walker_test.cpp |
187 |
index 98672aa..66ae75d 100644 |
188 |
--- a/test/walker_test.cpp |
189 |
+++ b/test/walker_test.cpp |
190 |
@@ -26,9 +26,9 @@ |
191 |
|
192 |
#include <gtest/gtest.h> |
193 |
|
194 |
-#include "bashastLexer.h" |
195 |
-#include "bashastParser.h" |
196 |
-#include "bashwalker.h" |
197 |
+#include "libbashLexer.h" |
198 |
+#include "libbashParser.h" |
199 |
+#include "libbashWalker.h" |
200 |
#include "core/interpreter.h" |
201 |
|
202 |
using namespace std; |
203 |
@@ -36,10 +36,10 @@ using namespace std; |
204 |
class walker_test: public ::testing::Test |
205 |
{ |
206 |
pANTLR3_INPUT_STREAM input; |
207 |
- pbashastLexer lxr; |
208 |
+ plibbashLexer lxr; |
209 |
pANTLR3_COMMON_TOKEN_STREAM tstream; |
210 |
- pbashastParser psr; |
211 |
- bashastParser_arithmetics_return langAST; |
212 |
+ plibbashParser psr; |
213 |
+ libbashParser_arithmetics_return langAST; |
214 |
pANTLR3_COMMON_TREE_NODE_STREAM nodes; |
215 |
protected: |
216 |
virtual void SetUp() |
217 |
@@ -57,7 +57,7 @@ protected: |
218 |
} |
219 |
void init_walker(const char* script); |
220 |
public: |
221 |
- pbashwalker treePsr; |
222 |
+ plibbashWalker treePsr; |
223 |
shared_ptr<interpreter> walker; |
224 |
|
225 |
int run_arithmetic(const char* script) |
226 |
@@ -88,7 +88,7 @@ void walker_test::init_walker(const char *script){ |
227 |
FAIL(); |
228 |
} |
229 |
|
230 |
- lxr = bashastLexerNew(input); |
231 |
+ lxr = libbashLexerNew(input); |
232 |
if ( lxr == NULL ) |
233 |
{ |
234 |
ANTLR3_FPRINTF(stderr, |
235 |
@@ -105,7 +105,7 @@ void walker_test::init_walker(const char *script){ |
236 |
FAIL(); |
237 |
} |
238 |
|
239 |
- psr = bashastParserNew(tstream); |
240 |
+ psr = libbashParserNew(tstream); |
241 |
if (psr == NULL) |
242 |
{ |
243 |
ANTLR3_FPRINTF(stderr, "Out of memory trying to allocate parser\n"); |
244 |
@@ -115,7 +115,7 @@ void walker_test::init_walker(const char *script){ |
245 |
langAST = psr->arithmetics(psr); |
246 |
nodes = antlr3CommonTreeNodeStreamNewTree(langAST.tree, |
247 |
ANTLR3_SIZE_HINT); |
248 |
- treePsr = bashwalkerNew(nodes); |
249 |
+ treePsr = libbashWalkerNew(nodes); |
250 |
walker->define("value", 100); |
251 |
set_interpreter(walker); |
252 |
} |