mirror of
https://github.com/ralsina/tartrazine.git
synced 2024-11-10 05:22:23 +00:00
Merge branch 'main' of github.com:ralsina/tartrazine
This commit is contained in:
commit
3725201f8a
@ -42,7 +42,6 @@ known_bad = {
|
||||
"#{__DIR__}/tests/mcfunction/selectors.txt",
|
||||
"#{__DIR__}/tests/php/anonymous_class.txt",
|
||||
"#{__DIR__}/tests/html/javascript_unclosed.txt",
|
||||
|
||||
}
|
||||
|
||||
# Tests that fail because of a limitation in PCRE2
|
||||
|
@ -30,7 +30,7 @@ module Tartrazine
|
||||
@standalone : Bool = false,
|
||||
@surrounding_pre : Bool = true,
|
||||
@wrap_long_lines : Bool = false,
|
||||
@weight_of_bold : Int32 = 600,)
|
||||
@weight_of_bold : Int32 = 600)
|
||||
end
|
||||
|
||||
def format(text : String, lexer : Lexer) : String
|
||||
|
@ -94,8 +94,13 @@ module Tartrazine
|
||||
end
|
||||
# If no rule matches, emit an error token
|
||||
unless matched
|
||||
# Log.trace { "Error at #{pos}" }
|
||||
tokens << {type: "Error", value: "#{text[pos]}"}
|
||||
if text[pos] == "\n"
|
||||
# at EOL, reset state to "root"
|
||||
tokens << {type: "TextWhitespace", value: "\n"}
|
||||
@state_stack = ["root"]
|
||||
else
|
||||
tokens << {type: "Error", value: text[pos..pos]}
|
||||
end
|
||||
pos += 1
|
||||
end
|
||||
end
|
||||
|
@ -19,7 +19,7 @@ module Tartrazine
|
||||
match = pattern.match(text, pos)
|
||||
# We don't match if the match doesn't move the cursor
|
||||
# because that causes infinite loops
|
||||
return false, pos, [] of Token if match.nil? || match.end == 0
|
||||
return false, pos, [] of Token if match.nil? || match.size == 0
|
||||
# Log.trace { "#{match}, #{pattern.inspect}, #{text}, #{pos}" }
|
||||
tokens = [] of Token
|
||||
# Emit the tokens
|
||||
|
Loading…
Reference in New Issue
Block a user