rouge 3.0.0 → 3.18.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +17 -3
- data/bin/rougify +1 -0
- data/lib/rouge.rb +67 -42
- data/lib/rouge/cli.rb +87 -18
- data/lib/rouge/demos/ada +26 -0
- data/lib/rouge/demos/apex +9 -0
- data/lib/rouge/demos/armasm +12 -0
- data/lib/rouge/demos/batchfile +3 -0
- data/lib/rouge/demos/bbcbasic +6 -0
- data/lib/rouge/demos/bpf +7 -0
- data/lib/rouge/demos/brainfuck +5 -0
- data/lib/rouge/demos/clean +6 -0
- data/lib/rouge/demos/cmhg +8 -0
- data/lib/rouge/demos/crystal +45 -0
- data/lib/rouge/demos/csvs +8 -0
- data/lib/rouge/demos/cuda +11 -0
- data/lib/rouge/demos/cypher +5 -0
- data/lib/rouge/demos/cython +6 -0
- data/lib/rouge/demos/datastudio +21 -0
- data/lib/rouge/demos/ecl +18 -0
- data/lib/rouge/demos/eex +1 -0
- data/lib/rouge/demos/elm +4 -0
- data/lib/rouge/demos/epp +4 -0
- data/lib/rouge/demos/escape +3 -0
- data/lib/rouge/demos/freefem +16 -0
- data/lib/rouge/demos/gdscript +18 -0
- data/lib/rouge/demos/ghc-cmm +23 -0
- data/lib/rouge/demos/ghc-core +26 -0
- data/lib/rouge/demos/hack +5 -0
- data/lib/rouge/demos/haxe +5 -0
- data/lib/rouge/demos/hcl +7 -0
- data/lib/rouge/demos/hocon +8 -0
- data/lib/rouge/demos/hql +5 -0
- data/lib/rouge/demos/isbl +4 -0
- data/lib/rouge/demos/jsl +3 -0
- data/lib/rouge/demos/jsp +29 -0
- data/lib/rouge/demos/liquid +0 -1
- data/lib/rouge/demos/lustre +6 -0
- data/lib/rouge/demos/lutin +18 -0
- data/lib/rouge/demos/m68k +16 -0
- data/lib/rouge/demos/magik +6 -0
- data/lib/rouge/demos/mason +22 -0
- data/lib/rouge/demos/mathematica +8 -0
- data/lib/rouge/demos/minizinc +23 -0
- data/lib/rouge/demos/msgtrans +4 -0
- data/lib/rouge/demos/nasm +6 -6
- data/lib/rouge/demos/nesasm +11 -0
- data/lib/rouge/demos/objective_cpp +17 -0
- data/lib/rouge/demos/openedge +4 -0
- data/lib/rouge/demos/opentype_feature_file +6 -0
- data/lib/rouge/demos/plist +1 -132
- data/lib/rouge/demos/powershell +12 -48
- data/lib/rouge/demos/q +6 -0
- data/lib/rouge/demos/reasonml +12 -0
- data/lib/rouge/demos/rego +8 -0
- data/lib/rouge/demos/robot_framework +27 -0
- data/lib/rouge/demos/sas +13 -0
- data/lib/rouge/demos/slice +10 -0
- data/lib/rouge/demos/solidity +13 -0
- data/lib/rouge/demos/sparql +6 -0
- data/lib/rouge/demos/sqf +14 -0
- data/lib/rouge/demos/supercollider +11 -0
- data/lib/rouge/demos/terraform +16 -0
- data/lib/rouge/demos/ttcn3 +6 -0
- data/lib/rouge/demos/vcl +12 -0
- data/lib/rouge/demos/xojo +14 -0
- data/lib/rouge/demos/xpath +2 -0
- data/lib/rouge/demos/xquery +22 -0
- data/lib/rouge/demos/yang +17 -0
- data/lib/rouge/formatter.rb +39 -2
- data/lib/rouge/formatters/html.rb +21 -2
- data/lib/rouge/formatters/html_inline.rb +1 -0
- data/lib/rouge/formatters/html_legacy.rb +1 -0
- data/lib/rouge/formatters/html_line_table.rb +53 -0
- data/lib/rouge/formatters/html_linewise.rb +7 -11
- data/lib/rouge/formatters/html_pygments.rb +2 -0
- data/lib/rouge/formatters/html_table.rb +21 -31
- data/lib/rouge/formatters/null.rb +1 -0
- data/lib/rouge/formatters/terminal256.rb +23 -5
- data/lib/rouge/formatters/terminal_truecolor.rb +37 -0
- data/lib/rouge/formatters/tex.rb +92 -0
- data/lib/rouge/guesser.rb +2 -0
- data/lib/rouge/guessers/disambiguation.rb +48 -0
- data/lib/rouge/guessers/filename.rb +2 -0
- data/lib/rouge/guessers/glob_mapping.rb +3 -1
- data/lib/rouge/guessers/mimetype.rb +2 -0
- data/lib/rouge/guessers/modeline.rb +3 -1
- data/lib/rouge/guessers/source.rb +3 -1
- data/lib/rouge/guessers/util.rb +2 -0
- data/lib/rouge/lexer.rb +71 -15
- data/lib/rouge/lexers/abap.rb +13 -11
- data/lib/rouge/lexers/actionscript.rb +35 -34
- data/lib/rouge/lexers/ada.rb +162 -0
- data/lib/rouge/lexers/apache.rb +13 -15
- data/lib/rouge/lexers/apache/keywords.rb +15 -0
- data/lib/rouge/lexers/apex.rb +126 -0
- data/lib/rouge/lexers/apiblueprint.rb +2 -0
- data/lib/rouge/lexers/apple_script.rb +17 -14
- data/lib/rouge/lexers/armasm.rb +145 -0
- data/lib/rouge/lexers/awk.rb +26 -25
- data/lib/rouge/lexers/batchfile.rb +164 -0
- data/lib/rouge/lexers/bbcbasic.rb +112 -0
- data/lib/rouge/lexers/biml.rb +6 -4
- data/lib/rouge/lexers/bpf.rb +118 -0
- data/lib/rouge/lexers/brainfuck.rb +53 -0
- data/lib/rouge/lexers/bsl.rb +13 -12
- data/lib/rouge/lexers/c.rb +36 -58
- data/lib/rouge/lexers/ceylon.rb +7 -34
- data/lib/rouge/lexers/cfscript.rb +27 -26
- data/lib/rouge/lexers/clean.rb +156 -0
- data/lib/rouge/lexers/clojure.rb +15 -14
- data/lib/rouge/lexers/cmake.rb +16 -14
- data/lib/rouge/lexers/cmhg.rb +34 -0
- data/lib/rouge/lexers/coffeescript.rb +90 -49
- data/lib/rouge/lexers/common_lisp.rb +39 -38
- data/lib/rouge/lexers/conf.rb +7 -6
- data/lib/rouge/lexers/console.rb +92 -38
- data/lib/rouge/lexers/coq.rb +27 -23
- data/lib/rouge/lexers/cpp.rb +24 -13
- data/lib/rouge/lexers/crystal.rb +430 -0
- data/lib/rouge/lexers/csharp.rb +29 -29
- data/lib/rouge/lexers/css.rb +24 -23
- data/lib/rouge/lexers/csvs.rb +44 -0
- data/lib/rouge/lexers/cuda.rb +35 -0
- data/lib/rouge/lexers/cypher.rb +108 -0
- data/lib/rouge/lexers/cython.rb +151 -0
- data/lib/rouge/lexers/d.rb +64 -63
- data/lib/rouge/lexers/dart.rb +34 -33
- data/lib/rouge/lexers/datastudio.rb +138 -0
- data/lib/rouge/lexers/diff.rb +10 -4
- data/lib/rouge/lexers/digdag.rb +3 -1
- data/lib/rouge/lexers/docker.rb +12 -11
- data/lib/rouge/lexers/dot.rb +19 -18
- data/lib/rouge/lexers/ecl.rb +175 -0
- data/lib/rouge/lexers/eex.rb +52 -0
- data/lib/rouge/lexers/eiffel.rb +21 -20
- data/lib/rouge/lexers/elixir.rb +52 -36
- data/lib/rouge/lexers/elm.rb +90 -0
- data/lib/rouge/lexers/epp.rb +51 -0
- data/lib/rouge/lexers/erb.rb +5 -4
- data/lib/rouge/lexers/erlang.rb +1 -0
- data/lib/rouge/lexers/escape.rb +58 -0
- data/lib/rouge/lexers/factor.rb +41 -40
- data/lib/rouge/lexers/fortran.rb +36 -34
- data/lib/rouge/lexers/freefem.rb +240 -0
- data/lib/rouge/lexers/fsharp.rb +34 -32
- data/lib/rouge/lexers/gdscript.rb +171 -0
- data/lib/rouge/lexers/ghc_cmm.rb +340 -0
- data/lib/rouge/lexers/ghc_core.rb +151 -0
- data/lib/rouge/lexers/gherkin.rb +17 -14
- data/lib/rouge/lexers/gherkin/keywords.rb +2 -0
- data/lib/rouge/lexers/glsl.rb +2 -5
- data/lib/rouge/lexers/go.rb +3 -2
- data/lib/rouge/lexers/gradle.rb +1 -0
- data/lib/rouge/lexers/graphql.rb +78 -60
- data/lib/rouge/lexers/groovy.rb +24 -25
- data/lib/rouge/lexers/hack.rb +49 -0
- data/lib/rouge/lexers/haml.rb +26 -29
- data/lib/rouge/lexers/handlebars.rb +32 -20
- data/lib/rouge/lexers/haskell.rb +78 -62
- data/lib/rouge/lexers/haxe.rb +246 -0
- data/lib/rouge/lexers/hcl.rb +163 -0
- data/lib/rouge/lexers/hocon.rb +86 -0
- data/lib/rouge/lexers/hql.rb +139 -0
- data/lib/rouge/lexers/html.rb +36 -33
- data/lib/rouge/lexers/http.rb +10 -9
- data/lib/rouge/lexers/hylang.rb +15 -14
- data/lib/rouge/lexers/idlang.rb +34 -32
- data/lib/rouge/lexers/igorpro.rb +481 -225
- data/lib/rouge/lexers/ini.rb +13 -12
- data/lib/rouge/lexers/io.rb +10 -9
- data/lib/rouge/lexers/irb.rb +6 -5
- data/lib/rouge/lexers/isbl.rb +97 -0
- data/lib/rouge/lexers/isbl/builtins.rb +17 -0
- data/lib/rouge/lexers/java.rb +30 -26
- data/lib/rouge/lexers/javascript.rb +59 -61
- data/lib/rouge/lexers/jinja.rb +39 -22
- data/lib/rouge/lexers/jsl.rb +55 -0
- data/lib/rouge/lexers/json.rb +54 -11
- data/lib/rouge/lexers/json_doc.rb +8 -5
- data/lib/rouge/lexers/jsonnet.rb +19 -18
- data/lib/rouge/lexers/jsp.rb +120 -0
- data/lib/rouge/lexers/jsx.rb +18 -16
- data/lib/rouge/lexers/julia.rb +192 -74
- data/lib/rouge/lexers/kotlin.rb +79 -27
- data/lib/rouge/lexers/lasso.rb +54 -58
- data/lib/rouge/lexers/lasso/keywords.rb +14 -0
- data/lib/rouge/lexers/liquid.rb +116 -118
- data/lib/rouge/lexers/literate_coffeescript.rb +3 -2
- data/lib/rouge/lexers/literate_haskell.rb +6 -5
- data/lib/rouge/lexers/llvm.rb +66 -49
- data/lib/rouge/lexers/lua.rb +43 -4
- data/lib/rouge/lexers/lua/builtins.rb +2 -0
- data/lib/rouge/lexers/lustre.rb +79 -0
- data/lib/rouge/lexers/lutin.rb +33 -0
- data/lib/rouge/lexers/m68k.rb +143 -0
- data/lib/rouge/lexers/magik.rb +127 -0
- data/lib/rouge/lexers/make.rb +57 -34
- data/lib/rouge/lexers/markdown.rb +67 -39
- data/lib/rouge/lexers/mason.rb +110 -0
- data/lib/rouge/lexers/mathematica.rb +96 -0
- data/lib/rouge/lexers/mathematica/builtins.rb +13 -0
- data/lib/rouge/lexers/matlab.rb +26 -17
- data/lib/rouge/lexers/matlab/builtins.rb +4 -4
- data/lib/rouge/lexers/minizinc.rb +87 -0
- data/lib/rouge/lexers/moonscript.rb +4 -3
- data/lib/rouge/lexers/mosel.rb +64 -63
- data/lib/rouge/lexers/msgtrans.rb +26 -0
- data/lib/rouge/lexers/mxml.rb +19 -18
- data/lib/rouge/lexers/nasm.rb +43 -169
- data/lib/rouge/lexers/nesasm.rb +78 -0
- data/lib/rouge/lexers/nginx.rb +15 -14
- data/lib/rouge/lexers/nim.rb +4 -2
- data/lib/rouge/lexers/nix.rb +48 -42
- data/lib/rouge/lexers/objective_c.rb +5 -178
- data/lib/rouge/lexers/objective_c/common.rb +184 -0
- data/lib/rouge/lexers/objective_cpp.rb +31 -0
- data/lib/rouge/lexers/ocaml.rb +29 -64
- data/lib/rouge/lexers/ocaml/common.rb +53 -0
- data/lib/rouge/lexers/openedge.rb +429 -0
- data/lib/rouge/lexers/opentype_feature_file.rb +113 -0
- data/lib/rouge/lexers/pascal.rb +6 -5
- data/lib/rouge/lexers/perl.rb +103 -68
- data/lib/rouge/lexers/php.rb +94 -54
- data/lib/rouge/lexers/php/builtins.rb +183 -174
- data/lib/rouge/lexers/plain_text.rb +2 -1
- data/lib/rouge/lexers/plist.rb +16 -14
- data/lib/rouge/lexers/pony.rb +21 -20
- data/lib/rouge/lexers/powershell.rb +191 -639
- data/lib/rouge/lexers/praat.rb +76 -75
- data/lib/rouge/lexers/prolog.rb +27 -19
- data/lib/rouge/lexers/prometheus.rb +32 -30
- data/lib/rouge/lexers/properties.rb +13 -12
- data/lib/rouge/lexers/protobuf.rb +23 -22
- data/lib/rouge/lexers/puppet.rb +33 -32
- data/lib/rouge/lexers/python.rb +124 -98
- data/lib/rouge/lexers/q.rb +17 -14
- data/lib/rouge/lexers/qml.rb +13 -12
- data/lib/rouge/lexers/r.rb +13 -13
- data/lib/rouge/lexers/racket.rb +47 -22
- data/lib/rouge/lexers/reasonml.rb +65 -0
- data/lib/rouge/lexers/rego.rb +45 -0
- data/lib/rouge/lexers/robot_framework.rb +249 -0
- data/lib/rouge/lexers/ruby.rb +88 -71
- data/lib/rouge/lexers/rust.rb +47 -46
- data/lib/rouge/lexers/sas.rb +563 -0
- data/lib/rouge/lexers/sass.rb +11 -10
- data/lib/rouge/lexers/sass/common.rb +41 -40
- data/lib/rouge/lexers/scala.rb +67 -40
- data/lib/rouge/lexers/scheme.rb +19 -18
- data/lib/rouge/lexers/scss.rb +6 -5
- data/lib/rouge/lexers/sed.rb +31 -30
- data/lib/rouge/lexers/shell.rb +83 -62
- data/lib/rouge/lexers/sieve.rb +10 -9
- data/lib/rouge/lexers/slice.rb +32 -0
- data/lib/rouge/lexers/slim.rb +27 -26
- data/lib/rouge/lexers/smalltalk.rb +34 -33
- data/lib/rouge/lexers/smarty.rb +20 -19
- data/lib/rouge/lexers/sml.rb +68 -67
- data/lib/rouge/lexers/solidity.rb +185 -0
- data/lib/rouge/lexers/sparql.rb +129 -0
- data/lib/rouge/lexers/sqf.rb +109 -0
- data/lib/rouge/lexers/sqf/commands.rb +15 -0
- data/lib/rouge/lexers/sql.rb +47 -26
- data/lib/rouge/lexers/supercollider.rb +116 -0
- data/lib/rouge/lexers/swift.rb +63 -38
- data/lib/rouge/lexers/tap.rb +22 -20
- data/lib/rouge/lexers/tcl.rb +28 -27
- data/lib/rouge/lexers/terraform.rb +128 -0
- data/lib/rouge/lexers/tex.rb +20 -19
- data/lib/rouge/lexers/toml.rb +59 -20
- data/lib/rouge/lexers/tsx.rb +1 -0
- data/lib/rouge/lexers/ttcn3.rb +119 -0
- data/lib/rouge/lexers/tulip.rb +38 -36
- data/lib/rouge/lexers/turtle.rb +36 -38
- data/lib/rouge/lexers/twig.rb +1 -0
- data/lib/rouge/lexers/typescript.rb +12 -0
- data/lib/rouge/lexers/typescript/common.rb +1 -0
- data/lib/rouge/lexers/vala.rb +19 -18
- data/lib/rouge/lexers/varnish.rb +168 -0
- data/lib/rouge/lexers/vb.rb +28 -27
- data/lib/rouge/lexers/verilog.rb +27 -28
- data/lib/rouge/lexers/vhdl.rb +13 -12
- data/lib/rouge/lexers/viml.rb +15 -14
- data/lib/rouge/lexers/viml/keywords.rb +2 -0
- data/lib/rouge/lexers/vue.rb +19 -12
- data/lib/rouge/lexers/wollok.rb +27 -26
- data/lib/rouge/lexers/xml.rb +18 -21
- data/lib/rouge/lexers/xojo.rb +61 -0
- data/lib/rouge/lexers/xpath.rb +332 -0
- data/lib/rouge/lexers/xquery.rb +145 -0
- data/lib/rouge/lexers/yaml.rb +64 -61
- data/lib/rouge/lexers/yang.rb +147 -0
- data/lib/rouge/plugins/redcarpet.rb +9 -2
- data/lib/rouge/regex_lexer.rb +27 -25
- data/lib/rouge/template_lexer.rb +1 -0
- data/lib/rouge/tex_theme_renderer.rb +132 -0
- data/lib/rouge/text_analyzer.rb +1 -0
- data/lib/rouge/theme.rb +5 -0
- data/lib/rouge/themes/base16.rb +1 -0
- data/lib/rouge/themes/bw.rb +41 -0
- data/lib/rouge/themes/colorful.rb +1 -0
- data/lib/rouge/themes/github.rb +1 -0
- data/lib/rouge/themes/gruvbox.rb +1 -0
- data/lib/rouge/themes/igor_pro.rb +1 -0
- data/lib/rouge/themes/magritte.rb +78 -0
- data/lib/rouge/themes/molokai.rb +1 -0
- data/lib/rouge/themes/monokai.rb +1 -0
- data/lib/rouge/themes/monokai_sublime.rb +4 -1
- data/lib/rouge/themes/pastie.rb +2 -1
- data/lib/rouge/themes/thankful_eyes.rb +2 -1
- data/lib/rouge/themes/tulip.rb +2 -1
- data/lib/rouge/token.rb +31 -22
- data/lib/rouge/util.rb +3 -2
- data/lib/rouge/version.rb +2 -1
- data/rouge.gemspec +8 -1
- metadata +141 -7
- data/lib/rouge/lexers/apache/keywords.yml +0 -764
- data/lib/rouge/lexers/lasso/keywords.yml +0 -446
data/lib/rouge/lexers/ruby.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Rouge
|
4
5
|
module Lexers
|
@@ -9,7 +10,8 @@ module Rouge
|
|
9
10
|
aliases 'rb'
|
10
11
|
filenames '*.rb', '*.ruby', '*.rbw', '*.rake', '*.gemspec', '*.podspec',
|
11
12
|
'Rakefile', 'Guardfile', 'Gemfile', 'Capfile', 'Podfile',
|
12
|
-
'Vagrantfile', '*.ru', '*.prawn', 'Berksfile'
|
13
|
+
'Vagrantfile', '*.ru', '*.prawn', 'Berksfile', '*.arb',
|
14
|
+
'Dangerfile', 'Fastfile', 'Deliverfile', 'Appfile'
|
13
15
|
|
14
16
|
mimetypes 'text/x-ruby', 'application/x-ruby'
|
15
17
|
|
@@ -29,15 +31,15 @@ module Rouge
|
|
29
31
|
rule %r(:(?:\*\*|[-+]@|[/\%&\|^`~]|\[\]=?|<<|>>|<=?>|<=?|===?)),
|
30
32
|
Str::Symbol
|
31
33
|
|
32
|
-
rule /:'(\\\\|\\'|[^'])*'/, Str::Symbol
|
33
|
-
rule /:"/, Str::Symbol, :simple_sym
|
34
|
+
rule %r/:'(\\\\|\\'|[^'])*'/, Str::Symbol
|
35
|
+
rule %r/:"/, Str::Symbol, :simple_sym
|
34
36
|
end
|
35
37
|
|
36
38
|
state :sigil_strings do
|
37
39
|
# %-sigiled strings
|
38
40
|
# %(abc), %[abc], %<abc>, %.abc., %r.abc., etc
|
39
41
|
delimiter_map = { '{' => '}', '[' => ']', '(' => ')', '<' => '>' }
|
40
|
-
rule /%([rqswQWxiI])?([^\w\s])/ do |m|
|
42
|
+
rule %r/%([rqswQWxiI])?([^\w\s])/ do |m|
|
41
43
|
open = Regexp.escape(m[2])
|
42
44
|
close = Regexp.escape(delimiter_map[m[2]] || m[2])
|
43
45
|
interp = /[rQWxI]/ === m[1]
|
@@ -55,38 +57,40 @@ module Rouge
|
|
55
57
|
token toktype
|
56
58
|
|
57
59
|
push do
|
58
|
-
|
60
|
+
uniq_chars = "#{open}#{close}".squeeze
|
61
|
+
uniq_chars = '' if open == close && open == "\\#"
|
62
|
+
rule %r/\\[##{uniq_chars}\\]/, Str::Escape
|
59
63
|
# nesting rules only with asymmetric delimiters
|
60
64
|
if open != close
|
61
|
-
rule /#{open}/ do
|
65
|
+
rule %r/#{open}/ do
|
62
66
|
token toktype
|
63
67
|
push
|
64
68
|
end
|
65
69
|
end
|
66
|
-
rule /#{close}/, toktype, :pop!
|
70
|
+
rule %r/#{close}/, toktype, :pop!
|
67
71
|
|
68
72
|
if interp
|
69
73
|
mixin :string_intp_escaped
|
70
|
-
rule /#/, toktype
|
74
|
+
rule %r/#/, toktype
|
71
75
|
else
|
72
|
-
rule /[\\#]/, toktype
|
76
|
+
rule %r/[\\#]/, toktype
|
73
77
|
end
|
74
78
|
|
75
|
-
rule /[^##{
|
79
|
+
rule %r/[^##{uniq_chars}\\]+/m, toktype
|
76
80
|
end
|
77
81
|
end
|
78
82
|
end
|
79
83
|
|
80
84
|
state :strings do
|
81
85
|
mixin :symbols
|
82
|
-
rule /\b[a-z_]\w*?[?!]?:\s+/, Str::Symbol, :expr_start
|
83
|
-
rule /'(\\\\|\\'|[^'])*'/, Str::Single
|
84
|
-
rule /"/, Str::Double, :simple_string
|
85
|
-
rule /(?<!\.)`/, Str::Backtick, :simple_backtick
|
86
|
+
rule %r/\b[a-z_]\w*?[?!]?:\s+/, Str::Symbol, :expr_start
|
87
|
+
rule %r/'(\\\\|\\'|[^'])*'/, Str::Single
|
88
|
+
rule %r/"/, Str::Double, :simple_string
|
89
|
+
rule %r/(?<!\.)`/, Str::Backtick, :simple_backtick
|
86
90
|
end
|
87
91
|
|
88
92
|
state :regex_flags do
|
89
|
-
rule /[mixounse]*/, Str::Regex, :pop!
|
93
|
+
rule %r/[mixounse]*/, Str::Regex, :pop!
|
90
94
|
end
|
91
95
|
|
92
96
|
# double-quoted string and symbol
|
@@ -95,9 +99,9 @@ module Rouge
|
|
95
99
|
[:backtick, Str::Backtick, '`']].each do |name, tok, fin|
|
96
100
|
state :"simple_#{name}" do
|
97
101
|
mixin :string_intp_escaped
|
98
|
-
rule /[^\\#{fin}#]+/m, tok
|
99
|
-
rule /[\\#]/, tok
|
100
|
-
rule /#{fin}/, tok, :pop!
|
102
|
+
rule %r/[^\\#{fin}#]+/m, tok
|
103
|
+
rule %r/[\\#]/, tok
|
104
|
+
rule %r/#{fin}/, tok, :pop!
|
101
105
|
end
|
102
106
|
end
|
103
107
|
|
@@ -149,38 +153,41 @@ module Rouge
|
|
149
153
|
|
150
154
|
state :whitespace do
|
151
155
|
mixin :inline_whitespace
|
152
|
-
rule /\n\s*/m, Text, :expr_start
|
153
|
-
rule /#.*$/, Comment::Single
|
156
|
+
rule %r/\n\s*/m, Text, :expr_start
|
157
|
+
rule %r/#.*$/, Comment::Single
|
154
158
|
|
155
159
|
rule %r(=begin\b.*?\n=end\b)m, Comment::Multiline
|
156
160
|
end
|
157
161
|
|
158
162
|
state :inline_whitespace do
|
159
|
-
rule /[ \t\r]+/, Text
|
163
|
+
rule %r/[ \t\r]+/, Text
|
160
164
|
end
|
161
165
|
|
162
166
|
state :root do
|
163
167
|
mixin :whitespace
|
164
|
-
rule /__END__/, Comment::Preproc, :end_part
|
168
|
+
rule %r/__END__/, Comment::Preproc, :end_part
|
165
169
|
|
166
|
-
rule /0_?[0-7]+(?:_[0-7]+)*/, Num::Oct
|
167
|
-
rule /0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/, Num::Hex
|
168
|
-
rule /0b[01]+(?:_[01]+)*/, Num::Bin
|
169
|
-
|
170
|
-
|
170
|
+
rule %r/0_?[0-7]+(?:_[0-7]+)*/, Num::Oct
|
171
|
+
rule %r/0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/, Num::Hex
|
172
|
+
rule %r/0b[01]+(?:_[01]+)*/, Num::Bin
|
173
|
+
|
174
|
+
decimal = %r/[\d]+(?:_\d+)*/
|
175
|
+
exp = %r/e[+-]?\d+/i
|
176
|
+
rule %r/#{decimal}(?:\.#{decimal}#{exp}?|#{exp})/, Num::Float
|
177
|
+
rule decimal, Num::Integer
|
171
178
|
|
172
179
|
# names
|
173
|
-
rule /@@[a-z_]\w*/i, Name::Variable::Class
|
174
|
-
rule /@[a-z_]\w*/i, Name::Variable::Instance
|
175
|
-
rule /\$\w+/, Name::Variable::Global
|
180
|
+
rule %r/@@[a-z_]\w*/i, Name::Variable::Class
|
181
|
+
rule %r/@[a-z_]\w*/i, Name::Variable::Instance
|
182
|
+
rule %r/\$\w+/, Name::Variable::Global
|
176
183
|
rule %r(\$[!@&`'+~=/\\,;.<>_*\$?:"]), Name::Variable::Global
|
177
|
-
rule /\$-[0adFiIlpvw]/, Name::Variable::Global
|
178
|
-
rule /::/, Operator
|
184
|
+
rule %r/\$-[0adFiIlpvw]/, Name::Variable::Global
|
185
|
+
rule %r/::/, Operator
|
179
186
|
|
180
187
|
mixin :strings
|
181
188
|
|
182
|
-
rule /(?:#{keywords.join('|')})
|
183
|
-
rule /(?:#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo, :expr_start
|
189
|
+
rule %r/(?:#{keywords.join('|')})(?=\W|$)/, Keyword, :expr_start
|
190
|
+
rule %r/(?:#{keywords_pseudo.join('|')})\b/, Keyword::Pseudo, :expr_start
|
184
191
|
|
185
192
|
rule %r(
|
186
193
|
(module)
|
@@ -190,52 +197,52 @@ module Rouge
|
|
190
197
|
groups Keyword, Text, Name::Namespace
|
191
198
|
end
|
192
199
|
|
193
|
-
rule /(def\b)(\s*)/ do
|
200
|
+
rule %r/(def\b)(\s*)/ do
|
194
201
|
groups Keyword, Text
|
195
202
|
push :funcname
|
196
203
|
end
|
197
204
|
|
198
|
-
rule /(class\b)(\s*)/ do
|
205
|
+
rule %r/(class\b)(\s*)/ do
|
199
206
|
groups Keyword, Text
|
200
207
|
push :classname
|
201
208
|
end
|
202
209
|
|
203
|
-
rule /(?:#{builtins_q.join('|')})[?]/, Name::Builtin, :expr_start
|
204
|
-
rule /(?:#{builtins_b.join('|')})!/, Name::Builtin, :expr_start
|
205
|
-
rule /(?<!\.)(?:#{builtins_g.join('|')})\b/,
|
210
|
+
rule %r/(?:#{builtins_q.join('|')})[?]/, Name::Builtin, :expr_start
|
211
|
+
rule %r/(?:#{builtins_b.join('|')})!/, Name::Builtin, :expr_start
|
212
|
+
rule %r/(?<!\.)(?:#{builtins_g.join('|')})\b/,
|
206
213
|
Name::Builtin, :method_call
|
207
214
|
|
208
215
|
mixin :has_heredocs
|
209
216
|
|
210
217
|
# `..` and `...` for ranges must have higher priority than `.`
|
211
218
|
# Otherwise, they will be parsed as :method_call
|
212
|
-
rule /\.{2,3}/, Operator, :expr_start
|
219
|
+
rule %r/\.{2,3}/, Operator, :expr_start
|
213
220
|
|
214
|
-
rule /[A-Z][a-zA-Z0-9_]*/, Name::Constant, :method_call
|
215
|
-
rule /(\.|::)(\s*)([a-z_]\w*[!?]?|[*%&^`~+-\/\[<>=])/ do
|
221
|
+
rule %r/[A-Z][a-zA-Z0-9_]*/, Name::Constant, :method_call
|
222
|
+
rule %r/(\.|::)(\s*)([a-z_]\w*[!?]?|[*%&^`~+-\/\[<>=])/ do
|
216
223
|
groups Punctuation, Text, Name::Function
|
217
224
|
push :method_call
|
218
225
|
end
|
219
226
|
|
220
|
-
rule /[a-zA-Z_]\w*[?!]/, Name, :expr_start
|
221
|
-
rule /[a-zA-Z_]\w*/, Name, :method_call
|
222
|
-
rule /\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|!~|&&?|\|\||\./,
|
227
|
+
rule %r/[a-zA-Z_]\w*[?!]/, Name, :expr_start
|
228
|
+
rule %r/[a-zA-Z_]\w*/, Name, :method_call
|
229
|
+
rule %r/\*\*|<<?|>>?|>=|<=|<=>|=~|={3}|!~|&&?|\|\||\./,
|
223
230
|
Operator, :expr_start
|
224
|
-
rule /[-+\/*%=<>&!^|~]=?/, Operator, :expr_start
|
231
|
+
rule %r/[-+\/*%=<>&!^|~]=?/, Operator, :expr_start
|
225
232
|
rule(/[?]/) { token Punctuation; push :ternary; push :expr_start }
|
226
233
|
rule %r<[\[({,:\\;/]>, Punctuation, :expr_start
|
227
234
|
rule %r<[\])}]>, Punctuation
|
228
235
|
end
|
229
236
|
|
230
237
|
state :has_heredocs do
|
231
|
-
rule /(?<!\w)(<<[-~]?)(["`']?)([a-zA-Z_]\w*)(\2)/ do |m|
|
238
|
+
rule %r/(?<!\w)(<<[-~]?)(["`']?)([a-zA-Z_]\w*)(\2)/ do |m|
|
232
239
|
token Operator, m[1]
|
233
240
|
token Name::Constant, "#{m[2]}#{m[3]}#{m[4]}"
|
234
241
|
@heredoc_queue << [['<<-', '<<~'].include?(m[1]), m[3]]
|
235
242
|
push :heredoc_queue unless state? :heredoc_queue
|
236
243
|
end
|
237
244
|
|
238
|
-
rule /(<<[-~]?)(["'])(\2)/ do |m|
|
245
|
+
rule %r/(<<[-~]?)(["'])(\2)/ do |m|
|
239
246
|
token Operator, m[1]
|
240
247
|
token Name::Constant, "#{m[2]}#{m[3]}#{m[4]}"
|
241
248
|
@heredoc_queue << [['<<-', '<<~'].include?(m[1]), '']
|
@@ -244,7 +251,7 @@ module Rouge
|
|
244
251
|
end
|
245
252
|
|
246
253
|
state :heredoc_queue do
|
247
|
-
rule /(?=\n)/ do
|
254
|
+
rule %r/(?=\n)/ do
|
248
255
|
goto :resolve_heredocs
|
249
256
|
end
|
250
257
|
|
@@ -254,13 +261,13 @@ module Rouge
|
|
254
261
|
state :resolve_heredocs do
|
255
262
|
mixin :string_intp_escaped
|
256
263
|
|
257
|
-
rule /\n/, Str::Heredoc, :test_heredoc
|
258
|
-
rule /[#\\\n]/, Str::Heredoc
|
259
|
-
rule /[^#\\\n]+/, Str::Heredoc
|
264
|
+
rule %r/\n/, Str::Heredoc, :test_heredoc
|
265
|
+
rule %r/[#\\\n]/, Str::Heredoc
|
266
|
+
rule %r/[^#\\\n]+/, Str::Heredoc
|
260
267
|
end
|
261
268
|
|
262
269
|
state :test_heredoc do
|
263
|
-
rule /[^#\\\n]*$/ do |m|
|
270
|
+
rule %r/[^#\\\n]*$/ do |m|
|
264
271
|
tolerant, heredoc_name = @heredoc_queue.first
|
265
272
|
check = tolerant ? m[0].strip : m[0].rstrip
|
266
273
|
|
@@ -282,12 +289,12 @@ module Rouge
|
|
282
289
|
end
|
283
290
|
|
284
291
|
state :funcname do
|
285
|
-
rule /\s+/, Text
|
286
|
-
rule /\(/, Punctuation, :defexpr
|
292
|
+
rule %r/\s+/, Text
|
293
|
+
rule %r/\(/, Punctuation, :defexpr
|
287
294
|
rule %r(
|
288
|
-
(?:([a-zA-Z_]
|
295
|
+
(?:([a-zA-Z_]\w*)(\.))?
|
289
296
|
(
|
290
|
-
[a-zA-Z_]
|
297
|
+
[a-zA-Z_]\w*[!?]? |
|
291
298
|
\*\*? | [-+]@? | [/%&\|^`~] | \[\]=? |
|
292
299
|
<<? | >>? | <=>? | >= | ===?
|
293
300
|
)
|
@@ -301,36 +308,46 @@ module Rouge
|
|
301
308
|
end
|
302
309
|
|
303
310
|
state :classname do
|
304
|
-
rule /\s+/, Text
|
305
|
-
rule /\(
|
311
|
+
rule %r/\s+/, Text
|
312
|
+
rule %r/\w+(::\w+)+/, Name::Class
|
313
|
+
|
314
|
+
rule %r/\(/ do
|
306
315
|
token Punctuation
|
307
316
|
push :defexpr
|
308
317
|
push :expr_start
|
309
318
|
end
|
310
319
|
|
311
320
|
# class << expr
|
312
|
-
rule /<</ do
|
321
|
+
rule %r/<</ do
|
313
322
|
token Operator
|
314
323
|
goto :expr_start
|
315
324
|
end
|
316
325
|
|
317
|
-
rule /[A-Z_]\w*/, Name::Class, :pop!
|
326
|
+
rule %r/[A-Z_]\w*/, Name::Class, :pop!
|
318
327
|
|
319
328
|
rule(//) { pop! }
|
320
329
|
end
|
321
330
|
|
322
331
|
state :ternary do
|
323
|
-
rule(
|
332
|
+
rule %r/(:)(\s+)/ do
|
333
|
+
groups Punctuation, Text
|
334
|
+
goto :expr_start
|
335
|
+
end
|
336
|
+
|
337
|
+
rule %r/:(?![^#\n]*?[:\\])/ do
|
338
|
+
token Punctuation
|
339
|
+
goto :expr_start
|
340
|
+
end
|
324
341
|
|
325
342
|
mixin :root
|
326
343
|
end
|
327
344
|
|
328
345
|
state :defexpr do
|
329
|
-
rule /(\))(\.|::)?/ do
|
346
|
+
rule %r/(\))(\.|::)?/ do
|
330
347
|
groups Punctuation, Operator
|
331
348
|
pop!
|
332
349
|
end
|
333
|
-
rule /\(/ do
|
350
|
+
rule %r/\(/ do
|
334
351
|
token Punctuation
|
335
352
|
push :defexpr
|
336
353
|
push :expr_start
|
@@ -340,20 +357,20 @@ module Rouge
|
|
340
357
|
end
|
341
358
|
|
342
359
|
state :in_interp do
|
343
|
-
rule /}/, Str::Interpol, :pop!
|
360
|
+
rule %r/}/, Str::Interpol, :pop!
|
344
361
|
mixin :root
|
345
362
|
end
|
346
363
|
|
347
364
|
state :string_intp do
|
348
|
-
rule /[#][{]/, Str::Interpol, :in_interp
|
349
|
-
rule /#(@@?|\$)[a-z_]\w*/i, Str::Interpol
|
365
|
+
rule %r/[#][{]/, Str::Interpol, :in_interp
|
366
|
+
rule %r/#(@@?|\$)[a-z_]\w*/i, Str::Interpol
|
350
367
|
end
|
351
368
|
|
352
369
|
state :string_intp_escaped do
|
353
370
|
mixin :string_intp
|
354
|
-
rule /\\([\\abefnrstv#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})/,
|
371
|
+
rule %r/\\([\\abefnrstv#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})/,
|
355
372
|
Str::Escape
|
356
|
-
rule /\\./, Str::Escape
|
373
|
+
rule %r/\\./, Str::Escape
|
357
374
|
end
|
358
375
|
|
359
376
|
state :method_call do
|
@@ -406,7 +423,7 @@ module Rouge
|
|
406
423
|
|
407
424
|
# special case for using a single space. Ruby demands that
|
408
425
|
# these be in a single line, otherwise it would make no sense.
|
409
|
-
rule /(\s*)(%[rqswQWxiI]? \S* )/ do
|
426
|
+
rule %r/(\s*)(%[rqswQWxiI]? \S* )/ do
|
410
427
|
groups Text, Str::Other
|
411
428
|
pop!
|
412
429
|
end
|
@@ -430,7 +447,7 @@ module Rouge
|
|
430
447
|
|
431
448
|
state :end_part do
|
432
449
|
# eat up the rest of the stream as Comment::Preproc
|
433
|
-
rule /.+/m, Comment::Preproc, :pop!
|
450
|
+
rule %r/.+/m, Comment::Preproc, :pop!
|
434
451
|
end
|
435
452
|
end
|
436
453
|
end
|
data/lib/rouge/lexers/rust.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# -*- coding: utf-8 -*- #
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
module Rouge
|
4
5
|
module Lexers
|
@@ -6,7 +7,12 @@ module Rouge
|
|
6
7
|
title "Rust"
|
7
8
|
desc 'The Rust programming language (rust-lang.org)'
|
8
9
|
tag 'rust'
|
9
|
-
aliases 'rs'
|
10
|
+
aliases 'rs',
|
11
|
+
# So that directives from https://github.com/budziq/rust-skeptic
|
12
|
+
# do not prevent highlighting.
|
13
|
+
'rust,no_run', 'rs,no_run',
|
14
|
+
'rust,ignore', 'rs,ignore',
|
15
|
+
'rust,should_panic', 'rs,should_panic'
|
10
16
|
filenames '*.rs'
|
11
17
|
mimetypes 'text/x-rust'
|
12
18
|
|
@@ -16,10 +22,10 @@ module Rouge
|
|
16
22
|
|
17
23
|
def self.keywords
|
18
24
|
@keywords ||= %w(
|
19
|
-
as assert break const copy do drop else enum extern fail false
|
25
|
+
as assert async await break const copy do drop else enum extern fail false
|
20
26
|
fn for if impl let log loop match mod move mut priv pub pure
|
21
|
-
ref return self static struct true trait type unsafe use
|
22
|
-
box
|
27
|
+
ref return self static struct true trait type unsafe use where
|
28
|
+
while box
|
23
29
|
)
|
24
30
|
end
|
25
31
|
|
@@ -43,6 +49,7 @@ module Rouge
|
|
43
49
|
|
44
50
|
start {
|
45
51
|
@macro_delims = { ']' => 0, ')' => 0, '}' => 0 }
|
52
|
+
push :bol
|
46
53
|
}
|
47
54
|
|
48
55
|
delim_map = { '[' => ']', '(' => ')', '{' => '}' }
|
@@ -50,57 +57,59 @@ module Rouge
|
|
50
57
|
id = /[a-z_]\w*/i
|
51
58
|
hex = /[0-9a-f]/i
|
52
59
|
escapes = %r(
|
53
|
-
\\ ([nrt'\\] | x#{hex}{2} | u#{hex}{4} | U#{hex}{8})
|
60
|
+
\\ ([nrt'"\\0] | x#{hex}{2} | u#{hex}{4} | U#{hex}{8})
|
54
61
|
)x
|
55
62
|
size = /8|16|32|64/
|
56
63
|
|
57
|
-
|
64
|
+
# Although not officially part of Rust, the rustdoc tool allows code in
|
65
|
+
# comments to begin with `#`. Code like this will be evaluated but not
|
66
|
+
# included in the HTML output produced by rustdoc. So that code intended
|
67
|
+
# for these comments can be higlighted with Rouge, the Rust lexer needs
|
68
|
+
# to check if the beginning of the line begins with a `# `.
|
69
|
+
state :bol do
|
58
70
|
mixin :whitespace
|
59
|
-
rule
|
60
|
-
rule /#\[/ do
|
61
|
-
token Name::Decorator; push :attribute
|
62
|
-
end
|
71
|
+
rule %r/#\s[^\n]*/, Comment::Special
|
63
72
|
rule(//) { pop! }
|
64
|
-
rule /#\s[^\n]*/, Comment::Preproc
|
65
73
|
end
|
66
74
|
|
67
75
|
state :attribute do
|
68
76
|
mixin :whitespace
|
69
77
|
mixin :has_literals
|
70
|
-
rule /[(,)
|
71
|
-
rule /\]/, Name::Decorator, :pop!
|
78
|
+
rule %r/[(,)=:]/, Name::Decorator
|
79
|
+
rule %r/\]/, Name::Decorator, :pop!
|
72
80
|
rule id, Name::Decorator
|
73
81
|
end
|
74
82
|
|
75
83
|
state :whitespace do
|
76
|
-
rule /\s+/, Text
|
84
|
+
rule %r/\s+/, Text
|
77
85
|
rule %r(//[^\n]*), Comment
|
78
86
|
rule %r(/[*].*?[*]/)m, Comment::Multiline
|
79
87
|
end
|
80
88
|
|
81
89
|
state :root do
|
82
|
-
rule /\n/, Text, :
|
90
|
+
rule %r/\n/, Text, :bol
|
83
91
|
mixin :whitespace
|
84
|
-
rule
|
92
|
+
rule %r/#!?\[/, Name::Decorator, :attribute
|
93
|
+
rule %r/\b(?:#{Rust.keywords.join('|')})\b/, Keyword
|
85
94
|
mixin :has_literals
|
86
95
|
|
87
96
|
rule %r([=-]>), Keyword
|
88
97
|
rule %r(<->), Keyword
|
89
|
-
rule /[()\[\]{}|,:;]/, Punctuation
|
90
|
-
rule /[
|
98
|
+
rule %r/[()\[\]{}|,:;]/, Punctuation
|
99
|
+
rule %r/[*\/!@~&+%^<>=\?-]|\.{2,3}/, Operator
|
91
100
|
|
92
|
-
rule /([.]\s*)?#{id}(?=\s*[(])/m, Name::Function
|
93
|
-
rule /[.]\s*#{id}/, Name::Property
|
94
|
-
rule /(#{id})(::)/m do
|
101
|
+
rule %r/([.]\s*)?#{id}(?=\s*[(])/m, Name::Function
|
102
|
+
rule %r/[.]\s*#{id}/, Name::Property
|
103
|
+
rule %r/(#{id})(::)/m do
|
95
104
|
groups Name::Namespace, Punctuation
|
96
105
|
end
|
97
106
|
|
98
107
|
# macros
|
99
|
-
rule /\bmacro_rules!/, Name::Decorator, :macro_rules
|
100
|
-
rule /#{id}!/, Name::Decorator, :macro
|
108
|
+
rule %r/\bmacro_rules!/, Name::Decorator, :macro_rules
|
109
|
+
rule %r/#{id}!/, Name::Decorator, :macro
|
101
110
|
|
102
|
-
rule /'#{id}/, Name::Variable
|
103
|
-
rule /#{id}/ do |m|
|
111
|
+
rule %r/'#{id}/, Name::Variable
|
112
|
+
rule %r/#{id}/ do |m|
|
104
113
|
name = m[0]
|
105
114
|
if self.class.builtins.include? name
|
106
115
|
token Name::Builtin
|
@@ -113,13 +122,13 @@ module Rouge
|
|
113
122
|
state :macro do
|
114
123
|
mixin :has_literals
|
115
124
|
|
116
|
-
rule /[\[{(]/ do |m|
|
125
|
+
rule %r/[\[{(]/ do |m|
|
117
126
|
@macro_delims[delim_map[m[0]]] += 1
|
118
127
|
puts " macro_delims: #{@macro_delims.inspect}" if @debug
|
119
128
|
token Punctuation
|
120
129
|
end
|
121
130
|
|
122
|
-
rule /[\]})]/ do |m|
|
131
|
+
rule %r/[\]})]/ do |m|
|
123
132
|
@macro_delims[m[0]] -= 1
|
124
133
|
puts " macro_delims: #{@macro_delims.inspect}" if @debug
|
125
134
|
pop! if macro_closed?
|
@@ -127,29 +136,30 @@ module Rouge
|
|
127
136
|
end
|
128
137
|
|
129
138
|
# same as the rule in root, but don't push another macro state
|
130
|
-
rule /#{id}!/, Name::Decorator
|
139
|
+
rule %r/#{id}!/, Name::Decorator
|
131
140
|
mixin :root
|
132
141
|
|
133
142
|
# No syntax errors in macros
|
134
|
-
rule /./, Text
|
143
|
+
rule %r/./, Text
|
135
144
|
end
|
136
145
|
|
137
146
|
state :macro_rules do
|
138
|
-
rule /[$]#{id}(:#{id})?/, Name::Variable
|
139
|
-
rule /[$]/, Name::Variable
|
147
|
+
rule %r/[$]#{id}(:#{id})?/, Name::Variable
|
148
|
+
rule %r/[$]/, Name::Variable
|
140
149
|
|
141
150
|
mixin :macro
|
142
151
|
end
|
143
152
|
|
144
153
|
state :has_literals do
|
145
154
|
# constants
|
146
|
-
rule /\b(?:true|false|nil)\b/, Keyword::Constant
|
155
|
+
rule %r/\b(?:true|false|nil)\b/, Keyword::Constant
|
147
156
|
# characters
|
148
157
|
rule %r(
|
149
158
|
' (?: #{escapes} | [^\\] ) '
|
150
159
|
)x, Str::Char
|
151
160
|
|
152
|
-
rule /"/, Str, :string
|
161
|
+
rule %r/"/, Str, :string
|
162
|
+
rule %r/r(#*)".*?"\1/m, Str
|
153
163
|
|
154
164
|
# numbers
|
155
165
|
dot = /[.][0-9_]+/
|
@@ -166,26 +176,17 @@ module Rouge
|
|
166
176
|
|
167
177
|
rule %r(
|
168
178
|
( 0b[10_]+
|
169
|
-
| 0x[0-9a-fA-
|
170
|
-
| [0-
|
179
|
+
| 0x[0-9a-fA-F_]+
|
180
|
+
| [0-9_]+
|
171
181
|
) (u#{size}?|i#{size})?
|
172
182
|
)x, Num::Integer
|
173
183
|
|
174
184
|
end
|
175
185
|
|
176
186
|
state :string do
|
177
|
-
rule /"/, Str, :pop!
|
187
|
+
rule %r/"/, Str, :pop!
|
178
188
|
rule escapes, Str::Escape
|
179
|
-
rule
|
180
|
-
rule %r(
|
181
|
-
%
|
182
|
-
( [0-9]+ [$] )? # Parameter
|
183
|
-
[0#+-]* # Flag
|
184
|
-
( [0-9]+ [$]? )? # Width
|
185
|
-
( [.] [0-9]+ )? # Precision
|
186
|
-
[bcdfiostuxX?] # Type
|
187
|
-
)x, Str::Interpol
|
188
|
-
rule /[^%"\\]+/m, Str
|
189
|
+
rule %r/[^"\\]+/m, Str
|
189
190
|
end
|
190
191
|
end
|
191
192
|
end
|