Compiles but really really broken

This commit is contained in:
2024-08-08 15:09:34 -03:00
parent e88fd3a48f
commit e38feb0736
2 changed files with 8 additions and 5 deletions

View File

@@ -26,7 +26,7 @@ module Tartrazine
end end
# ameba:disable Metrics/CyclomaticComplexity # ameba:disable Metrics/CyclomaticComplexity
def emit(match : Regex::MatchData | CRe2::MatchDataLike | Nil, def emit(match : MatchData,
lexer : Lexer, match_group = 0) : Array(Token) lexer : Lexer, match_group = 0) : Array(Token)
case type case type
when "token" when "token"

View File

@@ -1,5 +1,5 @@
require "./actions" require "./actions"
require "cre2" # require "cre2"
# These are lexer rules. They match with the text being parsed # These are lexer rules. They match with the text being parsed
# and perform actions, either emitting tokens or changing the # and perform actions, either emitting tokens or changing the
@@ -7,8 +7,12 @@ require "cre2"
module Tartrazine module Tartrazine
# This rule matches via a regex pattern # This rule matches via a regex pattern
# alias Regex = CRe2::Regex
# alias MatchData = CRe2::MatchDataLike | Regex::MatchData | Nil
alias MatchData = Regex::MatchData | Nil
class Rule class Rule
property pattern : Regex = CRe2::Regex.new "" property pattern : Regex = Regex.new ""
property actions : Array(Action) = [] of Action property actions : Array(Action) = [] of Action
property xml : String = "foo" property xml : String = "foo"
@@ -35,8 +39,7 @@ module Tartrazine
options |= Regex::Options::MULTILINE if multiline options |= Regex::Options::MULTILINE if multiline
options |= Regex::Options::DOTALL if dotall options |= Regex::Options::DOTALL if dotall
options |= Regex::Options::IGNORE_CASE if ignorecase options |= Regex::Options::IGNORE_CASE if ignorecase
@pattern = CRe2::Regex.new( @pattern = Regex.new(node["pattern"], options)
node["pattern"], options)
add_actions(node) add_actions(node)
end end