rouge 3.3.0 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +5 -5
  2. data/Gemfile +14 -2
  3. data/lib/rouge.rb +45 -41
  4. data/lib/rouge/cli.rb +26 -2
  5. data/lib/rouge/demos/escape +3 -0
  6. data/lib/rouge/demos/supercollider +11 -0
  7. data/lib/rouge/demos/xojo +13 -0
  8. data/lib/rouge/formatter.rb +36 -0
  9. data/lib/rouge/formatters/html.rb +2 -0
  10. data/lib/rouge/formatters/html_linewise.rb +6 -11
  11. data/lib/rouge/formatters/html_table.rb +20 -31
  12. data/lib/rouge/formatters/terminal256.rb +1 -0
  13. data/lib/rouge/guessers/disambiguation.rb +13 -0
  14. data/lib/rouge/guessers/source.rb +1 -1
  15. data/lib/rouge/lexer.rb +44 -13
  16. data/lib/rouge/lexers/c.rb +6 -29
  17. data/lib/rouge/lexers/coffeescript.rb +14 -6
  18. data/lib/rouge/lexers/common_lisp.rb +1 -1
  19. data/lib/rouge/lexers/console.rb +2 -2
  20. data/lib/rouge/lexers/coq.rb +1 -1
  21. data/lib/rouge/lexers/csharp.rb +0 -1
  22. data/lib/rouge/lexers/diff.rb +8 -4
  23. data/lib/rouge/lexers/docker.rb +1 -1
  24. data/lib/rouge/lexers/escape.rb +55 -0
  25. data/lib/rouge/lexers/go.rb +1 -1
  26. data/lib/rouge/lexers/graphql.rb +10 -0
  27. data/lib/rouge/lexers/html.rb +1 -0
  28. data/lib/rouge/lexers/java.rb +4 -0
  29. data/lib/rouge/lexers/javascript.rb +12 -16
  30. data/lib/rouge/lexers/jinja.rb +15 -1
  31. data/lib/rouge/lexers/julia.rb +140 -17
  32. data/lib/rouge/lexers/kotlin.rb +11 -4
  33. data/lib/rouge/lexers/markdown.rb +21 -4
  34. data/lib/rouge/lexers/matlab.rb +9 -2
  35. data/lib/rouge/lexers/objective_c.rb +7 -12
  36. data/lib/rouge/lexers/perl.rb +38 -6
  37. data/lib/rouge/lexers/powershell.rb +1 -1
  38. data/lib/rouge/lexers/rust.rb +1 -1
  39. data/lib/rouge/lexers/scala.rb +28 -2
  40. data/lib/rouge/lexers/shell.rb +1 -1
  41. data/lib/rouge/lexers/slim.rb +2 -2
  42. data/lib/rouge/lexers/supercollider.rb +116 -0
  43. data/lib/rouge/lexers/xml.rb +1 -1
  44. data/lib/rouge/lexers/xojo.rb +61 -0
  45. data/lib/rouge/regex_lexer.rb +12 -12
  46. data/lib/rouge/themes/bw.rb +41 -0
  47. data/lib/rouge/token.rb +30 -22
  48. data/lib/rouge/version.rb +1 -1
  49. metadata +10 -4
@@ -106,7 +106,7 @@ module Rouge
106
106
  rule /\d+[lu]*/i, Num::Integer
107
107
  rule %r(\*/), Error
108
108
  rule %r([~!%^&*+=\|?:<>/-]), Operator
109
- rule /[()\[\],.]/, Punctuation
109
+ rule /[()\[\],.;]/, Punctuation
110
110
  rule /\bcase\b/, Keyword, :case
111
111
  rule /(?:true|false|NULL)\b/, Name::Builtin
112
112
  rule id do |m|
@@ -133,13 +133,11 @@ module Rouge
133
133
 
134
134
  state :root do
135
135
  mixin :expr_whitespace
136
-
137
- # functions
138
136
  rule %r(
139
137
  ([\w*\s]+?[\s*]) # return arguments
140
138
  (#{id}) # function name
141
139
  (\s*\([^;]*?\)) # signature
142
- (#{ws})({) # open brace
140
+ (#{ws}?)({|;) # open brace or semicolon
143
141
  )mx do |m|
144
142
  # TODO: do this better.
145
143
  recurse m[1]
@@ -147,33 +145,12 @@ module Rouge
147
145
  recurse m[3]
148
146
  recurse m[4]
149
147
  token Punctuation, m[5]
150
- push :function
151
- end
152
-
153
- # function declarations
154
- rule %r(
155
- ([\w*\s]+?[\s*]) # return arguments
156
- (#{id}) # function name
157
- (\s*\([^;]*?\)) # signature
158
- (#{ws})(;) # semicolon
159
- )mx do |m|
160
- # TODO: do this better.
161
- recurse m[1]
162
- token Name::Function, m[2]
163
- recurse m[3]
164
- recurse m[4]
165
- token Punctuation, m[5]
166
- push :statement
148
+ if m[5] == ?{
149
+ push :function
150
+ end
167
151
  end
168
-
169
- rule(//) { push :statement }
170
- end
171
-
172
- state :statement do
173
- rule /;/, Punctuation, :pop!
174
- mixin :expr_whitespace
152
+ rule /\{/, Punctuation, :function
175
153
  mixin :statements
176
- rule /[{}]/, Punctuation
177
154
  end
178
155
 
179
156
  state :function do
@@ -18,9 +18,17 @@ module Rouge
18
18
 
19
19
  def self.keywords
20
20
  @keywords ||= Set.new %w(
21
- for in of while break return continue switch when then if else
22
- throw try catch finally new delete typeof instanceof super
23
- extends this class by
21
+ for by while until loop break continue return
22
+ switch when then if else do yield throw try catch finally await
23
+ new delete typeof instanceof super extends this class
24
+ import export debugger
25
+ )
26
+ end
27
+
28
+ def self.reserved
29
+ @reserved ||= Set.new %w(
30
+ case function var void with const let enum
31
+ native implements interface package private protected public static
24
32
  )
25
33
  end
26
34
 
@@ -43,7 +51,7 @@ module Rouge
43
51
 
44
52
  state :comments_and_whitespace do
45
53
  rule /\s+/m, Text
46
- rule /###\s*\n.*?###/m, Comment::Multiline
54
+ rule /###[^#].*?###/m, Comment::Multiline
47
55
  rule /#.*$/, Comment::Single
48
56
  end
49
57
 
@@ -77,8 +85,8 @@ module Rouge
77
85
  rule(%r(^(?=\s|/|<!--))) { push :slash_starts_regex }
78
86
  mixin :comments_and_whitespace
79
87
  rule %r(
80
- [+][+]|--|~|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|[?]|:|=|
81
- [|][|]|\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*`%&|^/])=?
88
+ [+][+]|--|~|&&|\band\b|\bor\b|\bis\b|\bisnt\b|\bnot\b|\bin\b|\bof\b|
89
+ [?]|:|=|[|][|]|\\(?=\n)|(<<|>>>?|==?|!=?|[-<>+*`%&|^/])=?
82
90
  )x, Operator, :slash_starts_regex
83
91
 
84
92
  rule /[-=]>/, Name::Function
@@ -320,7 +320,7 @@ module Rouge
320
320
 
321
321
  rule /\(/, Punctuation, :root
322
322
  rule /\)/, Punctuation do
323
- if stack.empty?
323
+ if stack.size == 1
324
324
  token Error
325
325
  else
326
326
  token Punctuation
@@ -118,7 +118,7 @@ module Rouge
118
118
  $' =~ /\A\s*/
119
119
  yield Text, $& unless $&.empty?
120
120
 
121
- lang_lexer.lex($', continue: true, &output)
121
+ lang_lexer.continue_lex($', &output)
122
122
  elsif comment_regex =~ input[0].strip
123
123
  puts "console: matched comment #{input[0].inspect}" if @debug
124
124
  output_lexer.reset!
@@ -129,7 +129,7 @@ module Rouge
129
129
  puts "console: matched output #{input[0].inspect}" if @debug
130
130
  lang_lexer.reset!
131
131
 
132
- output_lexer.lex(input[0], continue: true, &output)
132
+ output_lexer.continue_lex(input[0], &output)
133
133
  end
134
134
  end
135
135
  end
@@ -141,7 +141,7 @@ module Rouge
141
141
  end
142
142
 
143
143
  state :string do
144
- rule /[^\\"]+/, Str::Double
144
+ rule /(?:\\")+|[^"]/, Str::Double
145
145
  mixin :escape_sequence
146
146
  rule /\\\n/, Str::Double
147
147
  rule /"/, Str::Double, :pop!
@@ -71,7 +71,6 @@ module Rouge
71
71
  state :root do
72
72
  mixin :whitespace
73
73
 
74
- rule /^\s*\[.*?\]/, Name::Attribute
75
74
  rule /[$]\s*"/, Str, :splice_string
76
75
  rule /[$]@\s*"/, Str, :splice_literal
77
76
 
@@ -19,14 +19,18 @@ module Rouge
19
19
 
20
20
  state :root do
21
21
  rule(/^ .*$\n?/, Text)
22
- rule(/^---$\n?/, Text)
22
+ rule(/^---$\n?/, Punctuation)
23
+ rule(/^[+>]+.*$\n?/, Generic::Inserted)
23
24
  rule(/^\+.*$\n?/, Generic::Inserted)
24
- rule(/^-+.*$\n?/, Generic::Deleted)
25
+ rule(/^[-<]+.*$\n?/, Generic::Deleted)
25
26
  rule(/^!.*$\n?/, Generic::Strong)
26
- rule(/^@.*$\n?/, Generic::Subheading)
27
27
  rule(/^([Ii]ndex|diff).*$\n?/, Generic::Heading)
28
+ rule(/^(@@[^@]*@@)([^\n]*\n)/) do
29
+ groups Punctuation, Text
30
+ end
31
+ rule(/^\w.*$\n?/, Punctuation)
28
32
  rule(/^=.*$\n?/, Generic::Heading)
29
- rule(/.*$\n?/, Text)
33
+ rule(/\s.*$\n?/, Text)
30
34
  end
31
35
  end
32
36
  end
@@ -8,7 +8,7 @@ module Rouge
8
8
  desc "Dockerfile syntax"
9
9
  tag 'docker'
10
10
  aliases 'dockerfile'
11
- filenames 'Dockerfile', '*.docker'
11
+ filenames 'Dockerfile', '*.Dockerfile', '*.docker', 'Dockerfile_*'
12
12
  mimetypes 'text/x-dockerfile-config'
13
13
 
14
14
  KEYWORDS = %w(
@@ -0,0 +1,55 @@
1
+ module Rouge
2
+ module Lexers
3
+ class Escape < Lexer
4
+ tag 'escape'
5
+ aliases 'esc'
6
+
7
+ desc 'A generic lexer for including escaped content - see Formatter.enable_escape!'
8
+
9
+ option :start, 'the beginning of the escaped section, default "<!"'
10
+ option :end, 'the end of the escaped section, e.g. "!>"'
11
+ option :lang, 'the language to lex in unescaped sections'
12
+
13
+ attr_reader :start
14
+ attr_reader :end
15
+ attr_reader :lang
16
+
17
+ def initialize(*)
18
+ super
19
+ @start = string_option(:start) { '<!' }
20
+ @end = string_option(:end) { '!>' }
21
+ @lang = lexer_option(:lang) { PlainText.new }
22
+ end
23
+
24
+ def to_start_regex
25
+ @to_start_regex ||= /(.*?)(#{Regexp.escape(@start)})/m
26
+ end
27
+
28
+ def to_end_regex
29
+ @to_end_regex ||= /(.*?)(#{Regexp.escape(@end)})/m
30
+ end
31
+
32
+ def stream_tokens(str, &b)
33
+ stream = StringScanner.new(str)
34
+
35
+ loop do
36
+ if stream.scan(to_start_regex)
37
+ puts "pre-escape: #{stream[1].inspect}" if @debug
38
+ @lang.continue_lex(stream[1], &b)
39
+ else
40
+ # no more start delimiters, scan til the end
41
+ @lang.continue_lex(stream.rest, &b)
42
+ return
43
+ end
44
+
45
+ if stream.scan(to_end_regex)
46
+ yield Token::Tokens::Escape, stream[1]
47
+ else
48
+ yield Token::Tokens::Escape, stream.rest
49
+ return
50
+ end
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
@@ -149,7 +149,7 @@ module Rouge
149
149
  rule(OPERATOR, Operator)
150
150
  rule(SEPARATOR, Punctuation)
151
151
  rule(IDENTIFIER, Name)
152
- rule(WHITE_SPACE, Other)
152
+ rule(WHITE_SPACE, Text)
153
153
  end
154
154
 
155
155
  state :root do
@@ -27,6 +27,13 @@ module Rouge
27
27
  rule /\bunion\b/, Keyword, :union_definition
28
28
 
29
29
  mixin :basic
30
+
31
+ # Markdown descriptions
32
+ rule /(""")(.*?)(""")/m do |m|
33
+ token Str::Double, m[1]
34
+ delegate Markdown, m[2]
35
+ token Str::Double, m[3]
36
+ end
30
37
  end
31
38
 
32
39
  state :basic do
@@ -227,6 +234,9 @@ module Rouge
227
234
  }
228
235
  }
229
236
 
237
+ # Multiline strings
238
+ rule /""".*?"""/m, Str::Double
239
+
230
240
  rule /\$#{name}\b/, &pop_unless_list[Name::Variable]
231
241
  rule /\b(?:true|false|null)\b/, &pop_unless_list[Keyword::Constant]
232
242
  rule /[+-]?[0-9]+\.[0-9]+(?:[eE][+-]?[0-9]+)?/, &pop_unless_list[Num::Float]
@@ -12,6 +12,7 @@ module Rouge
12
12
 
13
13
  def self.detect?(text)
14
14
  return true if text.doctype?(/\bhtml\b/i)
15
+ return false if text =~ /\A<\?xml\b/
15
16
  return true if text =~ /<\s*html\b/
16
17
  end
17
18
 
@@ -24,6 +24,8 @@ module Rouge
24
24
  types = %w(boolean byte char double float int long short var void)
25
25
 
26
26
  id = /[a-zA-Z_][a-zA-Z0-9_]*/
27
+ const_name = /[A-Z][A-Z0-9_]*\b/
28
+ class_name = /[A-Z][a-zA-Z0-9]*\b/
27
29
 
28
30
  state :root do
29
31
  rule /[^\S\n]+/, Text
@@ -59,6 +61,8 @@ module Rouge
59
61
  end
60
62
 
61
63
  rule /#{id}:/, Name::Label
64
+ rule const_name, Name::Constant
65
+ rule class_name, Name::Class
62
66
  rule /\$?#{id}/, Name
63
67
  rule /[~^*!%&\[\](){}<>\|+=:;,.\/?-]/, Operator
64
68
 
@@ -98,26 +98,23 @@ module Rouge
98
98
 
99
99
  def self.keywords
100
100
  @keywords ||= Set.new %w(
101
- for in of while do break return continue switch case default
102
- if else throw try catch finally new delete typeof instanceof
103
- void this yield import export from as async super this
101
+ as async await break case catch continue debugger default delete
102
+ do else export finally from for if import in instanceof new of
103
+ return super switch this throw try typeof void while yield
104
104
  )
105
105
  end
106
106
 
107
107
  def self.declarations
108
108
  @declarations ||= Set.new %w(
109
109
  var let const with function class
110
- extends constructor get set
110
+ extends constructor get set static
111
111
  )
112
112
  end
113
113
 
114
114
  def self.reserved
115
115
  @reserved ||= Set.new %w(
116
- abstract boolean byte char debugger double enum
117
- final float goto implements int interface
118
- long native package private protected public short static
119
- synchronized throws transient volatile
120
- eval arguments await
116
+ enum implements interface
117
+ package private protected public
121
118
  )
122
119
  end
123
120
 
@@ -200,22 +197,21 @@ module Rouge
200
197
  rule /0b[01][01_]*/i, Num::Bin
201
198
  rule /[0-9]+/, Num::Integer
202
199
 
203
- rule /"/, Str::Double, :dq
204
- rule /'/, Str::Single, :sq
200
+ rule /"/, Str::Delimiter, :dq
201
+ rule /'/, Str::Delimiter, :sq
205
202
  rule /:/, Punctuation
206
203
  end
207
204
 
208
205
  state :dq do
206
+ rule /\\[\\nrt"]?/, Str::Escape
209
207
  rule /[^\\"]+/, Str::Double
210
- rule /\\n/, Str::Escape
211
- rule /\\"/, Str::Escape
212
- rule /"/, Str::Double, :pop!
208
+ rule /"/, Str::Delimiter, :pop!
213
209
  end
214
210
 
215
211
  state :sq do
212
+ rule /\\[\\nrt']?/, Str::Escape
216
213
  rule /[^\\']+/, Str::Single
217
- rule /\\'/, Str::Escape
218
- rule /'/, Str::Single, :pop!
214
+ rule /'/, Str::Delimiter, :pop!
219
215
  end
220
216
 
221
217
  # braced parts that aren't object literals
@@ -82,7 +82,7 @@ module Rouge
82
82
 
83
83
  # Arithmetic operators (+, -, *, **, //, /)
84
84
  # TODO : implement modulo (%)
85
- rule /(\+|\-|\*|\/\/?|\*\*?)/, Operator
85
+ rule /(\+|\-|\*|\/\/?|\*\*?|=)/, Operator
86
86
 
87
87
  # Comparisons operators (<=, <, >=, >, ==, ===, !=)
88
88
  rule /(<=?|>=?|===?|!=)/, Operator
@@ -112,6 +112,11 @@ module Rouge
112
112
  end
113
113
 
114
114
  state :statement do
115
+ rule /(raw|verbatim)(\s+)(\%\})/ do
116
+ groups Keyword, Text, Comment::Preproc
117
+ goto :raw
118
+ end
119
+
115
120
  rule /(\w+\.?)/ do |m|
116
121
  if self.class.keywords.include?(m[0])
117
122
  groups Keyword
@@ -133,6 +138,15 @@ module Rouge
133
138
 
134
139
  rule /\%\}/, Comment::Preproc, :pop!
135
140
  end
141
+
142
+ state :raw do
143
+ rule %r{(\{\%)(\s+)(endverbatim|endraw)(\s+)(\%\})} do
144
+ groups Comment::Preproc, Text, Keyword, Text, Comment::Preproc
145
+ pop!
146
+ end
147
+
148
+ rule /(.+?)/m, Text
149
+ end
136
150
  end
137
151
  end
138
152
  end
@@ -21,6 +21,8 @@ module Rouge
21
21
  | NaN | NaN16 | NaN32 | NaN64
22
22
  | stdout | stderr | stdin | devnull
23
23
  | pi | π | ℯ | im
24
+ | ARGS | C_NULL | ENV | ENDIAN_BOM
25
+ | VERSION | undef | (LOAD|DEPOT)_PATH
24
26
  )\b/x
25
27
 
26
28
  KEYWORDS = /\b(?:
@@ -30,21 +32,137 @@ module Rouge
30
32
  | const | local | global | using | struct
31
33
  | mutable struct | abstract type | finally
32
34
  | begin | do | quote | macro | for outer
35
+ | where
33
36
  )\b/x
34
37
 
38
+ # NOTE: The list of types was generated automatically using the following script:
39
+ # using Pkg, InteractiveUtils
40
+ #
41
+ # allnames = [names(Core); names(Base, imported=true)]
42
+ #
43
+ # for stdlib in readdir(Pkg.Types.stdlib_dir())
44
+ # mod = Symbol(basename(stdlib))
45
+ # @eval begin
46
+ # using $mod
47
+ # append!(allnames, names($mod))
48
+ # end
49
+ # end
50
+ #
51
+ # sort!(unique!(allnames))
52
+ #
53
+ # i = 1
54
+ # for sym in allnames
55
+ # global i # needed at the top level, e.g. in the REPL
56
+ # isdefined(Main, sym) || continue
57
+ # getfield(which(Main, sym), sym) isa Type || continue
58
+ # sym === :(=>) && continue # Actually an alias for Pair
59
+ # print("| ", sym)
60
+ # i % 3 == 0 ? println() : print(" ") # print 3 to a line
61
+ # i += 1
62
+ # end
35
63
  TYPES = /\b(?:
36
- Int | UInt | Int8
37
- | UInt8 | Int16 | UInt16
38
- | Int32 | UInt32 | Int64
39
- | UInt64 | Int128 | UInt128
40
- | Float16 | Float32 | Float64
41
- | Bool | BigInt | BigFloat
42
- | Complex | ComplexF16 | ComplexF32
43
- | ComplexF64 | Missing | Nothing
44
- | Char | String | SubString
45
- | Regex | RegexMatch | Any
46
- | Type | DataType | UnionAll
47
- | (Abstract)?(Array|Vector|Matrix|VecOrMat)
64
+ ARPACKException | AbstractArray | AbstractChannel
65
+ | AbstractChar | AbstractDict | AbstractDisplay
66
+ | AbstractFloat | AbstractIrrational | AbstractLogger
67
+ | AbstractMatrix | AbstractREPL | AbstractRNG
68
+ | AbstractRange | AbstractSerializer | AbstractSet
69
+ | AbstractSparseArray | AbstractSparseMatrix | AbstractSparseVector
70
+ | AbstractString | AbstractUnitRange | AbstractVecOrMat
71
+ | AbstractVector | AbstractWorkerPool | Adjoint
72
+ | Any | ArgumentError | Array
73
+ | AssertionError | Base64DecodePipe | Base64EncodePipe
74
+ | BasicREPL | Bidiagonal | BigFloat
75
+ | BigInt | BitArray | BitMatrix
76
+ | BitSet | BitVector | Bool
77
+ | BoundsError | BunchKaufman | CachingPool
78
+ | CapturedException | CartesianIndex | CartesianIndices
79
+ | Cchar | Cdouble | Cfloat
80
+ | Channel | Char | Cholesky
81
+ | CholeskyPivoted | Cint | Cintmax_t
82
+ | Clong | Clonglong | ClusterManager
83
+ | Cmd | Colon | Complex
84
+ | ComplexF16 | ComplexF32 | ComplexF64
85
+ | CompositeException | Condition | ConsoleLogger
86
+ | Cptrdiff_t | Cshort | Csize_t
87
+ | Cssize_t | Cstring | Cuchar
88
+ | Cuint | Cuintmax_t | Culong
89
+ | Culonglong | Cushort | Cvoid
90
+ | Cwchar_t | Cwstring | DataType
91
+ | Date | DateFormat | DatePeriod
92
+ | DateTime | Day | DenseArray
93
+ | DenseMatrix | DenseVecOrMat | DenseVector
94
+ | Diagonal | Dict | DimensionMismatch
95
+ | Dims | DivideError | DomainError
96
+ | EOFError | Eigen | Enum
97
+ | ErrorException | Exception | ExponentialBackOff
98
+ | Expr | FDWatcher | Factorization
99
+ | FileMonitor | Float16 | Float32
100
+ | Float64 | FolderMonitor | Function
101
+ | GeneralizedEigen | GeneralizedSVD | GeneralizedSchur
102
+ | GenericArray | GenericDict | GenericSet
103
+ | GenericString | GitConfig | GitRepo
104
+ | GlobalRef | HMAC_CTX | HTML
105
+ | Hermitian | Hessenberg | Hour
106
+ | IO | IOBuffer | IOContext
107
+ | IOStream | IPAddr | IPv4
108
+ | IPv6 | IdDict | IndexCartesian
109
+ | IndexLinear | IndexStyle | InexactError
110
+ | InitError | Int | Int128
111
+ | Int16 | Int32 | Int64
112
+ | Int8 | Integer | InterruptException
113
+ | InvalidStateException | Irrational | KeyError
114
+ | LAPACKException | LDLt | LQ
115
+ | LU | LinRange | LineEditREPL
116
+ | LineNumberNode | LinearIndices | LoadError
117
+ | LogLevel | LowerTriangular | MIME
118
+ | Matrix | MersenneTwister | Method
119
+ | MethodError | Microsecond | Millisecond
120
+ | Minute | Missing | MissingException
121
+ | Module | Month | NTuple
122
+ | NamedTuple | Nanosecond | Nothing
123
+ | NullLogger | Number | OrdinalRange
124
+ | OutOfMemoryError | OverflowError | PackageMode
125
+ | PackageSpec | Pair | PartialQuickSort
126
+ | Period | PermutedDimsArray | Pipe
127
+ | PollingFileWatcher | PosDefException | ProcessExitedException
128
+ | Ptr | QR | QRPivoted
129
+ | QuoteNode | RandomDevice | RankDeficientException
130
+ | Rational | RawFD | ReadOnlyMemoryError
131
+ | Real | ReentrantLock | Ref
132
+ | Regex | RegexMatch | RemoteChannel
133
+ | RemoteException | RoundingMode | SHA1_CTX
134
+ | SHA224_CTX | SHA256_CTX | SHA2_224_CTX
135
+ | SHA2_256_CTX | SHA2_384_CTX | SHA2_512_CTX
136
+ | SHA384_CTX | SHA3_224_CTX | SHA3_256_CTX
137
+ | SHA3_384_CTX | SHA3_512_CTX | SHA512_CTX
138
+ | SVD | Schur | Second
139
+ | SegmentationFault | Serializer | Set
140
+ | SharedArray | SharedMatrix | SharedVector
141
+ | Signed | SimpleLogger | SingularException
142
+ | Some | SparseMatrixCSC | SparseVector
143
+ | StackOverflowError | StepRange | StepRangeLen
144
+ | StreamREPL | StridedArray | StridedMatrix
145
+ | StridedVecOrMat | StridedVector | String
146
+ | StringIndexError | SubArray | SubString
147
+ | SubstitutionString | SymTridiagonal | Symbol
148
+ | Symmetric | SystemError | TCPSocket
149
+ | Task | TestSetException | Text
150
+ | TextDisplay | Time | TimePeriod
151
+ | TimeType | TimeZone | Timer
152
+ | Transpose | Tridiagonal | Tuple
153
+ | Type | TypeError | TypeVar
154
+ | UDPSocket | UInt | UInt128
155
+ | UInt16 | UInt32 | UInt64
156
+ | UInt8 | UTC | UUID
157
+ | UndefInitializer | UndefKeywordError | UndefRefError
158
+ | UndefVarError | UniformScaling | Union
159
+ | UnionAll | UnitLowerTriangular | UnitRange
160
+ | UnitUpperTriangular | Unsigned | UpgradeLevel
161
+ | UpperTriangular | Val | Vararg
162
+ | VecElement | VecOrMat | Vector
163
+ | VersionNumber | WeakKeyDict | WeakRef
164
+ | Week | WorkerConfig | WorkerPool
165
+ | Year
48
166
  )\b/x
49
167
 
50
168
  OPERATORS = / \+ | = | - | \* | \/
@@ -58,10 +176,10 @@ module Rouge
58
176
  | :: | <: | -> | \? | \.\*
59
177
  | \.\^ | \.\\ | \.\/ | \\ | <
60
178
  | > | ÷ | >: | : | ===
61
- | !==
179
+ | !== | =>
62
180
  /x
63
181
 
64
- PUNCTUATION = / [ \[ \] { } \( \) , ; @ ] /x
182
+ PUNCTUATION = / [ \[ \] { } \( \) , ; ] /x
65
183
 
66
184
 
67
185
  state :root do
@@ -74,14 +192,14 @@ module Rouge
74
192
  rule /\\/, Text
75
193
 
76
194
 
77
- # functions
78
- rule /(function)((?:\s|\\\s)+)/ do
195
+ # functions and macros
196
+ rule /(function|macro)((?:\s|\\\s)+)/ do
79
197
  groups Keyword, Name::Function
80
198
  push :funcname
81
199
  end
82
200
 
83
201
  # types
84
- rule /(type|typealias|abstract)((?:\s|\\\s)+)/ do
202
+ rule /((mutable )?struct|(abstract|primitive) type)((?:\s|\\\s)+)/ do
85
203
  groups Keyword, Name::Class
86
204
  push :typename
87
205
  end
@@ -91,8 +209,11 @@ module Rouge
91
209
  rule /(local|global|const)\b/, Keyword::Declaration
92
210
  rule KEYWORDS, Keyword
93
211
 
212
+ # TODO: end is a builtin when inside of an indexing expression
94
213
  rule BUILTINS, Name::Builtin
95
214
 
215
+ # TODO: symbols
216
+
96
217
  # backticks
97
218
  rule /`.*?`/, Literal::String::Backtick
98
219
 
@@ -103,6 +224,8 @@ module Rouge
103
224
  rule /(?<=[.\w)\]])\'+/, Operator
104
225
 
105
226
  # strings
227
+ # TODO: triple quoted string literals
228
+ # TODO: Detect string interpolation
106
229
  rule /(?:[IL])"/, Literal::String, :string
107
230
  rule /[E]?"/, Literal::String, :string
108
231