Skip to content

Commit

Permalink
Organize into subdirectories.
Browse files Browse the repository at this point in the history
  • Loading branch information
cdleary committed Oct 12, 2011
1 parent 77a3e93 commit 8692f69
Show file tree
Hide file tree
Showing 18 changed files with 33 additions and 11 deletions.
35 changes: 27 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,24 @@
JS_SHELL := jsv -m -n
CDLRE_UNICODE := generated/unicode.js
CDLRE_UNICODE_LZW := generated/unicode_lzw.js
CDLRE_LIB_ARGS := \
-f lib/common.js \
-f $(CDLRE_UNICODE) \
-f lib/unicode.js \
-f lib/log.js \
-f lib/set.js \
-f lib/parser.js \
-f lib/matcher.js \
-f lib/cdlre.js
CDLRE_TEST_ARGS := -f test/parser_test.js -f test/cdlre_test.js

.PHONY: test
test:
jsv -m -f common.js -f unicat.js -f unicode.js -f log.js -f set.js -f parser.js -f matcher.js -f cdlre.js -f parser_test.js -f cdlre_test.js -e 'testParser(); testCDLRE();'
$(JS_SHELL) $(CDLRE_LIB_ARGS) $(CDLRE_TEST_ARGS) -e 'testParser(); testCDLRE();'

.PHONY: test_cdlre
test_cdlre:
jsv -m -f common.js -f unicat.js -f unicode.js -f log.js -f set.js -f parser.js -f matcher.js -f cdlre.js -f parser_test.js -f cdlre_test.js -e 'testCDLRE();'
$(JS_SHELL) $(CDLRE_LIB_ARGS) $(CDLRE_TEST_ARGS) -e 'testCDLRE();'

.PHONY: hosted
hosted:
Expand All @@ -20,10 +34,15 @@ hosted:
ln -s ${PWD}/matcher.js hosted/cdlre/matcher.js
ln -s ${PWD}/unicat.js hosted/cdlre/unicat.js

.PHONY: unicode
unicode:
echo "var encIdentityEscape = " > $(CDLRE_UNICODE)
./tools/unicat.py >> $(CDLRE_UNICODE)
du -sh $(CDLRE_UNICODE)


.PHONY: lzw
lzw:
echo "var encIdentityEscape = " > unicat.js
./unicat.py >> unicat.js
jsv -f lzw.js -f unicat.js -e 'print("var encLZWIdentityEscape = ", uneval(LZW.encode(LZW.compress(encIdentityEscape))), ";")' > unicat_lzw.js
du -sh unicat.js
du -sh unicat_lzw.js
lzw: unicode
$(JS_SHELL) -f lib/lzw.js -f $(CDLRE_UNICODE) -e 'print("var encLZWIdentityEscape = ", uneval(LZW.encode(LZW.compress(encIdentityEscape))), ";")' > $(CDLRE_UNICODE_LZW)
du -sh $(CDLRE_UNICODE)
du -sh $(CDLRE_UNICODE_LZW)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
8 changes: 6 additions & 2 deletions unicat.py → tools/unicat.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
#!/usr/bin/env python3

"""Convert the union of several unicode categories to a single JS string."""
"""
Converts the union of several unicode categories to a single bitmask encoded as
a JS string.
"""

import collections
import os
from subprocess import Popen

TARGET_CATEGORIES = ['Mn', 'Mc', 'Nd', 'Pc', 'Lu', 'Ll', 'Lt', 'Lm', 'Lo', 'Nl']

# Each index in the bitmap corresponds to a uint16,
# because that's the best we can encode in a unicode character.
bitmap = collections.defaultdict(int)
with open('unicode_categories.txt') as file:
with open(os.path.join('metadata', 'unicode_categories.txt')) as file:
for line in file:
hexcode, category, *rest = line.split()
if category not in TARGET_CATEGORIES:
Expand Down
File renamed without changes.
Binary file removed uni.png
Binary file not shown.
1 change: 0 additions & 1 deletion unicat_lzw.js

This file was deleted.

0 comments on commit 8692f69

Please sign in to comment.