Compiles but really really broken

This commit is contained in:
Roberto Alsina 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
# 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"

View File

@ -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