Skip to content

Commit ddbe1fa

Browse files
committed
Drop JSX in favour of JavaScript (partial)
1 parent f69e0a1 commit ddbe1fa

File tree

7 files changed

+152
-310
lines changed

7 files changed

+152
-310
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
/src_c
55
/stemwords
66
/dist
7-
/jsx_out
7+
/js_out
88
/python_out
99
/rust/Cargo.lock
1010
/rust/target/

.travis.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ script:
3535
- test -z "$c_tests" || make check CC="$CC$cc_append" STEMMING_DATA=snowball-data
3636
- test -z "$PYTHON" || make check_python python="$PYTHON" STEMMING_DATA=snowball-data
3737
- test -z "$JAVA" -o -z "$JAVAC" || make check_java STEMMING_DATA=snowball-data
38-
- test -z "$NPM" || "$NPM" install -g jsx
39-
- test -z "$NPM" || make check_jsx STEMMING_DATA=snowball-data
38+
- test -z "$NPM" || make check_js STEMMING_DATA=snowball-data
4039
- test -z "$RUST" || make check_rust STEMMING_DATA=snowball-data
4140
- test -z "$RUST" || make check_rust cargoflags=--release STEMMING_DATA=snowball-data

GNUmakefile

Lines changed: 38 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ python_output_dir = python_out
1212
python_runtime_dir = snowballstemmer
1313
python_sample_dir = sample
1414

15-
jsx_output_dir = jsx_out
16-
jsx_runtime_src_dir = jsx
17-
jsx_runtime_dir = lib
18-
jsx_sample_dir = sample
15+
js_output_dir = js_out
16+
js_runtime_src_dir = js
17+
js_runtime_dir = lib
18+
js_sample_dir = sample
1919

2020
cargo ?= cargo
2121
cargoflags ?=
@@ -46,7 +46,7 @@ COMPILER_SOURCES = compiler/space.c \
4646
compiler/generator.c \
4747
compiler/driver.c \
4848
compiler/generator_java.c \
49-
compiler/generator_jsx.c \
49+
compiler/generator_js.c \
5050
compiler/generator_python.c \
5151
compiler/generator_rust.c
5252

@@ -65,12 +65,12 @@ JAVARUNTIME_SOURCES = java/org/tartarus/snowball/Among.java \
6565
java/org/tartarus/snowball/SnowballStemmer.java \
6666
java/org/tartarus/snowball/TestApp.java
6767

68-
JSX_RUNTIME_SOURCES = jsx/among.jsx \
69-
jsx/base-stemmer.jsx \
70-
jsx/stemmer.jsx
68+
JS_RUNTIME_SOURCES = js/among.js \
69+
js/base-stemmer.js \
70+
js/stemmer.js
7171

72-
JSX_SAMPLE_SOURCES = jsx/testapp.jsx \
73-
jsx/stemwords.jsx
72+
JS_SAMPLE_SOURCES = js/testapp.js \
73+
js/stemwords.js
7474

7575
PYTHON_RUNTIME_SOURCES = python/snowballstemmer/basestemmer.py \
7676
python/snowballstemmer/among.py
@@ -88,7 +88,7 @@ LIBSTEMMER_EXTRA = libstemmer/modules.txt libstemmer/modules_utf8.txt libstemmer
8888

8989
STEMWORDS_SOURCES = examples/stemwords.c
9090

91-
JSX_STEMWORDS_SOURCE = jsx/stemwords.jsx
91+
JS_STEMWORDS_SOURCE = js/stemwords.js
9292

9393
PYTHON_STEMWORDS_SOURCE = python/stemwords.py
9494

@@ -106,7 +106,7 @@ C_OTHER_HEADERS = $(other_algorithms:%=$(c_src_dir)/stem_UTF_8_%.h)
106106
JAVA_SOURCES = $(libstemmer_algorithms:%=$(java_src_dir)/%Stemmer.java)
107107
PYTHON_SOURCES = $(libstemmer_algorithms:%=$(python_output_dir)/%_stemmer.py) \
108108
$(python_output_dir)/__init__.py
109-
JSX_SOURCES = $(libstemmer_algorithms:%=$(jsx_output_dir)/%-stemmer.jsx)
109+
JS_SOURCES = $(libstemmer_algorithms:%=$(js_output_dir)/%-stemmer.js)
110110
RUST_SOURCES = $(libstemmer_algorithms:%=$(rust_src_dir)/%_stemmer.rs)
111111

112112
COMPILER_OBJECTS=$(COMPILER_SOURCES:.c=.o)
@@ -135,14 +135,14 @@ clean:
135135
$(C_OTHER_SOURCES) $(C_OTHER_HEADERS) $(C_OTHER_OBJECTS) \
136136
$(JAVA_SOURCES) $(JAVA_CLASSES) $(JAVA_RUNTIME_CLASSES) \
137137
$(PYTHON_SOURCES) \
138-
$(JSX_SOURCES) jsx_stemwords \
138+
$(JS_SOURCES) \
139139
$(RUST_SOURCES) \
140140
libstemmer/mkinc.mak libstemmer/mkinc_utf8.mak \
141141
libstemmer/libstemmer.c libstemmer/libstemmer_utf8.c
142142
rm -rf dist
143143
rmdir $(c_src_dir) || true
144144
rmdir $(python_output_dir) || true
145-
rmdir $(jsx_output_dir) || true
145+
rmdir $(js_output_dir) || true
146146

147147
snowball: $(COMPILER_OBJECTS)
148148
$(CC) -o $@ $^
@@ -169,9 +169,6 @@ libstemmer.o: libstemmer/libstemmer.o $(RUNTIME_OBJECTS) $(C_LIB_OBJECTS)
169169
stemwords: $(STEMWORDS_OBJECTS) libstemmer.o
170170
$(CC) -o $@ $^
171171

172-
jsx_stemwords: $(JSX_STEMWORDS_SOURCE) $(JSX_SOURCES)
173-
jsx --executable node --output $@ --add-search-path $(jsx_output_dir) --add-search-path $(jsx_runtime_src_dir) $(JSX_STEMWORDS_SOURCE)
174-
175172
algorithms/%/stem_Unicode.sbl: algorithms/%/stem_ISO_8859_1.sbl
176173
cp $^ $@
177174

@@ -231,19 +228,19 @@ $(rust_src_dir)/%_stemmer.rs: algorithms/%/stem_Unicode.sbl snowball
231228
echo "./snowball $< -rust -o $${o}"; \
232229
./snowball $< -rust -o $${o}
233230

234-
$(jsx_output_dir)/%-stemmer.jsx: algorithms/%/stem_Unicode.sbl snowball
235-
@mkdir -p $(jsx_output_dir)
231+
$(js_output_dir)/%-stemmer.js: algorithms/%/stem_Unicode.sbl snowball
232+
@mkdir -p $(js_output_dir)
236233
@l=`echo "$<" | sed 's!\(.*\)/stem_Unicode.sbl$$!\1!;s!^.*/!!'`; \
237-
o="$(jsx_output_dir)/$${l}-stemmer"; \
238-
echo "./snowball $< -jsx -o $${o} -p \"SnowballStemmer\" -n `$(python) -c "print('$${l}'.title())"`Stemmer"; \
239-
./snowball $< -jsx -o $${o} -p "BaseStemmer" -n `$(python) -c "print('$${l}'.title())"`Stemmer
234+
o="$(js_output_dir)/$${l}-stemmer"; \
235+
echo "./snowball $< -js -o $${o} -p \"SnowballStemmer\" -n `$(python) -c "print('$${l}'.title())"`Stemmer"; \
236+
./snowball $< -js -o $${o} -p "BaseStemmer" -n `$(python) -c "print('$${l}'.title())"`Stemmer
240237

241238
splint: snowball.splint
242239
snowball.splint: $(COMPILER_SOURCES)
243240
splint $^ >$@ -weak
244241

245242
# Make a full source distribution
246-
dist: dist_snowball dist_libstemmer_c dist_libstemmer_java dist_libstemmer_jsx dist_libstemmer_python
243+
dist: dist_snowball dist_libstemmer_c dist_libstemmer_java dist_libstemmer_js dist_libstemmer_python
247244

248245
# Make a distribution of all the sources involved in snowball
249246
dist_snowball: $(COMPILER_SOURCES) $(COMPILER_HEADERS) \
@@ -351,22 +348,22 @@ dist_libstemmer_python: $(PYTHON_SOURCES)
351348
(cd $${dest} && $(python) setup.py sdist && cp dist/*.tar.gz ..) && \
352349
rm -rf $${dest}
353350

354-
dist_libstemmer_jsx: $(JSX_SOURCES)
355-
destname=jsxstemmer; \
351+
dist_libstemmer_js: $(JS_SOURCES)
352+
destname=jsstemmer; \
356353
dest=dist/$${destname}; \
357354
rm -rf $${dest} && \
358355
rm -f $${dest}.tgz && \
359356
mkdir -p $${dest} && \
360-
mkdir -p $${dest}/$(jsx_runtime_dir) && \
361-
mkdir -p $${dest}/$(jsx_sample_dir) && \
362-
cp -a doc/libstemmer_jsx_README $${dest}/README && \
363-
cp -a $(JSX_RUNTIME_SOURCES) $${dest}/$(jsx_runtime_dir) && \
364-
cp -a $(JSX_SAMPLE_SOURCES) $${dest}/$(jsx_sample_dir) && \
365-
cp -a $(JSX_SOURCES) $${dest}/$(jsx_runtime_dir) && \
357+
mkdir -p $${dest}/$(js_runtime_dir) && \
358+
mkdir -p $${dest}/$(js_sample_dir) && \
359+
cp -a doc/libstemmer_js_README $${dest}/README && \
360+
cp -a $(JS_RUNTIME_SOURCES) $${dest}/$(js_runtime_dir) && \
361+
cp -a $(JS_SAMPLE_SOURCES) $${dest}/$(js_sample_dir) && \
362+
cp -a $(JS_SOURCES) $${dest}/$(js_runtime_dir) && \
366363
(cd $${dest} && \
367364
echo "README" >> MANIFEST && \
368-
ls $(jsx_runtime_dir)/*.jsx >> MANIFEST && \
369-
ls $(jsx_sample_dir)/*.jsx >> MANIFEST) && \
365+
ls $(js_runtime_dir)/*.js >> MANIFEST && \
366+
ls $(js_sample_dir)/*.js >> MANIFEST) && \
370367
(cd dist && tar zcf $${destname}.tgz $${destname}) && \
371368
rm -rf $${dest}
372369

@@ -446,13 +443,13 @@ check_java_%: $(STEMMING_DATA_ABS)/%
446443
fi
447444
@rm tmp.txt
448445

449-
check_jsx: $(libstemmer_algorithms:%=check_jsx_%)
446+
check_js: $(libstemmer_algorithms:%=check_js_%)
450447

451448
# Keep one in $(THIN_FACTOR) entries from gzipped vocabularies.
452449
THIN_FACTOR ?= 3
453450

454451
# Command to thin out the testdata - the full arabic test data causes
455-
# jsx_stemwords to run out of memory. Also use for Python tests, which
452+
# stemwords.js to run out of memory. Also use for Python tests, which
456453
# take a long time (unless you use pypy).
457454
THIN_TEST_DATA := awk '(FNR % $(THIN_FACTOR) == 0){print}'
458455

@@ -474,14 +471,16 @@ check_rust_%: $(STEMMING_DATA_ABS)/%
474471
fi
475472
@rm tmp.txt
476473

477-
check_jsx_%: $(STEMMING_DATA)/% jsx_stemwords
478-
@echo "Checking output of `echo $<|sed 's!.*/!!'` stemmer for JSX"
474+
export NODE_PATH = $(js_output_dir):$(js_runtime_src_dir)
475+
476+
check_js_%: $(STEMMING_DATA)/%
477+
@echo "Checking output of `echo $<|sed 's!.*/!!'` stemmer for JS"
479478
@if test -f '$</voc.txt.gz' ; then \
480479
gzip -dc '$</voc.txt.gz'|$(THIN_TEST_DATA) > tmp.in; \
481-
./jsx_stemwords -c utf8 -l `echo $<|sed 's!.*/!!'` -i tmp.in -o tmp.txt; \
480+
$(NODE) stemwords.js -c utf8 -l `echo $<|sed 's!.*/!!'` -i tmp.in -o tmp.txt; \
482481
rm tmp.in; \
483482
else \
484-
./jsx_stemwords -c utf8 -l `echo $<|sed 's!.*/!!'` -i $</voc.txt -o tmp.txt; \
483+
$(NODE) stemwords.js -c utf8 -l `echo $<|sed 's!.*/!!'` -i $</voc.txt -o tmp.txt; \
485484
fi
486485
@if test -f '$</output.txt.gz' ; then \
487486
gzip -dc '$</output.txt.gz'|$(THIN_TEST_DATA)|diff -u - tmp.txt; \

compiler/driver.c

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ static void print_arglist(void) {
2323
#ifndef DISABLE_PYTHON
2424
" [-py[thon]]\n"
2525
#endif
26-
#ifndef DISABLE_JSX
26+
#ifndef DISABLE_JS
2727
" [-js]\n"
28-
" [-jsx]\n"
2928
#endif
3029
#ifndef DISABLE_RUST
3130
" [-rust]\n"
@@ -101,17 +100,12 @@ static void read_options(struct options * o, int argc, char * argv[]) {
101100
o->name = argv[i++];
102101
continue;
103102
}
104-
#ifndef DISABLE_JSX
103+
#ifndef DISABLE_JS
105104
if (eq(s, "-js")) {
106105
o->make_lang = LANG_JAVASCRIPT;
107106
o->widechars = true;
108107
continue;
109108
}
110-
if (eq(s, "-jsx")) {
111-
o->make_lang = LANG_JSX;
112-
o->widechars = true;
113-
continue;
114-
}
115109
#endif
116110
#ifndef DISABLE_RUST
117111
if (eq(s, "-rust")) {
@@ -289,21 +283,13 @@ extern int main(int argc, char * argv[]) {
289283
fclose(o->output_src);
290284
}
291285
#endif
292-
#ifndef DISABLE_JSX
286+
#ifndef DISABLE_JS
293287
if (o->make_lang == LANG_JAVASCRIPT) {
294288
symbol * b = add_s_to_b(0, s);
295289
b = add_s_to_b(b, ".js");
296290
o->output_src = get_output(b);
297291
lose_b(b);
298-
generate_program_jsx(g);
299-
fclose(o->output_src);
300-
}
301-
if (o->make_lang == LANG_JSX) {
302-
symbol * b = add_s_to_b(0, s);
303-
b = add_s_to_b(b, ".jsx");
304-
o->output_src = get_output(b);
305-
lose_b(b);
306-
generate_program_jsx(g);
292+
generate_program_js(g);
307293
fclose(o->output_src);
308294
}
309295
#endif

0 commit comments

Comments
 (0)