rouge 3.4.1 → 3.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (151) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rouge.rb +3 -0
  3. data/lib/rouge/cli.rb +19 -2
  4. data/lib/rouge/demos/bpf +7 -0
  5. data/lib/rouge/demos/brainfuck +5 -0
  6. data/lib/rouge/demos/magik +6 -0
  7. data/lib/rouge/formatter.rb +2 -2
  8. data/lib/rouge/formatters/tex.rb +90 -0
  9. data/lib/rouge/guessers/glob_mapping.rb +1 -1
  10. data/lib/rouge/lexer.rb +22 -10
  11. data/lib/rouge/lexers/abap.rb +11 -11
  12. data/lib/rouge/lexers/actionscript.rb +34 -34
  13. data/lib/rouge/lexers/apache.rb +8 -8
  14. data/lib/rouge/lexers/apple_script.rb +15 -14
  15. data/lib/rouge/lexers/awk.rb +25 -25
  16. data/lib/rouge/lexers/biml.rb +4 -4
  17. data/lib/rouge/lexers/bpf.rb +104 -0
  18. data/lib/rouge/lexers/brainfuck.rb +53 -0
  19. data/lib/rouge/lexers/bsl.rb +12 -12
  20. data/lib/rouge/lexers/c.rb +30 -30
  21. data/lib/rouge/lexers/ceylon.rb +1 -29
  22. data/lib/rouge/lexers/cfscript.rb +26 -26
  23. data/lib/rouge/lexers/clojure.rb +14 -14
  24. data/lib/rouge/lexers/cmake.rb +14 -14
  25. data/lib/rouge/lexers/coffeescript.rb +30 -30
  26. data/lib/rouge/lexers/common_lisp.rb +36 -36
  27. data/lib/rouge/lexers/conf.rb +6 -6
  28. data/lib/rouge/lexers/coq.rb +18 -18
  29. data/lib/rouge/lexers/cpp.rb +8 -8
  30. data/lib/rouge/lexers/crystal.rb +70 -70
  31. data/lib/rouge/lexers/csharp.rb +28 -28
  32. data/lib/rouge/lexers/css.rb +23 -23
  33. data/lib/rouge/lexers/d.rb +59 -59
  34. data/lib/rouge/lexers/dart.rb +33 -33
  35. data/lib/rouge/lexers/digdag.rb +1 -1
  36. data/lib/rouge/lexers/docker.rb +10 -10
  37. data/lib/rouge/lexers/dot.rb +16 -16
  38. data/lib/rouge/lexers/eiffel.rb +20 -20
  39. data/lib/rouge/lexers/elixir.rb +29 -28
  40. data/lib/rouge/lexers/elm.rb +29 -29
  41. data/lib/rouge/lexers/erb.rb +4 -4
  42. data/lib/rouge/lexers/factor.rb +40 -40
  43. data/lib/rouge/lexers/fortran.rb +32 -32
  44. data/lib/rouge/lexers/fsharp.rb +26 -26
  45. data/lib/rouge/lexers/gherkin.rb +13 -13
  46. data/lib/rouge/lexers/glsl.rb +0 -4
  47. data/lib/rouge/lexers/go.rb +1 -1
  48. data/lib/rouge/lexers/graphql.rb +62 -62
  49. data/lib/rouge/lexers/groovy.rb +23 -25
  50. data/lib/rouge/lexers/hack.rb +1 -1
  51. data/lib/rouge/lexers/haml.rb +25 -29
  52. data/lib/rouge/lexers/handlebars.rb +18 -18
  53. data/lib/rouge/lexers/haskell.rb +66 -65
  54. data/lib/rouge/lexers/hcl.rb +25 -25
  55. data/lib/rouge/lexers/html.rb +31 -31
  56. data/lib/rouge/lexers/http.rb +4 -4
  57. data/lib/rouge/lexers/hylang.rb +14 -14
  58. data/lib/rouge/lexers/idlang.rb +32 -32
  59. data/lib/rouge/lexers/igorpro.rb +30 -30
  60. data/lib/rouge/lexers/ini.rb +12 -12
  61. data/lib/rouge/lexers/io.rb +7 -7
  62. data/lib/rouge/lexers/irb.rb +5 -5
  63. data/lib/rouge/lexers/java.rb +24 -24
  64. data/lib/rouge/lexers/javascript.rb +51 -51
  65. data/lib/rouge/lexers/jinja.rb +22 -22
  66. data/lib/rouge/lexers/json.rb +11 -10
  67. data/lib/rouge/lexers/json_doc.rb +2 -2
  68. data/lib/rouge/lexers/jsonnet.rb +18 -18
  69. data/lib/rouge/lexers/jsp.rb +28 -28
  70. data/lib/rouge/lexers/jsx.rb +16 -16
  71. data/lib/rouge/lexers/julia.rb +44 -44
  72. data/lib/rouge/lexers/kotlin.rb +3 -3
  73. data/lib/rouge/lexers/lasso.rb +50 -50
  74. data/lib/rouge/lexers/liquid.rb +53 -53
  75. data/lib/rouge/lexers/literate_coffeescript.rb +2 -2
  76. data/lib/rouge/lexers/literate_haskell.rb +5 -5
  77. data/lib/rouge/lexers/llvm.rb +23 -16
  78. data/lib/rouge/lexers/lua.rb +3 -3
  79. data/lib/rouge/lexers/m68k.rb +18 -19
  80. data/lib/rouge/lexers/magik.rb +126 -0
  81. data/lib/rouge/lexers/make.rb +22 -28
  82. data/lib/rouge/lexers/markdown.rb +37 -37
  83. data/lib/rouge/lexers/mathematica.rb +11 -11
  84. data/lib/rouge/lexers/matlab.rb +20 -20
  85. data/lib/rouge/lexers/moonscript.rb +3 -3
  86. data/lib/rouge/lexers/mosel.rb +17 -17
  87. data/lib/rouge/lexers/mxml.rb +18 -18
  88. data/lib/rouge/lexers/nasm.rb +24 -25
  89. data/lib/rouge/lexers/nginx.rb +14 -14
  90. data/lib/rouge/lexers/nim.rb +1 -1
  91. data/lib/rouge/lexers/nix.rb +42 -42
  92. data/lib/rouge/lexers/objective_c.rb +38 -38
  93. data/lib/rouge/lexers/ocaml.rb +29 -29
  94. data/lib/rouge/lexers/pascal.rb +4 -4
  95. data/lib/rouge/lexers/perl.rb +68 -68
  96. data/lib/rouge/lexers/php.rb +38 -38
  97. data/lib/rouge/lexers/plist.rb +14 -14
  98. data/lib/rouge/lexers/pony.rb +19 -19
  99. data/lib/rouge/lexers/powershell.rb +25 -25
  100. data/lib/rouge/lexers/praat.rb +75 -75
  101. data/lib/rouge/lexers/prolog.rb +26 -20
  102. data/lib/rouge/lexers/prometheus.rb +30 -30
  103. data/lib/rouge/lexers/properties.rb +12 -12
  104. data/lib/rouge/lexers/protobuf.rb +22 -22
  105. data/lib/rouge/lexers/puppet.rb +31 -31
  106. data/lib/rouge/lexers/python.rb +52 -52
  107. data/lib/rouge/lexers/q.rb +12 -12
  108. data/lib/rouge/lexers/qml.rb +12 -12
  109. data/lib/rouge/lexers/r.rb +12 -12
  110. data/lib/rouge/lexers/racket.rb +22 -22
  111. data/lib/rouge/lexers/ruby.rb +71 -69
  112. data/lib/rouge/lexers/rust.rb +30 -30
  113. data/lib/rouge/lexers/sass.rb +8 -8
  114. data/lib/rouge/lexers/sass/common.rb +40 -40
  115. data/lib/rouge/lexers/scala.rb +43 -43
  116. data/lib/rouge/lexers/scheme.rb +18 -18
  117. data/lib/rouge/lexers/scss.rb +3 -3
  118. data/lib/rouge/lexers/sed.rb +29 -29
  119. data/lib/rouge/lexers/shell.rb +61 -52
  120. data/lib/rouge/lexers/sieve.rb +8 -8
  121. data/lib/rouge/lexers/slim.rb +24 -24
  122. data/lib/rouge/lexers/smalltalk.rb +33 -33
  123. data/lib/rouge/lexers/smarty.rb +12 -12
  124. data/lib/rouge/lexers/sml.rb +67 -67
  125. data/lib/rouge/lexers/sqf.rb +1 -1
  126. data/lib/rouge/lexers/sql.rb +21 -21
  127. data/lib/rouge/lexers/supercollider.rb +19 -19
  128. data/lib/rouge/lexers/swift.rb +42 -39
  129. data/lib/rouge/lexers/tap.rb +20 -20
  130. data/lib/rouge/lexers/tcl.rb +27 -27
  131. data/lib/rouge/lexers/terraform.rb +13 -13
  132. data/lib/rouge/lexers/tex.rb +19 -19
  133. data/lib/rouge/lexers/toml.rb +18 -18
  134. data/lib/rouge/lexers/tulip.rb +36 -36
  135. data/lib/rouge/lexers/turtle.rb +35 -38
  136. data/lib/rouge/lexers/vala.rb +17 -17
  137. data/lib/rouge/lexers/vb.rb +27 -27
  138. data/lib/rouge/lexers/verilog.rb +25 -27
  139. data/lib/rouge/lexers/vhdl.rb +10 -10
  140. data/lib/rouge/lexers/viml.rb +14 -14
  141. data/lib/rouge/lexers/vue.rb +9 -9
  142. data/lib/rouge/lexers/wollok.rb +25 -25
  143. data/lib/rouge/lexers/xml.rb +17 -21
  144. data/lib/rouge/lexers/xojo.rb +15 -15
  145. data/lib/rouge/lexers/yaml.rb +61 -61
  146. data/lib/rouge/plugins/redcarpet.rb +1 -1
  147. data/lib/rouge/tex_theme_renderer.rb +128 -0
  148. data/lib/rouge/theme.rb +4 -0
  149. data/lib/rouge/themes/magritte.rb +78 -0
  150. data/lib/rouge/version.rb +1 -1
  151. metadata +11 -2
@@ -55,7 +55,7 @@ module Rouge
55
55
  end
56
56
 
57
57
  def self.commands
58
- load Pathname.new(__FILE__).dirname.join("sqf/commands.rb")
58
+ load File.join(__dir__, "sqf/commands.rb")
59
59
  @commands = self.commands
60
60
  end
61
61
 
@@ -89,15 +89,15 @@ module Rouge
89
89
  end
90
90
 
91
91
  state :root do
92
- rule /\s+/m, Text
93
- rule /--.*/, Comment::Single
92
+ rule %r/\s+/m, Text
93
+ rule %r/--.*/, Comment::Single
94
94
  rule %r(/\*), Comment::Multiline, :multiline_comments
95
- rule /\d+/, Num::Integer
96
- rule /'/, Str::Single, :single_string
97
- rule /"/, Name::Variable, :double_string
98
- rule /`/, Name::Variable, :backtick
95
+ rule %r/\d+/, Num::Integer
96
+ rule %r/'/, Str::Single, :single_string
97
+ rule %r/"/, Name::Variable, :double_string
98
+ rule %r/`/, Name::Variable, :backtick
99
99
 
100
- rule /\w[\w\d]*/ do |m|
100
+ rule %r/\w\w*/ do |m|
101
101
  if self.class.keywords.include? m[0].upcase
102
102
  token Keyword
103
103
  else
@@ -105,8 +105,8 @@ module Rouge
105
105
  end
106
106
  end
107
107
 
108
- rule %r([+*/<>=~!@#%^&|?^-]), Operator
109
- rule /[;:()\[\],.]/, Punctuation
108
+ rule %r([+*/<>=~!@#%&|?^-]), Operator
109
+ rule %r/[;:()\[\],.]/, Punctuation
110
110
  end
111
111
 
112
112
  state :multiline_comments do
@@ -117,24 +117,24 @@ module Rouge
117
117
  end
118
118
 
119
119
  state :backtick do
120
- rule /\\./, Str::Escape
121
- rule /``/, Str::Escape
122
- rule /`/, Name::Variable, :pop!
123
- rule /[^\\`]+/, Name::Variable
120
+ rule %r/\\./, Str::Escape
121
+ rule %r/``/, Str::Escape
122
+ rule %r/`/, Name::Variable, :pop!
123
+ rule %r/[^\\`]+/, Name::Variable
124
124
  end
125
125
 
126
126
  state :single_string do
127
- rule /\\./, Str::Escape
128
- rule /''/, Str::Escape
129
- rule /'/, Str::Single, :pop!
130
- rule /[^\\']+/, Str::Single
127
+ rule %r/\\./, Str::Escape
128
+ rule %r/''/, Str::Escape
129
+ rule %r/'/, Str::Single, :pop!
130
+ rule %r/[^\\']+/, Str::Single
131
131
  end
132
132
 
133
133
  state :double_string do
134
- rule /\\./, Str::Escape
135
- rule /""/, Str::Escape
136
- rule /"/, Name::Variable, :pop!
137
- rule /[^\\"]+/, Name::Variable
134
+ rule %r/\\./, Str::Escape
135
+ rule %r/""/, Str::Escape
136
+ rule %r/"/, Name::Variable, :pop!
137
+ rule %r/[^\\"]+/, Name::Variable
138
138
  end
139
139
  end
140
140
  end
@@ -35,7 +35,7 @@ module Rouge
35
35
  end
36
36
 
37
37
  state :whitespace do
38
- rule /\s+/m, Text
38
+ rule %r/\s+/m, Text
39
39
  end
40
40
 
41
41
  state :comments do
@@ -50,43 +50,43 @@ module Rouge
50
50
  rule %r(/[*]), Comment::Multiline, :nested_comment
51
51
  rule %r([*]/), Comment::Multiline, :pop!
52
52
  rule %r([^*/]+)m, Comment::Multiline
53
- rule /./, Comment::Multiline
53
+ rule %r/./, Comment::Multiline
54
54
  end
55
55
 
56
56
  state :root do
57
57
  mixin :whitespace
58
58
  mixin :comments
59
59
 
60
- rule /[\-+]?0[xX]\h+/, Num::Hex
60
+ rule %r/[\-+]?0[xX]\h+/, Num::Hex
61
61
 
62
62
  # radix float
63
- rule /[\-+]?\d+r[0-9a-zA-Z]*(\.[0-9A-Z]*)?/, Num::Float
63
+ rule %r/[\-+]?\d+r[0-9a-zA-Z]*(\.[0-9A-Z]*)?/, Num::Float
64
64
 
65
65
  # normal float
66
- rule /[\-+]?((\d+(\.\d+)?([eE][\-+]?\d+)?(pi)?)|pi)/, Num::Float
66
+ rule %r/[\-+]?((\d+(\.\d+)?([eE][\-+]?\d+)?(pi)?)|pi)/, Num::Float
67
67
 
68
- rule /[\-+]?\d+/, Num::Integer
68
+ rule %r/[\-+]?\d+/, Num::Integer
69
69
 
70
- rule /\$(\\.|.)/, Str::Char
70
+ rule %r/\$(\\.|.)/, Str::Char
71
71
 
72
- rule /"([^\\"]|\\.)*"/, Str
72
+ rule %r/"([^\\"]|\\.)*"/, Str
73
73
 
74
74
  # symbols (single-quote notation)
75
- rule /'([^\\']|\\.)*'/, Str::Other
75
+ rule %r/'([^\\']|\\.)*'/, Str::Other
76
76
 
77
77
  # symbols (backslash notation)
78
- rule /\\\w+/, Str::Other
78
+ rule %r/\\\w+/, Str::Other
79
79
 
80
80
  # symbol arg
81
- rule /[A-Za-z_]\w*:/, Name::Label
81
+ rule %r/[A-Za-z_]\w*:/, Name::Label
82
82
 
83
- rule /[A-Z]\w*/, Name::Class
83
+ rule %r/[A-Z]\w*/, Name::Class
84
84
 
85
85
  # primitive
86
- rule /_\w+/, Name::Function
86
+ rule %r/_\w+/, Name::Function
87
87
 
88
88
  # main identifiers section
89
- rule /[a-z]\w*/ do |m|
89
+ rule %r/[a-z]\w*/ do |m|
90
90
  if self.class.keywords.include? m[0]
91
91
  token Keyword
92
92
  elsif self.class.constants.include? m[0]
@@ -99,16 +99,16 @@ module Rouge
99
99
  end
100
100
 
101
101
  # environment variables
102
- rule /~\w+/, Name::Variable::Global
102
+ rule %r/~\w+/, Name::Variable::Global
103
103
 
104
- rule /[\{\}()\[\];,\.]/, Punctuation
104
+ rule %r/[\{\}()\[\];,\.]/, Punctuation
105
105
 
106
106
  # operators. treat # (array unpack) as an operator
107
- rule /[\+\-\*\/&\|%<>=]+/, Operator
108
- rule /[\^:#]/, Operator
107
+ rule %r/[\+\-\*\/&\|%<>=]+/, Operator
108
+ rule %r/[\^:#]/, Operator
109
109
 
110
110
  # treat curry argument as a special operator
111
- rule /\b_\b/, Name::Builtin
111
+ rule %r/\b_\b/, Name::Builtin
112
112
  end
113
113
  end
114
114
  end
@@ -20,6 +20,8 @@ module Rouge
20
20
  as dynamicType is new super self Self Type __COLUMN__ __FILE__ __FUNCTION__ __LINE__
21
21
 
22
22
  associativity didSet get infix inout mutating none nonmutating operator override postfix precedence prefix set unowned weak willSet throws rethrows precedencegroup
23
+
24
+ #available #colorLiteral #column #else #elseif #endif #error #file #fileLiteral #function #if #imageLiteral #line #selector #sourceLocation #warning
23
25
  )
24
26
 
25
27
  declarations = Set.new %w(
@@ -34,7 +36,7 @@ module Rouge
34
36
 
35
37
  # beginning of line
36
38
  state :bol do
37
- rule /#.*/, Comment::Preproc
39
+ rule %r/#.*/, Comment::Preproc
38
40
 
39
41
  mixin :inline_whitespace
40
42
 
@@ -42,12 +44,12 @@ module Rouge
42
44
  end
43
45
 
44
46
  state :inline_whitespace do
45
- rule /\s+/m, Text
47
+ rule %r/\s+/m, Text
46
48
  mixin :has_comments
47
49
  end
48
50
 
49
51
  state :whitespace do
50
- rule /\n+/m, Text, :bol
52
+ rule %r/\n+/m, Text, :bol
51
53
  rule %r(\/\/.*?$), Comment::Single, :bol
52
54
  mixin :inline_whitespace
53
55
  end
@@ -60,27 +62,27 @@ module Rouge
60
62
  mixin :has_comments
61
63
  rule %r([*]/), Comment::Multiline, :pop!
62
64
  rule %r([^*/]+)m, Comment::Multiline
63
- rule /./, Comment::Multiline
65
+ rule %r/./, Comment::Multiline
64
66
  end
65
67
 
66
68
  state :root do
67
69
  mixin :whitespace
68
- rule /\$(([1-9]\d*)?\d)/, Name::Variable
70
+ rule %r/\$(([1-9]\d*)?\d)/, Name::Variable
69
71
 
70
72
  rule %r{[()\[\]{}:;,?\\]}, Punctuation
71
73
  rule %r([-/=+*%<>!&|^.~]+), Operator
72
- rule /@?"/, Str, :dq
73
- rule /'(\\.|.)'/, Str::Char
74
- rule /(\d+\*|\d*\.\d+)(e[+-]?[0-9]+)?/i, Num::Float
75
- rule /\d+e[+-]?[0-9]+/i, Num::Float
76
- rule /0_?[0-7]+(?:_[0-7]+)*/, Num::Oct
77
- rule /0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/, Num::Hex
78
- rule /0b[01]+(?:_[01]+)*/, Num::Bin
74
+ rule %r/@?"/, Str, :dq
75
+ rule %r/'(\\.|.)'/, Str::Char
76
+ rule %r/(\d+(?:_\d+)*\*|(?:\d+(?:_\d+)*)*\.\d+(?:_\d)*)(e[+-]?\d+(?:_\d)*)?/i, Num::Float
77
+ rule %r/\d+e[+-]?[0-9]+/i, Num::Float
78
+ rule %r/0o?[0-7]+(?:_[0-7]+)*/, Num::Oct
79
+ rule %r/0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*((\.[0-9A-F]+(?:_[0-9A-F]+)*)?p[+-]?\d+)?/, Num::Hex
80
+ rule %r/0b[01]+(?:_[01]+)*/, Num::Bin
79
81
  rule %r{[\d]+(?:_\d+)*}, Num::Integer
80
82
 
81
- rule /@#{id}(\([^)]+\))?/, Keyword::Declaration
83
+ rule %r/@#{id}(\([^)]+\))?/, Keyword::Declaration
82
84
 
83
- rule /(private|internal)(\([ ]*)(\w+)([ ]*\))/ do |m|
85
+ rule %r/(private|internal)(\([ ]*)(\w+)([ ]*\))/ do |m|
84
86
  if m[3] == 'set'
85
87
  token Keyword::Declaration
86
88
  else
@@ -88,7 +90,7 @@ module Rouge
88
90
  end
89
91
  end
90
92
 
91
- rule /(unowned\([ ]*)(\w+)([ ]*\))/ do |m|
93
+ rule %r/(unowned\([ ]*)(\w+)([ ]*\))/ do |m|
92
94
  if m[2] == 'safe' || m[2] == 'unsafe'
93
95
  token Keyword::Declaration
94
96
  else
@@ -96,24 +98,24 @@ module Rouge
96
98
  end
97
99
  end
98
100
 
99
- rule /#available\([^)]+\)/, Keyword::Declaration
101
+ rule %r/#available\([^)]+\)/, Keyword::Declaration
100
102
 
101
- rule /(#(?:selector|keyPath)\()([^)]+?(?:[(].*?[)])?)(\))/ do
103
+ rule %r/(#(?:selector|keyPath)\()([^)]+?(?:[(].*?[)])?)(\))/ do
102
104
  groups Keyword::Declaration, Name::Function, Keyword::Declaration
103
105
  end
104
106
 
105
- rule /#(line|file|column|function|dsohandle)/, Keyword::Declaration
107
+ rule %r/#(line|file|column|function|dsohandle)/, Keyword::Declaration
106
108
 
107
- rule /(let|var)\b(\s*)(#{id})/ do
109
+ rule %r/(let|var)\b(\s*)(#{id})/ do
108
110
  groups Keyword, Text, Name::Variable
109
111
  end
110
112
 
111
- rule /(let|var)\b(\s*)([(])/ do
113
+ rule %r/(let|var)\b(\s*)([(])/ do
112
114
  groups Keyword, Text, Punctuation
113
115
  push :tuple
114
116
  end
115
117
 
116
- rule /(?!\b(if|while|for|private|internal|unowned|switch|case)\b)\b#{id}(?=(\?|!)?\s*[(])/ do |m|
118
+ rule %r/(?!\b(if|while|for|private|internal|unowned|switch|case)\b)\b#{id}(?=(\?|!)?\s*[(])/ do |m|
117
119
  if m[0] =~ /^[[:upper:]]/
118
120
  token Keyword::Type
119
121
  else
@@ -121,10 +123,10 @@ module Rouge
121
123
  end
122
124
  end
123
125
 
124
- rule /as[?!]?(?=\s)/, Keyword
125
- rule /try[!]?(?=\s)/, Keyword
126
+ rule %r/as[?!]?(?=\s)/, Keyword
127
+ rule %r/try[!]?(?=\s)/, Keyword
126
128
 
127
- rule /(#?(?!default)(?![[:upper:]])#{id})(\s*)(:)/ do
129
+ rule %r/(#?(?!default)(?![[:upper:]])#{id})(\s*)(:)/ do
128
130
  groups Name::Variable, Text, Punctuation
129
131
  end
130
132
 
@@ -142,39 +144,40 @@ module Rouge
142
144
  end
143
145
  end
144
146
 
145
- rule /(`)(#{id})(`)/ do
147
+ rule %r/(`)(#{id})(`)/ do
146
148
  groups Punctuation, Name::Variable, Punctuation
147
149
  end
148
150
  end
149
151
 
150
152
  state :tuple do
151
- rule /(#{id})/, Name::Variable
152
- rule /(`)(#{id})(`)/ do
153
+ rule %r/(#{id})/, Name::Variable
154
+ rule %r/(`)(#{id})(`)/ do
153
155
  groups Punctuation, Name::Variable, Punctuation
154
156
  end
155
- rule /,/, Punctuation
156
- rule /[(]/, Punctuation, :push
157
- rule /[)]/, Punctuation, :pop!
157
+ rule %r/,/, Punctuation
158
+ rule %r/[(]/, Punctuation, :push
159
+ rule %r/[)]/, Punctuation, :pop!
158
160
  mixin :inline_whitespace
159
161
  end
160
162
 
161
163
  state :dq do
162
- rule /\\[\\0tnr'"]/, Str::Escape
163
- rule /\\[(]/, Str::Escape, :interp
164
- rule /\\u\{\h{1,8}\}/, Str::Escape
165
- rule /[^\\"]+/, Str
166
- rule /"/, Str, :pop!
164
+ rule %r/\\[\\0tnr'"]/, Str::Escape
165
+ rule %r/\\[(]/, Str::Escape, :interp
166
+ rule %r/\\u\{\h{1,8}\}/, Str::Escape
167
+ rule %r/[^\\"]+/, Str
168
+ rule %r/"""/, Str, :pop!
169
+ rule %r/"/, Str, :pop!
167
170
  end
168
171
 
169
172
  state :interp do
170
- rule /[(]/, Punctuation, :interp_inner
171
- rule /[)]/, Str::Escape, :pop!
173
+ rule %r/[(]/, Punctuation, :interp_inner
174
+ rule %r/[)]/, Str::Escape, :pop!
172
175
  mixin :root
173
176
  end
174
177
 
175
178
  state :interp_inner do
176
- rule /[(]/, Punctuation, :push
177
- rule /[)]/, Punctuation, :pop!
179
+ rule %r/[(]/, Punctuation, :push
180
+ rule %r/[)]/, Punctuation, :pop!
178
181
  mixin :root
179
182
  end
180
183
  end
@@ -13,72 +13,72 @@ module Rouge
13
13
 
14
14
  state :root do
15
15
  # A TAP version may be specified.
16
- rule /^TAP version \d+\n/, Name::Namespace
16
+ rule %r/^TAP version \d+\n/, Name::Namespace
17
17
 
18
18
  # Specify a plan with a plan line.
19
- rule /^1\.\.\d+/, Keyword::Declaration, :plan
19
+ rule %r/^1\.\.\d+/, Keyword::Declaration, :plan
20
20
 
21
21
  # A test failure
22
- rule /^(not ok)([^\S\n]*)(\d*)/ do
22
+ rule %r/^(not ok)([^\S\n]*)(\d*)/ do
23
23
  groups Generic::Error, Text, Literal::Number::Integer
24
24
  push :test
25
25
  end
26
26
 
27
27
  # A test success
28
- rule /^(ok)([^\S\n]*)(\d*)/ do
28
+ rule %r/^(ok)([^\S\n]*)(\d*)/ do
29
29
  groups Keyword::Reserved, Text, Literal::Number::Integer
30
30
  push :test
31
31
  end
32
32
 
33
33
  # Diagnostics start with a hash.
34
- rule /^#.*\n/, Comment
34
+ rule %r/^#.*\n/, Comment
35
35
 
36
36
  # TAP's version of an abort statement.
37
- rule /^Bail out!.*\n/, Generic::Error
37
+ rule %r/^Bail out!.*\n/, Generic::Error
38
38
 
39
39
  # # TAP ignores any unrecognized lines.
40
- rule /^.*\n/, Text
40
+ rule %r/^.*\n/, Text
41
41
  end
42
42
 
43
43
  state :plan do
44
44
  # Consume whitespace (but not newline).
45
- rule /[^\S\n]+/, Text
45
+ rule %r/[^\S\n]+/, Text
46
46
 
47
47
  # A plan may have a directive with it.
48
- rule /#/, Comment, :directive
48
+ rule %r/#/, Comment, :directive
49
49
 
50
50
  # Or it could just end.
51
- rule /\n/, Comment, :pop!
51
+ rule %r/\n/, Comment, :pop!
52
52
 
53
53
  # Anything else is wrong.
54
- rule /.*\n/, Generic::Error, :pop!
54
+ rule %r/.*\n/, Generic::Error, :pop!
55
55
  end
56
56
 
57
57
  state :test do
58
58
  # Consume whitespace (but not newline).
59
- rule /[^\S\n]+/, Text
59
+ rule %r/[^\S\n]+/, Text
60
60
 
61
61
  # A test may have a directive with it.
62
- rule /#/, Comment, :directive
62
+ rule %r/#/, Comment, :directive
63
63
 
64
- rule /\S+/, Text
64
+ rule %r/\S+/, Text
65
65
 
66
- rule /\n/, Text, :pop!
66
+ rule %r/\n/, Text, :pop!
67
67
  end
68
68
 
69
69
  state :directive do
70
70
  # Consume whitespace (but not newline).
71
- rule /[^\S\n]+/, Comment
71
+ rule %r/[^\S\n]+/, Comment
72
72
 
73
73
  # Extract todo items.
74
- rule /(?i)\bTODO\b/, Comment::Preproc
74
+ rule %r/(?i)\bTODO\b/, Comment::Preproc
75
75
 
76
76
  # Extract skip items.
77
- rule /(?i)\bSKIP\S*/, Comment::Preproc
77
+ rule %r/(?i)\bSKIP\S*/, Comment::Preproc
78
78
 
79
- rule /\S+/, Comment
79
+ rule %r/\S+/, Comment
80
80
 
81
- rule /\n/ do
81
+ rule %r/\n/ do
82
82
  token Comment
83
83
  pop! 2
84
84
  end
@@ -39,33 +39,33 @@ module Rouge
39
39
  CLOSE = %w| \) \] \} |
40
40
  ALL = OPEN + CLOSE
41
41
  END_LINE = CLOSE + %w(; \n)
42
- END_WORD = END_LINE + %w(\s)
42
+ END_WORD = END_LINE + %w(\r \t \v)
43
43
 
44
44
  CHARS = lambda { |list| Regexp.new %/[#{list.join}]/ }
45
45
  NOT_CHARS = lambda { |list| Regexp.new %/[^#{list.join}]/ }
46
46
 
47
47
  state :word do
48
- rule /\{\*\}/, Keyword
48
+ rule %r/\{\*\}/, Keyword
49
49
 
50
50
  mixin :brace_abort
51
51
  mixin :interp
52
- rule /\{/, Punctuation, :brace
53
- rule /\(/, Punctuation, :paren
54
- rule /"/, Str::Double, :string
55
- rule /#{NOT_CHARS[END_WORD]}+?(?=#{CHARS[OPEN+['\\\\']]})/, Text
52
+ rule %r/\{/, Punctuation, :brace
53
+ rule %r/\(/, Punctuation, :paren
54
+ rule %r/"/, Str::Double, :string
55
+ rule %r/#{NOT_CHARS[END_WORD]}+?(?=#{CHARS[OPEN+['\\\\']]})/, Text
56
56
  end
57
57
 
58
58
  def self.gen_command_state(name='')
59
59
  state(:"command#{name}") do
60
60
  mixin :word
61
61
 
62
- rule /##{NOT_CHARS[END_LINE]}+/, Comment::Single
62
+ rule %r/##{NOT_CHARS[END_LINE]}+/, Comment::Single
63
63
 
64
- rule /(?=#{CHARS[END_WORD]})/ do
64
+ rule %r/(?=#{CHARS[END_WORD]})/ do
65
65
  push :"params#{name}"
66
66
  end
67
67
 
68
- rule /#{NOT_CHARS[END_WORD]}+/ do |m|
68
+ rule %r/#{NOT_CHARS[END_WORD]}+/ do |m|
69
69
  if KEYWORDS.include? m[0]
70
70
  token Keyword
71
71
  elsif BUILTINS.include? m[0]
@@ -116,7 +116,7 @@ module Rouge
116
116
  # such things as [ abc" ] are a runtime error, but will still
117
117
  # parse. Currently something like this will muck up the lex.
118
118
  state :brace_abort do
119
- rule /}/ do
119
+ rule %r/}/ do
120
120
  if in_state? :brace
121
121
  pop! until state? :brace
122
122
  pop!
@@ -128,12 +128,12 @@ module Rouge
128
128
  end
129
129
 
130
130
  state :params do
131
- rule /;/, Punctuation, :pop!
132
- rule /\n/, Text, :pop!
133
- rule /else|elseif|then/, Keyword
131
+ rule %r/;/, Punctuation, :pop!
132
+ rule %r/\n/, Text, :pop!
133
+ rule %r/else|elseif|then/, Keyword
134
134
  mixin :word
135
135
  mixin :whitespace
136
- rule /#{NOT_CHARS[END_WORD]}+/, Text
136
+ rule %r/#{NOT_CHARS[END_WORD]}+/, Text
137
137
  end
138
138
 
139
139
  gen_delimiter_states :brace, /\}/, :strict => false
@@ -147,37 +147,37 @@ module Rouge
147
147
 
148
148
  state :whitespace do
149
149
  # not a multiline regex because we want to capture \n sometimes
150
- rule /\s+/, Text
150
+ rule %r/\s+/, Text
151
151
  end
152
152
 
153
153
  state :interp do
154
- rule /\[/, Punctuation, :bracket
155
- rule /\$[a-z0-9.:-]+/, Name::Variable
156
- rule /\$\{.*?\}/m, Name::Variable
157
- rule /\$/, Text
154
+ rule %r/\[/, Punctuation, :bracket
155
+ rule %r/\$[a-z0-9.:-]+/, Name::Variable
156
+ rule %r/\$\{.*?\}/m, Name::Variable
157
+ rule %r/\$/, Text
158
158
 
159
159
  # escape sequences
160
- rule /\\[0-7]{3}/, Str::Escape
161
- rule /\\x[0-9a-f]{2}/i, Str::Escape
162
- rule /\\u[0-9a-f]{4}/i, Str::Escape
163
- rule /\\./m, Str::Escape
160
+ rule %r/\\[0-7]{3}/, Str::Escape
161
+ rule %r/\\x[0-9a-f]{2}/i, Str::Escape
162
+ rule %r/\\u[0-9a-f]{4}/i, Str::Escape
163
+ rule %r/\\./m, Str::Escape
164
164
  end
165
165
 
166
166
  state :string do
167
- rule /"/, Str::Double, :pop!
167
+ rule %r/"/, Str::Double, :pop!
168
168
  mixin :interp
169
- rule /[^\\\[\$"{}]+/m, Str::Double
169
+ rule %r/[^\\\[\$"{}]+/m, Str::Double
170
170
 
171
171
  # strings have to keep count of their internal braces, to support
172
172
  # for example { "{ }" }.
173
- rule /{/ do
173
+ rule %r/{/ do
174
174
  @brace_count ||= 0
175
175
  @brace_count += 1
176
176
 
177
177
  token Str::Double
178
178
  end
179
179
 
180
- rule /}/ do
180
+ rule %r/}/ do
181
181
  if in_state? :brace and @brace_count.to_i == 0
182
182
  pop! until state? :brace
183
183
  pop!