Rst lexer

This commit is contained in:
2024-08-24 19:49:02 -03:00
parent c6cd74e339
commit 38196d6e96
5 changed files with 107 additions and 65 deletions

View File

@ -23,7 +23,7 @@ module Tartrazine
struct Action
property actions : Array(Action) = [] of Action
@content_index : Int32 = 0
@content_index : Array(Int32) = [] of Int32
@depth : Int32 = 0
@lexer_index : Int32 = 0
@lexer_name : String = ""
@ -67,7 +67,7 @@ module Tartrazine
}.map &.content
when ActionType::Usingbygroup
@lexer_index = xml["lexer"].to_i
@content_index = xml["content"].to_i
@content_index = xml["content"].split(",").map(&.to_i)
end
end
@ -143,8 +143,12 @@ module Tartrazine
when ActionType::Usingbygroup
# Shunt to content-specified lexer
return [] of Token if match.empty?
content = ""
@content_index.each do |i|
content += String.new(match[i].value)
end
Tartrazine.lexer(String.new(match[@lexer_index].value)).tokenizer(
String.new(match[@content_index].value),
content,
secondary: true).to_a
else
raise Exception.new("Unknown action type: #{@type}")

View File

@ -324,10 +324,13 @@ module Tartrazine
"reg" => "reg",
"registry" => "reg",
"rego" => "rego",
"rest" => "rst",
"restructuredtext" => "rst",
"rexx" => "rexx",
"rkt" => "racket",
"rpmspec" => "rpm_spec",
"rs" => "rust",
"rst" => "rst",
"ruby" => "ruby",
"rust" => "rust",
"s" => "r",
@ -395,7 +398,7 @@ module Tartrazine
"turing" => "turing",
"turtle" => "turtle",
"tv" => "tradingview",
"twig" => "TwigLexer",
"twig" => "twig",
"typescript" => "typescript",
"typoscript" => "typoscript",
"typoscriptcssdata" => "typoscriptcssdata",
@ -467,7 +470,7 @@ module Tartrazine
"application/x-fennel" => "fennel",
"application/x-fish" => "fish",
"application/x-forth" => "forth",
"application/x-gdscript" => "gdscript3",
"application/x-gdscript" => "gdscript",
"application/x-hcl" => "hcl",
"application/x-hy" => "hy",
"application/x-javascript" => "javascript",
@ -500,7 +503,7 @@ module Tartrazine
"application/x-thrift" => "thrift",
"application/x-troff" => "groff",
"application/x-turtle" => "turtle",
"application/x-twig" => "TwigLexer",
"application/x-twig" => "twig",
"application/x-vue" => "vue",
"application/x.ucode" => "ucode",
"application/xhtml+xml" => "html",
@ -527,6 +530,7 @@ module Tartrazine
"text/odin" => "odin",
"text/org" => "org_mode",
"text/plain" => "plaintext",
"text/prs.fallenstein.rst" => "rst",
"text/rust" => "rust",
"text/s" => "r",
"text/s-plus" => "r",
@ -589,7 +593,7 @@ module Tartrazine
"text/x-fortran" => "fortran",
"text/x-fsharp" => "fsharp",
"text/x-gas" => "gas",
"text/x-gdscript" => "gdscript3",
"text/x-gdscript" => "gdscript",
"text/x-gherkin" => "gherkin",
"text/x-gleam" => "gleam",
"text/x-glslsrc" => "glsl",
@ -657,6 +661,7 @@ module Tartrazine
"text/x-reasonml" => "reasonml",
"text/x-rexx" => "rexx",
"text/x-rpm-spec" => "rpm_spec",
"text/x-rst" => "rst",
"text/x-ruby" => "ruby",
"text/x-rust" => "rust",
"text/x-sas" => "sas",
@ -725,8 +730,8 @@ module Tartrazine
"*.applescript" => ["applescript"],
"*.aql" => ["arangodb_aql"],
"*.arexx" => ["rexx"],
"*.as" => ["actionscript", "actionscript_3"],
"*.asm" => ["nasm", "z80_assembly", "tasm"],
"*.as" => ["actionscript_3", "actionscript"],
"*.asm" => ["tasm", "nasm", "z80_assembly"],
"*.au3" => ["autoit"],
"*.automount" => ["systemd"],
"*.aux" => ["tex"],
@ -745,7 +750,7 @@ module Tartrazine
"*.bnf" => ["bnf"],
"*.bqn" => ["bqn"],
"*.bzl" => ["python"],
"*.c" => ["c", "c++"],
"*.c" => ["c++", "c"],
"*.c++" => ["c++"],
"*.capnp" => ["cap_n_proto"],
"*.cc" => ["c++"],
@ -844,7 +849,7 @@ module Tartrazine
"*.graphql" => ["graphql"],
"*.graphqls" => ["graphql"],
"*.groovy" => ["groovy"],
"*.h" => ["objective-c", "c", "c++"],
"*.h" => ["c++", "c", "objective-c"],
"*.h++" => ["c++"],
"*.ha" => ["hare"],
"*.handlebars" => ["handlebars"],
@ -852,7 +857,7 @@ module Tartrazine
"*.hc" => ["holyc"],
"*.hc.z" => ["holyc"],
"*.hcl" => ["hcl"],
"*.hh" => ["holyc", "c++"],
"*.hh" => ["c++", "holyc"],
"*.hlb" => ["hlb"],
"*.hlsl" => ["hlsl"],
"*.hlsli" => ["hlsl"],
@ -867,7 +872,7 @@ module Tartrazine
"*.idc" => ["c"],
"*.idr" => ["idris"],
"*.ijs" => ["j"],
"*.inc" => ["php", "sourcepawn", "objectpascal", "povray"],
"*.inc" => ["objectpascal", "povray", "php", "sourcepawn"],
"*.inf" => ["ini"],
"*.ini" => ["ini"],
"*.ino" => ["arduino"],
@ -893,7 +898,7 @@ module Tartrazine
"*.lpk" => ["objectpascal"],
"*.lpr" => ["objectpascal"],
"*.lua" => ["lua"],
"*.m" => ["mason", "mathematica", "matlab", "octave", "objective-c"],
"*.m" => ["mathematica", "octave", "matlab", "objective-c", "mason"],
"*.ma" => ["mathematica"],
"*.mak" => ["makefile"],
"*.man" => ["groff"],
@ -948,7 +953,7 @@ module Tartrazine
"*.php" => ["php"],
"*.php[345]" => ["php"],
"*.pig" => ["pig"],
"*.pl" => ["prolog", "perl"],
"*.pl" => ["perl", "prolog"],
"*.plc" => ["plutus_core"],
"*.plot" => ["gnuplot"],
"*.plt" => ["gnuplot"],
@ -956,7 +961,7 @@ module Tartrazine
"*.pml" => ["promela"],
"*.pony" => ["pony"],
"*.pov" => ["povray"],
"*.pp" => ["objectpascal", "puppet"],
"*.pp" => ["puppet", "objectpascal"],
"*.pq" => ["powerquery"],
"*.pr" => ["promela"],
"*.prm" => ["promela"],
@ -992,6 +997,7 @@ module Tartrazine
"*.reg" => ["reg"],
"*.rego" => ["rego"],
"*.rei" => ["reasonml"],
"*.rest" => ["rst"],
"*.rex" => ["rexx"],
"*.rexx" => ["rexx"],
"*.rkt" => ["racket"],
@ -1001,9 +1007,10 @@ module Tartrazine
"*.rs" => ["rust"],
"*.rs.in" => ["rust"],
"*.rss" => ["xml"],
"*.rst" => ["rst"],
"*.rvt" => ["tcl"],
"*.rx" => ["rexx"],
"*.s" => ["r", "armasm", "gas"],
"*.s" => ["armasm", "r", "gas"],
"*.sage" => ["python"],
"*.sas" => ["sas"],
"*.sass" => ["sass"],