From e38feb07369940e21136cb1c2e65ed2d186229fa Mon Sep 17 00:00:00 2001 From: Roberto Alsina Date: Thu, 8 Aug 2024 15:09:34 -0300 Subject: [PATCH] Compiles but really really broken --- src/actions.cr | 2 +- src/rules.cr | 11 +++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/actions.cr b/src/actions.cr index 85a9545..36373ad 100644 --- a/src/actions.cr +++ b/src/actions.cr @@ -26,7 +26,7 @@ module Tartrazine end # ameba:disable Metrics/CyclomaticComplexity - def emit(match : Regex::MatchData | CRe2::MatchDataLike | Nil, + def emit(match : MatchData, lexer : Lexer, match_group = 0) : Array(Token) case type when "token" diff --git a/src/rules.cr b/src/rules.cr index a205634..a158375 100644 --- a/src/rules.cr +++ b/src/rules.cr @@ -1,5 +1,5 @@ require "./actions" -require "cre2" +# require "cre2" # These are lexer rules. They match with the text being parsed # and perform actions, either emitting tokens or changing the @@ -7,8 +7,12 @@ require "cre2" module Tartrazine # 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 - property pattern : Regex = CRe2::Regex.new "" + property pattern : Regex = Regex.new "" property actions : Array(Action) = [] of Action property xml : String = "foo" @@ -35,8 +39,7 @@ module Tartrazine options |= Regex::Options::MULTILINE if multiline options |= Regex::Options::DOTALL if dotall options |= Regex::Options::IGNORE_CASE if ignorecase - @pattern = CRe2::Regex.new( - node["pattern"], options) + @pattern = Regex.new(node["pattern"], options) add_actions(node) end