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
@@ -54,16 +54,16 @@ module Rouge
54
54
  upper_id = /[A-Z]\w*/
55
55
 
56
56
  state :whitespace do
57
- rule /\s+/, Text
58
- rule /\n/, Text, :bol
59
- rule /rem\b.*?$/i, Comment::Single
57
+ rule %r/\s+/, Text
58
+ rule %r/\n/, Text, :bol
59
+ rule %r/rem\b.*?$/i, Comment::Single
60
60
  rule %r(%\{.*?%\})m, Comment::Multiline
61
- rule /'.*$/, Comment::Single
61
+ rule %r/'.*$/, Comment::Single
62
62
  end
63
63
 
64
64
  state :bol do
65
- rule /\s+/, Text
66
- rule /<.*?>/, Name::Attribute
65
+ rule %r/\s+/, Text
66
+ rule %r/<.*?>/, Name::Attribute
67
67
  rule(//) { :pop! }
68
68
  end
69
69
 
@@ -80,15 +80,15 @@ module Rouge
80
80
  | [#]End \s+ Region
81
81
  | [#]ExternalChecksum
82
82
  )x, Comment::Preproc
83
- rule /[.]/, Punctuation, :dotted
84
- rule /[(){}!#,:]/, Punctuation
85
- rule /Option\s+(Strict|Explicit|Compare)\s+(On|Off|Binary|Text)/,
83
+ rule %r/[.]/, Punctuation, :dotted
84
+ rule %r/[(){}!#,:]/, Punctuation
85
+ rule %r/Option\s+(Strict|Explicit|Compare)\s+(On|Off|Binary|Text)/,
86
86
  Keyword::Declaration
87
- rule /End\b/, Keyword, :end
88
- rule /(Dim|Const)\b/, Keyword, :dim
89
- rule /(Function|Sub|Property)\b/, Keyword, :funcname
90
- rule /(Class|Structure|Enum)\b/, Keyword, :classname
91
- rule /(Module|Namespace|Imports)\b/, Keyword, :namespace
87
+ rule %r/End\b/, Keyword, :end
88
+ rule %r/(Dim|Const)\b/, Keyword, :dim
89
+ rule %r/(Function|Sub|Property)\b/, Keyword, :funcname
90
+ rule %r/(Class|Structure|Enum)\b/, Keyword, :classname
91
+ rule %r/(Module|Namespace|Imports)\b/, Keyword, :namespace
92
92
 
93
93
  rule upper_id do |m|
94
94
  match = m[0]
@@ -110,16 +110,16 @@ module Rouge
110
110
  Operator
111
111
  )
112
112
 
113
- rule /"/, Str, :string
114
- rule /#{id}[%&@!#\$]?/, Name
115
- rule /#.*?#/, Literal::Date
113
+ rule %r/"/, Str, :string
114
+ rule %r/#{id}[%&@!#\$]?/, Name
115
+ rule %r/#.*?#/, Literal::Date
116
116
 
117
- rule /(\d+\.\d*|\d*\.\d+)(f[+-]?\d+)?/i, Num::Float
118
- rule /\d+([SILDFR]|US|UI|UL)?/, Num::Integer
119
- rule /&H[0-9a-f]+([SILDFR]|US|UI|UL)?/, Num::Integer
120
- rule /&O[0-7]+([SILDFR]|US|UI|UL)?/, Num::Integer
117
+ rule %r/(\d+\.\d*|\d*\.\d+)(f[+-]?\d+)?/i, Num::Float
118
+ rule %r/\d+([SILDFR]|US|UI|UL)?/, Num::Integer
119
+ rule %r/&H[0-9a-f]+([SILDFR]|US|UI|UL)?/, Num::Integer
120
+ rule %r/&O[0-7]+([SILDFR]|US|UI|UL)?/, Num::Integer
121
121
 
122
- rule /_\n/, Keyword
122
+ rule %r/_\n/, Keyword
123
123
  end
124
124
 
125
125
  state :dotted do
@@ -128,9 +128,9 @@ module Rouge
128
128
  end
129
129
 
130
130
  state :string do
131
- rule /""/, Str::Escape
132
- rule /"C?/, Str, :pop!
133
- rule /[^"]+/, Str
131
+ rule %r/""/, Str::Escape
132
+ rule %r/"C?/, Str, :pop!
133
+ rule %r/[^"]+/, Str
134
134
  end
135
135
 
136
136
  state :dim do
@@ -151,12 +151,12 @@ module Rouge
151
151
 
152
152
  state :namespace do
153
153
  mixin :whitespace
154
- rule /#{id}([.]#{id})*/, Name::Namespace, :pop!
154
+ rule %r/#{id}([.]#{id})*/, Name::Namespace, :pop!
155
155
  end
156
156
 
157
157
  state :end do
158
158
  mixin :whitespace
159
- rule /(Function|Sub|Property|Class|Structure|Enum|Module|Namespace)\b/,
159
+ rule %r/(Function|Sub|Property|Class|Structure|Enum|Module|Namespace)\b/,
160
160
  Keyword, :pop!
161
161
  rule(//) { pop! }
162
162
  end
@@ -10,8 +10,6 @@ module Rouge
10
10
  filenames '*.v', '*.sv', '*.svh'
11
11
  mimetypes 'text/x-verilog', 'text/x-systemverilog'
12
12
 
13
- # optional comment or whitespace
14
- ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
15
13
  id = /[a-zA-Z_][a-zA-Z0-9_]*/
16
14
 
17
15
  def self.keywords
@@ -82,7 +80,7 @@ module Rouge
82
80
 
83
81
  state :expr_bol do
84
82
  mixin :inline_whitespace
85
- rule /`define/, Comment::Preproc, :macro
83
+ rule %r/`define/, Comment::Preproc, :macro
86
84
 
87
85
  rule(//) { pop! }
88
86
  end
@@ -90,47 +88,47 @@ module Rouge
90
88
  # :expr_bol is the same as :bol but without labels, since
91
89
  # labels can only appear at the beginning of a statement.
92
90
  state :bol do
93
- rule /#{id}:(?!:)/, Name::Label
91
+ rule %r/#{id}:(?!:)/, Name::Label
94
92
  mixin :expr_bol
95
93
  end
96
94
 
97
95
  state :inline_whitespace do
98
- rule /[ \t\r]+/, Text
99
- rule /\\\n/, Text # line continuation
96
+ rule %r/[ \t\r]+/, Text
97
+ rule %r/\\\n/, Text # line continuation
100
98
  rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
101
99
  end
102
100
 
103
101
  state :whitespace do
104
- rule /\n+/m, Text, :bol
102
+ rule %r/\n+/m, Text, :bol
105
103
  rule %r(//(\\.|.)*?\n), Comment::Single, :bol
106
104
  mixin :inline_whitespace
107
105
  end
108
106
 
109
107
  state :expr_whitespace do
110
- rule /\n+/m, Text, :expr_bol
108
+ rule %r/\n+/m, Text, :expr_bol
111
109
  mixin :whitespace
112
110
  end
113
111
 
114
112
  state :string do
115
- rule /"/, Str, :pop!
116
- rule /\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape
117
- rule /[^\\"\n]+/, Str
118
- rule /\\\n/, Str
119
- rule /\\/, Str # stray backslash
113
+ rule %r/"/, Str, :pop!
114
+ rule %r/\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape
115
+ rule %r/[^\\"\n]+/, Str
116
+ rule %r/\\\n/, Str
117
+ rule %r/\\/, Str # stray backslash
120
118
  end
121
119
 
122
120
  state :statement do
123
121
  mixin :whitespace
124
- rule /L?"/, Str, :string
125
- rule /([0-9_]+\.[0-9_]*|[0-9_]*\.[0-9_]+)(e[+-]?[0-9_]+)?/i, Num::Float
126
- rule /[0-9_]+e[+-]?[0-9_]+/i, Num::Float
127
- rule /[0-9]*'h[0-9a-fA-F_?]+/, Num::Hex
128
- rule /[0-9]*'b?[01xz_?]+/, Num::Bin
129
- rule /[0-9]*'d[0-9_?]+/, Num::Integer
130
- rule /[0-9_]+[lu]*/i, Num::Integer
131
- rule %r([~!%^&*+-=\|?:<>/@{}]), Operator
132
- rule /[()\[\],.$\#]/, Punctuation
133
- rule /`(\w+)/, Comment::Preproc
122
+ rule %r/L?"/, Str, :string
123
+ rule %r/([0-9_]+\.[0-9_]*|[0-9_]*\.[0-9_]+)(e[+-]?[0-9_]+)?/i, Num::Float
124
+ rule %r/[0-9_]+e[+-]?[0-9_]+/i, Num::Float
125
+ rule %r/[0-9]*'h[0-9a-fA-F_?]+/, Num::Hex
126
+ rule %r/[0-9]*'b?[01xz_?]+/, Num::Bin
127
+ rule %r/[0-9]*'d[0-9_?]+/, Num::Integer
128
+ rule %r/[0-9_]+[lu]*/i, Num::Integer
129
+ rule %r([-~!%^&*+=\|?:<>/@{}]), Operator
130
+ rule %r/[()\[\],.$\#;]/, Punctuation
131
+ rule %r/`(\w+)/, Comment::Preproc
134
132
 
135
133
  rule id do |m|
136
134
  name = m[0]
@@ -153,11 +151,11 @@ module Rouge
153
151
  end
154
152
 
155
153
  state :macro do
156
- rule /\n/, Comment::Preproc, :pop!
154
+ rule %r/\n/, Comment::Preproc, :pop!
157
155
  mixin :inline_whitespace
158
- rule /;/, Punctuation
159
- rule /\=/, Operator
160
- rule /(\w+)/, Text
156
+ rule %r/;/, Punctuation
157
+ rule %r/\=/, Operator
158
+ rule %r/(\w+)/, Text
161
159
  end
162
160
 
163
161
  end
@@ -41,30 +41,30 @@ module Rouge
41
41
  id = /[a-zA-Z][a-zA-Z0-9_]*/
42
42
 
43
43
  state :whitespace do
44
- rule /\s+/, Text
45
- rule /\n/, Text
44
+ rule %r/\s+/, Text
45
+ rule %r/\n/, Text
46
46
  # Find Comments (VHDL doesn't support multiline comments)
47
- rule /--.*$/, Comment::Single
47
+ rule %r/--.*$/, Comment::Single
48
48
  end
49
49
 
50
50
  state :statements do
51
51
 
52
52
  # Find Numbers
53
- rule /-?\d+/i, Num::Integer
54
- rule /-?\d+[.]\d+/i, Num::Float
53
+ rule %r/-?\d+/i, Num::Integer
54
+ rule %r/-?\d+[.]\d+/i, Num::Float
55
55
 
56
56
  # Find Strings
57
- rule /[box]?"[^"]*"/i, Str::Single
58
- rule /'[^']?'/i, Str::Char
57
+ rule %r/[box]?"[^"]*"/i, Str::Single
58
+ rule %r/'[^']?'/i, Str::Char
59
59
 
60
60
  # Find Attributes
61
- rule /'#{id}/i, Name::Attribute
61
+ rule %r/'#{id}/i, Name::Attribute
62
62
 
63
63
  # Punctuations
64
- rule /[(),:;]/, Punctuation
64
+ rule %r/[(),:;]/, Punctuation
65
65
 
66
66
  # Boolean and NULL
67
- rule /(?:true|false|null)\b/i, Name::Builtin
67
+ rule %r/(?:true|false|null)\b/i, Name::Builtin
68
68
 
69
69
  rule id do |m|
70
70
  match = m[0].downcase #convert to lower case
@@ -14,18 +14,18 @@ module Rouge
14
14
  mimetypes 'text/x-vim'
15
15
 
16
16
  def self.keywords
17
- load Pathname.new(__FILE__).dirname.join('viml/keywords.rb')
17
+ load File.join(__dir__, 'viml/keywords.rb')
18
18
  self.keywords
19
19
  end
20
20
 
21
21
  state :root do
22
- rule /^(\s*)(".*?)$/ do
22
+ rule %r/^(\s*)(".*?)$/ do
23
23
  groups Text, Comment
24
24
  end
25
25
 
26
- rule /^\s*\\/, Str::Escape
26
+ rule %r/^\s*\\/, Str::Escape
27
27
 
28
- rule /[ \t]+/, Text
28
+ rule %r/[ \t]+/, Text
29
29
 
30
30
  # TODO: regexes can have other delimiters
31
31
  rule %r(/(\\\\|\\/|[^\n/])*/), Str::Regex
@@ -33,19 +33,19 @@ module Rouge
33
33
  rule %r('(\\\\|\\'|[^\n'])*'), Str::Single
34
34
 
35
35
  # if it's not a string, it's a comment.
36
- rule /(?<=\s)"[^-:.%#=*].*?$/, Comment
36
+ rule %r/(?<=\s)"[^-:.%#=*].*?$/, Comment
37
37
 
38
- rule /-?\d+/, Num
39
- rule /#[0-9a-f]{6}/i, Num::Hex
40
- rule /^:/, Punctuation
41
- rule /[():<>+=!\[\]{}\|,~.-]/, Punctuation
42
- rule /\b(let|if|else|endif|elseif|fun|function|endfunction)\b/,
38
+ rule %r/-?\d+/, Num
39
+ rule %r/#[0-9a-f]{6}/i, Num::Hex
40
+ rule %r/^:/, Punctuation
41
+ rule %r/[():<>+=!\[\]{}\|,~.-]/, Punctuation
42
+ rule %r/\b(let|if|else|endif|elseif|fun|function|endfunction)\b/,
43
43
  Keyword
44
44
 
45
- rule /\b(NONE|bold|italic|underline|dark|light)\b/, Name::Builtin
45
+ rule %r/\b(NONE|bold|italic|underline|dark|light)\b/, Name::Builtin
46
46
 
47
- rule /[absg]:\w+\b/, Name::Variable
48
- rule /\b\w+\b/ do |m|
47
+ rule %r/[absg]:\w+\b/, Name::Variable
48
+ rule %r/\b\w+\b/ do |m|
49
49
  name = m[0]
50
50
  keywords = self.class.keywords
51
51
 
@@ -61,7 +61,7 @@ module Rouge
61
61
  end
62
62
 
63
63
  # no errors in VimL!
64
- rule /./m, Text
64
+ rule %r/./m, Text
65
65
  end
66
66
 
67
67
  def mapping_contains?(mapping, word)
@@ -36,21 +36,21 @@ module Rouge
36
36
  start { @js.reset! }
37
37
 
38
38
  prepend :root do
39
- rule /(<)(\s*)(template)/ do
39
+ rule %r/(<)(\s*)(template)/ do
40
40
  groups Name::Tag, Text, Keyword
41
41
  @lang = HTML
42
42
  push :template
43
43
  push :lang_tag
44
44
  end
45
45
 
46
- rule /(<)(\s*)(style)/ do
46
+ rule %r/(<)(\s*)(style)/ do
47
47
  groups Name::Tag, Text, Keyword
48
48
  @lang = CSS
49
49
  push :style
50
50
  push :lang_tag
51
51
  end
52
52
 
53
- rule /(<)(\s*)(script)/ do
53
+ rule %r/(<)(\s*)(script)/ do
54
54
  groups Name::Tag, Text, Keyword
55
55
  @lang = Javascript
56
56
  push :script
@@ -59,7 +59,7 @@ module Rouge
59
59
  end
60
60
 
61
61
  state :style do
62
- rule /(<\s*\/\s*)(style)(\s*>)/ do
62
+ rule %r/(<\s*\/\s*)(style)(\s*>)/ do
63
63
  groups Name::Tag, Keyword, Name::Tag
64
64
  pop!
65
65
  end
@@ -69,7 +69,7 @@ module Rouge
69
69
  end
70
70
 
71
71
  state :script do
72
- rule /(<\s*\/\s*)(script)(\s*>)/ do
72
+ rule %r/(<\s*\/\s*)(script)(\s*>)/ do
73
73
  groups Name::Tag, Keyword, Name::Tag
74
74
  pop!
75
75
  end
@@ -79,7 +79,7 @@ module Rouge
79
79
  end
80
80
 
81
81
  state :lang_tag do
82
- rule /(lang\s*=)(\s*)("(?:\\.|[^\\])*?"|'(\\.|[^\\])*?'|[^\s>]+)/ do |m|
82
+ rule %r/(lang\s*=)(\s*)("(?:\\.|[^\\])*?"|'(\\.|[^\\])*?'|[^\s>]+)/ do |m|
83
83
  groups Name::Attribute, Text, Str
84
84
  @lang = lookup_lang(m[3])
85
85
  end
@@ -93,7 +93,7 @@ module Rouge
93
93
  pop!
94
94
  end
95
95
 
96
- rule /{{/ do
96
+ rule %r/{{/ do
97
97
  token Str::Interpol
98
98
  push :template_interpol
99
99
  @js.reset!
@@ -103,8 +103,8 @@ module Rouge
103
103
  end
104
104
 
105
105
  state :template_interpol do
106
- rule /}}/, Str::Interpol, :pop!
107
- rule /}/, Error
106
+ rule %r/}}/, Str::Interpol, :pop!
107
+ rule %r/}/, Error
108
108
  mixin :template_interpol_inner
109
109
  end
110
110
 
@@ -7,7 +7,7 @@ module Rouge
7
7
  title 'Wollok'
8
8
  desc 'Wollok lang'
9
9
  tag 'wollok'
10
- filenames *%w(*.wlk *.wtest *.wpgm)
10
+ filenames '*.wlk', '*.wtest', '*.wpgm'
11
11
 
12
12
  keywords = %w(new super return if else var const override constructor)
13
13
 
@@ -17,23 +17,23 @@ module Rouge
17
17
  entities = []
18
18
 
19
19
  state :whitespaces_and_comments do
20
- rule /\s+/m, Text::Whitespace
21
- rule /$+/m, Text::Whitespace
20
+ rule %r/\s+/m, Text::Whitespace
21
+ rule %r/$+/m, Text::Whitespace
22
22
  rule %r(//.*$), Comment::Single
23
23
  rule %r(/\*(.|\s)*?\*/)m, Comment::Multiline
24
24
  end
25
25
 
26
26
  state :root do
27
27
  mixin :whitespaces_and_comments
28
- rule /(import)(.+$)/ do
28
+ rule %r/(import)(.+$)/ do
29
29
  groups Keyword::Reserved, Text
30
30
  end
31
- rule /(class|object|mixin)/, Keyword::Reserved, :foo
32
- rule /test|program/, Keyword::Reserved #, :chunk_naming
33
- rule /(package)(\s+)(#{entity_name})/ do
31
+ rule %r/(class|object|mixin)/, Keyword::Reserved, :foo
32
+ rule %r/test|program/, Keyword::Reserved #, :chunk_naming
33
+ rule %r/(package)(\s+)(#{entity_name})/ do
34
34
  groups Keyword::Reserved, Text::Whitespace, Name::Class
35
35
  end
36
- rule /{|}/, Text
36
+ rule %r/{|}/, Text
37
37
  mixin :keywords
38
38
  mixin :symbols
39
39
  mixin :objects
@@ -41,13 +41,13 @@ module Rouge
41
41
 
42
42
  state :foo do
43
43
  mixin :whitespaces_and_comments
44
- rule /inherits|mixed|with|and/, Keyword::Reserved
45
- rule /#{entity_name}(?=\s*{)/ do |m|
44
+ rule %r/inherits|mixed|with|and/, Keyword::Reserved
45
+ rule %r/#{entity_name}(?=\s*{)/ do |m|
46
46
  token Name::Class
47
47
  entities << m[0]
48
48
  pop!
49
49
  end
50
- rule /#{entity_name}/ do |m|
50
+ rule %r/#{entity_name}/ do |m|
51
51
  token Name::Class
52
52
  entities << m[0]
53
53
  end
@@ -58,9 +58,9 @@ module Rouge
58
58
  /#{expressions.map { |keyword| "#{keyword}\\b" }.join('|')}/
59
59
  end
60
60
 
61
- rule /self\b/, Name::Builtin::Pseudo
61
+ rule %r/self\b/, Name::Builtin::Pseudo
62
62
  rule any(keywords), Keyword::Reserved
63
- rule /(method)(\s+)(#{variable_naming})/ do
63
+ rule %r/(method)(\s+)(#{variable_naming})/ do
64
64
  groups Keyword::Reserved, Text::Whitespace, Text
65
65
  end
66
66
  end
@@ -74,30 +74,30 @@ module Rouge
74
74
  token Keyword::Variable
75
75
  end
76
76
  end
77
- rule /\.#{entity_name}/, Text
77
+ rule %r/\.#{entity_name}/, Text
78
78
  mixin :literals
79
79
  end
80
80
 
81
81
  state :literals do
82
82
  mixin :whitespaces_and_comments
83
- rule /[0-9]+\.?[0-9]*/, Literal::Number
84
- rule /"[^"]*"/m, Literal::String
85
- rule /\[|\#{/, Punctuation, :lists
83
+ rule %r/[0-9]+\.?[0-9]*/, Literal::Number
84
+ rule %r/"[^"]*"/m, Literal::String
85
+ rule %r/\[|\#{/, Punctuation, :lists
86
86
  end
87
87
 
88
88
  state :lists do
89
- rule /,/, Punctuation
90
- rule /]|}/, Punctuation, :pop!
89
+ rule %r/,/, Punctuation
90
+ rule %r/]|}/, Punctuation, :pop!
91
91
  mixin :objects
92
92
  end
93
93
 
94
94
  state :symbols do
95
- rule /\+\+|--|\+=|-=|\*\*|!/, Operator
96
- rule /\+|-|\*|\/|%/, Operator
97
- rule /<=|=>|===|==|<|>/, Operator
98
- rule /and\b|or\b|not\b/, Operator
99
- rule /\(|\)|=/, Text
100
- rule /,/, Punctuation
95
+ rule %r/\+\+|--|\+=|-=|\*\*|!/, Operator
96
+ rule %r/\+|-|\*|\/|%/, Operator
97
+ rule %r/<=|=>|===|==|<|>/, Operator
98
+ rule %r/and\b|or\b|not\b/, Operator
99
+ rule %r/\(|\)|=/, Text
100
+ rule %r/,/, Punctuation
101
101
  end
102
102
  end
103
103
  end