rouge 4.2.0 → 4.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +7 -7
  3. data/lib/rouge/cli.rb +2 -4
  4. data/lib/rouge/demos/iecst +21 -0
  5. data/lib/rouge/guessers/disambiguation.rb +6 -1
  6. data/lib/rouge/lexers/ada.rb +1 -1
  7. data/lib/rouge/lexers/brainfuck.rb +1 -0
  8. data/lib/rouge/lexers/clean.rb +4 -4
  9. data/lib/rouge/lexers/cpp.rb +1 -1
  10. data/lib/rouge/lexers/crystal.rb +17 -17
  11. data/lib/rouge/lexers/ecl.rb +2 -2
  12. data/lib/rouge/lexers/eiffel.rb +1 -1
  13. data/lib/rouge/lexers/elixir.rb +1 -1
  14. data/lib/rouge/lexers/gdscript.rb +4 -4
  15. data/lib/rouge/lexers/ghc_cmm.rb +3 -3
  16. data/lib/rouge/lexers/hcl.rb +1 -0
  17. data/lib/rouge/lexers/iecst.rb +92 -0
  18. data/lib/rouge/lexers/javascript.rb +1 -1
  19. data/lib/rouge/lexers/julia.rb +3 -2
  20. data/lib/rouge/lexers/kotlin.rb +1 -1
  21. data/lib/rouge/lexers/make.rb +1 -1
  22. data/lib/rouge/lexers/markdown.rb +2 -1
  23. data/lib/rouge/lexers/mathematica.rb +1 -1
  24. data/lib/rouge/lexers/meson.rb +0 -1
  25. data/lib/rouge/lexers/nasm.rb +5 -4
  26. data/lib/rouge/lexers/nginx.rb +1 -0
  27. data/lib/rouge/lexers/objective_c/common.rb +0 -2
  28. data/lib/rouge/lexers/objective_c.rb +1 -1
  29. data/lib/rouge/lexers/ocl.rb +2 -2
  30. data/lib/rouge/lexers/openedge.rb +0 -2
  31. data/lib/rouge/lexers/plsql.rb +5 -5
  32. data/lib/rouge/lexers/ruby.rb +19 -19
  33. data/lib/rouge/lexers/scala.rb +5 -2
  34. data/lib/rouge/lexers/sql.rb +1 -1
  35. data/lib/rouge/lexers/syzlang.rb +0 -1
  36. data/lib/rouge/lexers/tcl.rb +7 -2
  37. data/lib/rouge/lexers/toml.rb +13 -12
  38. data/lib/rouge/lexers/ttcn3.rb +0 -2
  39. data/lib/rouge/lexers/typescript/common.rb +9 -0
  40. data/lib/rouge/lexers/xojo.rb +1 -1
  41. data/lib/rouge/lexers/yang.rb +1 -1
  42. data/lib/rouge/tex_theme_renderer.rb +1 -1
  43. data/lib/rouge/themes/base16.rb +23 -18
  44. data/lib/rouge/themes/bw.rb +1 -0
  45. data/lib/rouge/themes/colorful.rb +1 -0
  46. data/lib/rouge/themes/github.rb +1 -0
  47. data/lib/rouge/themes/gruvbox.rb +4 -1
  48. data/lib/rouge/themes/igor_pro.rb +3 -0
  49. data/lib/rouge/themes/magritte.rb +1 -0
  50. data/lib/rouge/themes/molokai.rb +2 -1
  51. data/lib/rouge/themes/monokai.rb +2 -1
  52. data/lib/rouge/themes/monokai_sublime.rb +4 -3
  53. data/lib/rouge/themes/pastie.rb +1 -0
  54. data/lib/rouge/themes/thankful_eyes.rb +1 -0
  55. data/lib/rouge/themes/tulip.rb +1 -0
  56. data/lib/rouge/token.rb +2 -1
  57. data/lib/rouge/version.rb +1 -1
  58. metadata +5 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a3281f8cbea5fa288016ada176d8fd748d2426af2f6a02a49c4f519ae4a385c9
4
- data.tar.gz: a0e5aae51677fa27c6c448d3d617b0f4748934ad267dc0be49b705e2fc89f93b
3
+ metadata.gz: de3a38233be791cfb87fbcee4e092afc1731ed4c2ac0bd9f4e8eb8d889a262c4
4
+ data.tar.gz: 81d1cf226f514155b861b1f127e55ffdf7cf9d40e2a8c8fa1ee5cd211052aeb0
5
5
  SHA512:
6
- metadata.gz: 3fe33d5d2a60be45a82839227de784d92440a99c77e700d55cba412f1d8a2cb5b516013bd92f7db62f88a25fa6aee8bdd65415cd9c2203c1e4a1538549d7a1a7
7
- data.tar.gz: 1b4598ed31db53da50a79e5aeaff8eca539c91dd7102b07a7e1106c4bd050071e689fb21a4d435b2e8d465cb91ae8a9275a91d777509961a6c95739e1ecc8d76
6
+ metadata.gz: 3ba279624b6990706218bced834a373cd4d5a15a487c862b07cc7042a924b429cad7518bea407f8ca85bda087395f1fa15abb231f0dd9ff0faa3b2b5e7cb108a
7
+ data.tar.gz: 93021b4af8761ddc54e22038b6926b7522f67c70c1ba0e7ebdb76ccb21375760f23efe4ebc9c4000bf3bba73499476fb9832596ac3f8eeca5f6f6f626e15069d
data/Gemfile CHANGED
@@ -10,22 +10,22 @@ gem 'minitest', '>= 5.0'
10
10
  gem 'minitest-power_assert'
11
11
  gem 'power_assert', '~> 2.0'
12
12
 
13
- gem 'rubocop', '~> 1.0', '<= 1.11'
14
- gem 'rubocop-performance'
15
-
16
13
  # don't try to install redcarpet under jruby
17
14
  gem 'redcarpet', platforms: :ruby
18
15
 
19
16
  # Profiling
20
17
  gem 'memory_profiler', require: false
21
18
 
22
- # Needed for a Rake task
23
- gem 'git'
24
- gem 'yard'
25
-
26
19
  group :development do
27
20
  gem 'pry'
28
21
 
22
+ # Needed for a Rake task
23
+ gem 'git'
24
+ gem 'yard'
25
+
26
+ gem 'rubocop', '~> 1.0', '<= 1.11'
27
+ gem 'rubocop-performance'
28
+
29
29
  # docs
30
30
  gem 'github-markup'
31
31
 
data/lib/rouge/cli.rb CHANGED
@@ -347,8 +347,7 @@ module Rouge
347
347
  formatter.format(lexer.lex(input), &method(:print))
348
348
  end
349
349
 
350
- private_class_method
351
- def self.parse_cgi(str)
350
+ private_class_method def self.parse_cgi(str)
352
351
  pairs = CGI.parse(str).map { |k, v| [k.to_sym, v.first] }
353
352
  Hash[pairs]
354
353
  end
@@ -511,8 +510,7 @@ module Rouge
511
510
  end
512
511
 
513
512
 
514
- private_class_method
515
- def self.normalize_syntax(argv)
513
+ private_class_method def self.normalize_syntax(argv)
516
514
  out = []
517
515
  argv.each do |arg|
518
516
  case arg
@@ -0,0 +1,21 @@
1
+ // first-order lag derivative term
2
+ (*
3
+ Parameter K must be set to T / (T + T1)
4
+ *)
5
+ FUNCTION_BLOCK DT2
6
+
7
+ VAR_INPUT
8
+ IN : REAL;
9
+ K : REAL;
10
+ END_VAR
11
+ VAR_OUTPUT
12
+ Q : REAL;
13
+ END_VAR
14
+ VAR
15
+ H : REAL := 0.0;
16
+ END_VAR
17
+
18
+ BEGIN
19
+ Q := IN - H;
20
+ H := H + K * Q;
21
+ END_FUNCTION_BLOCK
@@ -140,12 +140,17 @@ module Rouge
140
140
 
141
141
  Puppet
142
142
  end
143
-
143
+
144
144
  disambiguate '*.p' do
145
145
  next Prolog if contains?(':-')
146
146
  next Prolog if matches?(/\A\w+(\(\w+\,\s*\w+\))*\./)
147
147
  next OpenEdge
148
148
  end
149
+
150
+ disambiguate '*.st' do
151
+ next IecST if matches?(/^\s*END_/i)
152
+ next Smalltalk
153
+ end
149
154
  end
150
155
  end
151
156
  end
@@ -155,7 +155,7 @@ module Rouge
155
155
  end
156
156
 
157
157
  # Flag word-like things that don't match the ID pattern.
158
- rule %r{\b(\p{Pc}|[[alpha]])\p{Word}*}, Error
158
+ rule %r{\b(\p{Pc}|[[:alpha:]])\p{Word}*}, Error
159
159
  end
160
160
  end
161
161
  end
@@ -9,6 +9,7 @@ module Rouge
9
9
  mimetypes 'text/x-brainfuck'
10
10
 
11
11
  title "Brainfuck"
12
+ aliases "bf"
12
13
  desc "The Brainfuck programming language"
13
14
 
14
15
  start { push :bol }
@@ -79,7 +79,7 @@ module Rouge
79
79
 
80
80
  rule %r/code(\s+inline)?\s*{/, Comment::Preproc, :abc
81
81
 
82
- rule %r/_*[a-z][\w_`]*/ do |m|
82
+ rule %r/_*[a-z][\w`]*/ do |m|
83
83
  if self.class.keywords.include?(m[0])
84
84
  token Keyword
85
85
  else
@@ -87,7 +87,7 @@ module Rouge
87
87
  end
88
88
  end
89
89
 
90
- rule %r/_*[A-Z][\w_`]*/ do |m|
90
+ rule %r/_*[A-Z][\w`]*/ do |m|
91
91
  if m[0]=='True' || m[0]=='False'
92
92
  token Keyword::Constant
93
93
  else
@@ -95,7 +95,7 @@ module Rouge
95
95
  end
96
96
  end
97
97
 
98
- rule %r/[^\w_\s`]/, Punctuation
98
+ rule %r/[^\w\s`]/, Punctuation
99
99
  rule %r/_\b/, Punctuation
100
100
  end
101
101
 
@@ -136,7 +136,7 @@ module Rouge
136
136
 
137
137
  rule %r/}/, Comment::Preproc, :pop!
138
138
  rule %r/\.\w*/, Keyword, :abc_rest_of_line
139
- rule %r/[\w_]+/, Name::Builtin, :abc_rest_of_line
139
+ rule %r/[\w]+/, Name::Builtin, :abc_rest_of_line
140
140
  end
141
141
 
142
142
  state :abc_rest_of_line do
@@ -27,7 +27,7 @@ module Rouge
27
27
  delete dynamic_cast explicit export friend
28
28
  mutable namespace new operator private protected public
29
29
  reinterpret_cast requires restrict size_of static_cast this throw throws
30
- typeid typename using virtual final override
30
+ typeid typename using virtual final override import module
31
31
 
32
32
  alignas alignof decltype noexcept static_assert
33
33
  thread_local try
@@ -21,7 +21,7 @@ module Rouge
21
21
  rule %r(
22
22
  : # initial :
23
23
  @{0,2} # optional ivar, for :@foo and :@@foo
24
- [a-z_]\w*[!?]? # the symbol
24
+ [\p{Ll}_]\p{Word}*[!?]? # the symbol
25
25
  )xi, Str::Symbol
26
26
 
27
27
  # special symbols
@@ -35,7 +35,7 @@ module Rouge
35
35
  # %-sigiled strings
36
36
  # %(abc), %[abc], %<abc>, %.abc., %r.abc., etc
37
37
  delimiter_map = { '{' => '}', '[' => ']', '(' => ')', '<' => '>' }
38
- rule %r/%([rqswQWxiI])?([^\w\s}])/ do |m|
38
+ rule %r/%([rqswQWxiI])?([^\p{Word}\s}])/ do |m|
39
39
  open = Regexp.escape(m[2])
40
40
  close = Regexp.escape(delimiter_map[m[2]] || m[2])
41
41
  interp = /[rQWxI]/ === m[1]
@@ -77,7 +77,7 @@ module Rouge
77
77
 
78
78
  state :strings do
79
79
  mixin :symbols
80
- rule %r/\b[a-z_]\w*?[?!]?:\s+/, Str::Symbol, :expr_start
80
+ rule %r/\b[\p{Ll}_]\p{Word}*?[?!]?:\s+/, Str::Symbol, :expr_start
81
81
  rule %r/"/, Str::Double, :simple_string
82
82
  rule %r/(?<!\.)`/, Str::Backtick, :simple_backtick
83
83
  rule %r/(')(\\u[a-fA-F0-9]{4}|\\u\{[a-fA-F0-9]{1,6}\}|\\[abefnrtv])?(\\\\|\\'|[^'])*(')/ do
@@ -166,9 +166,9 @@ module Rouge
166
166
  rule %r/@\[([^\]]+)\]/, Name::Decorator
167
167
 
168
168
  # names
169
- rule %r/@@[a-z_]\w*/i, Name::Variable::Class
170
- rule %r/@[a-z_]\w*/i, Name::Variable::Instance
171
- rule %r/\$\w+/, Name::Variable::Global
169
+ rule %r/@@[\p{Ll}_]\p{Word}*/i, Name::Variable::Class
170
+ rule %r/@[\p{Ll}_]\p{Word}*/i, Name::Variable::Instance
171
+ rule %r/\$\p{Word}+/, Name::Variable::Global
172
172
  rule %r(\$[!@&`'+~=/\\,;.<>_*\$?:"]), Name::Variable::Global
173
173
  rule %r/\$-[0adFiIlpvw]/, Name::Variable::Global
174
174
  rule %r/::/, Operator
@@ -181,7 +181,7 @@ module Rouge
181
181
  rule %r(
182
182
  (module)
183
183
  (\s+)
184
- ([a-zA-Z_][a-zA-Z0-9_]*(::[a-zA-Z_][a-zA-Z0-9_]*)*)
184
+ ([\p{L}_][\p{L}0-9_]*(::[\p{L}_][\p{L}0-9_]*)*)
185
185
  )x do
186
186
  groups Keyword, Text, Name::Namespace
187
187
  end
@@ -207,14 +207,14 @@ module Rouge
207
207
  # Otherwise, they will be parsed as :method_call
208
208
  rule %r/\.{2,3}/, Operator, :expr_start
209
209
 
210
- rule %r/[A-Z][a-zA-Z0-9_]*/, Name::Constant, :method_call
211
- rule %r/(\.|::)(\s*)([a-z_]\w*[!?]?|[*%&^`~+-\/\[<>=])/ do
210
+ rule %r/[\p{Lu}][\p{L}0-9_]*/, Name::Constant, :method_call
211
+ rule %r/(\.|::)(\s*)([\p{Ll}_]\p{Word}*[!?]?|[*%&^`~+-\/\[<>=])/ do
212
212
  groups Punctuation, Text, Name::Function
213
213
  push :method_call
214
214
  end
215
215
 
216
- rule %r/[a-zA-Z_]\w*[?!]/, Name, :expr_start
217
- rule %r/[a-zA-Z_]\w*/, Name, :method_call
216
+ rule %r/[\p{L}_]\p{Word}*[?!]/, Name, :expr_start
217
+ rule %r/[\p{L}_]\p{Word}*/, Name, :method_call
218
218
  rule %r/\*\*|\/\/|>=|<=|<=>|<<?|>>?|=~|={3}|!~|&&?|\|\||\./,
219
219
  Operator, :expr_start
220
220
  rule %r/{%|%}/, Punctuation
@@ -225,7 +225,7 @@ module Rouge
225
225
  end
226
226
 
227
227
  state :has_heredocs do
228
- rule %r/(?<!\w)(<<[-~]?)(["`']?)([a-zA-Z_]\w*)(\2)/ do |m|
228
+ rule %r/(?<!\p{Word})(<<[-~]?)(["`']?)([\p{L}_]\p{Word}*)(\2)/ do |m|
229
229
  token Operator, m[1]
230
230
  token Name::Constant, "#{m[2]}#{m[3]}#{m[4]}"
231
231
  @heredoc_queue << [['<<-', '<<~'].include?(m[1]), m[3]]
@@ -282,9 +282,9 @@ module Rouge
282
282
  rule %r/\s+/, Text
283
283
  rule %r/\(/, Punctuation, :defexpr
284
284
  rule %r(
285
- (?:([a-zA-Z_]\w*)(\.))?
285
+ (?:([\p{L}_]\p{Word}*)(\.))?
286
286
  (
287
- [a-zA-Z_]\w*[!?]? |
287
+ [\p{L}_]\p{Word}*[!?]? |
288
288
  \*\*? | [-+]@? | [/%&\|^`~] | \[\]=? |
289
289
  <<? | >>? | <=>? | >= | ===?
290
290
  )
@@ -311,7 +311,7 @@ module Rouge
311
311
  goto :expr_start
312
312
  end
313
313
 
314
- rule %r/[A-Z_]\w*/, Name::Class, :pop!
314
+ rule %r/[\p{Lu}_]\p{Word}*/, Name::Class, :pop!
315
315
 
316
316
  rule(//) { pop! }
317
317
  end
@@ -343,7 +343,7 @@ module Rouge
343
343
 
344
344
  state :string_intp do
345
345
  rule %r/[#][{]/, Str::Interpol, :in_interp
346
- rule %r/#(@@?|\$)[a-z_]\w*/i, Str::Interpol
346
+ rule %r/#(@@?|\$)[\p{Ll}_]\p{Word}*/i, Str::Interpol
347
347
  end
348
348
 
349
349
  state :string_intp_escaped do
@@ -399,7 +399,7 @@ module Rouge
399
399
  rule %r(
400
400
  [?](\\[MC]-)* # modifiers
401
401
  (\\([\\abefnrstv\#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})|\S)
402
- (?!\w)
402
+ (?!\p{Word})
403
403
  )x, Str::Char, :pop!
404
404
 
405
405
  # special case for using a single space. Ruby demands that
@@ -114,8 +114,8 @@ module Rouge
114
114
  mixin :single_quote
115
115
 
116
116
  rule %r(\b(?i:(and|not|or|in))\b), Operator::Word
117
- rule %r([:=|>|<|<>|/|\\|\+|-|=]), Operator
118
- rule %r([\[\]{}();,\&,\.,\%]), Punctuation
117
+ rule %r(:=|>|<|<>|/|\\|\+|-|=), Operator
118
+ rule %r([\[\]{}();,\&\.\%]), Punctuation
119
119
 
120
120
  rule %r(\b(?i:(beginc\+\+.*?endc\+\+)))m, Str::Single
121
121
  rule %r(\b(?i:(embed.*?endembed)))m, Str::Single
@@ -44,7 +44,7 @@ module Rouge
44
44
  rule %r/(?:\d(?:_*\d)*)?\.(?:(?:\d(?:_*\d)*)?[eE][+-]?)?\d(?:_*\d)*|\d(?:_*\d)*\.?/, Num::Float
45
45
 
46
46
  rule %r/:=|<<|>>|\(\||\|\)|->|\.|[{}\[\];(),:?]/, Punctuation::Indicator
47
- rule %r/\\\\|\|\.\.\||\.\.|\/[~\/]?|[><\/]=?|[-+*^=~]/, Operator
47
+ rule %r/\\\\|\|\.\.\||\.\.|\/[~\/]?|[><\/]=?|[-+*^=~≤≥−∀∃¦⟳⟲]/, Operator
48
48
 
49
49
  rule %r/[A-Z][\dA-Z_]*/, Name::Class
50
50
  rule %r/[A-Za-z][\dA-Za-z_]*/, Name
@@ -135,7 +135,7 @@ module Rouge
135
135
  rule %r/[\\#]/, toktype
136
136
  end
137
137
 
138
- uniq_chars = "#{open}#{close}".squeeze
138
+ uniq_chars = [open, close].uniq.join
139
139
  rule %r/[^##{uniq_chars}\\]+/m, toktype
140
140
  end
141
141
  end
@@ -12,7 +12,7 @@ module Rouge
12
12
  mimetypes 'text/x-gdscript', 'application/x-gdscript'
13
13
 
14
14
  def self.keywords
15
- @keywords = %w(
15
+ @keywords ||= %w(
16
16
  and in not or as breakpoint class class_name extends is func setget
17
17
  signal tool const enum export onready static var break continue
18
18
  if elif else for pass return match while remote master puppet
@@ -22,13 +22,13 @@ module Rouge
22
22
 
23
23
  # Reserved for future implementation
24
24
  def self.keywords_reserved
25
- @keywords_reserved = %w(
25
+ @keywords_reserved ||= %w(
26
26
  do switch case
27
27
  ).join('|')
28
28
  end
29
29
 
30
30
  def self.builtins
31
- builtins = %w(
31
+ @builtins ||= %w(
32
32
  Color8 ColorN abs acos asin assert atan atan2 bytes2var ceil char
33
33
  clamp convert cos cosh db2linear decimals dectime deg2rad dict2inst
34
34
  ease exp floor fmod fposmod funcref hash inst2dict instance_from_id
@@ -41,7 +41,7 @@ module Rouge
41
41
  end
42
42
 
43
43
  def self.builtins_type
44
- @builtins_type = %w(
44
+ @builtins_type ||= %w(
45
45
  bool int float String Vector2 Rect2 Transform2D Vector3 AABB
46
46
  Plane Quat Basis Transform Color RID Object NodePath Dictionary
47
47
  Array PoolByteArray PoolIntArray PoolRealArray PoolStringArray
@@ -22,11 +22,11 @@ module Rouge
22
22
  ws = %r(\s|//.*?\n|/[*](?:[^*]|(?:[*][^/]))*[*]+/)mx
23
23
 
24
24
  # Make sure that this is not a preprocessor macro, e.g. `#if` or `#define`.
25
- id = %r((?!\#[a-zA-Z])[\w#\$%_']+)
25
+ id = %r((?!\#[a-zA-Z])[\w#\$%']+)
26
26
 
27
27
  complex_id = %r(
28
- (?:[\w#$%_']|\(\)|\(,\)|\[\]|[0-9])*
29
- (?:[\w#$%_']+)
28
+ (?:[\w#$%']|\(\)|\(,\)|\[\]|[0-9])*
29
+ (?:[\w#$%']+)
30
30
  )mx
31
31
 
32
32
  state :root do
@@ -26,6 +26,7 @@ module Rouge
26
26
  state :primitives do
27
27
  rule %r/[0-9][0-9]*\.[0-9]+([eE][0-9]+)?[fd]?([kKmMgG]b?)?/, Num::Float
28
28
  rule %r/[0-9]+([kKmMgG]b?)?/, Num::Integer
29
+ rule %r/[-+*\/!%&<>|=:?]/, Operator
29
30
 
30
31
  rule %r/"/, Str::Double, :dq
31
32
  rule %r/'/, Str::Single, :sq
@@ -0,0 +1,92 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class IecST < RegexLexer
7
+ tag 'iecst'
8
+ title "IEC 61131-3 Structured Text"
9
+ desc 'Structured text is a programming language for PLCs (programmable logic controllers).'
10
+ filenames '*.awl', '*.scl', '*.st'
11
+
12
+ mimetypes 'text/x-iecst'
13
+
14
+ def self.keywords
15
+ blocks = %w(
16
+ PROGRAM CONFIGURATION INITIAL_STEP INTERFACE FUNCTION_BLOCK FUNCTION ACTION TRANSITION
17
+ TYPE STRUCT STEP NAMESPACE LIBRARY CHANNEL FOLDER RESOURCE
18
+ VAR_ACCESS VAR_CONFIG VAR_EXTERNAL VAR_GLOBAL VAR_INPUT VAR_IN_OUT VAR_OUTPUT VAR_TEMP VAR
19
+ CONST METHOD PROPERTY
20
+ CASE FOR IF REPEAT WHILE
21
+ )
22
+ @keywords ||= Set.new %w(
23
+ AT BEGIN BY CONSTANT CONTINUE DO ELSE ELSIF EXIT EXTENDS FROM GET GOTO IMPLEMENTS JMP
24
+ NON_RETAIN OF PRIVATE PROTECTED PUBLIC RETAIN RETURN SET TASK THEN TO UNTIL USING WITH
25
+ __CATCH __ENDTRY __FINALLY __TRY
26
+ ) + blocks + blocks.map {|kw| "END_" + kw}
27
+ end
28
+
29
+ def self.types
30
+ @types ||= Set.new %w(
31
+ ANY ARRAY BOOL BYTE POINTER STRING
32
+ DATE DATE_AND_TIME DT TIME TIME_OF_DAY TOD
33
+ INT DINT LINT SINT UINT UDINT ULINT USINT
34
+ WORD DWORD LWORD
35
+ REAL LREAL
36
+ )
37
+ end
38
+
39
+ def self.literals
40
+ @literals ||= Set.new %w(TRUE FALSE NULL)
41
+ end
42
+
43
+ def self.operators
44
+ @operators ||= Set.new %w(AND EQ EXPT GE GT LE LT MOD NE NOT OR XOR)
45
+ end
46
+
47
+ state :whitespace do
48
+ # Spaces
49
+ rule %r/\s+/m, Text
50
+ # // Comments
51
+ rule %r((//).*$\n?), Comment::Single
52
+ # (* Comments *)
53
+ rule %r(\(\*.*?\*\))m, Comment::Multiline
54
+ # { Comments }
55
+ rule %r(\{.*?\})m, Comment::Special
56
+ end
57
+
58
+ state :root do
59
+ mixin :whitespace
60
+
61
+ rule %r/'[^']+'/, Literal::String::Single
62
+ rule %r/"[^"]+"/, Literal::String::Symbol
63
+ rule %r/%[IQM][XBWDL][\d.]*|%[IQ][\d.]*/, Name::Variable::Magic
64
+ rule %r/\b(?:D|DT|T|TOD)#[\d_shmd:]*/i, Literal::Date
65
+ rule %r/\b(?:16#[\d_a-f]+|0x[\d_a-f]+)\b/i, Literal::Number::Hex
66
+ rule %r/\b2#[01_]+/, Literal::Number::Bin
67
+ rule %r/(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i, Literal::Number::Float
68
+ rule %r/\b[\d.,_]+/, Literal::Number
69
+
70
+ rule %r/\b[A-Z_]+\b/i do |m|
71
+ name = m[0].upcase
72
+ if self.class.keywords.include?(name)
73
+ token Keyword
74
+ elsif self.class.types.include?(name)
75
+ token Keyword::Type
76
+ elsif self.class.literals.include?(name)
77
+ token Literal
78
+ elsif self.class.operators.include?(name)
79
+ token Operator
80
+ else
81
+ token Name
82
+ end
83
+ end
84
+
85
+ rule %r/S?R?:?=>?|&&?|\*\*?|<[=>]?|>=?|[-:^\/+#]/, Operator
86
+ rule %r/\b[a-z_]\w*(?=\s*\()/i, Name::Function
87
+ rule %r/\b[a-z_]\w*\b/i, Name
88
+ rule %r/[()\[\].,;]/, Punctuation
89
+ end
90
+ end
91
+ end
92
+ end
@@ -100,7 +100,7 @@ module Rouge
100
100
 
101
101
  def self.keywords
102
102
  @keywords ||= Set.new %w(
103
- as async await break case catch continue debugger default delete
103
+ async await break case catch continue debugger default delete
104
104
  do else export finally from for if import in instanceof new of
105
105
  return super switch this throw try typeof void while yield
106
106
  )
@@ -252,15 +252,16 @@ module Rouge
252
252
  rule %r/\d+/, Literal::Number::Integer
253
253
  end
254
254
 
255
+ NAME_RE = %r/[\p{L}\p{Nl}\p{S}_][\p{Word}\p{S}\p{Po}!]*/
255
256
 
256
257
  state :funcname do
257
- rule %r/[\p{L}\p{Nl}\p{S}_][\p{Word}\p{S}\p{Po}!]*/, Name::Function, :pop!
258
+ rule NAME_RE, Name::Function, :pop!
258
259
  rule %r/\([^\s\w{]{1,2}\)/, Operator, :pop!
259
260
  rule %r/[^\s\w{]{1,2}/, Operator, :pop!
260
261
  end
261
262
 
262
263
  state :typename do
263
- rule %r/[\p{L}\p{Nl}\p{S}_][\p{Word}\p{S}\p{Po}!]*/, Name::Class, :pop!
264
+ rule NAME_RE, Name::Class, :pop!
264
265
  end
265
266
 
266
267
  state :stringescape do
@@ -24,7 +24,7 @@ module Rouge
24
24
  while yield
25
25
  )
26
26
 
27
- name_chars = %r'[-_\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Nl}\p{Nd}\p{Pc}\p{Cf}\p{Mn}\p{Mc}]*'
27
+ name_chars = %r'[-\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Nl}\p{Nd}\p{Pc}\p{Cf}\p{Mn}\p{Mc}]*'
28
28
 
29
29
  class_name = %r'`?[\p{Lu}]#{name_chars}`?'
30
30
  name = %r'`?[_\p{Lu}\p{Ll}\p{Lt}\p{Lm}\p{Nl}]#{name_chars}`?'
@@ -73,7 +73,7 @@ module Rouge
73
73
  end
74
74
 
75
75
  state :export do
76
- rule %r/[\w[\$]{1,2}{}()-]/, Name::Variable
76
+ rule %r/[\w\${}()-]/, Name::Variable
77
77
  rule %r/\n/, Text, :pop!
78
78
  rule %r/[\t ]+/, Text
79
79
  end
@@ -107,7 +107,8 @@ module Rouge
107
107
  push :link
108
108
  end
109
109
 
110
- rule %r/[*][*]#{edot}*?[*][*]/, Generic::Strong
110
+ rule %r/[*]{2}[^* \n][^*\n]*[*]{2}/, Generic::Strong
111
+ rule %r/[*]{3}[^* \n][^*\n]*[*]{3}/, Generic::EmphStrong
111
112
  rule %r/__#{edot}*?__/, Generic::Strong
112
113
 
113
114
  rule %r/[*]#{edot}*?[*]/, Generic::Emph
@@ -7,7 +7,7 @@ module Rouge
7
7
  title "Mathematica"
8
8
  desc "Wolfram Mathematica, the world's definitive system for modern technical computing."
9
9
  tag 'mathematica'
10
- aliases 'wl'
10
+ aliases 'wl', 'wolfram'
11
11
  filenames '*.m', '*.wl'
12
12
  mimetypes 'application/vnd.wolfram.mathematica.package', 'application/vnd.wolfram.wl'
13
13
 
@@ -38,7 +38,6 @@ module Rouge
38
38
  end
39
39
 
40
40
  identifier = /[[:alpha:]_][[:alnum:]_]*/
41
- dotted_identifier = /[[:alpha:]_.][[:alnum:]_.]*/
42
41
 
43
42
  def current_string
44
43
  @current_string ||= StringRegister.new
@@ -14,11 +14,12 @@ module Rouge
14
14
  mimetypes 'text/x-nasm'
15
15
 
16
16
  state :root do
17
- rule %r/^\s*%/, Comment::Preproc, :preproc
17
+ rule %r/^\s*%/, Comment::Preproc, :preproc
18
18
 
19
- mixin :whitespace
19
+ mixin :whitespace
20
+ mixin :punctuation
20
21
 
21
- rule %r/[a-z$._?][\w$.?#@~]*:/i, Name::Label
22
+ rule %r/[a-z$._?][\w$.?#@~]*:/i, Name::Label
22
23
 
23
24
  rule %r/([a-z$._?][\w$.?#@~]*)(\s+)(equ)/i do
24
25
  groups Name::Constant, Keyword::Declaration, Keyword::Declaration
@@ -32,7 +33,7 @@ module Rouge
32
33
  end
33
34
 
34
35
  state :instruction_args do
35
- rule %r/"(\\\\"|[^"\\n])*"|'(\\\\'|[^'\\n])*'|`(\\\\`|[^`\\n])*`/, Str
36
+ rule %r/"(\\\\"|[^"\\n])*"|'(\\\\'|[^'\\n])*'|`(\\\\`|[^`\\n])*`/, Str
36
37
  rule %r/(?:0x[\da-f]+|$0[\da-f]*|\d+[\da-f]*h)/i, Num::Hex
37
38
  rule %r/[0-7]+q/i, Num::Oct
38
39
  rule %r/[01]+b/i, Num::Bin
@@ -53,6 +53,7 @@ module Rouge
53
53
  # mimetype
54
54
  rule %r([a-z-]+/[a-z-]+)i, Name::Class
55
55
 
56
+ rule %r/\d+\.\d+/, Num::Float
56
57
  rule %r/[0-9]+[kmg]?\b/i, Num::Integer
57
58
  rule %r/(~)(\s*)([^\s{]+)/ do
58
59
  groups Punctuation, Text, Str::Regex
@@ -4,8 +4,6 @@
4
4
  module Rouge
5
5
  module Lexers
6
6
  module ObjectiveCCommon
7
- id = /[a-z$_][a-z0-9$_]*/i
8
-
9
7
  def at_keywords
10
8
  @at_keywords ||= %w(
11
9
  selector private protected public encode synchronized try
@@ -12,7 +12,7 @@ module Rouge
12
12
  tag 'objective_c'
13
13
  title "Objective-C"
14
14
  desc 'an extension of C commonly used to write Apple software'
15
- aliases 'objc', 'obj-c', 'obj_c', 'objectivec'
15
+ aliases 'objc', 'obj-c', 'obj_c', 'objectivec', 'objective-c'
16
16
  filenames '*.m', '*.h'
17
17
 
18
18
  mimetypes 'text/x-objective_c', 'application/x-objective_c'
@@ -61,9 +61,9 @@ module Rouge
61
61
  rule %r/--.*/, Comment::Single
62
62
  rule %r/\d+/, Num::Integer
63
63
  rule %r/'/, Str::Single, :single_string
64
- rule %r([->|+*/<>=~!@#%&|?^-]), Operator
64
+ rule %r([-|+*/<>=~!@#%&?^]), Operator
65
65
  rule %r/[;:()\[\],.]/, Punctuation
66
- rule %r/\w[\w\d]*/ do |m|
66
+ rule %r/[a-zA-Z]\w*/ do |m|
67
67
  if self.class.operators.include? m[0]
68
68
  token Operator
69
69
  elsif self.class.keywords_type.include? m[0]
@@ -12,8 +12,6 @@ module Rouge
12
12
  title 'OpenEdge ABL'
13
13
  desc 'The OpenEdge ABL programming language'
14
14
 
15
- # optional comment or whitespace
16
- ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
17
15
  id = /[a-zA-Z_&{}!][a-zA-Z0-9_\-&!}]*/
18
16
 
19
17
  def self.keywords