rouge 3.1.0 → 3.18.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (318) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +17 -3
  3. data/bin/rougify +1 -0
  4. data/lib/rouge.rb +67 -42
  5. data/lib/rouge/cli.rb +87 -18
  6. data/lib/rouge/demos/ada +26 -0
  7. data/lib/rouge/demos/apex +9 -0
  8. data/lib/rouge/demos/armasm +12 -0
  9. data/lib/rouge/demos/batchfile +3 -0
  10. data/lib/rouge/demos/bbcbasic +6 -0
  11. data/lib/rouge/demos/bpf +7 -0
  12. data/lib/rouge/demos/brainfuck +5 -0
  13. data/lib/rouge/demos/clean +6 -0
  14. data/lib/rouge/demos/cmhg +8 -0
  15. data/lib/rouge/demos/crystal +45 -0
  16. data/lib/rouge/demos/csvs +8 -0
  17. data/lib/rouge/demos/cuda +11 -0
  18. data/lib/rouge/demos/cypher +5 -0
  19. data/lib/rouge/demos/cython +6 -0
  20. data/lib/rouge/demos/datastudio +21 -0
  21. data/lib/rouge/demos/ecl +18 -0
  22. data/lib/rouge/demos/eex +1 -0
  23. data/lib/rouge/demos/epp +4 -0
  24. data/lib/rouge/demos/escape +3 -0
  25. data/lib/rouge/demos/freefem +16 -0
  26. data/lib/rouge/demos/gdscript +18 -0
  27. data/lib/rouge/demos/ghc-cmm +23 -0
  28. data/lib/rouge/demos/ghc-core +26 -0
  29. data/lib/rouge/demos/haxe +5 -0
  30. data/lib/rouge/demos/hcl +7 -0
  31. data/lib/rouge/demos/hocon +8 -0
  32. data/lib/rouge/demos/hql +5 -0
  33. data/lib/rouge/demos/isbl +4 -0
  34. data/lib/rouge/demos/jsl +3 -0
  35. data/lib/rouge/demos/jsp +29 -0
  36. data/lib/rouge/demos/liquid +0 -1
  37. data/lib/rouge/demos/lustre +6 -0
  38. data/lib/rouge/demos/lutin +18 -0
  39. data/lib/rouge/demos/m68k +16 -0
  40. data/lib/rouge/demos/magik +6 -0
  41. data/lib/rouge/demos/mason +22 -0
  42. data/lib/rouge/demos/mathematica +8 -0
  43. data/lib/rouge/demos/minizinc +23 -0
  44. data/lib/rouge/demos/msgtrans +4 -0
  45. data/lib/rouge/demos/nasm +6 -6
  46. data/lib/rouge/demos/nesasm +11 -0
  47. data/lib/rouge/demos/objective_cpp +17 -0
  48. data/lib/rouge/demos/openedge +4 -0
  49. data/lib/rouge/demos/opentype_feature_file +6 -0
  50. data/lib/rouge/demos/plist +1 -132
  51. data/lib/rouge/demos/powershell +12 -48
  52. data/lib/rouge/demos/q +6 -0
  53. data/lib/rouge/demos/reasonml +12 -0
  54. data/lib/rouge/demos/rego +8 -0
  55. data/lib/rouge/demos/robot_framework +27 -0
  56. data/lib/rouge/demos/sas +13 -0
  57. data/lib/rouge/demos/slice +10 -0
  58. data/lib/rouge/demos/solidity +13 -0
  59. data/lib/rouge/demos/sparql +6 -0
  60. data/lib/rouge/demos/sqf +14 -0
  61. data/lib/rouge/demos/supercollider +11 -0
  62. data/lib/rouge/demos/terraform +16 -0
  63. data/lib/rouge/demos/ttcn3 +6 -0
  64. data/lib/rouge/demos/vcl +12 -0
  65. data/lib/rouge/demos/xojo +14 -0
  66. data/lib/rouge/demos/xpath +2 -0
  67. data/lib/rouge/demos/xquery +22 -0
  68. data/lib/rouge/demos/yang +17 -0
  69. data/lib/rouge/formatter.rb +39 -2
  70. data/lib/rouge/formatters/html.rb +21 -2
  71. data/lib/rouge/formatters/html_inline.rb +1 -0
  72. data/lib/rouge/formatters/html_legacy.rb +1 -0
  73. data/lib/rouge/formatters/html_line_table.rb +53 -0
  74. data/lib/rouge/formatters/html_linewise.rb +7 -11
  75. data/lib/rouge/formatters/html_pygments.rb +2 -0
  76. data/lib/rouge/formatters/html_table.rb +21 -31
  77. data/lib/rouge/formatters/null.rb +1 -0
  78. data/lib/rouge/formatters/terminal256.rb +23 -5
  79. data/lib/rouge/formatters/terminal_truecolor.rb +37 -0
  80. data/lib/rouge/formatters/tex.rb +92 -0
  81. data/lib/rouge/guesser.rb +2 -0
  82. data/lib/rouge/guessers/disambiguation.rb +35 -0
  83. data/lib/rouge/guessers/filename.rb +2 -0
  84. data/lib/rouge/guessers/glob_mapping.rb +3 -1
  85. data/lib/rouge/guessers/mimetype.rb +2 -0
  86. data/lib/rouge/guessers/modeline.rb +3 -1
  87. data/lib/rouge/guessers/source.rb +3 -1
  88. data/lib/rouge/guessers/util.rb +2 -0
  89. data/lib/rouge/lexer.rb +71 -15
  90. data/lib/rouge/lexers/abap.rb +13 -11
  91. data/lib/rouge/lexers/actionscript.rb +35 -34
  92. data/lib/rouge/lexers/ada.rb +162 -0
  93. data/lib/rouge/lexers/apache.rb +13 -15
  94. data/lib/rouge/lexers/apache/keywords.rb +15 -0
  95. data/lib/rouge/lexers/apex.rb +126 -0
  96. data/lib/rouge/lexers/apiblueprint.rb +2 -0
  97. data/lib/rouge/lexers/apple_script.rb +17 -14
  98. data/lib/rouge/lexers/armasm.rb +145 -0
  99. data/lib/rouge/lexers/awk.rb +26 -25
  100. data/lib/rouge/lexers/batchfile.rb +164 -0
  101. data/lib/rouge/lexers/bbcbasic.rb +112 -0
  102. data/lib/rouge/lexers/biml.rb +6 -4
  103. data/lib/rouge/lexers/bpf.rb +118 -0
  104. data/lib/rouge/lexers/brainfuck.rb +53 -0
  105. data/lib/rouge/lexers/bsl.rb +13 -12
  106. data/lib/rouge/lexers/c.rb +35 -57
  107. data/lib/rouge/lexers/ceylon.rb +7 -34
  108. data/lib/rouge/lexers/cfscript.rb +27 -26
  109. data/lib/rouge/lexers/clean.rb +156 -0
  110. data/lib/rouge/lexers/clojure.rb +15 -14
  111. data/lib/rouge/lexers/cmake.rb +16 -14
  112. data/lib/rouge/lexers/cmhg.rb +34 -0
  113. data/lib/rouge/lexers/coffeescript.rb +90 -49
  114. data/lib/rouge/lexers/common_lisp.rb +39 -38
  115. data/lib/rouge/lexers/conf.rb +7 -6
  116. data/lib/rouge/lexers/console.rb +92 -38
  117. data/lib/rouge/lexers/coq.rb +27 -23
  118. data/lib/rouge/lexers/cpp.rb +24 -13
  119. data/lib/rouge/lexers/crystal.rb +430 -0
  120. data/lib/rouge/lexers/csharp.rb +29 -29
  121. data/lib/rouge/lexers/css.rb +24 -23
  122. data/lib/rouge/lexers/csvs.rb +44 -0
  123. data/lib/rouge/lexers/cuda.rb +35 -0
  124. data/lib/rouge/lexers/cypher.rb +108 -0
  125. data/lib/rouge/lexers/cython.rb +151 -0
  126. data/lib/rouge/lexers/d.rb +64 -63
  127. data/lib/rouge/lexers/dart.rb +34 -33
  128. data/lib/rouge/lexers/datastudio.rb +138 -0
  129. data/lib/rouge/lexers/diff.rb +10 -4
  130. data/lib/rouge/lexers/digdag.rb +3 -1
  131. data/lib/rouge/lexers/docker.rb +12 -11
  132. data/lib/rouge/lexers/dot.rb +19 -18
  133. data/lib/rouge/lexers/ecl.rb +175 -0
  134. data/lib/rouge/lexers/eex.rb +52 -0
  135. data/lib/rouge/lexers/eiffel.rb +21 -20
  136. data/lib/rouge/lexers/elixir.rb +52 -36
  137. data/lib/rouge/lexers/elm.rb +30 -29
  138. data/lib/rouge/lexers/epp.rb +51 -0
  139. data/lib/rouge/lexers/erb.rb +5 -4
  140. data/lib/rouge/lexers/erlang.rb +1 -0
  141. data/lib/rouge/lexers/escape.rb +58 -0
  142. data/lib/rouge/lexers/factor.rb +41 -40
  143. data/lib/rouge/lexers/fortran.rb +36 -34
  144. data/lib/rouge/lexers/freefem.rb +240 -0
  145. data/lib/rouge/lexers/fsharp.rb +33 -31
  146. data/lib/rouge/lexers/gdscript.rb +171 -0
  147. data/lib/rouge/lexers/ghc_cmm.rb +340 -0
  148. data/lib/rouge/lexers/ghc_core.rb +151 -0
  149. data/lib/rouge/lexers/gherkin.rb +17 -14
  150. data/lib/rouge/lexers/gherkin/keywords.rb +2 -0
  151. data/lib/rouge/lexers/glsl.rb +2 -5
  152. data/lib/rouge/lexers/go.rb +3 -2
  153. data/lib/rouge/lexers/gradle.rb +1 -0
  154. data/lib/rouge/lexers/graphql.rb +78 -60
  155. data/lib/rouge/lexers/groovy.rb +24 -25
  156. data/lib/rouge/lexers/hack.rb +2 -1
  157. data/lib/rouge/lexers/haml.rb +26 -29
  158. data/lib/rouge/lexers/handlebars.rb +32 -20
  159. data/lib/rouge/lexers/haskell.rb +78 -61
  160. data/lib/rouge/lexers/haxe.rb +246 -0
  161. data/lib/rouge/lexers/hcl.rb +163 -0
  162. data/lib/rouge/lexers/hocon.rb +86 -0
  163. data/lib/rouge/lexers/hql.rb +139 -0
  164. data/lib/rouge/lexers/html.rb +36 -33
  165. data/lib/rouge/lexers/http.rb +10 -9
  166. data/lib/rouge/lexers/hylang.rb +15 -14
  167. data/lib/rouge/lexers/idlang.rb +34 -32
  168. data/lib/rouge/lexers/igorpro.rb +481 -225
  169. data/lib/rouge/lexers/ini.rb +13 -12
  170. data/lib/rouge/lexers/io.rb +10 -9
  171. data/lib/rouge/lexers/irb.rb +6 -5
  172. data/lib/rouge/lexers/isbl.rb +97 -0
  173. data/lib/rouge/lexers/isbl/builtins.rb +17 -0
  174. data/lib/rouge/lexers/java.rb +30 -26
  175. data/lib/rouge/lexers/javascript.rb +59 -61
  176. data/lib/rouge/lexers/jinja.rb +39 -22
  177. data/lib/rouge/lexers/jsl.rb +55 -0
  178. data/lib/rouge/lexers/json.rb +54 -11
  179. data/lib/rouge/lexers/json_doc.rb +8 -5
  180. data/lib/rouge/lexers/jsonnet.rb +19 -18
  181. data/lib/rouge/lexers/jsp.rb +120 -0
  182. data/lib/rouge/lexers/jsx.rb +18 -16
  183. data/lib/rouge/lexers/julia.rb +192 -74
  184. data/lib/rouge/lexers/kotlin.rb +79 -27
  185. data/lib/rouge/lexers/lasso.rb +54 -58
  186. data/lib/rouge/lexers/lasso/keywords.rb +14 -0
  187. data/lib/rouge/lexers/liquid.rb +116 -118
  188. data/lib/rouge/lexers/literate_coffeescript.rb +3 -2
  189. data/lib/rouge/lexers/literate_haskell.rb +6 -5
  190. data/lib/rouge/lexers/llvm.rb +66 -49
  191. data/lib/rouge/lexers/lua.rb +43 -4
  192. data/lib/rouge/lexers/lua/builtins.rb +2 -0
  193. data/lib/rouge/lexers/lustre.rb +79 -0
  194. data/lib/rouge/lexers/lutin.rb +33 -0
  195. data/lib/rouge/lexers/m68k.rb +143 -0
  196. data/lib/rouge/lexers/magik.rb +127 -0
  197. data/lib/rouge/lexers/make.rb +57 -34
  198. data/lib/rouge/lexers/markdown.rb +67 -39
  199. data/lib/rouge/lexers/mason.rb +110 -0
  200. data/lib/rouge/lexers/mathematica.rb +96 -0
  201. data/lib/rouge/lexers/mathematica/builtins.rb +13 -0
  202. data/lib/rouge/lexers/matlab.rb +26 -17
  203. data/lib/rouge/lexers/matlab/builtins.rb +4 -4
  204. data/lib/rouge/lexers/minizinc.rb +87 -0
  205. data/lib/rouge/lexers/moonscript.rb +4 -3
  206. data/lib/rouge/lexers/mosel.rb +64 -63
  207. data/lib/rouge/lexers/msgtrans.rb +26 -0
  208. data/lib/rouge/lexers/mxml.rb +19 -18
  209. data/lib/rouge/lexers/nasm.rb +43 -169
  210. data/lib/rouge/lexers/nesasm.rb +78 -0
  211. data/lib/rouge/lexers/nginx.rb +15 -14
  212. data/lib/rouge/lexers/nim.rb +4 -2
  213. data/lib/rouge/lexers/nix.rb +48 -42
  214. data/lib/rouge/lexers/objective_c.rb +5 -178
  215. data/lib/rouge/lexers/objective_c/common.rb +184 -0
  216. data/lib/rouge/lexers/objective_cpp.rb +31 -0
  217. data/lib/rouge/lexers/ocaml.rb +29 -64
  218. data/lib/rouge/lexers/ocaml/common.rb +53 -0
  219. data/lib/rouge/lexers/openedge.rb +429 -0
  220. data/lib/rouge/lexers/opentype_feature_file.rb +113 -0
  221. data/lib/rouge/lexers/pascal.rb +6 -5
  222. data/lib/rouge/lexers/perl.rb +103 -68
  223. data/lib/rouge/lexers/php.rb +91 -53
  224. data/lib/rouge/lexers/php/builtins.rb +183 -174
  225. data/lib/rouge/lexers/plain_text.rb +2 -1
  226. data/lib/rouge/lexers/plist.rb +16 -14
  227. data/lib/rouge/lexers/pony.rb +21 -20
  228. data/lib/rouge/lexers/powershell.rb +190 -638
  229. data/lib/rouge/lexers/praat.rb +76 -75
  230. data/lib/rouge/lexers/prolog.rb +27 -19
  231. data/lib/rouge/lexers/prometheus.rb +32 -30
  232. data/lib/rouge/lexers/properties.rb +13 -12
  233. data/lib/rouge/lexers/protobuf.rb +23 -22
  234. data/lib/rouge/lexers/puppet.rb +33 -32
  235. data/lib/rouge/lexers/python.rb +124 -99
  236. data/lib/rouge/lexers/q.rb +17 -14
  237. data/lib/rouge/lexers/qml.rb +13 -12
  238. data/lib/rouge/lexers/r.rb +13 -13
  239. data/lib/rouge/lexers/racket.rb +47 -22
  240. data/lib/rouge/lexers/reasonml.rb +65 -0
  241. data/lib/rouge/lexers/rego.rb +45 -0
  242. data/lib/rouge/lexers/robot_framework.rb +249 -0
  243. data/lib/rouge/lexers/ruby.rb +88 -71
  244. data/lib/rouge/lexers/rust.rb +45 -44
  245. data/lib/rouge/lexers/sas.rb +563 -0
  246. data/lib/rouge/lexers/sass.rb +9 -8
  247. data/lib/rouge/lexers/sass/common.rb +41 -40
  248. data/lib/rouge/lexers/scala.rb +67 -40
  249. data/lib/rouge/lexers/scheme.rb +19 -18
  250. data/lib/rouge/lexers/scss.rb +4 -3
  251. data/lib/rouge/lexers/sed.rb +31 -30
  252. data/lib/rouge/lexers/shell.rb +67 -55
  253. data/lib/rouge/lexers/sieve.rb +10 -9
  254. data/lib/rouge/lexers/slice.rb +32 -0
  255. data/lib/rouge/lexers/slim.rb +27 -26
  256. data/lib/rouge/lexers/smalltalk.rb +34 -33
  257. data/lib/rouge/lexers/smarty.rb +20 -19
  258. data/lib/rouge/lexers/sml.rb +68 -67
  259. data/lib/rouge/lexers/solidity.rb +185 -0
  260. data/lib/rouge/lexers/sparql.rb +129 -0
  261. data/lib/rouge/lexers/sqf.rb +109 -0
  262. data/lib/rouge/lexers/sqf/commands.rb +15 -0
  263. data/lib/rouge/lexers/sql.rb +47 -26
  264. data/lib/rouge/lexers/supercollider.rb +116 -0
  265. data/lib/rouge/lexers/swift.rb +50 -45
  266. data/lib/rouge/lexers/tap.rb +22 -20
  267. data/lib/rouge/lexers/tcl.rb +28 -27
  268. data/lib/rouge/lexers/terraform.rb +128 -0
  269. data/lib/rouge/lexers/tex.rb +20 -19
  270. data/lib/rouge/lexers/toml.rb +59 -20
  271. data/lib/rouge/lexers/tsx.rb +1 -0
  272. data/lib/rouge/lexers/ttcn3.rb +119 -0
  273. data/lib/rouge/lexers/tulip.rb +38 -36
  274. data/lib/rouge/lexers/turtle.rb +36 -38
  275. data/lib/rouge/lexers/twig.rb +1 -0
  276. data/lib/rouge/lexers/typescript.rb +12 -0
  277. data/lib/rouge/lexers/typescript/common.rb +1 -0
  278. data/lib/rouge/lexers/vala.rb +19 -18
  279. data/lib/rouge/lexers/varnish.rb +168 -0
  280. data/lib/rouge/lexers/vb.rb +28 -27
  281. data/lib/rouge/lexers/verilog.rb +27 -28
  282. data/lib/rouge/lexers/vhdl.rb +13 -12
  283. data/lib/rouge/lexers/viml.rb +15 -14
  284. data/lib/rouge/lexers/viml/keywords.rb +2 -0
  285. data/lib/rouge/lexers/vue.rb +19 -12
  286. data/lib/rouge/lexers/wollok.rb +27 -26
  287. data/lib/rouge/lexers/xml.rb +18 -21
  288. data/lib/rouge/lexers/xojo.rb +61 -0
  289. data/lib/rouge/lexers/xpath.rb +332 -0
  290. data/lib/rouge/lexers/xquery.rb +145 -0
  291. data/lib/rouge/lexers/yaml.rb +64 -61
  292. data/lib/rouge/lexers/yang.rb +147 -0
  293. data/lib/rouge/plugins/redcarpet.rb +9 -2
  294. data/lib/rouge/regex_lexer.rb +27 -25
  295. data/lib/rouge/template_lexer.rb +1 -0
  296. data/lib/rouge/tex_theme_renderer.rb +132 -0
  297. data/lib/rouge/text_analyzer.rb +1 -0
  298. data/lib/rouge/theme.rb +5 -0
  299. data/lib/rouge/themes/base16.rb +1 -0
  300. data/lib/rouge/themes/bw.rb +41 -0
  301. data/lib/rouge/themes/colorful.rb +1 -0
  302. data/lib/rouge/themes/github.rb +1 -0
  303. data/lib/rouge/themes/gruvbox.rb +1 -0
  304. data/lib/rouge/themes/igor_pro.rb +1 -0
  305. data/lib/rouge/themes/magritte.rb +78 -0
  306. data/lib/rouge/themes/molokai.rb +1 -0
  307. data/lib/rouge/themes/monokai.rb +1 -0
  308. data/lib/rouge/themes/monokai_sublime.rb +4 -1
  309. data/lib/rouge/themes/pastie.rb +2 -1
  310. data/lib/rouge/themes/thankful_eyes.rb +2 -1
  311. data/lib/rouge/themes/tulip.rb +2 -1
  312. data/lib/rouge/token.rb +31 -22
  313. data/lib/rouge/util.rb +3 -2
  314. data/lib/rouge/version.rb +2 -1
  315. data/rouge.gemspec +6 -3
  316. metadata +136 -8
  317. data/lib/rouge/lexers/apache/keywords.yml +0 -764
  318. data/lib/rouge/lexers/lasso/keywords.yml +0 -446
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Rouge
4
5
  module Lexers
@@ -53,16 +54,16 @@ module Rouge
53
54
  upper_id = /[A-Z]\w*/
54
55
 
55
56
  state :whitespace do
56
- rule /\s+/, Text
57
- rule /\n/, Text, :bol
58
- 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
59
60
  rule %r(%\{.*?%\})m, Comment::Multiline
60
- rule /'.*$/, Comment::Single
61
+ rule %r/'.*$/, Comment::Single
61
62
  end
62
63
 
63
64
  state :bol do
64
- rule /\s+/, Text
65
- rule /<.*?>/, Name::Attribute
65
+ rule %r/\s+/, Text
66
+ rule %r/<.*?>/, Name::Attribute
66
67
  rule(//) { :pop! }
67
68
  end
68
69
 
@@ -79,15 +80,15 @@ module Rouge
79
80
  | [#]End \s+ Region
80
81
  | [#]ExternalChecksum
81
82
  )x, Comment::Preproc
82
- rule /[.]/, Punctuation, :dotted
83
- rule /[(){}!#,:]/, Punctuation
84
- 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)/,
85
86
  Keyword::Declaration
86
- rule /End\b/, Keyword, :end
87
- rule /(Dim|Const)\b/, Keyword, :dim
88
- rule /(Function|Sub|Property)\b/, Keyword, :funcname
89
- rule /(Class|Structure|Enum)\b/, Keyword, :classname
90
- 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
91
92
 
92
93
  rule upper_id do |m|
93
94
  match = m[0]
@@ -109,16 +110,16 @@ module Rouge
109
110
  Operator
110
111
  )
111
112
 
112
- rule /"/, Str, :string
113
- rule /#{id}[%&@!#\$]?/, Name
114
- rule /#.*?#/, Literal::Date
113
+ rule %r/"/, Str, :string
114
+ rule %r/#{id}[%&@!#\$]?/, Name
115
+ rule %r/#.*?#/, Literal::Date
115
116
 
116
- rule /(\d+\.\d*|\d*\.\d+)(f[+-]?\d+)?/i, Num::Float
117
- rule /\d+([SILDFR]|US|UI|UL)?/, Num::Integer
118
- rule /&H[0-9a-f]+([SILDFR]|US|UI|UL)?/, Num::Integer
119
- 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
120
121
 
121
- rule /_\n/, Keyword
122
+ rule %r/_\n/, Keyword
122
123
  end
123
124
 
124
125
  state :dotted do
@@ -127,9 +128,9 @@ module Rouge
127
128
  end
128
129
 
129
130
  state :string do
130
- rule /""/, Str::Escape
131
- rule /"C?/, Str, :pop!
132
- rule /[^"]+/, Str
131
+ rule %r/""/, Str::Escape
132
+ rule %r/"C?/, Str, :pop!
133
+ rule %r/[^"]+/, Str
133
134
  end
134
135
 
135
136
  state :dim do
@@ -150,12 +151,12 @@ module Rouge
150
151
 
151
152
  state :namespace do
152
153
  mixin :whitespace
153
- rule /#{id}([.]#{id})*/, Name::Namespace, :pop!
154
+ rule %r/#{id}([.]#{id})*/, Name::Namespace, :pop!
154
155
  end
155
156
 
156
157
  state :end do
157
158
  mixin :whitespace
158
- rule /(Function|Sub|Property|Class|Structure|Enum|Module|Namespace)\b/,
159
+ rule %r/(Function|Sub|Property|Class|Structure|Enum|Module|Namespace)\b/,
159
160
  Keyword, :pop!
160
161
  rule(//) { pop! }
161
162
  end
@@ -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,8 +10,6 @@ module Rouge
9
10
  filenames '*.v', '*.sv', '*.svh'
10
11
  mimetypes 'text/x-verilog', 'text/x-systemverilog'
11
12
 
12
- # optional comment or whitespace
13
- ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
14
13
  id = /[a-zA-Z_][a-zA-Z0-9_]*/
15
14
 
16
15
  def self.keywords
@@ -81,7 +80,7 @@ module Rouge
81
80
 
82
81
  state :expr_bol do
83
82
  mixin :inline_whitespace
84
- rule /`define/, Comment::Preproc, :macro
83
+ rule %r/`define/, Comment::Preproc, :macro
85
84
 
86
85
  rule(//) { pop! }
87
86
  end
@@ -89,47 +88,47 @@ module Rouge
89
88
  # :expr_bol is the same as :bol but without labels, since
90
89
  # labels can only appear at the beginning of a statement.
91
90
  state :bol do
92
- rule /#{id}:(?!:)/, Name::Label
91
+ rule %r/#{id}:(?!:)/, Name::Label
93
92
  mixin :expr_bol
94
93
  end
95
94
 
96
95
  state :inline_whitespace do
97
- rule /[ \t\r]+/, Text
98
- rule /\\\n/, Text # line continuation
96
+ rule %r/[ \t\r]+/, Text
97
+ rule %r/\\\n/, Text # line continuation
99
98
  rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
100
99
  end
101
100
 
102
101
  state :whitespace do
103
- rule /\n+/m, Text, :bol
104
- rule %r(//(\\.|.)*?\n), Comment::Single, :bol
102
+ rule %r/\n+/m, Text, :bol
103
+ rule %r(//(\\.|.)*?$), Comment::Single, :bol
105
104
  mixin :inline_whitespace
106
105
  end
107
106
 
108
107
  state :expr_whitespace do
109
- rule /\n+/m, Text, :expr_bol
108
+ rule %r/\n+/m, Text, :expr_bol
110
109
  mixin :whitespace
111
110
  end
112
111
 
113
112
  state :string do
114
- rule /"/, Str, :pop!
115
- rule /\\([\\abfnrtv"']|x[a-fA-F0-9]{2,4}|[0-7]{1,3})/, Str::Escape
116
- rule /[^\\"\n]+/, Str
117
- rule /\\\n/, Str
118
- 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
119
118
  end
120
119
 
121
120
  state :statement do
122
121
  mixin :whitespace
123
- rule /L?"/, Str, :string
124
- rule /([0-9_]+\.[0-9_]*|[0-9_]*\.[0-9_]+)(e[+-]?[0-9_]+)?/i, Num::Float
125
- rule /[0-9_]+e[+-]?[0-9_]+/i, Num::Float
126
- rule /[0-9]*'h[0-9a-fA-F_?]+/, Num::Hex
127
- rule /[0-9]*'b?[01xz_?]+/, Num::Bin
128
- rule /[0-9]*'d[0-9_?]+/, Num::Integer
129
- rule /[0-9_]+[lu]*/i, Num::Integer
130
- rule %r([~!%^&*+-=\|?:<>/@{}]), Operator
131
- rule /[()\[\],.$\#]/, Punctuation
132
- 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
133
132
 
134
133
  rule id do |m|
135
134
  name = m[0]
@@ -152,11 +151,11 @@ module Rouge
152
151
  end
153
152
 
154
153
  state :macro do
155
- rule /\n/, Comment::Preproc, :pop!
154
+ rule %r/\n/, Comment::Preproc, :pop!
156
155
  mixin :inline_whitespace
157
- rule /;/, Punctuation
158
- rule /\=/, Operator
159
- rule /(\w+)/, Text
156
+ rule %r/;/, Punctuation
157
+ rule %r/\=/, Operator
158
+ rule %r/(\w+)/, Text
160
159
  end
161
160
 
162
161
  end
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Rouge
4
5
  module Lexers
@@ -27,7 +28,7 @@ module Rouge
27
28
  @keywords_type ||= Set.new %w(
28
29
  bit bit_vector boolean boolean_vector character integer integer_vector natural positive
29
30
  real real_vector severity_level signed std_logic std_logic_vector std_ulogic
30
- std_ulogic_vector string unsigned time time__vector
31
+ std_ulogic_vector string unsigned time time_vector
31
32
  )
32
33
  end
33
34
 
@@ -40,30 +41,30 @@ module Rouge
40
41
  id = /[a-zA-Z][a-zA-Z0-9_]*/
41
42
 
42
43
  state :whitespace do
43
- rule /\s+/, Text
44
- rule /\n/, Text
44
+ rule %r/\s+/, Text
45
+ rule %r/\n/, Text
45
46
  # Find Comments (VHDL doesn't support multiline comments)
46
- rule /--.*$/, Comment::Single
47
+ rule %r/--.*$/, Comment::Single
47
48
  end
48
49
 
49
50
  state :statements do
50
51
 
51
52
  # Find Numbers
52
- rule /-?\d+/i, Num::Integer
53
- rule /-?\d+[.]\d+/i, Num::Float
53
+ rule %r/-?\d+/i, Num::Integer
54
+ rule %r/-?\d+[.]\d+/i, Num::Float
54
55
 
55
56
  # Find Strings
56
- rule /[box]?"[^"]*"/i, Str::Single
57
- rule /'[^']?'/i, Str::Char
57
+ rule %r/[box]?"[^"]*"/i, Str::Single
58
+ rule %r/'[^']?'/i, Str::Char
58
59
 
59
60
  # Find Attributes
60
- rule /'#{id}/i, Name::Attribute
61
-
61
+ rule %r/'#{id}/i, Name::Attribute
62
+
62
63
  # Punctuations
63
- rule /[(),:;]/, Punctuation
64
+ rule %r/[(),:;]/, Punctuation
64
65
 
65
66
  # Boolean and NULL
66
- rule /(?:true|false|null)\b/i, Name::Builtin
67
+ rule %r/(?:true|false|null)\b/i, Name::Builtin
67
68
 
68
69
  rule id do |m|
69
70
  match = m[0].downcase #convert to lower case
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Rouge
4
5
  module Lexers
@@ -13,18 +14,18 @@ module Rouge
13
14
  mimetypes 'text/x-vim'
14
15
 
15
16
  def self.keywords
16
- load Pathname.new(__FILE__).dirname.join('viml/keywords.rb')
17
+ load File.join(Lexers::BASE_DIR, 'viml/keywords.rb')
17
18
  self.keywords
18
19
  end
19
20
 
20
21
  state :root do
21
- rule /^(\s*)(".*?)$/ do
22
+ rule %r/^(\s*)(".*?)$/ do
22
23
  groups Text, Comment
23
24
  end
24
25
 
25
- rule /^\s*\\/, Str::Escape
26
+ rule %r/^\s*\\/, Str::Escape
26
27
 
27
- rule /[ \t]+/, Text
28
+ rule %r/[ \t]+/, Text
28
29
 
29
30
  # TODO: regexes can have other delimiters
30
31
  rule %r(/(\\\\|\\/|[^\n/])*/), Str::Regex
@@ -32,19 +33,19 @@ module Rouge
32
33
  rule %r('(\\\\|\\'|[^\n'])*'), Str::Single
33
34
 
34
35
  # if it's not a string, it's a comment.
35
- rule /(?<=\s)"[^-:.%#=*].*?$/, Comment
36
+ rule %r/(?<=\s)"[^-:.%#=*].*?$/, Comment
36
37
 
37
- rule /-?\d+/, Num
38
- rule /#[0-9a-f]{6}/i, Num::Hex
39
- rule /^:/, Punctuation
40
- rule /[():<>+=!\[\]{}\|,~.-]/, Punctuation
41
- 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/,
42
43
  Keyword
43
44
 
44
- rule /\b(NONE|bold|italic|underline|dark|light)\b/, Name::Builtin
45
+ rule %r/\b(NONE|bold|italic|underline|dark|light)\b/, Name::Builtin
45
46
 
46
- rule /[absg]:\w+\b/, Name::Variable
47
- rule /\b\w+\b/ do |m|
47
+ rule %r/[absg]:\w+\b/, Name::Variable
48
+ rule %r/\b\w+\b/ do |m|
48
49
  name = m[0]
49
50
  keywords = self.class.keywords
50
51
 
@@ -60,7 +61,7 @@ module Rouge
60
61
  end
61
62
 
62
63
  # no errors in VimL!
63
- rule /./m, Text
64
+ rule %r/./m, Text
64
65
  end
65
66
 
66
67
  def mapping_contains?(mapping, word)
@@ -1,4 +1,6 @@
1
1
  # encoding: utf-8
2
+ # frozen_string_literal: true
3
+
2
4
  # DO NOT EDIT: automatically generated by `rake builtins:vim`.
3
5
  # see tasks/vim.rake for more info.
4
6
  module Rouge
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Rouge
2
4
  module Lexers
3
5
  load_lexer 'html.rb'
@@ -16,13 +18,15 @@ module Rouge
16
18
  end
17
19
 
18
20
  def lookup_lang(lang)
21
+ lang.downcase!
22
+ lang = lang.gsub(/["']*/, '')
19
23
  case lang
20
24
  when 'html' then HTML
21
25
  when 'css' then CSS
22
26
  when 'javascript' then Javascript
23
27
  when 'sass' then Sass
24
28
  when 'scss' then Scss
25
- when 'coffee' then CoffeeScript
29
+ when 'coffee' then Coffeescript
26
30
  # TODO: add more when the lexers are done
27
31
  else
28
32
  PlainText
@@ -32,21 +36,21 @@ module Rouge
32
36
  start { @js.reset! }
33
37
 
34
38
  prepend :root do
35
- rule /(<)(\s*)(template)/ do
39
+ rule %r/(<)(\s*)(template)/ do
36
40
  groups Name::Tag, Text, Keyword
37
41
  @lang = HTML
38
42
  push :template
39
43
  push :lang_tag
40
44
  end
41
45
 
42
- rule /(<)(\s*)(style)/ do
46
+ rule %r/(<)(\s*)(style)/ do
43
47
  groups Name::Tag, Text, Keyword
44
48
  @lang = CSS
45
49
  push :style
46
50
  push :lang_tag
47
51
  end
48
52
 
49
- rule /(<)(\s*)(script)/ do
53
+ rule %r/(<)(\s*)(script)/ do
50
54
  groups Name::Tag, Text, Keyword
51
55
  @lang = Javascript
52
56
  push :script
@@ -54,8 +58,12 @@ module Rouge
54
58
  end
55
59
  end
56
60
 
61
+ prepend :tag do
62
+ rule %r/[a-zA-Z0-9_:#\[\]()*.-]+\s*=\s*/m, Name::Attribute, :attr
63
+ end
64
+
57
65
  state :style do
58
- rule /(<\s*\/\s*)(style)(\s*>)/ do
66
+ rule %r/(<\s*\/\s*)(style)(\s*>)/ do
59
67
  groups Name::Tag, Keyword, Name::Tag
60
68
  pop!
61
69
  end
@@ -65,7 +73,7 @@ module Rouge
65
73
  end
66
74
 
67
75
  state :script do
68
- rule /(<\s*\/\s*)(script)(\s*>)/ do
76
+ rule %r/(<\s*\/\s*)(script)(\s*>)/ do
69
77
  groups Name::Tag, Keyword, Name::Tag
70
78
  pop!
71
79
  end
@@ -75,9 +83,9 @@ module Rouge
75
83
  end
76
84
 
77
85
  state :lang_tag do
78
- rule /(lang\s*=)(\s*)("(?:\\.|[^\\])*?"|'(\\.|[^\\])*?'|[^\s>]+)/ do |m|
86
+ rule %r/(lang\s*=)(\s*)("(?:\\.|[^\\])*?"|'(\\.|[^\\])*?'|[^\s>]+)/ do |m|
79
87
  groups Name::Attribute, Text, Str
80
- @lang = lookup_lang(m[2])
88
+ @lang = lookup_lang(m[3])
81
89
  end
82
90
 
83
91
  mixin :tag
@@ -89,7 +97,7 @@ module Rouge
89
97
  pop!
90
98
  end
91
99
 
92
- rule /{{/ do
100
+ rule %r/{{/ do
93
101
  token Str::Interpol
94
102
  push :template_interpol
95
103
  @js.reset!
@@ -99,8 +107,8 @@ module Rouge
99
107
  end
100
108
 
101
109
  state :template_interpol do
102
- rule /}}/, Str::Interpol, :pop!
103
- rule /}/, Error
110
+ rule %r/}}/, Str::Interpol, :pop!
111
+ rule %r/}/, Error
104
112
  mixin :template_interpol_inner
105
113
  end
106
114
 
@@ -117,4 +125,3 @@ module Rouge
117
125
  end
118
126
  end
119
127
  end
120
-
@@ -1,4 +1,5 @@
1
- # -*- coding: utf-8 -*- #
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
2
3
 
3
4
  module Rouge
4
5
  module Lexers
@@ -6,7 +7,7 @@ module Rouge
6
7
  title 'Wollok'
7
8
  desc 'Wollok lang'
8
9
  tag 'wollok'
9
- filenames *%w(*.wlk *.wtest *.wpgm)
10
+ filenames '*.wlk', '*.wtest', '*.wpgm'
10
11
 
11
12
  keywords = %w(new super return if else var const override constructor)
12
13
 
@@ -16,23 +17,23 @@ module Rouge
16
17
  entities = []
17
18
 
18
19
  state :whitespaces_and_comments do
19
- rule /\s+/m, Text::Whitespace
20
- rule /$+/m, Text::Whitespace
20
+ rule %r/\s+/m, Text::Whitespace
21
+ rule %r/$+/m, Text::Whitespace
21
22
  rule %r(//.*$), Comment::Single
22
23
  rule %r(/\*(.|\s)*?\*/)m, Comment::Multiline
23
24
  end
24
25
 
25
26
  state :root do
26
27
  mixin :whitespaces_and_comments
27
- rule /(import)(.+$)/ do
28
+ rule %r/(import)(.+$)/ do
28
29
  groups Keyword::Reserved, Text
29
30
  end
30
- rule /(class|object|mixin)/, Keyword::Reserved, :foo
31
- rule /test|program/, Keyword::Reserved #, :chunk_naming
32
- 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
33
34
  groups Keyword::Reserved, Text::Whitespace, Name::Class
34
35
  end
35
- rule /{|}/, Text
36
+ rule %r/{|}/, Text
36
37
  mixin :keywords
37
38
  mixin :symbols
38
39
  mixin :objects
@@ -40,13 +41,13 @@ module Rouge
40
41
 
41
42
  state :foo do
42
43
  mixin :whitespaces_and_comments
43
- rule /inherits|mixed|with|and/, Keyword::Reserved
44
- rule /#{entity_name}(?=\s*{)/ do |m|
44
+ rule %r/inherits|mixed|with|and/, Keyword::Reserved
45
+ rule %r/#{entity_name}(?=\s*{)/ do |m|
45
46
  token Name::Class
46
47
  entities << m[0]
47
48
  pop!
48
49
  end
49
- rule /#{entity_name}/ do |m|
50
+ rule %r/#{entity_name}/ do |m|
50
51
  token Name::Class
51
52
  entities << m[0]
52
53
  end
@@ -57,9 +58,9 @@ module Rouge
57
58
  /#{expressions.map { |keyword| "#{keyword}\\b" }.join('|')}/
58
59
  end
59
60
 
60
- rule /self\b/, Name::Builtin::Pseudo
61
+ rule %r/self\b/, Name::Builtin::Pseudo
61
62
  rule any(keywords), Keyword::Reserved
62
- rule /(method)(\s+)(#{variable_naming})/ do
63
+ rule %r/(method)(\s+)(#{variable_naming})/ do
63
64
  groups Keyword::Reserved, Text::Whitespace, Text
64
65
  end
65
66
  end
@@ -73,30 +74,30 @@ module Rouge
73
74
  token Keyword::Variable
74
75
  end
75
76
  end
76
- rule /\.#{entity_name}/, Text
77
+ rule %r/\.#{entity_name}/, Text
77
78
  mixin :literals
78
79
  end
79
80
 
80
81
  state :literals do
81
82
  mixin :whitespaces_and_comments
82
- rule /[0-9]+\.?[0-9]*/, Literal::Number
83
- rule /"[^"]*"/m, Literal::String
84
- rule /\[|\#{/, Punctuation, :lists
83
+ rule %r/[0-9]+\.?[0-9]*/, Literal::Number
84
+ rule %r/"[^"]*"/m, Literal::String
85
+ rule %r/\[|\#{/, Punctuation, :lists
85
86
  end
86
87
 
87
88
  state :lists do
88
- rule /,/, Punctuation
89
- rule /]|}/, Punctuation, :pop!
89
+ rule %r/,/, Punctuation
90
+ rule %r/]|}/, Punctuation, :pop!
90
91
  mixin :objects
91
92
  end
92
93
 
93
94
  state :symbols do
94
- rule /\+\+|--|\+=|-=|\*\*|!/, Operator
95
- rule /\+|-|\*|\/|%/, Operator
96
- rule /<=|=>|===|==|<|>/, Operator
97
- rule /and\b|or\b|not\b/, Operator
98
- rule /\(|\)|=/, Text
99
- 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
100
101
  end
101
102
  end
102
103
  end