mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-06-07 20:20:26 -03:00
Use deluxe, no difference
This commit is contained in:
parent
32816eb207
commit
8e8296139a
@ -17,9 +17,18 @@ regex_t *onigwrap_create(char *pattern, int len, int ignoreCase, int multiline,
|
||||
if (dotall == 1)
|
||||
onigOptions |= ONIG_OPTION_DOTALL;
|
||||
|
||||
OnigCompileInfo ci;
|
||||
ci.num_of_elements = 5;
|
||||
ci.pattern_enc = ONIG_ENCODING_UTF8;
|
||||
ci.target_enc = ONIG_ENCODING_UTF8;
|
||||
ci.syntax = ONIG_SYNTAX_PYTHON;
|
||||
ci.option = onigOptions;
|
||||
ci.case_fold_flag = ONIGENC_CASE_FOLD_MIN;
|
||||
|
||||
OnigUChar *stringStart = (OnigUChar*) pattern;
|
||||
OnigUChar *stringEnd = (OnigUChar*) pattern + len;
|
||||
int res = onig_new(®, stringStart, stringEnd, onigOptions, ONIG_ENCODING_UTF8, ONIG_SYNTAX_PYTHON, &einfo);
|
||||
// int res = onig_new(®, stringStart, stringEnd, onigOptions, ONIG_ENCODING_UTF8, ONIG_SYNTAX_PYTHON, &einfo);
|
||||
int res = onig_new_deluxe(®, stringStart, stringEnd, &ci, &einfo);
|
||||
|
||||
return reg;
|
||||
}
|
||||
|
10
src/rules.cr
10
src/rules.cr
@ -15,13 +15,11 @@ module Tartrazine
|
||||
|
||||
class Rule
|
||||
property pattern : Regex = Regex.new ""
|
||||
property pattern2 : ::Regex = ::Regex.new ""
|
||||
property actions : Array(Action) = [] of Action
|
||||
property xml : String = "foo"
|
||||
|
||||
def match(text, pos, lexer) : Tuple(Bool, Int32, Array(Token))
|
||||
match = pattern.match(text, pos)
|
||||
match2 = pattern2.match(text, pos)
|
||||
# We don't match if the match doesn't move the cursor
|
||||
# because that causes infinite loops
|
||||
# The `match.begin > pos` is the same as the ANCHORED option
|
||||
@ -41,16 +39,8 @@ module Tartrazine
|
||||
def initialize(node : XML::Node, multiline, dotall, ignorecase)
|
||||
@xml = node.to_s
|
||||
pattern = node["pattern"]
|
||||
# flags = Regex::Options::ANCHORED
|
||||
flags = ::Regex::Options::NO_UTF_CHECK
|
||||
# MULTILINE implies DOTALL which we don't want, so we
|
||||
# use in-pattern flag (?m) instead
|
||||
flags |= ::Regex::Options::MULTILINE if multiline
|
||||
pattern = "(?m)" + pattern if multiline
|
||||
flags |= ::Regex::Options::DOTALL if dotall
|
||||
flags |= ::Regex::Options::IGNORE_CASE if ignorecase
|
||||
@pattern = Regex.new(pattern, ignorecase, multiline, dotall)
|
||||
@pattern2 = ::Regex.new(pattern, flags)
|
||||
add_actions(node)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user