rouge 3.24.0 → 3.27.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/rouge/demos/dafny +16 -0
- data/lib/rouge/demos/ocl +4 -0
- data/lib/rouge/demos/rescript +26 -0
- data/lib/rouge/formatter.rb +2 -2
- data/lib/rouge/formatters/html_line_highlighter.rb +2 -4
- data/lib/rouge/formatters/html_line_table.rb +1 -3
- data/lib/rouge/formatters/html_linewise.rb +2 -3
- data/lib/rouge/lexers/batchfile.rb +2 -1
- data/lib/rouge/lexers/ceylon.rb +2 -2
- data/lib/rouge/lexers/cmake.rb +10 -0
- data/lib/rouge/lexers/cpp.rb +2 -2
- data/lib/rouge/lexers/crystal.rb +14 -9
- data/lib/rouge/lexers/dafny.rb +128 -0
- data/lib/rouge/lexers/docker.rb +1 -1
- data/lib/rouge/lexers/eex.rb +2 -2
- data/lib/rouge/lexers/factor.rb +2 -2
- data/lib/rouge/lexers/ghc_core.rb +1 -1
- data/lib/rouge/lexers/javascript.rb +2 -1
- data/lib/rouge/lexers/jsl.rb +24 -13
- data/lib/rouge/lexers/kotlin.rb +1 -1
- data/lib/rouge/lexers/ocaml/common.rb +1 -1
- data/lib/rouge/lexers/ocl.rb +85 -0
- data/lib/rouge/lexers/perl.rb +6 -4
- data/lib/rouge/lexers/powershell.rb +39 -29
- data/lib/rouge/lexers/python.rb +1 -1
- data/lib/rouge/lexers/reasonml.rb +6 -5
- data/lib/rouge/lexers/rescript.rb +119 -0
- data/lib/rouge/lexers/ruby.rb +2 -2
- data/lib/rouge/lexers/rust.rb +77 -17
- data/lib/rouge/lexers/sql.rb +7 -7
- data/lib/rouge/lexers/swift.rb +3 -3
- data/lib/rouge/lexers/velocity.rb +1 -1
- data/lib/rouge/lexers/yaml.rb +1 -1
- data/lib/rouge/themes/base16.rb +1 -0
- data/lib/rouge/themes/bw.rb +1 -0
- data/lib/rouge/themes/colorful.rb +1 -0
- data/lib/rouge/themes/github.rb +1 -0
- data/lib/rouge/themes/gruvbox.rb +2 -0
- data/lib/rouge/themes/igor_pro.rb +1 -0
- data/lib/rouge/themes/magritte.rb +1 -0
- data/lib/rouge/themes/monokai.rb +1 -0
- data/lib/rouge/themes/pastie.rb +1 -0
- data/lib/rouge/themes/thankful_eyes.rb +1 -0
- data/lib/rouge/themes/tulip.rb +1 -0
- data/lib/rouge/version.rb +1 -1
- metadata +9 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 396c335066b8bb01574b5d81b25d43a98b58dd1bad1d3d9588b7a35c573e2209
|
4
|
+
data.tar.gz: d899fb3968d38a1a93415c21c62e332f1a8ba230952c0a33adda5c4755c4c8f3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1fed00ea4906f18e1939675dff9c02508cddef4b1878622422d66b3cbee6d07111ab434cb83314d5d3077f3b86375424d4af05f2fce46cb105a9ecef698aec9
|
7
|
+
data.tar.gz: 7764c52128ef376d3af7e2c5d1a958a62bddffadc4b2d8c868161fd786a9af63827d143a8b85d6d5251d65f8adefc6a405e2fef5d29e6c7d73bc00f041d8c024
|
data/Gemfile
CHANGED
@@ -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 }
|
data/lib/rouge/demos/ocl
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Person = {
|
2
|
+
type t = Teacher | Director | Student(string)
|
3
|
+
|
4
|
+
let greeting = person =>
|
5
|
+
switch person {
|
6
|
+
| Teacher => "Hey Professor!"
|
7
|
+
| Director => "Hello Director."
|
8
|
+
| Student("Richard") => "Still here Ricky?"
|
9
|
+
| Student(other) => "Hey, " ++ other ++ "."
|
10
|
+
}
|
11
|
+
}
|
12
|
+
|
13
|
+
module Button = {
|
14
|
+
@react.component
|
15
|
+
let make = (~count: int, ~onClick) => {
|
16
|
+
let times = switch count {
|
17
|
+
| 1 => "once"
|
18
|
+
| 2 => "twice"
|
19
|
+
| n => Belt.Int.toString(n) ++ " times"
|
20
|
+
}
|
21
|
+
|
22
|
+
let msg = "Click me " ++ times
|
23
|
+
|
24
|
+
<button onClick> {msg->React.string} </button>
|
25
|
+
}
|
26
|
+
}
|
data/lib/rouge/formatter.rb
CHANGED
@@ -42,8 +42,8 @@ module Rouge
|
|
42
42
|
end
|
43
43
|
|
44
44
|
# Format a token stream. Delegates to {#format}.
|
45
|
-
def self.format(tokens, *
|
46
|
-
new(*
|
45
|
+
def self.format(tokens, *args, **kwargs, &b)
|
46
|
+
new(*args, **kwargs).format(tokens, &b)
|
47
47
|
end
|
48
48
|
|
49
49
|
def initialize(opts={})
|
@@ -13,10 +13,8 @@ module Rouge
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def stream(tokens)
|
16
|
-
|
17
|
-
|
18
|
-
lineno += 1
|
19
|
-
line = %(#{@delegate.format(tokens_in_line)}\n)
|
16
|
+
token_lines(tokens).with_index(1) do |line_tokens, lineno|
|
17
|
+
line = %(#{@delegate.format(line_tokens)}\n)
|
20
18
|
line = %(<span class="#{@highlight_line_class}">#{line}</span>) if @highlight_lines.include? lineno
|
21
19
|
yield line
|
22
20
|
end
|
@@ -32,10 +32,8 @@ module Rouge
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def stream(tokens, &b)
|
35
|
-
lineno = @start_line - 1
|
36
35
|
buffer = [%(<table class="#@table_class"><tbody>)]
|
37
|
-
token_lines(tokens) do |line_tokens|
|
38
|
-
lineno += 1
|
36
|
+
token_lines(tokens).with_index(@start_line) do |line_tokens, lineno|
|
39
37
|
buffer << %(<tr id="#{sprintf @line_id, lineno}" class="#@line_class">)
|
40
38
|
buffer << %(<td class="#@gutter_class gl" )
|
41
39
|
buffer << %(style="-moz-user-select: none;-ms-user-select: none;)
|
@@ -11,9 +11,8 @@ module Rouge
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def stream(tokens, &b)
|
14
|
-
|
15
|
-
|
16
|
-
yield %(<#{@tag_name} class="#{sprintf @class_format, lineno += 1}">)
|
14
|
+
token_lines(tokens).with_index(1) do |line_tokens, lineno|
|
15
|
+
yield %(<#{@tag_name} class="#{sprintf @class_format, lineno}">)
|
17
16
|
@formatter.stream(line_tokens) {|formatted| yield formatted }
|
18
17
|
yield %(\n</#{@tag_name}>)
|
19
18
|
end
|
@@ -79,6 +79,7 @@ module Rouge
|
|
79
79
|
state :basic do
|
80
80
|
# Comments
|
81
81
|
rule %r/@?\brem\b.*$/i, Comment
|
82
|
+
|
82
83
|
# Empty Labels
|
83
84
|
rule %r/^::.*$/, Comment
|
84
85
|
|
@@ -105,7 +106,7 @@ module Rouge
|
|
105
106
|
end
|
106
107
|
end
|
107
108
|
|
108
|
-
rule %r/([
|
109
|
+
rule %r/((?:[\/\+]|--?)[a-z]+)\s*/i, Name::Attribute
|
109
110
|
|
110
111
|
mixin :expansions
|
111
112
|
|
data/lib/rouge/lexers/ceylon.rb
CHANGED
@@ -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("
|
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
|
data/lib/rouge/lexers/cmake.rb
CHANGED
@@ -22,6 +22,7 @@ module Rouge
|
|
22
22
|
}
|
23
23
|
|
24
24
|
BUILTIN_COMMANDS = Set.new %w[
|
25
|
+
add_compile_definitions
|
25
26
|
add_compile_options
|
26
27
|
add_custom_command
|
27
28
|
add_custom_target
|
@@ -29,6 +30,7 @@ module Rouge
|
|
29
30
|
add_dependencies
|
30
31
|
add_executable
|
31
32
|
add_library
|
33
|
+
add_link_options
|
32
34
|
add_subdirectory
|
33
35
|
add_test
|
34
36
|
aux_source_directory
|
@@ -36,7 +38,9 @@ module Rouge
|
|
36
38
|
build_command
|
37
39
|
build_name
|
38
40
|
cmake_host_system_information
|
41
|
+
cmake_language
|
39
42
|
cmake_minimum_required
|
43
|
+
cmake_parse_arguments
|
40
44
|
cmake_policy
|
41
45
|
configure_file
|
42
46
|
create_test_sourcelist
|
@@ -74,6 +78,7 @@ module Rouge
|
|
74
78
|
include
|
75
79
|
include_directories
|
76
80
|
include_external_msproject
|
81
|
+
include_guard
|
77
82
|
include_regular_expression
|
78
83
|
install
|
79
84
|
install_files
|
@@ -110,9 +115,14 @@ module Rouge
|
|
110
115
|
subdir_depends
|
111
116
|
subdirs
|
112
117
|
target_compile_definitions
|
118
|
+
target_compile_features
|
113
119
|
target_compile_options
|
114
120
|
target_include_directories
|
121
|
+
target_link_directories
|
115
122
|
target_link_libraries
|
123
|
+
target_link_options
|
124
|
+
target_precompile_headers
|
125
|
+
target_sources
|
116
126
|
try_compile
|
117
127
|
try_run
|
118
128
|
unset
|
data/lib/rouge/lexers/cpp.rb
CHANGED
@@ -59,11 +59,11 @@ module Rouge
|
|
59
59
|
prepend :statements do
|
60
60
|
rule %r/(class|struct)\b/, Keyword, :classname
|
61
61
|
rule %r/template\b/, Keyword, :template
|
62
|
-
rule %r
|
62
|
+
rule %r/#{dq}(\.#{dq})?(?:y|d|h|(?:min)|s|(?:ms)|(?:us)|(?:ns)|i|(?:if)|(?:il))\b/, Num::Other
|
63
63
|
rule %r((#{dq}[.]#{dq}?|[.]#{dq})(e[+-]?#{dq}[lu]*)?)i, Num::Float
|
64
64
|
rule %r(#{dq}e[+-]?#{dq}[lu]*)i, Num::Float
|
65
65
|
rule %r/0x\h('?\h)*[lu]*/i, Num::Hex
|
66
|
-
rule %r/0b[01]+(
|
66
|
+
rule %r/0b[01]+('[01]+)*/, Num::Bin
|
67
67
|
rule %r/0[0-7]('?[0-7])*[lu]*/i, Num::Oct
|
68
68
|
rule %r/#{dq}[lu]*/i, Num::Integer
|
69
69
|
rule %r/\bnullptr\b/, Name::Builtin
|
data/lib/rouge/lexers/crystal.rb
CHANGED
@@ -25,8 +25,7 @@ module Rouge
|
|
25
25
|
)xi, Str::Symbol
|
26
26
|
|
27
27
|
# special symbols
|
28
|
-
rule %r(:(
|
29
|
-
Str::Symbol
|
28
|
+
rule %r(:(?:===|=?~|\[\][=?]?|\*\*=?|\/\/=?|[=^*/+-]=?|&[&*+-]?=?|\|\|?=?|![=~]?|%=?|<=>|<<?=?|>>?=?|\.\.\.?)), Str::Symbol
|
30
29
|
|
31
30
|
rule %r/:'(\\\\|\\'|[^'])*'/, Str::Symbol
|
32
31
|
rule %r/:"/, Str::Symbol, :simple_sym
|
@@ -36,7 +35,7 @@ module Rouge
|
|
36
35
|
# %-sigiled strings
|
37
36
|
# %(abc), %[abc], %<abc>, %.abc., %r.abc., etc
|
38
37
|
delimiter_map = { '{' => '}', '[' => ']', '(' => ')', '<' => '>' }
|
39
|
-
rule %r/%([rqswQWxiI])?([^\w\s])/ do |m|
|
38
|
+
rule %r/%([rqswQWxiI])?([^\w\s}])/ do |m|
|
40
39
|
open = Regexp.escape(m[2])
|
41
40
|
close = Regexp.escape(delimiter_map[m[2]] || m[2])
|
42
41
|
interp = /[rQWxI]/ === m[1]
|
@@ -79,9 +78,11 @@ module Rouge
|
|
79
78
|
state :strings do
|
80
79
|
mixin :symbols
|
81
80
|
rule %r/\b[a-z_]\w*?[?!]?:\s+/, Str::Symbol, :expr_start
|
82
|
-
rule %r/'(\\\\|\\'|[^'])*'/, Str::Single
|
83
81
|
rule %r/"/, Str::Double, :simple_string
|
84
82
|
rule %r/(?<!\.)`/, Str::Backtick, :simple_backtick
|
83
|
+
rule %r/(')(\\u[a-fA-F0-9]{4}|\\u\{[a-fA-F0-9]{1,6}\}|\\[abefnrtv])?(\\\\|\\'|[^'])*(')/ do
|
84
|
+
groups Str::Single, Str::Escape, Str::Single, Str::Single
|
85
|
+
end
|
85
86
|
end
|
86
87
|
|
87
88
|
state :regex_flags do
|
@@ -154,11 +155,13 @@ module Rouge
|
|
154
155
|
mixin :whitespace
|
155
156
|
rule %r/__END__/, Comment::Preproc, :end_part
|
156
157
|
|
157
|
-
rule %r/
|
158
|
+
rule %r/0o[0-7]+(?:_[0-7]+)*/, Num::Oct
|
158
159
|
rule %r/0x[0-9A-Fa-f]+(?:_[0-9A-Fa-f]+)*/, Num::Hex
|
159
160
|
rule %r/0b[01]+(?:_[01]+)*/, Num::Bin
|
160
|
-
rule %r/\d+\.\d+(e[\+\-]?\d+)
|
161
|
-
rule %r
|
161
|
+
rule %r/\d+\.\d+(e[\+\-]?\d+)?(_f32)?/i, Num::Float
|
162
|
+
rule %r/\d+(e[\+\-]?\d+)/i, Num::Float
|
163
|
+
rule %r/\d+_f32/i, Num::Float
|
164
|
+
rule %r/[\d]+(?:_\d+)*(_[iu]\d+)?/, Num::Integer
|
162
165
|
|
163
166
|
rule %r/@\[([^\]]+)\]/, Name::Decorator
|
164
167
|
|
@@ -183,7 +186,7 @@ module Rouge
|
|
183
186
|
groups Keyword, Text, Name::Namespace
|
184
187
|
end
|
185
188
|
|
186
|
-
rule %r/(def\b)(\s*)/ do
|
189
|
+
rule %r/(def|macro\b)(\s*)/ do
|
187
190
|
groups Keyword, Text
|
188
191
|
push :funcname
|
189
192
|
end
|
@@ -212,8 +215,9 @@ module Rouge
|
|
212
215
|
|
213
216
|
rule %r/[a-zA-Z_]\w*[?!]/, Name, :expr_start
|
214
217
|
rule %r/[a-zA-Z_]\w*/, Name, :method_call
|
215
|
-
rule %r
|
218
|
+
rule %r/\*\*|\/\/|>=|<=|<=>|<<?|>>?|=~|={3}|!~|&&?|\|\||\./,
|
216
219
|
Operator, :expr_start
|
220
|
+
rule %r/{%|%}/, Punctuation
|
217
221
|
rule %r/[-+\/*%=<>&!^|~]=?/, Operator, :expr_start
|
218
222
|
rule(/[?]/) { token Punctuation; push :ternary; push :expr_start }
|
219
223
|
rule %r<[\[({,:\\;/]>, Punctuation, :expr_start
|
@@ -346,6 +350,7 @@ module Rouge
|
|
346
350
|
mixin :string_intp
|
347
351
|
rule %r/\\([\\abefnrstv#"']|x[a-fA-F0-9]{1,2}|[0-7]{1,3})/,
|
348
352
|
Str::Escape
|
353
|
+
rule %r/\\u([a-fA-F0-9]{4}|\{[^}]+\})/, Str::Escape
|
349
354
|
rule %r/\\./, Str::Escape
|
350
355
|
end
|
351
356
|
|
@@ -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
|
data/lib/rouge/lexers/docker.rb
CHANGED
data/lib/rouge/lexers/eex.rb
CHANGED
data/lib/rouge/lexers/factor.rb
CHANGED
@@ -243,8 +243,8 @@ module Rouge
|
|
243
243
|
end
|
244
244
|
|
245
245
|
# strings
|
246
|
-
rule %r/"""
|
247
|
-
rule %r
|
246
|
+
rule %r/"(?:\\\\|\\"|[^"])*"/, Str
|
247
|
+
rule %r/\S+"\s+(?:\\\\|\\"|[^"])*"/, Str
|
248
248
|
rule %r/(CHAR:)(\s+)(\\[\\abfnrstv]*|\S)(?=\s)/, Str::Char
|
249
249
|
|
250
250
|
# comments
|
@@ -17,7 +17,7 @@ module Rouge
|
|
17
17
|
rule %r/^=====.*=====$/, Generic::Heading
|
18
18
|
# timestamps
|
19
19
|
rule %r/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d+ UTC$/, Comment::Single
|
20
|
-
rule %r/^Result size of .+\
|
20
|
+
rule %r/^Result size of .+\n.+{[^}]*}/, Comment::Multiline
|
21
21
|
rule %r/--.*$/, Comment::Single
|
22
22
|
|
23
23
|
rule %r/\[/, Comment::Special, :annotation
|
@@ -272,7 +272,8 @@ module Rouge
|
|
272
272
|
rule %r/[$]{/, Punctuation, :template_string_expr
|
273
273
|
rule %r/`/, Str::Double, :pop!
|
274
274
|
rule %r/\\[$`]/, Str::Escape
|
275
|
-
rule %r/[
|
275
|
+
rule %r/[^$`\\]+/, Str::Double
|
276
|
+
rule %r/[\\$]/, Str::Double
|
276
277
|
end
|
277
278
|
|
278
279
|
state :template_string_expr do
|
data/lib/rouge/lexers/jsl.rb
CHANGED
@@ -14,42 +14,53 @@ module Rouge
|
|
14
14
|
rule %r/\s+/m, Text::Whitespace
|
15
15
|
|
16
16
|
rule %r(//.*?$), Comment::Single
|
17
|
-
rule %r
|
17
|
+
rule %r'/[*].*?', Comment::Multiline, :comment # multiline block comment
|
18
18
|
|
19
19
|
# messages
|
20
|
-
rule %r
|
21
|
-
groups Operator, Name::Function, Punctuation
|
22
|
-
end
|
20
|
+
rule %r/<</, Operator, :message
|
23
21
|
|
24
22
|
# covers built-in and custom functions
|
25
|
-
rule %r/([a-z_][\w\s'%.\\]*)(\()/i do |m|
|
26
|
-
groups Keyword, Punctuation
|
23
|
+
rule %r/(::|:)?([a-z_][\w\s'%.\\]*)(\()/i do |m|
|
24
|
+
groups Punctuation, Keyword, Punctuation
|
27
25
|
end
|
28
26
|
|
29
|
-
rule %r/\b[+-]?(?:[0-9]+(?:\.[0-9]+)?|\.[0-9]+|\.)(?:e[+-]?[0-9]+)?i?\b/i, Num
|
30
|
-
|
31
27
|
rule %r/\d{2}(jan|feb|mar|apr|may|jun|jul|aug|sep|oct|nov|dec)\d{2}(\d{2})?(:\d{2}:\d{2}(:\d{2}(\.\d*)?)?)?/i, Literal::Date
|
32
28
|
|
33
|
-
rule %r
|
34
|
-
|
35
|
-
rule %r/[a-z_][\w\s'%.\\]
|
36
|
-
|
29
|
+
rule %r/-?(?:[0-9]+(?:[.][0-9]+)?|[.][0-9]*)(?:e[+-]?[0-9]+)?i?/i, Num
|
30
|
+
|
31
|
+
rule %r/(::|:)?([a-z_][\w\s'%.\\]*|"(?:\\!"|[^"])*?"n)/i do |m|
|
32
|
+
groups Punctuation, Name::Variable
|
33
|
+
end
|
37
34
|
|
38
35
|
rule %r/(")(\\\[)(.*?)(\]\\)(")/m do
|
39
36
|
groups Str::Double, Str::Escape, Str::Double, Str::Escape, Str::Double # escaped string
|
40
37
|
end
|
41
38
|
rule %r/"/, Str::Double, :dq
|
42
39
|
|
43
|
-
rule %r/[
|
40
|
+
rule %r/[-+*\/!%&<>\|=:`^]/, Operator
|
44
41
|
rule %r/[\[\](){},;]/, Punctuation
|
45
42
|
end
|
46
43
|
|
44
|
+
state :message do
|
45
|
+
rule %r/\s+/m, Text::Whitespace
|
46
|
+
rule %r/[a-z_][\w\s'%.\\]*/i, Name::Function
|
47
|
+
rule %r/[(),;]/, Punctuation, :pop!
|
48
|
+
rule %r/[&|!=<>]/, Operator, :pop!
|
49
|
+
end
|
50
|
+
|
47
51
|
state :dq do
|
48
52
|
rule %r/\\![btrnNf0\\"]/, Str::Escape
|
49
53
|
rule %r/\\/, Str::Double
|
50
54
|
rule %r/"/, Str::Double, :pop!
|
51
55
|
rule %r/[^\\"]+/m, Str::Double
|
52
56
|
end
|
57
|
+
|
58
|
+
state :comment do
|
59
|
+
rule %r'/[*]', Comment::Multiline, :comment
|
60
|
+
rule %r'[*]/', Comment::Multiline, :pop!
|
61
|
+
rule %r'[^/*]+', Comment::Multiline
|
62
|
+
rule %r'[/*]', Comment::Multiline
|
63
|
+
end
|
53
64
|
end
|
54
65
|
end
|
55
66
|
end
|
data/lib/rouge/lexers/kotlin.rb
CHANGED
@@ -53,7 +53,7 @@ module Rouge
|
|
53
53
|
groups Keyword::Declaration, Text
|
54
54
|
push :property
|
55
55
|
end
|
56
|
-
rule %r'(return|continue|break|this|super)(@#{name})
|
56
|
+
rule %r'(return|continue|break|this|super)(@#{name})?\b' do
|
57
57
|
groups Keyword, Name::Decorator
|
58
58
|
end
|
59
59
|
rule %r'\bfun\b', Keyword
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Rouge
|
2
|
+
module Lexers
|
3
|
+
class OCL < RegexLexer
|
4
|
+
title "OCL"
|
5
|
+
desc "OMG Object Constraint Language (omg.org/spec/OCL)"
|
6
|
+
tag 'ocl'
|
7
|
+
aliases 'OCL'
|
8
|
+
filenames '*.ocl'
|
9
|
+
mimetypes 'text/x-ocl'
|
10
|
+
|
11
|
+
def self.keywords
|
12
|
+
@keywords ||= Set.new %w(
|
13
|
+
context pre post inv init body def derive if then else endif import
|
14
|
+
package endpackage let in
|
15
|
+
)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.keywords_type
|
19
|
+
@keywords_type ||= Set.new %w(
|
20
|
+
Boolean Integer UnlimitedNatural Real String OrderedSet Tuple Bag Set
|
21
|
+
Sequence OclInvalid OclVoid TupleType OclState Collection OclMessage
|
22
|
+
)
|
23
|
+
end
|
24
|
+
|
25
|
+
def self.builtins
|
26
|
+
@builtins ||= Set.new %w(
|
27
|
+
self null result true false invalid @pre
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.operators
|
32
|
+
@operators ||= Set.new %w(
|
33
|
+
or xor and not implies
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.functions
|
38
|
+
@functions ||= Set.new %w(
|
39
|
+
oclAsSet oclIsNew oclIsUndefined oclIsInvalid oclAsType oclIsTypeOf
|
40
|
+
oclIsKindOf oclInState oclType oclLocale hasReturned result
|
41
|
+
isSignalSent isOperationCallabs floor round max min toString div mod
|
42
|
+
size substring concat toInteger toReal toUpperCase toLowerCase
|
43
|
+
indexOf equalsIgnoreCase at characters toBoolean includes excludes
|
44
|
+
count includesAll excludesAll isEmpty notEmpty sum product
|
45
|
+
selectByKind selectByType asBag asSequence asOrderedSet asSet flatten
|
46
|
+
union intersection including excluding symmetricDifferencecount
|
47
|
+
append prepend insertAt subOrderedSet first last reverse subSequence
|
48
|
+
any closure collect collectNested exists forAll isUnique iterate one
|
49
|
+
reject select sortedBy allInstances average conformsTo
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
state :single_string do
|
54
|
+
rule %r/\\./, Str::Escape
|
55
|
+
rule %r/'/, Str::Single, :pop!
|
56
|
+
rule %r/[^\\']+/, Str::Single
|
57
|
+
end
|
58
|
+
|
59
|
+
state :root do
|
60
|
+
rule %r/\s+/m, Text
|
61
|
+
rule %r/--.*/, Comment::Single
|
62
|
+
rule %r/\d+/, Num::Integer
|
63
|
+
rule %r/'/, Str::Single, :single_string
|
64
|
+
rule %r([->|+*/<>=~!@#%&|?^-]), Operator
|
65
|
+
rule %r/[;:()\[\],.]/, Punctuation
|
66
|
+
rule %r/\w[\w\d]*/ do |m|
|
67
|
+
if self.class.operators.include? m[0]
|
68
|
+
token Operator
|
69
|
+
elsif self.class.keywords_type.include? m[0]
|
70
|
+
token Keyword::Declaration
|
71
|
+
elsif self.class.keywords.include? m[0]
|
72
|
+
token Keyword
|
73
|
+
elsif self.class.builtins.include? m[0]
|
74
|
+
token Name::Builtin
|
75
|
+
elsif self.class.functions.include? m[0]
|
76
|
+
token Name::Function
|
77
|
+
else
|
78
|
+
token Name
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|