mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-08 12:40:25 -03:00
Exploring re2, doesn't really work
This commit is contained in:
parent
ff1c0012ec
commit
b9e51824df
@ -22,6 +22,7 @@ OPT_bool(longest_match)
|
|||||||
OPT_bool(log_errors)
|
OPT_bool(log_errors)
|
||||||
OPT_bool(literal)
|
OPT_bool(literal)
|
||||||
OPT_bool(never_nl)
|
OPT_bool(never_nl)
|
||||||
|
OPT_bool(dot_nl)
|
||||||
OPT_bool(case_sensitive)
|
OPT_bool(case_sensitive)
|
||||||
OPT_bool(perl_classes)
|
OPT_bool(perl_classes)
|
||||||
OPT_bool(word_boundary)
|
OPT_bool(word_boundary)
|
||||||
|
@ -14,6 +14,7 @@ lib LibCre2
|
|||||||
fun opt_perl_classes = cre2_opt_perl_classes(op : Options, flag : Bool) : Nil
|
fun opt_perl_classes = cre2_opt_perl_classes(op : Options, flag : Bool) : Nil
|
||||||
fun opt_word_boundary = cre2_opt_word_boundary(op : Options, flag : Bool) : Nil
|
fun opt_word_boundary = cre2_opt_word_boundary(op : Options, flag : Bool) : Nil
|
||||||
fun opt_one_line = cre2_opt_one_line(op : Options, flag : Bool) : Nil
|
fun opt_one_line = cre2_opt_one_line(op : Options, flag : Bool) : Nil
|
||||||
|
fun opt_dot_nl = cre2_opt_dot_nl(op : Options, flag : Bool) : Nil
|
||||||
fun opt_encoding = cre2_opt_encoding(op : Options, encoding : Int32) : Nil
|
fun opt_encoding = cre2_opt_encoding(op : Options, encoding : Int32) : Nil
|
||||||
fun opt_max_mem = cre2_opt_max_mem(op : Options, flag : Bool) : Nil
|
fun opt_max_mem = cre2_opt_max_mem(op : Options, flag : Bool) : Nil
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ void cre2_opt_case_sensitive(cre2_options *opt, int flag);
|
|||||||
void cre2_opt_perl_classes(cre2_options *opt, int flag);
|
void cre2_opt_perl_classes(cre2_options *opt, int flag);
|
||||||
void cre2_opt_word_boundary(cre2_options *opt, int flag);
|
void cre2_opt_word_boundary(cre2_options *opt, int flag);
|
||||||
void cre2_opt_one_line(cre2_options *opt, int flag);
|
void cre2_opt_one_line(cre2_options *opt, int flag);
|
||||||
|
void cre2_opt_dot_nl(cre2_options *opt, int flag);
|
||||||
void cre2_opt_encoding(cre2_options *opt, encoding_t enc);
|
void cre2_opt_encoding(cre2_options *opt, encoding_t enc);
|
||||||
void cre2_opt_max_mem(cre2_options *opt, int m);
|
void cre2_opt_max_mem(cre2_options *opt, int m);
|
||||||
|
|
||||||
|
BIN
src/cre2/cre2.o
BIN
src/cre2/cre2.o
Binary file not shown.
18
src/rules.cr
18
src/rules.cr
@ -125,12 +125,16 @@ module Tartrazine
|
|||||||
ignorecase = false, anchored = false)
|
ignorecase = false, anchored = false)
|
||||||
@opts = LibCre2.opt_new
|
@opts = LibCre2.opt_new
|
||||||
LibCre2.opt_posix_syntax(@opts, false)
|
LibCre2.opt_posix_syntax(@opts, false)
|
||||||
LibCre2.opt_longest_match(@opts, true)
|
LibCre2.opt_longest_match(@opts, false)
|
||||||
LibCre2.opt_perl_classes(@opts, true)
|
# These 3 are ignored when posix_syntax is false
|
||||||
|
# LibCre2.opt_one_line(@opts, !multiline)
|
||||||
|
# LibCre2.opt_perl_classes(@opts, true)
|
||||||
|
# LibCre2.opt_word_boundary(@opts, true)
|
||||||
LibCre2.opt_encoding(@opts, 1)
|
LibCre2.opt_encoding(@opts, 1)
|
||||||
LibCre2.opt_one_line(@opts, !multiline)
|
|
||||||
LibCre2.opt_case_sensitive(@opts, !ignorecase)
|
LibCre2.opt_case_sensitive(@opts, !ignorecase)
|
||||||
|
LibCre2.opt_dot_nl(@opts, dotall)
|
||||||
pattern = "(m?)#{pattern}" if multiline
|
pattern = "(m?)#{pattern}" if multiline
|
||||||
|
p! pattern
|
||||||
@re = LibCre2.new(pattern, pattern.size, @opts)
|
@re = LibCre2.new(pattern, pattern.size, @opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -142,6 +146,10 @@ module Tartrazine
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
re = Tartrazine::Re3.new("(require-instance|fraction-digits|error-app-tag|error-message|min-elements|max-elements|yin-element|ordered-by|position|modifier|default|pattern|length|status|units|value|range|type|path|enum|base|bit)(?=[^\w\-\:])")
|
|
||||||
p! re.match("value ", 0)
|
# I can't find a combination of flags that makes this match "#foo"
|
||||||
|
# and without that this is never going to work.
|
||||||
|
re = Tartrazine::Re3.new("#.*$", multiline: true, dotall: false)
|
||||||
|
m = re.match("#foo\nbar", 0)
|
||||||
|
p m[0], m[1][0]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user