This commit is contained in:
Roberto Alsina 2024-08-02 17:09:05 -03:00
parent 444db0abda
commit 7d7a4294ed

View File

@ -12,14 +12,6 @@ module Tartrazine
priority: 0,
}
macro xml_to_s(node, name)
{{node}}.children.find{|n| n.name == "{{name}}".lstrip("_")}.as(XML::Node).content.to_s
end
macro xml_to_a(node, name)
{{node}}.children.select{|n| n.name == "{{name}}".lstrip("_")}.map {|n| n.content.to_s}
end
def self.from_xml(xml : String) : Lexer
l = Lexer.new
lexer = XML.parse(xml).first_element_child
@ -40,5 +32,14 @@ module Tartrazine
end
end
l = Tartrazine::Lexer.from_xml(File.read("chroma/lexers/embedded/plaintext.xml"))
l = Tartrazine::Lexer.from_xml(File.read("lexers/plaintext.xml"))
p! l.config
# Convenience macros to parse XML
macro xml_to_s(node, name)
{{node}}.children.find{|n| n.name == "{{name}}".lstrip("_")}.as(XML::Node).content.to_s
end
macro xml_to_a(node, name)
{{node}}.children.select{|n| n.name == "{{name}}".lstrip("_")}.map {|n| n.content.to_s}
end