rouge 3.30.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: acc37e14414bcaa3f67dda77f1b746f8035cfc972dc807610b4a1ef4fcffe848
4
- data.tar.gz: 2380291e01345a7251f229dddf858d612f64d89f7ef93d7b75b2c44fa9a093a6
3
+ metadata.gz: 9229545bdc0804f0a7f0fea6a4fd1b94dbe8d022d0d29c1ffa254c09f42003d1
4
+ data.tar.gz: cf12e8de0f2d03d37ed6f1380a5deb04ad385d8628b4f2ed7c1921b16161636f
5
5
  SHA512:
6
- metadata.gz: a4d60e1f37e66b4991b040ff82db8cc59983f37923a7f8b41a44a149407167467b443cd6ac8bb47f8800588e82301be1d58c14175bb1513a728952be21144ed8
7
- data.tar.gz: 6f0e6ab3786ac315f0a2d658d02091bb3b8a0b6cd75ef3aac6dc2a116eee9dd5a45b1a4c9ef11f40f0f6338ae50d7c0f0b219e9ab20de950e4ae865f3824e002
6
+ metadata.gz: 31f64a3f386d01829f9a2d2e9711ad40c3c48fbf122dc66b0e9519d4c02676cf530879c388e280efd996d6a57ec3497f5faa54423d081af02450348037c58712
7
+ data.tar.gz: fad76c2d5d770fb172e09a2614e37ff78d362b81dfb73d50ce5c25de04f07c93aabae357e4a1a5b6b47be3792edf146e1299c1ec78204d55e998dd54c169f307
data/Gemfile CHANGED
@@ -10,17 +10,14 @@ gem 'minitest', '>= 5.0'
10
10
  gem 'minitest-power_assert'
11
11
  gem 'power_assert', '~> 1.2'
12
12
 
13
- gem 'parallel', '~> 1.13.0' if RUBY_VERSION < '2.2.0'
14
13
  gem 'rubocop', '~> 1.0', '<= 1.11'
15
14
  gem 'rubocop-performance'
16
15
 
17
16
  # don't try to install redcarpet under jruby
18
- gem 'redcarpet', :platforms => :ruby
17
+ gem 'redcarpet', platforms: :ruby
19
18
 
20
19
  # Profiling
21
- if RUBY_VERSION >= '2.3.0'
22
- gem 'memory_profiler', :require => false
23
- end
20
+ gem 'memory_profiler', require: false
24
21
 
25
22
  # Needed for a Rake task
26
23
  gem 'git'
@@ -33,11 +30,7 @@ group :development do
33
30
  gem 'github-markup'
34
31
 
35
32
  # for visual tests
36
- if RUBY_VERSION < '2.2.0'
37
- gem 'sinatra', '~> 1.4.8'
38
- else
39
- gem 'sinatra'
40
- end
33
+ gem 'sinatra'
41
34
 
42
35
  # Ruby 3 no longer ships with a web server
43
36
  gem 'puma' if RUBY_VERSION >= '3'
@@ -0,0 +1,33 @@
1
+ // A system agnostic domain specific language for runtime monitoring and verification
2
+ // Basic events
3
+
4
+ insert(index,elem) matches {event:'func_pre',name:'my_insert',args:[index,elem]};
5
+
6
+ relevant matches insert(_,_)|remove(_,_)|size(_)|get(_,_);
7
+
8
+ insert_in_bounds(size) matches insert(index,_) with index >= 0 && index <= size;
9
+
10
+ del_false matches del(_,false);
11
+ not_add_true_del(el) not matches add(el,true) | del(el,_);
12
+
13
+ Main = relevant >> (CheckIndex<0> /\ add_rm_get >> CheckElem)!;
14
+ CheckIndex<size> =
15
+ get_size(size)* (insert_in_bounds(size) CheckIndex<size+1> \/ remove_in_bounds(size) CheckIndex<size-1>);
16
+
17
+ Msg<inf,sup> = if(inf<=sup) msg(inf) Msg<inf+1,sup> else empty;
18
+ Main=relevant>>Msg<1,4>*!;
19
+
20
+ acquire(id) matches {event:'func_pre',name:'acquire',args:[_,id,...]};
21
+
22
+ Main = relevant >> Resources;
23
+ Resources =
24
+ {let id; acquire(id)
25
+ ((Resources | use(id)* release(id)) /\
26
+ acqRel(id) >> release(id) all)
27
+ }?;
28
+
29
+ msg(ty) matches {event:'func_pre',name:'msg',args:[ty]};
30
+ relevant matches msg(_);
31
+
32
+ Msg<inf,sup> = if(inf<=sup) msg(inf) Msg<inf+1,sup> else empty;
33
+ Main=relevant>>Msg<1,4>*!;
@@ -20,9 +20,19 @@ module Rouge
20
20
  state :root do
21
21
  rule(/^ .*$\n?/, Text)
22
22
  rule(/^---$\n?/, Punctuation)
23
- rule(/^[+>]+.*$\n?/, Generic::Inserted)
24
- rule(/^\+.*$\n?/, Generic::Inserted)
25
- rule(/^[-<]+.*$\n?/, Generic::Deleted)
23
+
24
+ rule %r(
25
+ (^\++.*$\n?) |
26
+ (^>+[ \t]+.*$\n?) |
27
+ (^>+$\n?)
28
+ )x, Generic::Inserted
29
+
30
+ rule %r(
31
+ (^-+.*$\n?) |
32
+ (^<+[ \t]+.*$\n?) |
33
+ (^<+$\n?)
34
+ )x, Generic::Deleted
35
+
26
36
  rule(/^!.*$\n?/, Generic::Strong)
27
37
  rule(/^([Ii]ndex|diff).*$\n?/, Generic::Heading)
28
38
  rule(/^(@@[^@]*@@)([^\n]*\n)/) do
@@ -30,7 +40,7 @@ module Rouge
30
40
  end
31
41
  rule(/^\w.*$\n?/, Punctuation)
32
42
  rule(/^=.*$\n?/, Generic::Heading)
33
- rule(/\s.*$\n?/, Text)
43
+ rule(/.+$\n?/, Text)
34
44
  end
35
45
  end
36
46
  end
@@ -17,15 +17,15 @@ module Rouge
17
17
 
18
18
  def self.keywords
19
19
  @keywords ||= Set.new %w(
20
- break case cast catch class continue default do else enum false for
21
- function if import interface macro new null override package private
20
+ as break case cast catch class continue default do else enum false for
21
+ function if import in interface macro new null override package private
22
22
  public return switch this throw true try untyped while
23
23
  )
24
24
  end
25
25
 
26
26
  def self.imports
27
27
  @imports ||= Set.new %w(
28
- import using
28
+ package import using
29
29
  )
30
30
  end
31
31
 
@@ -55,6 +55,7 @@ module Rouge
55
55
  end
56
56
 
57
57
  id = /[$a-zA-Z_][a-zA-Z0-9_]*/
58
+ dotted_id = /[$a-zA-Z_][a-zA-Z0-9_.]*/
58
59
 
59
60
  state :comments_and_whitespace do
60
61
  rule %r/\s+/, Text
@@ -77,6 +78,22 @@ module Rouge
77
78
  rule %r//, Text, :pop!
78
79
  end
79
80
 
81
+ state :namespace do
82
+ mixin :comments_and_whitespace
83
+
84
+ rule %r/
85
+ (#{dotted_id})
86
+ (\s+)(in|as)(\s+)
87
+ (#{id})
88
+ /x do
89
+ groups(Name::Namespace, Text::Whitespace, Keyword, Text::Whitespace, Name)
90
+ end
91
+
92
+ rule %r/#{dotted_id}/, Name::Namespace
93
+
94
+ rule(//) { pop! }
95
+ end
96
+
80
97
  state :regex do
81
98
  rule %r(/) do
82
99
  token Str::Regex
@@ -141,20 +158,22 @@ module Rouge
141
158
  end
142
159
 
143
160
  rule id do |m|
144
- if self.class.keywords.include? m[0]
161
+ match = m[0]
162
+
163
+ if self.class.imports.include?(match)
164
+ token Keyword::Namespace
165
+ push :namespace
166
+ elsif self.class.keywords.include?(match)
145
167
  token Keyword
146
168
  push :expr_start
147
- elsif self.class.imports.include? m[0]
148
- token Keyword
149
- push :namespace
150
- elsif self.class.declarations.include? m[0]
169
+ elsif self.class.declarations.include?(match)
151
170
  token Keyword::Declaration
152
171
  push :expr_start
153
- elsif self.class.reserved.include? m[0]
172
+ elsif self.class.reserved.include?(match)
154
173
  token Keyword::Reserved
155
- elsif self.class.constants.include? m[0]
174
+ elsif self.class.constants.include?(match)
156
175
  token Keyword::Constant
157
- elsif self.class.builtins.include? m[0]
176
+ elsif self.class.builtins.include?(match)
158
177
  token Name::Builtin
159
178
  else
160
179
  token Name::Other
@@ -46,7 +46,7 @@ module Rouge
46
46
 
47
47
  # response
48
48
  rule %r(
49
- (HTTPS?)(/)(\d(?:\.\d))([ ]+) # http version
49
+ (HTTPS?)(/)(\d(?:\.\d)?)([ ]+) # http version
50
50
  (\d{3})([ ]+)? # status
51
51
  ([^\r\n]*)?(\r?\n|$) # status message
52
52
  )x do
@@ -20,11 +20,6 @@ module Rouge
20
20
  )
21
21
  end
22
22
 
23
- # TODO: Add support for special keywords
24
- # bsd_special = %w(
25
- # include undef error warning if else elif endif for endfor
26
- # )
27
-
28
23
  def initialize(opts={})
29
24
  super
30
25
  @shell = Shell.new(opts)
@@ -41,11 +36,11 @@ module Rouge
41
36
  groups Keyword, Literal::String::Other
42
37
  end
43
38
 
44
- rule %r/(ifn?def|ifn?eq)([\t ]+)([^#\n]+)/ do
39
+ rule %r/((?:ifn?def|ifn?eq|unexport)\b)([\t ]+)([^#\n]+)/ do
45
40
  groups Keyword, Text, Name::Variable
46
41
  end
47
42
 
48
- rule %r/(?:else|endif)[\t ]*(?=[#\n])/, Keyword
43
+ rule %r/(?:else|endif|endef|endfor)[\t ]*(?=[#\n])/, Keyword
49
44
 
50
45
  rule %r/(export)([\t ]+)(?=[\w\${}()\t -]+\n)/ do
51
46
  groups Keyword, Text
@@ -55,10 +50,8 @@ module Rouge
55
50
  rule %r/export[\t ]+/, Keyword
56
51
 
57
52
  # assignment
58
- rule %r/([\w${}().-]+)([\t ]*)([!?:+]?=)/m do |m|
59
- token Name::Variable, m[1]
60
- token Text, m[2]
61
- token Operator, m[3]
53
+ rule %r/(override\b)*([\t ]*)([\w${}().-]+)([\t ]*)([!?:+]?=)/m do |m|
54
+ groups Name::Builtin, Text, Name::Variable, Text, Operator
62
55
  push :shell_line
63
56
  end
64
57
 
@@ -68,10 +61,19 @@ module Rouge
68
61
  groups Name::Label, Operator, Text
69
62
  push :block_header
70
63
  end
64
+
65
+ rule %r/(override\b)*([\t ])*(define)([\t ]+)([^#\n]+)/ do
66
+ groups Name::Builtin, Text, Keyword, Text, Name::Variable
67
+ end
68
+
69
+ rule %r/(\$[({])([\t ]*)(#{Make.functions.join('|')})([\t ]+)/m do
70
+ groups Name::Function, Text, Name::Builtin, Text
71
+ push :shell_expr
72
+ end
71
73
  end
72
74
 
73
75
  state :export do
74
- rule %r/[\w\${}()-]/, Name::Variable
76
+ rule %r/[\w[\$]{1,2}{}()-]/, Name::Variable
75
77
  rule %r/\n/, Text, :pop!
76
78
  rule %r/[\t ]+/, Text
77
79
  end
@@ -107,22 +109,29 @@ module Rouge
107
109
 
108
110
  state :shell do
109
111
  # macro interpolation
110
- rule %r/\$[({][\t ]*\w[\w:=%.]*[\t ]*[)}]/i, Name::Variable
112
+ rule %r/[\$]{1,2}[({]/, Punctuation, :macro_expr
113
+
111
114
  # function invocation
112
115
  rule %r/(\$[({])([\t ]*)(#{Make.functions.join('|')})([\t ]+)/m do
113
- groups Name::Function, Text, Name::Builtin, Text
116
+ groups Punctuation, Text, Name::Builtin, Text
114
117
  push :shell_expr
115
118
  end
116
119
 
117
120
  rule(/\\./m) { delegate @shell }
118
- stop = /\$\(|\$\{|\(|\)|\}|\\|$/
121
+ stop = /[\$]{1,2}\(|[\$]{1,2}\{|\(|\)|\}|\\|$/
119
122
  rule(/.+?(?=#{stop})/m) { delegate @shell }
120
123
  rule(stop) { delegate @shell }
121
124
  end
122
125
 
126
+ state :macro_expr do
127
+ rule %r/[)}]/, Punctuation, :pop!
128
+ rule %r/\n/, Text, :pop!
129
+ mixin :shell
130
+ end
131
+
123
132
  state :shell_expr do
124
133
  rule(/[({]/) { delegate @shell; push }
125
- rule %r/[)}]/, Name::Function, :pop!
134
+ rule %r/[)}]/, Punctuation, :pop!
126
135
  mixin :shell
127
136
  end
128
137
 
@@ -58,6 +58,16 @@ module Rouge
58
58
  linear randomGauss randomInteger randomUniform zero
59
59
  )
60
60
 
61
+ functions_matrix = %w(
62
+ linear mul mul_fast mul_metal mul_nt mul_tn mul_tt outer peaks
63
+ randomGamma randomGauss randomInteger randomUniform softmaxPerRow
64
+ solve transpose zero
65
+ )
66
+
67
+ functions_string_vector = %w(
68
+ empty fileNames folderNames readLinesFromFile splitByWhitespace
69
+ )
70
+
61
71
  objects = %w(
62
72
  Activation AffineTransform AmplitudeTier Art Artword Autosegment
63
73
  BarkFilter BarkSpectrogram CCA Categories Cepstrogram Cepstrum
@@ -142,6 +152,7 @@ module Rouge
142
152
 
143
153
  mixin :variable_name
144
154
  mixin :number
155
+ mixin :vector_literal
145
156
 
146
157
  rule %r/"/, Literal::String, :string
147
158
 
@@ -196,6 +207,8 @@ module Rouge
196
207
  state :function_call do
197
208
  rule %r/\b(#{functions_string.join('|')})\$(?=\s*[:(])/, Name::Function, :function
198
209
  rule %r/\b(#{functions_array.join('|')})#(?=\s*[:(])/, Name::Function, :function
210
+ rule %r/\b(#{functions_matrix.join('|')})##(?=\s*[:(])/, Name::Function, :function
211
+ rule %r/\b(#{functions_string_vector.join('|')})\$#(?=\s*[:(])/, Name::Function, :function
199
212
  rule %r/\b(#{functions_numeric.join('|')})(?=\s*[:(])/, Name::Function, :function
200
213
  end
201
214
 
@@ -214,7 +227,7 @@ module Rouge
214
227
  groups Text, Punctuation
215
228
  end
216
229
 
217
- rule %r/\s*[\])\n]/, Text, :pop!
230
+ rule %r/\s*[\]\})\n]/, Text, :pop!
218
231
 
219
232
  rule %r/\s+/, Text
220
233
  rule %r/"/, Literal::String, :string
@@ -224,6 +237,7 @@ module Rouge
224
237
  mixin :variable_name
225
238
  mixin :operator
226
239
  mixin :number
240
+ mixin :vector_literal
227
241
 
228
242
  rule %r/[()]/, Text
229
243
  rule %r/,/, Punctuation
@@ -257,11 +271,15 @@ module Rouge
257
271
  push :object_reference
258
272
  end
259
273
 
260
- rule %r/\.?[a-z][a-zA-Z0-9_.]*(\$|#)?/, Text
274
+ rule %r/\.?[a-z][a-zA-Z0-9_.]*(\$#|##|\$|#)?/, Text
261
275
  rule %r/[\[\]]/, Text, :comma_list
262
276
  mixin :string_interpolated
263
277
  end
264
278
 
279
+ state :vector_literal do
280
+ rule %r/(\{)/, Text, :comma_list
281
+ end
282
+
265
283
  state :object_reference do
266
284
  mixin :string_interpolated
267
285
  rule %r/([a-z][a-zA-Z0-9_]*|\d+)/, Name::Builtin
@@ -0,0 +1,142 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class RML < RegexLexer
7
+ title "RML"
8
+ desc "A system agnostic domain-specific language for runtime monitoring and verification (https://rmlatdibris.github.io/)"
9
+ tag 'rml'
10
+ filenames '*.rml'
11
+
12
+ def self.keywords
13
+ @keywords ||= Set.new %w(
14
+ matches not with empty
15
+ all if else true false
16
+ )
17
+ end
18
+
19
+ def self.arithmetic_keywords
20
+ @arithmetic_keywords ||= Set.new %w(
21
+ abs sin cos tan min max
22
+ )
23
+ end
24
+
25
+ id_char = /[a-zA-Z0-9_]/
26
+ uppercase_id = /[A-Z]#{id_char}*/
27
+ lowercase_id = /[a-z]#{id_char}*/
28
+
29
+ ellipsis = /(\.){3}/
30
+ int = /[0-9]+/
31
+ float = /#{int}\.#{int}/
32
+ string = /'(\\'|[ a-zA-Z0-9_.])*'/
33
+
34
+ whitespace = /[ \t\r\n]+/
35
+ comment = /\/\/[^\r\n]*/
36
+
37
+ state :common_rules do
38
+ rule %r/#{whitespace}/, Text
39
+ rule %r/#{comment}/, Comment::Single
40
+ rule %r/#{string}/, Literal::String
41
+ rule %r/#{float}/, Num::Float
42
+ rule %r/#{int}/, Num::Integer
43
+ end
44
+
45
+ state :root do
46
+ mixin :common_rules
47
+ rule %r/(#{lowercase_id})(\()/ do
48
+ groups Name::Function, Operator
49
+ push :event_type_params
50
+ end
51
+ rule %r/#{lowercase_id}/ do |m|
52
+ if m[0] == 'with'
53
+ token Keyword
54
+ push :data_expression_with
55
+ elsif self.class.keywords.include? m[0]
56
+ token Keyword
57
+ else
58
+ token Name::Function
59
+ end
60
+ end
61
+ rule %r/\(|\{|\[/, Operator, :event_type_params
62
+ rule %r/[_\|]/, Operator
63
+ rule %r/#{uppercase_id}/, Name::Class, :equation_block_expression
64
+ rule %r/;/, Operator
65
+ end
66
+
67
+ state :event_type_params do
68
+ mixin :common_rules
69
+ rule %r/\(|\{|\[/, Operator, :push
70
+ rule %r/\)|\}|\]/, Operator, :pop!
71
+ rule %r/#{lowercase_id}(?=:)/, Name::Entity
72
+ rule %r/(#{lowercase_id})/ do |m|
73
+ if self.class.keywords.include? m[0]
74
+ token Keyword
75
+ else
76
+ token Literal::String::Regex
77
+ end
78
+ end
79
+ rule %r/#{ellipsis}/, Literal::String::Symbol
80
+ rule %r/[_\|;,:]/, Operator
81
+ end
82
+
83
+ state :equation_block_expression do
84
+ mixin :common_rules
85
+ rule %r/[<,>]/, Operator
86
+ rule %r/#{lowercase_id}/, Literal::String::Regex
87
+ rule %r/=/ do
88
+ token Operator
89
+ goto :exp
90
+ end
91
+ rule %r/;/, Operator, :pop!
92
+ end
93
+
94
+ state :exp do
95
+ mixin :common_rules
96
+ rule %r/(if)(\()/ do
97
+ groups Keyword, Operator
98
+ push :data_expression
99
+ end
100
+ rule %r/let|var/, Keyword, :equation_block_expression
101
+ rule %r/(#{lowercase_id})(\()/ do
102
+ groups Name::Function, Operator
103
+ push :event_type_params
104
+ end
105
+ rule %r/(#{lowercase_id})/ do |m|
106
+ if self.class.keywords.include? m[0]
107
+ token Keyword
108
+ else
109
+ token Name::Function
110
+ end
111
+ end
112
+ rule %r/#{uppercase_id}(?=<)/, Name::Class, :data_expression
113
+ rule %r/#{uppercase_id}/, Name::Class
114
+ rule %r/[=(){}*+\/\\\|!>?]/, Operator
115
+ rule %r/;/, Operator, :pop!
116
+ end
117
+
118
+ state :data_expression do
119
+ mixin :common_rules
120
+ rule %r/#{lowercase_id}/ do |m|
121
+ if (self.class.arithmetic_keywords | self.class.keywords).include? m[0]
122
+ token Keyword
123
+ else
124
+ token Literal::String::Regex
125
+ end
126
+ end
127
+ rule %r/\(/, Operator, :push
128
+ rule %r/\)/, Operator, :pop!
129
+ rule %r/(>)(?=[^A-Z;]+[A-Z;>])/, Operator, :pop!
130
+ rule %r/[*^?!%&\[\]<>\|+=:,.\/\\_-]/, Operator
131
+ rule %r/;/, Operator, :pop!
132
+ end
133
+
134
+ state :data_expression_with do
135
+ mixin :common_rules
136
+ rule %r/>/, Operator
137
+ mixin :data_expression
138
+
139
+ end
140
+ end
141
+ end
142
+ end
@@ -5,10 +5,10 @@ module Rouge
5
5
  module Lexers
6
6
  class TOML < RegexLexer
7
7
  title "TOML"
8
- desc 'the TOML configuration format (https://github.com/mojombo/toml)'
8
+ desc 'the TOML configuration format (https://github.com/toml-lang/toml)'
9
9
  tag 'toml'
10
10
 
11
- filenames '*.toml', 'Pipfile'
11
+ filenames '*.toml', 'Pipfile', 'poetry.lock'
12
12
  mimetypes 'text/x-toml'
13
13
 
14
14
  # bare keys and quoted keys
@@ -24,8 +24,6 @@ module Rouge
24
24
  push :inline
25
25
  end
26
26
 
27
- rule %r/(?<!=)\s*\[[\S]+\]/, Name::Namespace
28
-
29
27
  rule %r/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, Literal::Date
30
28
 
31
29
  rule %r/[+-]?\d+(?:_\d+)*\.\d+(?:_\d+)*(?:[eE][+-]?\d+(?:_\d+)*)?/, Num::Float
@@ -41,6 +39,8 @@ module Rouge
41
39
  state :root do
42
40
  mixin :basic
43
41
 
42
+ rule %r/(?<!=)\s*\[.*?\]+/, Name::Namespace
43
+
44
44
  rule %r/(#{identifier})(\s*)(=)/ do
45
45
  groups Name::Property, Text, Punctuation
46
46
  push :value
@@ -20,6 +20,13 @@ module Rouge
20
20
  groups Name::Other, Punctuation
21
21
  pop! 3
22
22
  end
23
+
24
+ rule %r/</, Punctuation, :type
25
+ end
26
+
27
+ state :type do
28
+ mixin :object
29
+ rule %r/>/, Punctuation, :pop!
23
30
  end
24
31
  end
25
32
  end
@@ -26,7 +26,10 @@ module Rouge
26
26
 
27
27
  def builtins
28
28
  @builtins ||= super + %w(
29
- Pick Partial Readonly Record
29
+ Capitalize ConstructorParameters Exclude Extract InstanceType
30
+ Lowercase NonNullable Omit OmitThisParameter Parameters
31
+ Partial Pick Readonly Record Required
32
+ ReturnType ThisParameterType ThisType Uncapitalize Uppercase
30
33
  )
31
34
  end
32
35
 
data/lib/rouge/version.rb CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Rouge
5
5
  def self.version
6
- "3.30.0"
6
+ "4.0.0"
7
7
  end
8
8
  end
data/rouge.gemspec CHANGED
@@ -16,7 +16,7 @@ Gem::Specification.new do |s|
16
16
  s.files = Dir['Gemfile', 'LICENSE', 'rouge.gemspec', 'lib/**/*.rb', 'lib/**/*.yml', 'bin/rougify', 'lib/rouge/demos/*']
17
17
  s.executables = %w(rougify)
18
18
  s.licenses = ['MIT', 'BSD-2-Clause']
19
- s.required_ruby_version = '>= 2.0'
19
+ s.required_ruby_version = '>= 2.7'
20
20
  s.metadata = {
21
21
  "bug_tracker_uri" => "https://github.com/rouge-ruby/rouge/issues",
22
22
  "changelog_uri" => "https://github.com/rouge-ruby/rouge/blob/master/CHANGELOG.md",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rouge
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.30.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeanine Adkisson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-30 00:00:00.000000000 Z
11
+ date: 2022-09-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Rouge aims to a be a simple, easy-to-extend drop-in replacement for pygments.
14
14
  email:
@@ -185,6 +185,7 @@ files:
185
185
  - lib/rouge/demos/reasonml
186
186
  - lib/rouge/demos/rego
187
187
  - lib/rouge/demos/rescript
188
+ - lib/rouge/demos/rml
188
189
  - lib/rouge/demos/robot_framework
189
190
  - lib/rouge/demos/ruby
190
191
  - lib/rouge/demos/rust
@@ -201,7 +202,6 @@ files:
201
202
  - lib/rouge/demos/smalltalk
202
203
  - lib/rouge/demos/smarty
203
204
  - lib/rouge/demos/sml
204
- - lib/rouge/demos/solidity
205
205
  - lib/rouge/demos/sparql
206
206
  - lib/rouge/demos/sqf
207
207
  - lib/rouge/demos/sql
@@ -435,6 +435,7 @@ files:
435
435
  - lib/rouge/lexers/reasonml.rb
436
436
  - lib/rouge/lexers/rego.rb
437
437
  - lib/rouge/lexers/rescript.rb
438
+ - lib/rouge/lexers/rml.rb
438
439
  - lib/rouge/lexers/robot_framework.rb
439
440
  - lib/rouge/lexers/ruby.rb
440
441
  - lib/rouge/lexers/rust.rb
@@ -452,7 +453,6 @@ files:
452
453
  - lib/rouge/lexers/smalltalk.rb
453
454
  - lib/rouge/lexers/smarty.rb
454
455
  - lib/rouge/lexers/sml.rb
455
- - lib/rouge/lexers/solidity.rb
456
456
  - lib/rouge/lexers/sparql.rb
457
457
  - lib/rouge/lexers/sqf.rb
458
458
  - lib/rouge/lexers/sqf/keywords.rb
@@ -534,7 +534,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
534
534
  requirements:
535
535
  - - ">="
536
536
  - !ruby/object:Gem::Version
537
- version: '2.0'
537
+ version: '2.7'
538
538
  required_rubygems_version: !ruby/object:Gem::Requirement
539
539
  requirements:
540
540
  - - ">="
@@ -1,13 +0,0 @@
1
- pragma solidity ~0.4.15;
2
-
3
- interface IMirror {
4
- function reflect() external payable returns(bool /* ain't I pretty?.. */);
5
- }
6
-
7
- contract Mirror is IMirror {
8
- event logMessage(address indexed sender, uint256 value, uint256 gas, bytes data);
9
-
10
- function () { // no funny stuff
11
- revert();
12
- }
13
- }
@@ -1,185 +0,0 @@
1
- # -*- coding: utf-8 -*- #
2
-
3
- module Rouge
4
- module Lexers
5
- class Solidity < RegexLexer
6
- title "Solidity"
7
- desc "Solidity, an Ethereum smart contract programming language"
8
- tag 'solidity'
9
- filenames '*.sol', '*.solidity'
10
- mimetypes 'text/x-solidity'
11
-
12
- # optional comment or whitespace
13
- ws = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
14
- id = /[a-zA-Z$_][\w$_]*/
15
-
16
- def self.detect?(text)
17
- return true if text.start_with? 'pragma solidity'
18
- end
19
-
20
- # TODO: seperate by "type"
21
- def self.keywords
22
- @keywords ||= Set.new %w(
23
- abstract anonymous as assembly break catch calldata constant
24
- constructor continue contract do delete else emit enum event
25
- external fallback for function hex if indexed interface
26
- internal import is library mapping memory modifier new
27
- override payable public pure pragma private receive return
28
- returns storage struct throw try type using var view virtual
29
- while
30
- )
31
- end
32
-
33
- def self.builtins
34
- return @builtins if @builtins
35
-
36
- @builtins = Set.new %w(
37
- now
38
- false true
39
- balance now selector super this
40
- blockhash gasleft
41
- assert require revert
42
- selfdestruct suicide
43
- call callcode delegatecall
44
- send transfer
45
- addmod ecrecover keccak256 mulmod sha256 sha3 ripemd160
46
- )
47
-
48
- # TODO: use (currently shadowed by catch-all in :statements)
49
- abi = %w(decode encode encodePacked encodeWithSelector encodeWithSignature)
50
- @builtins.merge( abi.map { |i| "abi.#{i}" } )
51
- block = %w(coinbase difficulty gaslimit hash number timestamp)
52
- @builtins.merge( block.map { |i| "block.#{i}" } )
53
- msg = %w(data gas sender sig value)
54
- @builtins.merge( msg.map { |i| "msg.#{i}" } )
55
- tx = %w(gasprice origin)
56
- @builtins.merge( tx.map { |i| "tx.#{i}" } )
57
- end
58
-
59
- def self.constants
60
- @constants ||= Set.new %w(
61
- wei finney szabo ether
62
- seconds minutes hours days weeks years
63
- )
64
- end
65
-
66
- def self.keywords_type
67
- @keywords_type ||= Set.new %w(
68
- address bool byte bytes int string uint
69
- )
70
- end
71
-
72
- def self.reserved
73
- @reserved ||= Set.new %w(
74
- alias after apply auto case copyof default define final fixed
75
- immutable implements in inline let macro match mutable null of
76
- partial promise reference relocatable sealed sizeof static
77
- supports switch typedef typeof ufixed unchecked
78
- )
79
- end
80
-
81
- start { push :bol }
82
-
83
- state :expr_bol do
84
- mixin :inline_whitespace
85
-
86
- rule(//) { pop! }
87
- end
88
-
89
- # :expr_bol is the same as :bol but without labels, since
90
- # labels can only appear at the beginning of a statement.
91
- state :bol do
92
- mixin :expr_bol
93
- end
94
-
95
- # TODO: natspec in comments
96
- state :inline_whitespace do
97
- rule %r/[ \t\r]+/, Text
98
- rule %r/\\\n/, Text # line continuation
99
- rule %r(/\*), Comment::Multiline, :comment_multi
100
- end
101
-
102
- state :whitespace do
103
- rule %r/\n+/m, Text, :bol
104
- rule %r(//(\\.|.)*?\n), Comment::Single, :bol
105
- mixin :inline_whitespace
106
- end
107
-
108
- state :expr_whitespace do
109
- rule %r/\n+/m, Text, :expr_bol
110
- mixin :whitespace
111
- end
112
-
113
- state :statements do
114
- mixin :whitespace
115
- rule %r/(hex)?\"/, Str, :string_double
116
- rule %r/(hex)?\'/, Str, :string_single
117
- rule %r('(\\.|\\[0-7]{1,3}|\\x[a-f0-9]{1,2}|[^\\'\n])')i, Str::Char
118
- rule %r/\d\d*\.\d+([eE]\d+)?/i, Num::Float
119
- rule %r/0x[0-9a-f]+/i, Num::Hex
120
- rule %r/\d+([eE]\d+)?/i, Num::Integer
121
- rule %r(\*/), Error
122
- rule %r([~!%^&*+=\|?:<>/-]), Operator
123
- rule %r/[()\[\],.]/, Punctuation
124
- rule %r/u?fixed\d+x\d+/, Keyword::Reserved
125
- rule %r/bytes\d+/, Keyword::Type
126
- rule %r/u?int\d+/, Keyword::Type
127
- rule id do |m|
128
- name = m[0]
129
-
130
- if self.class.keywords.include? name
131
- token Keyword
132
- elsif self.class.builtins.include? name
133
- token Name::Builtin
134
- elsif self.class.constants.include? name
135
- token Keyword::Constant
136
- elsif self.class.keywords_type.include? name
137
- token Keyword::Type
138
- elsif self.class.reserved.include? name
139
- token Keyword::Reserved
140
- else
141
- token Name
142
- end
143
- end
144
- end
145
-
146
- state :root do
147
- mixin :expr_whitespace
148
- rule(//) { push :statement }
149
- # TODO: function declarations
150
- end
151
-
152
- state :statement do
153
- rule %r/;/, Punctuation, :pop!
154
- mixin :expr_whitespace
155
- mixin :statements
156
- rule %r/[{}]/, Punctuation
157
- end
158
-
159
- state :string_common do
160
- rule %r/\\(u[a-fA-F0-9]{4}|x..|[^x])/, Str::Escape
161
- rule %r/[^\\\"\'\n]+/, Str
162
- rule %r/\\\n/, Str # line continuation
163
- rule %r/\\/, Str # stray backslash
164
- end
165
-
166
- state :string_double do
167
- mixin :string_common
168
- rule %r/\"/, Str, :pop!
169
- rule %r/\'/, Str
170
- end
171
-
172
- state :string_single do
173
- mixin :string_common
174
- rule %r/\'/, Str, :pop!
175
- rule %r/\"/, Str
176
- end
177
-
178
- state :comment_multi do
179
- rule %r(\*/), Comment::Multiline, :pop!
180
- rule %r([^*/]+), Comment::Multiline
181
- rule %r([*/]), Comment::Multiline
182
- end
183
- end
184
- end
185
- end