mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-08-14 22:43:02 +00:00
Not going to work
This commit is contained in:
14
src/rules.cr
14
src/rules.cr
@@ -13,7 +13,6 @@ module Tartrazine
|
|||||||
property xml : String = "foo"
|
property xml : String = "foo"
|
||||||
|
|
||||||
def match(text, pos, lexer) : Tuple(Bool, Int32, Array(Token))
|
def match(text, pos, lexer) : Tuple(Bool, Int32, Array(Token))
|
||||||
return false, pos, [] of Token
|
|
||||||
matched, matches = pattern.match(text, pos)
|
matched, matches = pattern.match(text, pos)
|
||||||
# We don't match if the match doesn't move the cursor
|
# We don't match if the match doesn't move the cursor
|
||||||
# because that causes infinite loops
|
# because that causes infinite loops
|
||||||
@@ -32,7 +31,6 @@ module Tartrazine
|
|||||||
|
|
||||||
def initialize(node : XML::Node, multiline, dotall, ignorecase)
|
def initialize(node : XML::Node, multiline, dotall, ignorecase)
|
||||||
@xml = node.to_s
|
@xml = node.to_s
|
||||||
p! node["pattern"]
|
|
||||||
@pattern = Re3.new(
|
@pattern = Re3.new(
|
||||||
node["pattern"],
|
node["pattern"],
|
||||||
multiline,
|
multiline,
|
||||||
@@ -133,8 +131,7 @@ module Tartrazine
|
|||||||
LibCre2.opt_encoding(@opts, 1)
|
LibCre2.opt_encoding(@opts, 1)
|
||||||
LibCre2.opt_case_sensitive(@opts, !ignorecase)
|
LibCre2.opt_case_sensitive(@opts, !ignorecase)
|
||||||
LibCre2.opt_dot_nl(@opts, dotall)
|
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
|
||||||
|
|
||||||
@@ -147,9 +144,8 @@ module Tartrazine
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
# I can't find a combination of flags that makes this match "#foo"
|
# re2 doesn't support this (should match "x")
|
||||||
# and without that this is never going to work.
|
# re = Tartrazine::Re3.new("x(?!foo)", multiline: true, dotall: false)
|
||||||
re = Tartrazine::Re3.new("#.*$", multiline: true, dotall: false)
|
# m = re.match("xfoo", 0)
|
||||||
m = re.match("#foo\nbar", 0)
|
# p m[0], m[1][0]
|
||||||
p m[0], m[1][0]
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user