Skip to content

Commit 495d090

Browse files
committed
drop regexp from stdlib, regex literals only work if pixie.regex/regexp is refered directly
1 parent 6002ef0 commit 495d090

File tree

2 files changed

+62
-8
lines changed

2 files changed

+62
-8
lines changed

pixie/regex.pxi

Lines changed: 62 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,65 @@
66
"-lcre2"
77
"-Iexternals/cre2/src"]
88
:includes ["cre2.h"]}
9-
(i/defcfn cre2_version_string))
9+
10+
(i/defcstruct cre2_string_t [:data :length])
11+
(i/defcfn cre2_version_string)
12+
13+
;; Options
14+
(i/defcfn cre2_opt_new)
15+
(i/defcfn cre2_opt_delete)
16+
(i/defcfn cre2_opt_set_posix_syntax)
17+
(i/defcfn cre2_opt_set_longest_match)
18+
(i/defcfn cre2_opt_set_log_errors)
19+
(i/defcfn cre2_opt_set_literal)
20+
(i/defcfn cre2_opt_set_never_nl)
21+
(i/defcfn cre2_opt_set_case_sensitive)
22+
(i/defcfn cre2_opt_set_perl_classes)
23+
(i/defcfn cre2_opt_set_word_boundary)
24+
(i/defcfn cre2_opt_set_one_line)
25+
(i/defcfn cre2_opt_set_max_mem)
26+
(i/defcfn cre2_opt_set_encoding)
27+
28+
;; Construction / destruction
29+
(i/defcfn cre2_new)
30+
(i/defcfn cre2_delete)
31+
32+
;; Inspection
33+
(i/defcfn cre2_pattern)
34+
(i/defcfn cre2_error_code)
35+
(i/defcfn cre2_num_capturing_groups)
36+
(i/defcfn cre2_program_size)
37+
38+
;; Errors something?
39+
(i/defcfn cre2_error_string)
40+
(i/defcfn cre2_error_arg)
41+
42+
;; Matching
43+
(i/defcstruct cre2_range_t [:start :past])
44+
(i/defcfn cre2_match)
45+
(i/defcfn cre2_easy_match)
46+
(i/defcfn cre2_strings_to_ranges)
47+
)
48+
49+
(def optmap
50+
{ :ascii #(cre2_set_encoding % 2)
51+
:posix #(cre2_opt_set_posix_syntax % 1)
52+
:longest_match #(cre2_opt_set_longest_match % 1)
53+
:silent #(cre2_opt_set_log_errors % 0)
54+
:literal #(cre2_opt_set_literal % 1)
55+
:never_nl #(cre2_opt_set_never_nl % 1)
56+
:dot_nl #(cre2_opt_set_one_line % 0)
57+
:never_capture #(do %) ;; ??
58+
:ignore_case #(cre2_opt_set_case_sensitive % 0) })
59+
60+
(defn- cre2-opts [opts]
61+
(let [opt (cre2_opt_new)]
62+
(doseq [key opts] ((key optmap) opt))
63+
opt))
64+
65+
(defn regexp
66+
{:doc "Returns internal representation for regular
67+
expression, used in matching functions."
68+
:signatures [[rexegp-str opts]]}
69+
[regexp-str opts]
70+
(cre2_new regexp-str (count regexp-str) (cre2-opts opts)))

pixie/stdlib.pxi

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3073,13 +3073,6 @@ ex: (vary-meta x assoc :foo 42)"
30733073
ret)
30743074
val)))))
30753075

3076-
(defn regexp
3077-
{:doc "Returns internal representation for regular
3078-
expression, used in matching functions."
3079-
:signatures [[rexegp-str opts]]}
3080-
[regexp-str opts]
3081-
(println (str regexp-str " " opts)))
3082-
30833076
(deftype Iterate [f x]
30843077
IReduce
30853078
(-reduce [self rf init]

0 commit comments

Comments
 (0)