Commit ea4394f6 authored by Niels Möller's avatar Niels Möller
Browse files

* make_char_classes (make-char-classes): Use #ifdef to separate

the table from the #defines.

Rev: src/make_char_classes:1.3
parent 7decb8f9
...@@ -287,21 +287,28 @@ ...@@ -287,21 +287,28 @@
(let* ((classes (prepare-input input)) (let* ((classes (prepare-input input))
(roots (map cdr classes))) (roots (map cdr classes)))
(partition! roots) (partition! roots)
(write-string "#ifdef CHAR_CLASSES_TABLE\n")
(write-string "int CHAR_CLASSES_TABLE[] =\n")
(let ((leafs (index-leafs! roots))) (let ((leafs (index-leafs! roots)))
(werror "~s disjunct classes found.\n" (length leafs)) (werror "~s disjunct classes found.\n" (length leafs))
(format #t "int char_classes[] = {\n ~a\n};\n\n" (format #t
"{\n ~a\n};\n"
(implode ",\n " (implode ",\n "
(map (lambda (row) (map (lambda (row)
(implode ", " (map bit->mask (implode ", " (map bit->mask
(vector->list row)))) (vector->list row))))
(vector->list (vector-split (build-char-table leafs) (vector->list (vector-split (build-char-table leafs)
32)))))) 32))))))
(write-string "#else /* !CHAR_CLASSES_TABLE */\n")
(for-each (lambda (class) (for-each (lambda (class)
(format #t "#define CHAR_~a (~a)\n" (format #t "#define CHAR_~a (~a)\n"
(car class) (car class)
(implode " | " (map bit->mask (build-flags (cdr class)))))) (implode " | " (map bit->mask (build-flags (cdr class))))))
classes) classes)
(format #t "#define CHAR_other 1\n"))) (write-string "#define CHAR_other 1\n")
(write-string "#endif /* !CHAR_CLASSES_TABLE */\n")))
(define test-2-input (define test-2-input
'((lower . "abcdefghijklmnopqrstuvwxyz") '((lower . "abcdefghijklmnopqrstuvwxyz")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment