mirror of
https://github.com/ralsina/tartrazine.git
synced 2025-08-14 22:43:02 +00:00
Compiles but really really broken
This commit is contained in:
@@ -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"
|
||||||
|
11
src/rules.cr
11
src/rules.cr
@@ -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
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user