rouge 3.26.1 → 3.27.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: bf66ca242ee17857f0f67422e11b25a18f5638d57f54b50399d10983a899ec8b
4
- data.tar.gz: 05d8673d6c6c1c84e4691137574b18f3a5bd251faa1e8d861a6fa342416be01b
3
+ metadata.gz: 396c335066b8bb01574b5d81b25d43a98b58dd1bad1d3d9588b7a35c573e2209
4
+ data.tar.gz: d899fb3968d38a1a93415c21c62e332f1a8ba230952c0a33adda5c4755c4c8f3
5
5
  SHA512:
6
- metadata.gz: 105a0d4429dc9109c4029e7bb142c4e42fb670039b24e8a5aed8f249ba35a85fa8c3aa63ce3be996cc848f4ee54fff50bba5e5061d6e099c36137c0f60948221
7
- data.tar.gz: a745067ac6959e3ea36ea20b9c73f2df54d75533125545ce4940489faab5cd2293bc123cceb4752cce451871de5702ab927e738a40cadfabc2525886db88715a
6
+ metadata.gz: c1fed00ea4906f18e1939675dff9c02508cddef4b1878622422d66b3cbee6d07111ab434cb83314d5d3077f3b86375424d4af05f2fce46cb105a9ecef698aec9
7
+ data.tar.gz: 7764c52128ef376d3af7e2c5d1a958a62bddffadc4b2d8c868161fd786a9af63827d143a8b85d6d5251d65f8adefc6a405e2fef5d29e6c7d73bc00f041d8c024
@@ -0,0 +1,16 @@
1
+ module A {
2
+ const i: int := 56_78
3
+ }
4
+
5
+ method m(b: bool, s: string) {
6
+ var x: string;
7
+ var i: int;
8
+ if b then i := 1; else i := 2;
9
+ i := if b 1 else 2;
10
+ assert b;
11
+ assume b;
12
+ print s;
13
+ expect b;
14
+ }
15
+
16
+ function f(i: int): int { i + 1 }
@@ -51,8 +51,8 @@ module Rouge
51
51
 
52
52
  rule %r("(\\\\|\\"|[^"])*"), Literal::String
53
53
  rule %r('\\.'|'[^\\]'|'\\\{#[0-9a-fA-F]{4}\}'), Literal::String::Char
54
- rule %r(".*``.*``.*"', String::Interpol
55
- rule %r(\.)([a-z_]\w*)) do
54
+ rule %r("[^`]*``[^`]*``[^`]*"), Literal::String::Interpol
55
+ rule %r((\.)([a-z_]\w*)) do
56
56
  groups Operator, Name::Attribute
57
57
  end
58
58
  rule %r([a-zA-Z_]\w*:), Name::Label
@@ -0,0 +1,128 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Dafny < RegexLexer
7
+ title "Dafny"
8
+ desc "The Dafny programming language (github.com/dafny-lang/dafny)"
9
+ tag "dafny"
10
+ filenames "*.dfy"
11
+ mimetypes "text/x-dafny"
12
+
13
+ keywords = %w(
14
+ abstract allocated assert assume
15
+ break by
16
+ calc case class codatatype const constructor
17
+ datatype decreases downto
18
+ else ensures exists expect export extends
19
+ false for forall fresh function
20
+ ghost greatest
21
+ if import include invariant iterator
22
+ label least lemma
23
+ match method modifies modify module
24
+ nameonly new newtype null
25
+ old opened
26
+ predicate print provides
27
+ reads refines requires return returns reveal reveals
28
+ static
29
+ then this to trait true twostate type
30
+ unchanged
31
+ var
32
+ while witness
33
+ yield yields
34
+ )
35
+
36
+ literals = %w{ true false null }
37
+
38
+ textOperators = %w{ as is in }
39
+
40
+ types = %w(bool char int real string nat
41
+ array array? object object? ORDINAL
42
+ seq set iset map imap multiset )
43
+
44
+ idstart = /[0-9a-zA-Z?]/
45
+ idchar = /[0-9a-zA-Z_'?]/
46
+ id = /#{idstart}#{idchar}*/
47
+
48
+ arrayType = /array(?:1[0-9]+|[2-9][0-9]*)\??(?!#{idchar})/
49
+ bvType = /bv(?:0|[1-9][0-9]*)(?!#{idchar})/
50
+
51
+ digit = /\d/
52
+ digits = /#{digit}+(?:_#{digit}+)*/
53
+ bin_digits = /[01]+(?:_[01]+)*/
54
+ hex_digit = /(?:[0-9a-fA-F])/
55
+ hex_digits = /#{hex_digit}+(?:_#{hex_digit}+)*/
56
+
57
+ cchar = /(?:[^\\'\n\r]|\\["'ntr\\0])/
58
+ schar = /(?:[^\\"\n\r]|\\["'ntr\\0])/
59
+ uchar = /(?:\\u#{hex_digit}{4})/
60
+
61
+ ## IMPORTANT: Rules are ordered, which allows later rules to be
62
+ ## simpler than they would otherwise be
63
+ state :root do
64
+ rule %r(/\*), Comment::Multiline, :comment
65
+ rule %r(//.*?$), Comment::Single
66
+ rule %r(\*/), Error # should not have closing comment in :root
67
+ # is an improperly nested comment
68
+
69
+ rule %r/'#{cchar}'/, Str::Char # standard or escape char
70
+ rule %r/'#{uchar}'/, Str::Char # unicode char
71
+ rule %r/'[^'\n\r]*'/, Error # bad any other enclosed char
72
+ rule %r/'[^'\n\r]*$/, Error # bad unclosed char
73
+
74
+ rule %r/"(?:#{schar}|#{uchar})*"/, Str::Double # valid string
75
+ rule %r/".*"/, Error # anything else that is closed
76
+ rule %r/".*$/, Error # bad unclosed string
77
+
78
+ rule %r/@"([^"]|"")*"/, Str::Other # valid verbatim string
79
+ rule %r/@".*/m, Error # anything else , multiline unclosed
80
+
81
+
82
+ rule %r/#{digits}\.#{digits}(?!#{idchar})/, Num::Float
83
+ rule %r/0b#{bin_digits}(?!#{idchar})/, Num::Bin
84
+ rule %r/0b#{idchar}*/, Error
85
+ rule %r/0x#{hex_digits}(?!#{idchar})/, Num::Hex
86
+ rule %r/0x#{idchar}*/, Error
87
+ rule %r/#{digits}(?!#{idchar})/, Num::Integer
88
+ rule %r/_(?!#{idchar})/, Name
89
+ rule %r/_[0-9_]+[_]?(?!#{idchar})/, Error
90
+ rule %r/[0-9_]+_(?!#{idchar})/, Error
91
+ rule %r/[0-9]#{idchar}+/, Error
92
+
93
+ rule %r/#{arrayType}/, Keyword::Type
94
+ rule %r/#{bvType}/, Keyword::Type
95
+
96
+ rule id do |m|
97
+ if types.include?(m[0])
98
+ token Keyword::Type
99
+ elsif literals.include?(m[0])
100
+ token Keyword::Constant
101
+ elsif textOperators.include?(m[0])
102
+ token Operator::Word
103
+ elsif keywords.include?(m[0])
104
+ token Keyword::Reserved
105
+ else
106
+ token Name
107
+ end
108
+ end
109
+
110
+ rule %r/\.\./, Operator
111
+ rule %r/[*!%&<>\|^+=:.\/-]/, Operator
112
+ rule %r/[\[\](){},;`]/, Punctuation
113
+
114
+ rule %r/[^\S\n]+/, Text
115
+ rule %r/\n/, Text
116
+ rule %r/./, Error # Catchall
117
+ end
118
+
119
+ state :comment do
120
+ rule %r(\*/), Comment::Multiline, :pop!
121
+ rule %r(/\*), Comment::Multiline, :comment
122
+ rule %r([^*/]+), Comment::Multiline
123
+ rule %r(.), Comment::Multiline
124
+ end
125
+
126
+ end
127
+ end
128
+ end
@@ -7,9 +7,9 @@ module Rouge
7
7
  desc "Embedded Elixir"
8
8
 
9
9
  tag 'eex'
10
- aliases 'leex'
10
+ aliases 'leex', 'heex'
11
11
 
12
- filenames '*.eex', '*.leex'
12
+ filenames '*.eex', '*.leex', '*.heex'
13
13
 
14
14
  def initialize(opts={})
15
15
  @elixir_lexer = Elixir.new(opts)
@@ -22,10 +22,10 @@ module Rouge
22
22
 
23
23
  def self.keywords
24
24
  @keywords ||= %w(
25
- as assert async await break const continue copy do drop else enum extern
26
- fail false fn for if impl let log loop match mod move mut priv pub pure
27
- ref return self static struct true trait type unsafe use where
28
- while box
25
+ as assert async await break crate const continue copy do drop dyn else enum extern
26
+ fail false fn for if impl let log loop macro match mod move mut priv pub pure
27
+ ref return self Self static struct super true try trait type union unsafe use
28
+ where while yield box
29
29
  )
30
30
  end
31
31
 
@@ -40,6 +40,9 @@ module Rouge
40
40
  Right Send Shl Shr size_t Some ssize_t str Sub Success time_t
41
41
  u16 u32 u64 u8 usize uint uintptr_t
42
42
  Box Vec String Gc Rc Arc
43
+ u128 i128 Result Sync Pin Unpin Sized Drop drop Fn FnMut FnOnce
44
+ Clone PartialEq PartialOrd AsMut AsRef From Into Default
45
+ DoubleEndedIterator ExactSizeIterator Extend IntoIterator Iterator
43
46
  )
44
47
  end
45
48
 
@@ -54,12 +57,12 @@ module Rouge
54
57
 
55
58
  delim_map = { '[' => ']', '(' => ')', '{' => '}' }
56
59
 
57
- id = /[a-z_]\w*/i
60
+ id = /[\p{XID_Start}_]\p{XID_Continue}*/
58
61
  hex = /[0-9a-f]/i
59
62
  escapes = %r(
60
- \\ ([nrt'"\\0] | x#{hex}{2} | u#{hex}{4} | U#{hex}{8})
63
+ \\ ([nrt'"\\0] | x#{hex}{2} | u\{(#{hex}_*){1,6}\})
61
64
  )x
62
- size = /8|16|32|64/
65
+ size = /8|16|32|64|128|size/
63
66
 
64
67
  # Although not officially part of Rust, the rustdoc tool allows code in
65
68
  # comments to begin with `#`. Code like this will be evaluated but not
@@ -82,8 +85,62 @@ module Rouge
82
85
 
83
86
  state :whitespace do
84
87
  rule %r/\s+/, Text
85
- rule %r(//[^\n]*), Comment
86
- rule %r(/[*].*?[*]/)m, Comment::Multiline
88
+ mixin :comments
89
+ end
90
+
91
+ state :comments do
92
+ # Only 3 slashes are doc comments, `////` and beyond become normal
93
+ # comments again (for some reason), so match this before the
94
+ # doc line comments rather than figure out a
95
+ rule %r(////+[^\n]*), Comment::Single
96
+ # doc line comments — either inner (`//!`), or outer (`///`).
97
+ rule %r(//[/!][^\n]*), Comment::Doc
98
+ # otherwise, `//` is just a plain line comme
99
+ rule %r(//[^\n]*), Comment::Single
100
+ # /**/ and /***/ are self-closing block comments, not doc. Because this
101
+ # is self-closing, it doesn't enter the states for nested comments
102
+ rule %r(/\*\*\*?/), Comment::Multiline
103
+ # 3+ stars and it's a normal non-doc block comment.
104
+ rule %r(/\*\*\*+), Comment::Multiline, :nested_plain_block
105
+ # `/*!` and `/**` begin doc comments. These nest and can have internal
106
+ # block/doc comments, but they're still part of the documentation
107
+ # inside.
108
+ rule %r(/[*][*!]), Comment::Doc, :nested_doc_block
109
+ # any other /* is a plain multiline comment
110
+ rule %r(/[*]), Comment::Multiline, :nested_plain_block
111
+ end
112
+
113
+ # Multiline/block comments fully nest. This is true for ones that are
114
+ # marked as documentation too. The behavior here is:
115
+ #
116
+ # - Anything inside a block doc comment is still included in the
117
+ # documentation, even if it's a nested non-doc block comment. For
118
+ # example: `/** /* still docs */ */`
119
+ # - Anything inside of a block non-doc comment is still just a normal
120
+ # comment, even if it's a nested block documentation comment. For
121
+ # example: `/* /** not docs */ */`
122
+ #
123
+ # This basically means: if (on the outermost level) the comment starts as
124
+ # one kind of block comment (either doc/non-doc), then everything inside
125
+ # of it, including nested block comments of the opposite type, needs to
126
+ # stay that type.
127
+ #
128
+ # Also note that single line comments do nothing anywhere inside of block
129
+ # comments, thankfully.
130
+ #
131
+ # We just define this as two states, because this seems easier than
132
+ # tracking it with instance vars.
133
+ [
134
+ [:nested_plain_block, Comment::Multiline],
135
+ [:nested_doc_block, Comment::Doc]
136
+ ].each do |state_name, comment_token|
137
+ state state_name do
138
+ rule %r(\*/), comment_token, :pop!
139
+ rule %r(/\*), comment_token, state_name
140
+ # We only want to eat at most one `[*/]` at a time,
141
+ # but we can skip past non-`[*/]` in bulk.
142
+ rule %r([^*/]+|[*/]), comment_token
143
+ end
87
144
  end
88
145
 
89
146
  state :root do
@@ -110,6 +167,7 @@ module Rouge
110
167
  rule %r/\bmacro_rules!/, Name::Decorator, :macro_rules
111
168
  rule %r/#{id}!/, Name::Decorator, :macro
112
169
 
170
+ rule %r/'static\b/, Keyword
113
171
  rule %r/'#{id}/, Name::Variable
114
172
  rule %r/#{id}/ do |m|
115
173
  name = m[0]
@@ -155,32 +213,33 @@ module Rouge
155
213
  state :has_literals do
156
214
  # constants
157
215
  rule %r/\b(?:true|false|nil)\b/, Keyword::Constant
158
- # characters
216
+ # characters/bytes
159
217
  rule %r(
160
- ' (?: #{escapes} | [^\\] ) '
218
+ b?' (?: #{escapes} | [^\\] ) '
161
219
  )x, Str::Char
162
220
 
163
- rule %r/"/, Str, :string
164
- rule %r/r(#*)".*?"\1/m, Str
221
+ rule %r/b?"/, Str, :string
222
+ rule %r/b?r(#*)".*?"\1/m, Str
165
223
 
166
224
  # numbers
167
- dot = /[.][0-9_]+/
168
- exp = /e[-+]?[0-9_]+/
225
+ dot = /[.][0-9][0-9_]*/
226
+ exp = /[eE][-+]?[0-9_]+/
169
227
  flt = /f32|f64/
170
228
 
171
229
  rule %r(
172
- [0-9_]+
230
+ [0-9][0-9_]*
173
231
  (#{dot} #{exp}? #{flt}?
174
232
  |#{dot}? #{exp} #{flt}?
175
233
  |#{dot}? #{exp}? #{flt}
234
+ |[.](?![._\p{XID_Start}])
176
235
  )
177
236
  )x, Num::Float
178
237
 
179
238
  rule %r(
180
239
  ( 0b[10_]+
181
240
  | 0x[0-9a-fA-F_]+
182
- | 0o[0-7]+
183
- | [0-9_]+
241
+ | 0o[0-7_]+
242
+ | [0-9][0-9_]*
184
243
  ) (u#{size}?|i#{size})?
185
244
  )x, Num::Integer
186
245
 
@@ -38,8 +38,8 @@ module Rouge
38
38
  DYNAMIC DYNAMIC_FUNCTION DYNAMIC_FUNCTION_CODE EACH ELSE
39
39
  ENCODING ENCRYPTED END END-EXEC EQUALS ESCAPE EVERY EXCEPT
40
40
  ESCEPTION EXCLUDING EXCLUSIVE EXEC EXECUTE EXISTING EXISTS
41
- EXPLAIN EXTERNAL EXTRACT FALSE FETCH FINAL FIRST FOR FORCE
42
- FOREIGN FORTRAN FORWARD FOUND FREE FREEZE FROM FULL FUNCTION
41
+ EXPLAIN EXTERNAL EXTRACT FALSE FETCH FINAL FIRST FOLLOWING FOR
42
+ FORCE FOREIGN FORTRAN FORWARD FOUND FREE FREEZE FROM FULL FUNCTION
43
43
  G GENERAL GENERATED GET GLOBAL GO GOTO GRANT GRANTED GROUP
44
44
  GROUPING HANDLER HAVING HIERARCHY HOLD HOST IDENTITY IGNORE
45
45
  ILIKE IMMEDIATE IMMUTABLE IMPLEMENTATION IMPLICIT IN INCLUDING
@@ -58,10 +58,10 @@ module Rouge
58
58
  ORDINALITY OUT OUTER OUTPUT OVERLAPS OVERLAY OVERRIDING
59
59
  OWNER PAD PARAMETER PARAMETERS PARAMETER_MODE PARAMATER_NAME
60
60
  PARAMATER_ORDINAL_POSITION PARAMETER_SPECIFIC_CATALOG
61
- PARAMETER_SPECIFIC_NAME PARAMATER_SPECIFIC_SCHEMA PARTIAL PASCAL
62
- PENDANT PLACING PLI POSITION POSTFIX PREFIX PREORDER
61
+ PARAMETER_SPECIFIC_NAME PARAMATER_SPECIFIC_SCHEMA PARTIAL PARTITION
62
+ PASCAL PENDANT PLACING PLI POSITION POSTFIX PREFIX PRECEDING PREORDER
63
63
  PREPARE PRESERVE PRIMARY PRIOR PRIVILEGES PROCEDURAL PROCEDURE
64
- PUBLIC READ READS RECHECK RECURSIVE REF REFERENCES REFERENCING
64
+ PUBLIC RANGE READ READS RECHECK RECURSIVE REF REFERENCES REFERENCING
65
65
  REINDEX RELATIVE RENAME REPEATABLE REPLACE RESET RESTART
66
66
  RESTRICT RESULT RETURN RETURNED_LENGTH RETURNED_OCTET_LENGTH
67
67
  RETURNED_SQLSTATE RETURNS REVOKE RIGHT ROLE ROLLBACK ROLLUP
@@ -84,7 +84,7 @@ module Rouge
84
84
  USAGE USER USER_DEFINED_TYPE_CATALOG USER_DEFINED_TYPE_NAME
85
85
  USER_DEFINED_TYPE_SCHEMA USING VACUUM VALID VALIDATOR VALUES
86
86
  VARIABLE VERBOSE VERSION VIEW VOLATILE WHEN WHENEVER WHERE
87
- WITH WITHOUT WORK WRITE ZONE
87
+ WINDOW WITH WITHOUT WORK WRITE ZONE
88
88
  )
89
89
  end
90
90
 
@@ -126,7 +126,7 @@ module Rouge
126
126
  end
127
127
 
128
128
  rule %r([+*/<>=~!@#%&|?^-]), Operator
129
- rule %r/[;:()\[\],.]/, Punctuation
129
+ rule %r/[;:()\[\]\{\},.]/, Punctuation
130
130
  end
131
131
 
132
132
  state :multiline_comments do
@@ -15,17 +15,17 @@ module Rouge
15
15
  id = /#{id_head}#{id_rest}*/
16
16
 
17
17
  keywords = Set.new %w(
18
- break case continue default do else fallthrough if in for return switch where while try catch throw guard defer repeat
18
+ await break case continue default do else fallthrough if in for return switch where while try catch throw guard defer repeat
19
19
 
20
20
  as dynamicType is new super self Self Type __COLUMN__ __FILE__ __FUNCTION__ __LINE__
21
21
 
22
- associativity didSet get infix inout mutating none nonmutating operator override postfix precedence prefix set unowned weak willSet throws rethrows precedencegroup
22
+ associativity async didSet get infix inout isolated mutating none nonmutating operator override postfix precedence prefix set unowned weak willSet throws rethrows precedencegroup
23
23
 
24
24
  #available #colorLiteral #column #else #elseif #endif #error #file #fileLiteral #function #if #imageLiteral #line #selector #sourceLocation #warning
25
25
  )
26
26
 
27
27
  declarations = Set.new %w(
28
- class deinit enum convenience extension final func import init internal lazy let optional private protocol public required static struct subscript typealias var dynamic indirect associatedtype open fileprivate some
28
+ actor class deinit enum convenience extension final func import init internal lazy let nonisolated optional private protocol public required static struct subscript typealias var dynamic indirect associatedtype open fileprivate some
29
29
  )
30
30
 
31
31
  constants = Set.new %w(
data/lib/rouge/version.rb CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Rouge
5
5
  def self.version
6
- "3.26.1"
6
+ "3.27.0"
7
7
  end
8
8
  end
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.26.1
4
+ version: 3.27.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: 2021-09-17 00:00:00.000000000 Z
11
+ date: 2021-12-15 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:
@@ -62,6 +62,7 @@ files:
62
62
  - lib/rouge/demos/cypher
63
63
  - lib/rouge/demos/cython
64
64
  - lib/rouge/demos/d
65
+ - lib/rouge/demos/dafny
65
66
  - lib/rouge/demos/dart
66
67
  - lib/rouge/demos/datastudio
67
68
  - lib/rouge/demos/diff
@@ -290,6 +291,7 @@ files:
290
291
  - lib/rouge/lexers/cypher.rb
291
292
  - lib/rouge/lexers/cython.rb
292
293
  - lib/rouge/lexers/d.rb
294
+ - lib/rouge/lexers/dafny.rb
293
295
  - lib/rouge/lexers/dart.rb
294
296
  - lib/rouge/lexers/datastudio.rb
295
297
  - lib/rouge/lexers/diff.rb