rouge 3.27.0 → 3.28.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.
- checksums.yaml +4 -4
- data/Gemfile +3 -0
- data/lib/rouge/demos/fluent +13 -0
- data/lib/rouge/demos/stan +13 -0
- data/lib/rouge/demos/stata +14 -0
- data/lib/rouge/lexers/c.rb +12 -2
- data/lib/rouge/lexers/console.rb +1 -1
- data/lib/rouge/lexers/cpp.rb +6 -4
- data/lib/rouge/lexers/cypher.rb +8 -0
- data/lib/rouge/lexers/dart.rb +8 -8
- data/lib/rouge/lexers/fluent.rb +74 -0
- data/lib/rouge/lexers/hcl.rb +1 -0
- data/lib/rouge/lexers/jsx.rb +1 -1
- data/lib/rouge/lexers/kotlin.rb +3 -1
- data/lib/rouge/lexers/rust.rb +9 -5
- data/lib/rouge/lexers/sparql.rb +5 -4
- data/lib/rouge/lexers/stan.rb +451 -0
- data/lib/rouge/lexers/stata.rb +165 -0
- data/lib/rouge/lexers/toml.rb +8 -6
- data/lib/rouge/version.rb +1 -1
- metadata +12 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a74c520254d1312e4a5343103e3d83b48c967025a77a01701c42820a5eb3c708
|
|
4
|
+
data.tar.gz: 2fb290b030a0d60910973c53398c0dd4b127d17c1b489c88105f0bddb3689f6e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f499d28b76cd95fa2182d64809c4b6828c735a95c05c1b9af858ac6c1d0d17755fdafa90ae93f9d7fd27bd826fb4055cb8d3985d94b17172018ef408a397d8cf
|
|
7
|
+
data.tar.gz: 7fcd54cac21c2fb1b1cdc0825691ce812f42bc5d18cace205b281aaf87e7d8a75ee2dca544e92b9b193084605811f74151b00c51237850952cb22d4e4dde5db9
|
data/Gemfile
CHANGED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Simple things are simple.
|
|
2
|
+
hello-user = Hello, {$userName}!
|
|
3
|
+
|
|
4
|
+
# Complex things are possible.
|
|
5
|
+
shared-photos =
|
|
6
|
+
{$userName} {$photoCount ->
|
|
7
|
+
[one] added a new photo
|
|
8
|
+
*[other] added {$photoCount} new photos
|
|
9
|
+
} to {$userGender ->
|
|
10
|
+
[male] his stream
|
|
11
|
+
[female] her stream
|
|
12
|
+
*[other] their stream
|
|
13
|
+
}.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
* Run a series of linear regressions
|
|
2
|
+
sysuse auto, clear
|
|
3
|
+
foreach v of varlist mpg weight-turn {
|
|
4
|
+
regress price `v', robust
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
regress price i.foreign
|
|
8
|
+
local num_obs = e(N)
|
|
9
|
+
global myglobal = 4
|
|
10
|
+
|
|
11
|
+
* Generate and manipulate variables
|
|
12
|
+
generate newvar1 = "string"
|
|
13
|
+
generate newvar2 = 34 - `num_obs'
|
|
14
|
+
replace newvar2 = $myglobal
|
data/lib/rouge/lexers/c.rb
CHANGED
|
@@ -170,12 +170,22 @@ module Rouge
|
|
|
170
170
|
end
|
|
171
171
|
|
|
172
172
|
state :macro do
|
|
173
|
-
|
|
174
|
-
rule %r/\n/, Comment::Preproc, :pop!
|
|
173
|
+
mixin :include
|
|
175
174
|
rule %r([^/\n\\]+), Comment::Preproc
|
|
176
175
|
rule %r/\\./m, Comment::Preproc
|
|
177
176
|
mixin :inline_whitespace
|
|
178
177
|
rule %r(/), Comment::Preproc
|
|
178
|
+
# NB: pop! goes back to :bol
|
|
179
|
+
rule %r/\n/, Comment::Preproc, :pop!
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
state :include do
|
|
183
|
+
rule %r/(include)(\s*)(<[^>]+>)([^\n]*)/ do
|
|
184
|
+
groups Comment::Preproc, Text, Comment::PreprocFile, Comment::Single
|
|
185
|
+
end
|
|
186
|
+
rule %r/(include)(\s*)("[^"]+")([^\n]*)/ do
|
|
187
|
+
groups Comment::Preproc, Text, Comment::PreprocFile, Comment::Single
|
|
188
|
+
end
|
|
179
189
|
end
|
|
180
190
|
|
|
181
191
|
state :if_0 do
|
data/lib/rouge/lexers/console.rb
CHANGED
data/lib/rouge/lexers/cpp.rb
CHANGED
|
@@ -22,12 +22,14 @@ module Rouge
|
|
|
22
22
|
|
|
23
23
|
def self.keywords
|
|
24
24
|
@keywords ||= super + Set.new(%w(
|
|
25
|
-
asm auto catch
|
|
25
|
+
asm auto catch char8_t concept
|
|
26
|
+
consteval constexpr constinit const_cast co_await co_return co_yield
|
|
27
|
+
delete dynamic_cast explicit export friend
|
|
26
28
|
mutable namespace new operator private protected public
|
|
27
|
-
reinterpret_cast restrict size_of static_cast this throw throws
|
|
29
|
+
reinterpret_cast requires restrict size_of static_cast this throw throws
|
|
28
30
|
typeid typename using virtual final override
|
|
29
31
|
|
|
30
|
-
alignas alignof
|
|
32
|
+
alignas alignof decltype noexcept static_assert
|
|
31
33
|
thread_local try
|
|
32
34
|
))
|
|
33
35
|
end
|
|
@@ -68,7 +70,7 @@ module Rouge
|
|
|
68
70
|
rule %r/#{dq}[lu]*/i, Num::Integer
|
|
69
71
|
rule %r/\bnullptr\b/, Name::Builtin
|
|
70
72
|
rule %r/(?:u8|u|U|L)?R"([a-zA-Z0-9_{}\[\]#<>%:;.?*\+\-\/\^&|~!=,"']{,16})\(.*?\)\1"/m, Str
|
|
71
|
-
rule %r
|
|
73
|
+
rule %r/(::|<=>)/, Operator
|
|
72
74
|
end
|
|
73
75
|
|
|
74
76
|
state :classname do
|
data/lib/rouge/lexers/cypher.rb
CHANGED
|
@@ -45,6 +45,7 @@ module Rouge
|
|
|
45
45
|
state :root do
|
|
46
46
|
rule %r/[\s]+/, Text
|
|
47
47
|
rule %r(//.*?$), Comment::Single
|
|
48
|
+
rule %r(/\*), Comment::Multiline, :multiline_comments
|
|
48
49
|
|
|
49
50
|
rule %r([*+\-<>=&|~%^]), Operator
|
|
50
51
|
rule %r/[{}),;\[\]]/, Str::Symbol
|
|
@@ -103,6 +104,13 @@ module Rouge
|
|
|
103
104
|
rule %r/'(\\\\|\\'|[^'])*'/, Str::Single
|
|
104
105
|
rule %r/`(\\\\|\\`|[^`])*`/, Str::Backtick
|
|
105
106
|
end
|
|
107
|
+
|
|
108
|
+
state :multiline_comments do
|
|
109
|
+
rule %r(/[*]), Comment::Multiline, :multiline_comments
|
|
110
|
+
rule %r([*]/), Comment::Multiline, :pop!
|
|
111
|
+
rule %r([^/*]+), Comment::Multiline
|
|
112
|
+
rule %r([/*]), Comment::Multiline
|
|
113
|
+
end
|
|
106
114
|
end
|
|
107
115
|
end
|
|
108
116
|
end
|
data/lib/rouge/lexers/dart.rb
CHANGED
|
@@ -5,25 +5,25 @@ module Rouge
|
|
|
5
5
|
module Lexers
|
|
6
6
|
class Dart < RegexLexer
|
|
7
7
|
title "Dart"
|
|
8
|
-
desc "The Dart programming language (
|
|
8
|
+
desc "The Dart programming language (dart.dev)"
|
|
9
9
|
|
|
10
10
|
tag 'dart'
|
|
11
11
|
filenames '*.dart'
|
|
12
12
|
mimetypes 'text/x-dart'
|
|
13
13
|
|
|
14
14
|
keywords = %w(
|
|
15
|
-
as assert break case catch continue default do else finally for
|
|
16
|
-
if in is new rethrow return super switch this throw try while with
|
|
15
|
+
as assert await break case catch continue default do else finally for
|
|
16
|
+
if in is new rethrow return super switch this throw try while with yield
|
|
17
17
|
)
|
|
18
18
|
|
|
19
19
|
declarations = %w(
|
|
20
|
-
abstract dynamic const external extends factory final get
|
|
21
|
-
native operator set static typedef var
|
|
20
|
+
abstract async dynamic const covariant external extends factory final get
|
|
21
|
+
implements late native on operator required set static sync typedef var
|
|
22
22
|
)
|
|
23
23
|
|
|
24
|
-
types = %w(bool double Dynamic enum int num Object Set String void)
|
|
24
|
+
types = %w(bool Comparable double Dynamic enum Function int List Map Never Null num Object Pattern Set String Symbol Type Uri void)
|
|
25
25
|
|
|
26
|
-
imports = %w(import export library part\s*of part source)
|
|
26
|
+
imports = %w(import deferred export library part\s*of part source)
|
|
27
27
|
|
|
28
28
|
id = /[a-zA-Z_]\w*/
|
|
29
29
|
|
|
@@ -53,7 +53,7 @@ module Rouge
|
|
|
53
53
|
rule %r/(?:#{declarations.join('|')})\b/, Keyword::Declaration
|
|
54
54
|
rule %r/(?:#{types.join('|')})\b/, Keyword::Type
|
|
55
55
|
rule %r/(?:true|false|null)\b/, Keyword::Constant
|
|
56
|
-
rule %r/(?:class|interface)\b/, Keyword::Declaration, :class
|
|
56
|
+
rule %r/(?:class|interface|mixin)\b/, Keyword::Declaration, :class
|
|
57
57
|
rule %r/(?:#{imports.join('|')})\b/, Keyword::Namespace, :import
|
|
58
58
|
rule %r/(\.)(#{id})/ do
|
|
59
59
|
groups Operator, Name::Attribute
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Rouge
|
|
5
|
+
module Lexers
|
|
6
|
+
class Fluent < RegexLexer
|
|
7
|
+
title 'Fluent'
|
|
8
|
+
desc 'Fluent localization files'
|
|
9
|
+
tag 'fluent'
|
|
10
|
+
aliases 'ftl'
|
|
11
|
+
filenames '*.ftl'
|
|
12
|
+
|
|
13
|
+
state :root do
|
|
14
|
+
rule %r{( *)(\=)( *)} do
|
|
15
|
+
groups Text::Whitespace, Punctuation, Text::Whitespace
|
|
16
|
+
push :template
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
rule %r{(?:\s*\n)+}m, Text::Whitespace
|
|
20
|
+
rule %r{\#{1,3}(?: .*)?$}, Comment::Single
|
|
21
|
+
rule %r{[a-zA-Z][a-zA-Z0-9_-]*}, Name::Constant
|
|
22
|
+
rule %r{\-[a-zA-Z][a-zA-Z0-9_-]*}, Name::Entity
|
|
23
|
+
rule %r{\s*\.[a-zA-Z][a-zA-Z0-9_-]*}, Name::Attribute
|
|
24
|
+
rule %r{\s+(?=[^\s\.])}, Text::Whitespace, :template
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
state :template do
|
|
28
|
+
rule %r{\n}m, Text::Whitespace, :pop!
|
|
29
|
+
rule %r{[^\{\n\}\*]+}, Text
|
|
30
|
+
rule %r{\{}, Punctuation, :placeable
|
|
31
|
+
rule %r{(?=\})}, Punctuation, :pop!
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
state :placeable do
|
|
35
|
+
rule %r{\s+}m, Text::Whitespace
|
|
36
|
+
rule %r{\{}, Punctuation, :placeable
|
|
37
|
+
rule %r{\}}, Punctuation, :pop!
|
|
38
|
+
rule %r{\$[a-zA-Z][a-zA-Z0-9_-]*}, Name::Variable
|
|
39
|
+
rule %r{\-[a-zA-Z][a-zA-Z0-9_-]*}, Name::Entity
|
|
40
|
+
rule %r{\.[a-zA-Z][a-zA-Z0-9_-]*}, Name::Attribute
|
|
41
|
+
rule %r{[A-Z]+}, Name::Builtin
|
|
42
|
+
rule %r{[a-zA-Z][a-zA-Z0-9_-]*}, Name::Constant
|
|
43
|
+
rule %r{[\(\),\:]}, Punctuation
|
|
44
|
+
rule %r{->}, Punctuation
|
|
45
|
+
rule %r{\*}, Punctuation::Indicator
|
|
46
|
+
rule %r{\-?\d+\.\d+?}, Literal::Number::Float
|
|
47
|
+
rule %r{\-?\d+}, Literal::Number::Integer
|
|
48
|
+
rule %r{"}, Str::Double, :string
|
|
49
|
+
|
|
50
|
+
rule %r{(\[)(\-?\d+\.\d+)(\])} do
|
|
51
|
+
groups Punctuation, Literal::Number::Float, Punctuation
|
|
52
|
+
push :template
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
rule %r{(\[)(\-?\d+)(\])} do
|
|
56
|
+
groups Punctuation, Literal::Number::Integer, Punctuation
|
|
57
|
+
push :template
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
rule %r{(\[)([a-zA-Z][a-zA-Z0-9_-]+)(\])} do
|
|
61
|
+
groups Punctuation, Str::Symbol, Punctuation
|
|
62
|
+
push :template
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
state :string do
|
|
67
|
+
rule %r{\\u[0-9a-fA-F]{4}|\\U[0-9a-fA-F]{6}}, Str::Escape
|
|
68
|
+
rule %r{\\.}, Str::Escape
|
|
69
|
+
rule %r{[^\"\\]}, Str::Double
|
|
70
|
+
rule %r{"}, Str::Double, :pop!
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
data/lib/rouge/lexers/hcl.rb
CHANGED
data/lib/rouge/lexers/jsx.rb
CHANGED
data/lib/rouge/lexers/kotlin.rb
CHANGED
|
@@ -116,12 +116,14 @@ module Rouge
|
|
|
116
116
|
rule class_name, Name::Class
|
|
117
117
|
rule %r'(<)', Punctuation, :generic_parameters
|
|
118
118
|
rule %r'(reified|out|in)', Keyword
|
|
119
|
-
rule %r'([
|
|
119
|
+
rule %r'([,:.?])', Punctuation
|
|
120
120
|
rule %r'(\s+)', Text
|
|
121
121
|
rule %r'(>)', Punctuation, :pop!
|
|
122
122
|
end
|
|
123
123
|
|
|
124
124
|
state :property do
|
|
125
|
+
rule %r'(<)', Punctuation, :generic_parameters
|
|
126
|
+
rule %r'(\s+)', Text
|
|
125
127
|
rule name, Name::Property, :pop!
|
|
126
128
|
end
|
|
127
129
|
|
data/lib/rouge/lexers/rust.rb
CHANGED
|
@@ -22,10 +22,13 @@ module Rouge
|
|
|
22
22
|
|
|
23
23
|
def self.keywords
|
|
24
24
|
@keywords ||= %w(
|
|
25
|
-
as
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
25
|
+
as async await break const continue crate dyn else enum extern false
|
|
26
|
+
fn for if impl in let log loop match mod move mut pub ref return self
|
|
27
|
+
Self static struct super trait true type unsafe use where while
|
|
28
|
+
abstract become box do final macro
|
|
29
|
+
override priv typeof unsized virtual
|
|
30
|
+
yield try
|
|
31
|
+
union
|
|
29
32
|
)
|
|
30
33
|
end
|
|
31
34
|
|
|
@@ -212,7 +215,8 @@ module Rouge
|
|
|
212
215
|
|
|
213
216
|
state :has_literals do
|
|
214
217
|
# constants
|
|
215
|
-
rule %r/\b(?:true|false
|
|
218
|
+
rule %r/\b(?:true|false)\b/, Keyword::Constant
|
|
219
|
+
|
|
216
220
|
# characters/bytes
|
|
217
221
|
rule %r(
|
|
218
222
|
b?' (?: #{escapes} | [^\\] ) '
|
data/lib/rouge/lexers/sparql.rb
CHANGED
|
@@ -41,16 +41,17 @@ module Rouge
|
|
|
41
41
|
rule %r('''), Str::Single, :string_single_literal
|
|
42
42
|
rule %r('), Str::Single, :string_single
|
|
43
43
|
|
|
44
|
-
rule %r([$?]
|
|
45
|
-
rule %r((
|
|
44
|
+
rule %r([$?][[:word:]]+), Name::Variable
|
|
45
|
+
rule %r(([[:word:]-]*)(:)([[:word:]-]+)?) do |m|
|
|
46
46
|
token Name::Namespace, m[1]
|
|
47
|
-
token
|
|
47
|
+
token Operator, m[2]
|
|
48
|
+
token Str::Symbol, m[3]
|
|
48
49
|
end
|
|
49
50
|
rule %r(<[^>]*>), Name::Namespace
|
|
50
51
|
rule %r(true|false)i, Keyword::Constant
|
|
51
52
|
rule %r/a\b/, Keyword
|
|
52
53
|
|
|
53
|
-
rule %r([A-Z]
|
|
54
|
+
rule %r([A-Z][[:word:]]+\b)i do |m|
|
|
54
55
|
if self.class.builtins.include? m[0].upcase
|
|
55
56
|
token Name::Builtin
|
|
56
57
|
elsif self.class.keywords.include? m[0].upcase
|
|
@@ -0,0 +1,451 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Rouge
|
|
5
|
+
module Lexers
|
|
6
|
+
class Stan < RegexLexer
|
|
7
|
+
title "Stan"
|
|
8
|
+
desc 'Stan Modeling Language (mc-stan.org)'
|
|
9
|
+
tag 'stan'
|
|
10
|
+
filenames '*.stan', '*.stanfunctions'
|
|
11
|
+
|
|
12
|
+
# optional comment or whitespace
|
|
13
|
+
WS = %r((?:\s|//.*?\n|/[*].*?[*]/)+)
|
|
14
|
+
ID = /[a-zA-Z_][a-zA-Z0-9_]*/
|
|
15
|
+
RT = /(?:(?:[a-z_]\s*(?:\[[0-9, ]\])?)\s+)*/
|
|
16
|
+
OP = Regexp.new([
|
|
17
|
+
# Assigment operators
|
|
18
|
+
"=",
|
|
19
|
+
|
|
20
|
+
# Comparison operators
|
|
21
|
+
"<", "<=", ">", ">=", "==", "!=",
|
|
22
|
+
|
|
23
|
+
# Boolean operators
|
|
24
|
+
"!", "&&", "\\|\\|",
|
|
25
|
+
|
|
26
|
+
# Real-valued arithmetic operators
|
|
27
|
+
"\\+", "-", "\\*", "/", "\\^",
|
|
28
|
+
|
|
29
|
+
# Transposition operator
|
|
30
|
+
"'",
|
|
31
|
+
|
|
32
|
+
# Elementwise functions
|
|
33
|
+
"\\.\\+", "\\.-", "\\.\\*", "\\./", "\\.\\^",
|
|
34
|
+
|
|
35
|
+
# Matrix division operators
|
|
36
|
+
"\\\\",
|
|
37
|
+
|
|
38
|
+
# Compound assigment operators
|
|
39
|
+
"\\+=", "-=", "\\*=", "/=", "\\.\\*=", "\\./=",
|
|
40
|
+
|
|
41
|
+
# Sampling
|
|
42
|
+
"~",
|
|
43
|
+
|
|
44
|
+
# Conditional operator
|
|
45
|
+
"\\?", ":"
|
|
46
|
+
].join("|"))
|
|
47
|
+
|
|
48
|
+
def self.keywords
|
|
49
|
+
@keywords ||= Set.new %w(
|
|
50
|
+
if else while for break continue print reject return
|
|
51
|
+
)
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.types
|
|
55
|
+
@types ||= Set.new %w(
|
|
56
|
+
int real vector ordered positive_ordered simplex unit_vector
|
|
57
|
+
row_vector matrix cholesky_factor_corr cholesky_factor_cov corr_matrix
|
|
58
|
+
cov_matrix data void complex array
|
|
59
|
+
)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def self.reserved
|
|
63
|
+
@reserved ||= Set.new [
|
|
64
|
+
# Reserved words from Stan language
|
|
65
|
+
"for", "in", "while", "repeat", "until", "if", "then", "else", "true",
|
|
66
|
+
"false", "target", "functions", "model", "data", "parameters",
|
|
67
|
+
"quantities", "transformed", "generated",
|
|
68
|
+
|
|
69
|
+
# Reserved names from Stan implementation
|
|
70
|
+
"var", "fvar", "STAN_MAJOR", "STAN_MINOR", "STAN_PATCH",
|
|
71
|
+
"STAN_MATH_MAJOR", "STAN_MATH_MINOR", "STAN_MATH_PATCH",
|
|
72
|
+
|
|
73
|
+
# Reserved names from C++
|
|
74
|
+
"alignas", "alignof", "and", "and_eq", "asm", "auto", "bitand",
|
|
75
|
+
"bitor", "bool", "break", "case", "catch", "char", "char16_t",
|
|
76
|
+
"char32_t", "class", "compl", "const", "constexpr", "const_cast",
|
|
77
|
+
"continue", "decltype", "default", "delete", "do", "double",
|
|
78
|
+
"dynamic_cast", "else", "enum", "explicit", "export", "extern",
|
|
79
|
+
"false", "float", "for", "friend", "goto", "if", "inline", "int",
|
|
80
|
+
"long", "mutable", "namespace", "new", "noexcept", "not", "not_eq",
|
|
81
|
+
"nullptr", "operator", "or", "or_eq", "private", "protected",
|
|
82
|
+
"public", "register", "reinterpret_cast", "return", "short", "signed",
|
|
83
|
+
"sizeof", "static", "static_assert", "static_cast", "struct",
|
|
84
|
+
"switch", "template", "this", "thread_local", "throw", "true", "try",
|
|
85
|
+
"typedef", "typeid", "typename", "union", "unsigned", "using",
|
|
86
|
+
"virtual", "void", "volatile", "wchar_t", "while", "xor", "xor_eq"
|
|
87
|
+
]
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
def self.builtin_functions
|
|
91
|
+
@builtin_functions ||= Set.new [
|
|
92
|
+
# Integer-Valued Basic Functions
|
|
93
|
+
|
|
94
|
+
## Absolute functions
|
|
95
|
+
"abs", "int_step",
|
|
96
|
+
|
|
97
|
+
## Bound functions
|
|
98
|
+
"min", "max",
|
|
99
|
+
|
|
100
|
+
## Size functions
|
|
101
|
+
"size",
|
|
102
|
+
|
|
103
|
+
# Real-Valued Basic Functions
|
|
104
|
+
|
|
105
|
+
## Log probability function
|
|
106
|
+
"target", "get_lp",
|
|
107
|
+
|
|
108
|
+
## Logical functions
|
|
109
|
+
"step", "is_inf", "is_nan",
|
|
110
|
+
|
|
111
|
+
## Step-like functions
|
|
112
|
+
"fabs", "fdim", "fmin", "fmax", "fmod", "floor", "ceil", "round",
|
|
113
|
+
"trunc",
|
|
114
|
+
|
|
115
|
+
## Power and logarithm functions
|
|
116
|
+
"sqrt", "cbrt", "square", "exp", "exp2", "log", "log2", "log10",
|
|
117
|
+
"pow", "inv", "inv_sqrt", "inv_square",
|
|
118
|
+
|
|
119
|
+
## Trigonometric functions
|
|
120
|
+
"hypot", "cos", "sin", "tan", "acos", "asin", "atan", "atan2",
|
|
121
|
+
|
|
122
|
+
## Hyperbolic trigonometric functions
|
|
123
|
+
"cosh", "sinh", "tanh", "acosh", "asinh", "atanh",
|
|
124
|
+
|
|
125
|
+
## Link functions
|
|
126
|
+
"logit", "inv_logit", "inv_cloglog",
|
|
127
|
+
|
|
128
|
+
## Probability-related functions
|
|
129
|
+
"erf", "erfc", "Phi", "inv_Phi", "Phi_approx", "binary_log_loss",
|
|
130
|
+
"owens_t",
|
|
131
|
+
|
|
132
|
+
## Combinatorial functions
|
|
133
|
+
"beta", "inc_beta", "lbeta", "tgamma", "lgamma", "digamma",
|
|
134
|
+
"trigamma", "lmgamma", "gamma_p", "gamma_q",
|
|
135
|
+
"binomial_coefficient_log", "choose", "bessel_first_kind",
|
|
136
|
+
"bessel_second_kind", "modified_bessel_first_kind",
|
|
137
|
+
"log_modified_bessel_first_kind", "modified_bessel_second_kind",
|
|
138
|
+
"falling_factorial", "lchoose", "log_falling_factorial",
|
|
139
|
+
"rising_factorial", "log_rising_factorial",
|
|
140
|
+
|
|
141
|
+
## Composed functions
|
|
142
|
+
"expm1", "fma", "multiply_log", "ldexp", "lmultiply", "log1p",
|
|
143
|
+
"log1m", "log1p_exp", "log1m_exp", "log_diff_exp", "log_mix",
|
|
144
|
+
"log_sum_exp", "log_inv_logit", "log_inv_logit_diff",
|
|
145
|
+
"log1m_inv_logit",
|
|
146
|
+
|
|
147
|
+
## Special functions
|
|
148
|
+
"lambert_w0", "lambert_wm1",
|
|
149
|
+
|
|
150
|
+
# Complex-Valued Basic Functions
|
|
151
|
+
|
|
152
|
+
## Complex constructors and accessors
|
|
153
|
+
"to_complex", "get_real", "get_imag",
|
|
154
|
+
|
|
155
|
+
## Complex special functions
|
|
156
|
+
"arg", "norm", "conj", "proj", "polar",
|
|
157
|
+
|
|
158
|
+
# Array Operations
|
|
159
|
+
|
|
160
|
+
## Reductions
|
|
161
|
+
"sum", "prod", "log_sum_exp", "mean", "variance", "sd", "distance",
|
|
162
|
+
"squared_distance", "quantile",
|
|
163
|
+
|
|
164
|
+
## Array size and dimension function
|
|
165
|
+
"dims", "num_elements",
|
|
166
|
+
|
|
167
|
+
## Array broadcasting
|
|
168
|
+
"rep_array",
|
|
169
|
+
|
|
170
|
+
## Array concatenation
|
|
171
|
+
"append_array",
|
|
172
|
+
|
|
173
|
+
## Sorting functions
|
|
174
|
+
"sort_asc", "sort_desc", "sort_indices_asc", "sort_indices_desc",
|
|
175
|
+
"rank",
|
|
176
|
+
|
|
177
|
+
## Reversing functions
|
|
178
|
+
"reverse",
|
|
179
|
+
|
|
180
|
+
# Matrix Operations
|
|
181
|
+
|
|
182
|
+
## Integer-valued matrix size functions
|
|
183
|
+
"num_elements", "rows", "cols",
|
|
184
|
+
|
|
185
|
+
## Dot products and specialized products
|
|
186
|
+
"dot_product", "columns_dot_product", "rows_dot_product", "dot_self",
|
|
187
|
+
"columns_dot_self", "rows_dot_self", "tcrossprod", "crossprod",
|
|
188
|
+
"quad_form", "quad_form_diag", "quad_form_sym", "trace_quad_form",
|
|
189
|
+
"trace_gen_quad_form", "multiply_lower_tri_self_transpose",
|
|
190
|
+
"diag_pre_multiply", "diag_post_multiply",
|
|
191
|
+
|
|
192
|
+
## Broadcast functions
|
|
193
|
+
"rep_vector", "rep_row_vector", "rep_matrix",
|
|
194
|
+
"symmetrize_from_lower_tri",
|
|
195
|
+
|
|
196
|
+
## Diagonal matrix functions
|
|
197
|
+
"add_diag", "diagonal", "diag_matrix", "identity_matrix",
|
|
198
|
+
|
|
199
|
+
## Container construction functions
|
|
200
|
+
"linspaced_array", "linspaced_int_array", "linspaced_vector",
|
|
201
|
+
"linspaced_row_vector", "one_hot_int_array", "one_hot_array",
|
|
202
|
+
"one_hot_vector", "one_hot_row_vector", "ones_int_array",
|
|
203
|
+
"ones_array", "ones_vector", "ones_row_vector", "zeros_int_array",
|
|
204
|
+
"zeros_array", "zeros_vector", "zeros_row_vector", "uniform_simplex",
|
|
205
|
+
|
|
206
|
+
## Slicing and blocking functions
|
|
207
|
+
"col", "row", "block", "sub_col", "sub_row", "head", "tail",
|
|
208
|
+
"segment",
|
|
209
|
+
|
|
210
|
+
## Matrix concatenation
|
|
211
|
+
"append_col", "append_row",
|
|
212
|
+
|
|
213
|
+
## Special matrix functions
|
|
214
|
+
"softmax", "log_softmax", "cumulative_sum",
|
|
215
|
+
|
|
216
|
+
## Covariance functions
|
|
217
|
+
"cov_exp_quad",
|
|
218
|
+
|
|
219
|
+
## Linear algebra functions and solvers
|
|
220
|
+
"mdivide_left_tri_low", "mdivide_right_tri_low", "mdivide_left_spd",
|
|
221
|
+
"mdivide_right_spd", "matrix_exp", "matrix_exp_multiply",
|
|
222
|
+
"scale_matrix_exp_multiply", "matrix_power", "trace", "determinant",
|
|
223
|
+
"log_determinant", "inverse", "inverse_spd", "chol2inv",
|
|
224
|
+
"generalized_inverse", "eigenvalues_sym", "eigenvectors_sym",
|
|
225
|
+
"qr_thin_Q", "qr_thin_R", "qr_Q", "qr_R", "cholseky_decompose",
|
|
226
|
+
"singular_values", "svd_U", "svd_V",
|
|
227
|
+
|
|
228
|
+
# Sparse Matrix Operations
|
|
229
|
+
|
|
230
|
+
## Conversion functions
|
|
231
|
+
"csr_extract_w", "csr_extract_v", "csr_extract_u",
|
|
232
|
+
"csr_to_dense_matrix",
|
|
233
|
+
|
|
234
|
+
## Sparse matrix arithmetic
|
|
235
|
+
"csr_matrix_times_vector",
|
|
236
|
+
|
|
237
|
+
# Mixed Operations
|
|
238
|
+
"to_matrix", "to_vector", "to_row_vector", "to_array_2d",
|
|
239
|
+
"to_array_1d",
|
|
240
|
+
|
|
241
|
+
# Higher-Order Functions
|
|
242
|
+
|
|
243
|
+
## Algebraic equation solver
|
|
244
|
+
"algebra_solver", "algebra_solver_newton",
|
|
245
|
+
|
|
246
|
+
## Ordinary differential equation
|
|
247
|
+
"ode_rk45", "ode_rk45_tol", "ode_ckrk", "ode_ckrk_tol", "ode_adams",
|
|
248
|
+
"ode_adams_tol", "ode_bdf", "ode_bdf_tol", "ode_adjoint_tol_ctl",
|
|
249
|
+
|
|
250
|
+
## 1D integrator
|
|
251
|
+
"integrate_1d",
|
|
252
|
+
|
|
253
|
+
## Reduce-sum function
|
|
254
|
+
"reduce_sum", "reduce_sum_static",
|
|
255
|
+
|
|
256
|
+
## Map-rect function
|
|
257
|
+
"map_rect",
|
|
258
|
+
|
|
259
|
+
# Deprecated Functions
|
|
260
|
+
"integrate_ode_rk45", "integrate_ode", "integrate_ode_adams",
|
|
261
|
+
"integrate_ode_bdf",
|
|
262
|
+
|
|
263
|
+
# Hidden Markov Models
|
|
264
|
+
"hmm_marginal", "hmm_latent_rng", "hmm_hidden_state_prob"
|
|
265
|
+
]
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
def self.distributions
|
|
269
|
+
@distributions ||= Set.new(
|
|
270
|
+
[
|
|
271
|
+
# Discrete Distributions
|
|
272
|
+
|
|
273
|
+
## Binary Distributions
|
|
274
|
+
"bernoulli", "bernoulli_logit", "bernoulli_logit_glm",
|
|
275
|
+
|
|
276
|
+
## Bounded Discrete Distributions
|
|
277
|
+
"binomial", "binomial_logit", "beta_binomial", "hypergeometric",
|
|
278
|
+
"categorical", "categorical_logit_glm", "discrete_range",
|
|
279
|
+
"ordered_logistic", "ordered_logistic_glm", "ordered_probit",
|
|
280
|
+
|
|
281
|
+
## Unbounded Discrete Distributions
|
|
282
|
+
"neg_binomial", "neg_binomial_2", "neg_binomial_2_log",
|
|
283
|
+
"neg_binomial_2_log_glm", "poisson", "poisson_log",
|
|
284
|
+
"poisson_log_glm",
|
|
285
|
+
|
|
286
|
+
## Multivariate Discrete Distributions
|
|
287
|
+
"multinomial", "multinomial_logit",
|
|
288
|
+
|
|
289
|
+
# Continuous Distributions
|
|
290
|
+
|
|
291
|
+
## Unbounded Continuous Distributions
|
|
292
|
+
"normal", "std_normal", "normal_id_glm", "exp_mod_normal",
|
|
293
|
+
"skew_normal", "student_t", "cauchy", "double_exponential",
|
|
294
|
+
"logistic", "gumbel", "skew_double_exponential",
|
|
295
|
+
|
|
296
|
+
## Positive Continuous Distributions
|
|
297
|
+
"lognormal", "chi_square", "inv_chi_square",
|
|
298
|
+
"scaled_inv_chi_square", "exponential", "gamma", "inv_gamma",
|
|
299
|
+
"weibull", "frechet", "rayleigh",
|
|
300
|
+
|
|
301
|
+
## Positive Lower-Bounded Distributions
|
|
302
|
+
"pareto", "pareto_type_2", "wiener",
|
|
303
|
+
|
|
304
|
+
## Continuous Distributions on [0, 1]
|
|
305
|
+
"beta", "beta_proportion",
|
|
306
|
+
|
|
307
|
+
## Circular Distributions
|
|
308
|
+
"von_mises",
|
|
309
|
+
|
|
310
|
+
## Bounded Continuous Distributions
|
|
311
|
+
"uniform",
|
|
312
|
+
|
|
313
|
+
## Distributions over Unbounded Vectors
|
|
314
|
+
"multi_normal", "multi_normal_prec", "multi_normal_cholesky",
|
|
315
|
+
"multi_gp", "multi_gp_cholesky", "multi_student_t",
|
|
316
|
+
"gaussian_dlm_obs",
|
|
317
|
+
|
|
318
|
+
## Simplex Distributions
|
|
319
|
+
"dirichlet",
|
|
320
|
+
|
|
321
|
+
## Correlation Matrix Distributions
|
|
322
|
+
"lkj_corr", "lkj_corr_cholesky",
|
|
323
|
+
|
|
324
|
+
## Covariance Matrix Distributions
|
|
325
|
+
"wishart", "inv_wishart"
|
|
326
|
+
].product([
|
|
327
|
+
"", "_lpmf", "_lupmf", "_lpdf", "_lcdf", "_lccdf", "_rng", "_log",
|
|
328
|
+
"_cdf_log", "_ccdf_log"
|
|
329
|
+
]).map {|s| "#{s[0]}#{s[1]}"}
|
|
330
|
+
)
|
|
331
|
+
end
|
|
332
|
+
|
|
333
|
+
def self.constants
|
|
334
|
+
@constants ||= Set.new [
|
|
335
|
+
# Mathematical constants
|
|
336
|
+
"pi", "e", "sqrt2", "log2", "log10",
|
|
337
|
+
|
|
338
|
+
# Special values
|
|
339
|
+
"not_a_number", "positive_infinity", "negative_infinity",
|
|
340
|
+
"machine_precision"
|
|
341
|
+
]
|
|
342
|
+
end
|
|
343
|
+
|
|
344
|
+
state :root do
|
|
345
|
+
mixin :whitespace
|
|
346
|
+
rule %r/#include/, Comment::Preproc, :include
|
|
347
|
+
rule %r/#.*$/, Generic::Deleted
|
|
348
|
+
rule %r(
|
|
349
|
+
functions
|
|
350
|
+
|(?:transformed\s+)?data
|
|
351
|
+
|(?:transformed\s+)?parameters
|
|
352
|
+
|model
|
|
353
|
+
|generated\s+quantities
|
|
354
|
+
)x, Name::Namespace
|
|
355
|
+
rule %r(\{), Punctuation, :bracket_scope
|
|
356
|
+
mixin :scope
|
|
357
|
+
end
|
|
358
|
+
|
|
359
|
+
state :include do
|
|
360
|
+
rule %r((\s+)(\S+)(\s*)) do |m|
|
|
361
|
+
token Text, m[1]
|
|
362
|
+
token Comment::PreprocFile, m[2]
|
|
363
|
+
token Text, m[3]
|
|
364
|
+
pop!
|
|
365
|
+
end
|
|
366
|
+
end
|
|
367
|
+
|
|
368
|
+
state :whitespace do
|
|
369
|
+
rule %r(\n+)m, Text
|
|
370
|
+
rule %r(//(\\.|.)*?$), Comment::Single
|
|
371
|
+
mixin :inline_whitespace
|
|
372
|
+
end
|
|
373
|
+
|
|
374
|
+
state :inline_whitespace do
|
|
375
|
+
rule %r([ \t\r]+), Text
|
|
376
|
+
rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
|
|
377
|
+
end
|
|
378
|
+
|
|
379
|
+
state :statements do
|
|
380
|
+
mixin :whitespace
|
|
381
|
+
rule %r/#include/, Comment::Preproc, :include
|
|
382
|
+
rule %r/#.*$/, Generic::Deleted
|
|
383
|
+
rule %r("), Str, :string
|
|
384
|
+
rule %r(
|
|
385
|
+
(
|
|
386
|
+
((\d+[.]\d*|[.]?\d+)e[+-]?\d+|\d*[.]\d+|\d+)
|
|
387
|
+
(#{WS})[+-](#{WS})
|
|
388
|
+
((\d+[.]\d*|[.]?\d+)e[+-]?\d+|\d*[.]\d+|\d+)i
|
|
389
|
+
)
|
|
390
|
+
|((\d+[.]\d*|[.]?\d+)e[+-]?\d+|\d*[.]\d+|\d+)i
|
|
391
|
+
|((\d+[.]\d*|[.]?\d+)e[+-]?\d+|\d*[.]\d+)
|
|
392
|
+
)mx, Num::Float
|
|
393
|
+
rule %r/\d+/, Num::Integer
|
|
394
|
+
rule %r(\*/), Error
|
|
395
|
+
rule OP, Operator
|
|
396
|
+
rule %r([\[\],.;]), Punctuation
|
|
397
|
+
rule %r([|](?![|])), Punctuation
|
|
398
|
+
rule %r(T\b), Keyword::Reserved
|
|
399
|
+
rule %r((lower|upper)\b), Name::Attribute
|
|
400
|
+
rule ID do |m|
|
|
401
|
+
name = m[0]
|
|
402
|
+
|
|
403
|
+
if self.class.keywords.include? name
|
|
404
|
+
token Keyword
|
|
405
|
+
elsif self.class.types.include? name
|
|
406
|
+
token Keyword::Type
|
|
407
|
+
elsif self.class.reserved.include? name
|
|
408
|
+
token Keyword::Reserved
|
|
409
|
+
else
|
|
410
|
+
token Name::Variable
|
|
411
|
+
end
|
|
412
|
+
end
|
|
413
|
+
end
|
|
414
|
+
|
|
415
|
+
state :scope do
|
|
416
|
+
mixin :whitespace
|
|
417
|
+
rule %r(
|
|
418
|
+
(#{RT}) # Return type
|
|
419
|
+
(#{ID}) # Function name
|
|
420
|
+
(?=\([^;]*?\)) # Signature or arguments
|
|
421
|
+
)mx do |m|
|
|
422
|
+
recurse m[1]
|
|
423
|
+
|
|
424
|
+
name = m[2]
|
|
425
|
+
if self.class.builtin_functions.include? name
|
|
426
|
+
token Name::Builtin, name
|
|
427
|
+
elsif self.class.distributions.include? name
|
|
428
|
+
token Name::Builtin, name
|
|
429
|
+
elsif self.class.constants.include? name
|
|
430
|
+
token Keyword::Constant
|
|
431
|
+
else
|
|
432
|
+
token Name::Function, name
|
|
433
|
+
end
|
|
434
|
+
end
|
|
435
|
+
rule %r(\{), Punctuation, :bracket_scope
|
|
436
|
+
rule %r(\(), Punctuation, :parens_scope
|
|
437
|
+
mixin :statements
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
state :bracket_scope do
|
|
441
|
+
mixin :scope
|
|
442
|
+
rule %r(\}), Punctuation, :pop!
|
|
443
|
+
end
|
|
444
|
+
|
|
445
|
+
state :parens_scope do
|
|
446
|
+
mixin :scope
|
|
447
|
+
rule %r(\)), Punctuation, :pop!
|
|
448
|
+
end
|
|
449
|
+
end
|
|
450
|
+
end
|
|
451
|
+
end
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*- #
|
|
2
|
+
# frozen_string_literal: true
|
|
3
|
+
|
|
4
|
+
module Rouge
|
|
5
|
+
module Lexers
|
|
6
|
+
class Stata < RegexLexer
|
|
7
|
+
title "Stata"
|
|
8
|
+
desc "The Stata programming language (www.stata.com)"
|
|
9
|
+
tag 'stata'
|
|
10
|
+
filenames '*.do', '*.ado'
|
|
11
|
+
mimetypes 'application/x-stata', 'text/x-stata'
|
|
12
|
+
|
|
13
|
+
###
|
|
14
|
+
# Stata reference manual is available online at: https://www.stata.com/features/documentation/
|
|
15
|
+
###
|
|
16
|
+
|
|
17
|
+
# Partial list of common programming and estimation commands, as of Stata 16
|
|
18
|
+
# Note: not all abbreviations are included
|
|
19
|
+
KEYWORDS = %w(
|
|
20
|
+
do run include clear assert set mata log
|
|
21
|
+
by bys bysort cap capt capture char class classutil which cdir confirm new existence creturn
|
|
22
|
+
_datasignature discard di dis disp displ displa display ereturn error _estimates exit file open read write seek close query findfile fvexpand
|
|
23
|
+
gettoken java home heapmax java_heapmax icd9 icd9p icd10 icd10cm icd10pcs initialize javacall levelsof
|
|
24
|
+
tempvar tempname tempfile macro shift uniq dups retokenize clean sizeof posof
|
|
25
|
+
makecns matcproc marksample mark markout markin svymarkout matlist
|
|
26
|
+
accum define dissimilarity eigenvalues get rowjoinbyname rownames score svd symeigen dir list ren rename
|
|
27
|
+
more pause plugin call postfile _predict preserve restore program define drop end python qui quietly noi noisily _return return _rmcoll rmsg _robust
|
|
28
|
+
serset locale_functions locale_ui signestimationsample checkestimationsample sleep syntax sysdir adopath adosize
|
|
29
|
+
tabdisp timer tokenize trace unab unabcmd varabbrev version viewsource
|
|
30
|
+
window fopen fsave manage menu push stopbox
|
|
31
|
+
net from cd link search install sj stb ado update uninstall pwd ssc ls
|
|
32
|
+
using insheet outsheet mkmat svmat sum summ summarize
|
|
33
|
+
graph gr_edit twoway histogram kdensity spikeplot
|
|
34
|
+
mi miss missing var varname order compress append
|
|
35
|
+
gen gene gener genera generat generate egen replace duplicates
|
|
36
|
+
estimates nlcom lincom test testnl predict suest
|
|
37
|
+
_regress reg regr regre regres regress probit logit ivregress logistic svy gmm ivprobit ivtobit
|
|
38
|
+
bsample assert codebook collapse compare contract copy count cross datasignature d ds desc describe destring tostring
|
|
39
|
+
drawnorm edit encode decode erase expand export filefilter fillin format frame frget frlink gsort
|
|
40
|
+
import dbase delimited excel fred haver sas sasxport5 sasxport8 spss infile infix input insobs inspect ipolate isid
|
|
41
|
+
joinby label language labelbook lookfor memory mem merge mkdir mvencode notes obs odbc order outfile
|
|
42
|
+
pctile xtile _pctile putmata range recast recode rename group reshape rm rmdir sample save saveold separate shell snapshot sort split splitsample stack statsby sysuse
|
|
43
|
+
type unicode use varmanage vl webuse xpose zipfile
|
|
44
|
+
number keep tab table tabulate stset stcox tsset xtset
|
|
45
|
+
)
|
|
46
|
+
|
|
47
|
+
# Complete list of functions by name, as of Stata 16
|
|
48
|
+
PRIMITIVE_FUNCTIONS = %w(
|
|
49
|
+
abbrev abs acos acosh age age_frac asin asinh atan atan2 atanh autocode
|
|
50
|
+
betaden binomial binomialp binomialtail binormal birthday bofd byteorder
|
|
51
|
+
c _caller cauchy cauchyden cauchytail Cdhms ceil char chi2 chi2den chi2tail Chms
|
|
52
|
+
chop cholesky clip Clock clock clockdiff cloglog Cmdyhms Cofc cofC Cofd cofd coleqnumb
|
|
53
|
+
collatorlocale collatorversion colnfreeparms colnumb colsof comb cond corr cos cosh
|
|
54
|
+
daily date datediff datediff_frac day det dgammapda dgammapdada dgammapdadx dgammapdxdx dhms
|
|
55
|
+
diag diag0cnt digamma dofb dofC dofc dofh dofm dofq dofw dofy dow doy dunnettprob e el epsdouble
|
|
56
|
+
epsfloat exp expm1 exponential exponentialden exponentialtail
|
|
57
|
+
F Fden fileexists fileread filereaderror filewrite float floor fmtwidth frval _frval Ftail
|
|
58
|
+
fammaden gammap gammaptail get hadamard halfyear halfyearly has_eprop hh hhC hms hofd hours
|
|
59
|
+
hypergeometric hypergeometricp
|
|
60
|
+
I ibeta ibetatail igaussian igaussianden igaussiantail indexnot inlist inrange int inv invbinomial invbinomialtail
|
|
61
|
+
invcauchy invcauchytail invchi2 invchi2tail invcloglog invdunnettprob invexponential invexponentialtail invF
|
|
62
|
+
invFtail invgammap invgammaptail invibeta invibetatail invigaussian invigaussiantail invlaplace invlaplacetail
|
|
63
|
+
invlogistic invlogistictail invlogit invnbinomial invnbinomialtail invnchi2 invnchi2tail invnF invnFtail invnibeta invnormal invnt invnttail
|
|
64
|
+
invpoisson invpoissontail invsym invt invttail invtukeyprob invweibull invweibullph invweibullphtail invweibulltail irecode islepyear issymmetric
|
|
65
|
+
J laplace laplaceden laplacetail ln ln1m ln1p lncauchyden lnfactorial lngamma lnigammaden lnigaussianden lniwishartden lnlaplaceden lnmvnormalden
|
|
66
|
+
lnnormal lnnormalden lnnormalden lnnormalden lnwishartden log log10 log1m log1p logistic logisticden logistictail logit
|
|
67
|
+
matmissing matrix matuniform max maxbyte maxdouble maxfloat maxint maxlong mdy mdyhms mi min minbyte mindouble minfloat minint minlong minutes
|
|
68
|
+
missing mm mmC mod mofd month monthly mreldif msofhours msofminutes msofseconds
|
|
69
|
+
nbetaden nbinomial nbinomialp nbinomialtail nchi2 nchi2den nchi2tail nextbirthday nextleapyear nF nFden nFtail nibeta
|
|
70
|
+
normal normalden npnchi2 npnF npnt nt ntden nttail nullmat
|
|
71
|
+
plural poisson poissonp poissontail previousbirthday previousleapyear qofd quarter quarterly r rbeta rbinomial rcauchy rchi2 recode
|
|
72
|
+
real regexm regexr regexs reldif replay return rexponential rgamma rhypergeometric rigaussian rlaplace rlogistic rnormal
|
|
73
|
+
round roweqnumb rownfreeparms rownumb rowsof rpoisson rt runiform runiformint rweibull rweibullph
|
|
74
|
+
s scalar seconds sign sin sinh smallestdouble soundex soundex_nara sqrt ss ssC strcat strdup string stritrim strlen strlower
|
|
75
|
+
strltrim strmatch strofreal strpos strproper strreverse strrpos strrtrim strtoname strtrim strupper subinstr subinword substr sum sweep
|
|
76
|
+
t tan tanh tC tc td tden th tin tm tobytes tq trace trigamma trunc ttail tukeyprob tw twithin
|
|
77
|
+
uchar udstrlen udsubstr uisdigit uisletter uniform ustrcompare ustrcompareex ustrfix ustrfrom ustrinvalidcnt ustrleft ustrlen ustrlower
|
|
78
|
+
ustrltrim ustrnormalize ustrpos ustrregexm ustrregexra ustrregexrf ustrregexs ustrreverse ustrright ustrrpos ustrrtrim ustrsortkey
|
|
79
|
+
ustrsortkeyex ustrtitle ustrto ustrtohex ustrtoname ustrtrim ustrunescape ustrupper ustrword ustrwordcount usubinstr usubstr
|
|
80
|
+
vec vecdiag week weekly weibull weibullden weibullph weibullphden weibullphtail weibulltail wofd word wordbreaklocale wordcount
|
|
81
|
+
year yearly yh ym yofd yq yw
|
|
82
|
+
)
|
|
83
|
+
|
|
84
|
+
# Note: types `str1-str2045` handled separately below
|
|
85
|
+
def self.type_keywords
|
|
86
|
+
@type_keywords ||= Set.new %w(byte int long float double str strL numeric string integer scalar matrix local global numlist varlist newlist)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
# Stata commands used with braces. Includes all valid abbreviations for 'forvalues'.
|
|
90
|
+
def self.reserved_keywords
|
|
91
|
+
@reserved_keywords ||= Set.new %w(if else foreach forv forva forval forvalu forvalue forvalues to while in of continue break nobreak)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
###
|
|
95
|
+
# Lexer state and rules
|
|
96
|
+
###
|
|
97
|
+
state :root do
|
|
98
|
+
|
|
99
|
+
# Pre-processor commands: #
|
|
100
|
+
rule %r/^\s*#.*$/, Comment::Preproc
|
|
101
|
+
|
|
102
|
+
# Hashbang comments: *!
|
|
103
|
+
rule %r/^\*!.*$/, Comment::Hashbang
|
|
104
|
+
|
|
105
|
+
# Single-line comment: *
|
|
106
|
+
rule %r/^\s*\*.*$/, Comment::Single
|
|
107
|
+
|
|
108
|
+
# Keywords: recognize only when they are the first word
|
|
109
|
+
rule %r/^\s*(#{KEYWORDS.join('|')})\b/, Keyword
|
|
110
|
+
|
|
111
|
+
# Whitespace. Classify `\n` as `Text` to avoid interference with `Comment` and `Keyword` above
|
|
112
|
+
rule(/[ \t]+/, Text::Whitespace)
|
|
113
|
+
rule(/[\n\r]+/, Text)
|
|
114
|
+
|
|
115
|
+
# In-line comment: //
|
|
116
|
+
rule %r/\/\/.*?$/, Comment::Single
|
|
117
|
+
|
|
118
|
+
# Multi-line comment: /* and */
|
|
119
|
+
rule %r(/(\\\n)?[*].*?[*](\\\n)?/)m, Comment::Multiline
|
|
120
|
+
|
|
121
|
+
# Strings indicated by compound double-quotes (`""') and double-quotes ("")
|
|
122
|
+
rule %r/`"(\\.|.)*?"'/, Str::Double
|
|
123
|
+
rule %r/"(\\.|.)*?"/, Str::Double
|
|
124
|
+
|
|
125
|
+
# Format locals (`') and globals ($) as strings
|
|
126
|
+
rule %r/`(\\.|.)*?'/, Str::Double
|
|
127
|
+
rule %r/(?<!\w)\$\w+/, Str::Double
|
|
128
|
+
|
|
129
|
+
# Display formats
|
|
130
|
+
rule %r/\%\S+/, Name::Property
|
|
131
|
+
|
|
132
|
+
# Additional string types: str1-str2045
|
|
133
|
+
rule %r/\bstr(204[0-5]|20[0-3][0-9]|[01][0-9][0-9][0-9]|[0-9][0-9][0-9]|[0-9][0-9]|[1-9])\b/, Keyword::Type
|
|
134
|
+
|
|
135
|
+
# Only recognize primitive functions when they are actually used as a function call, i.e. followed by an opening parenthesis
|
|
136
|
+
# `Name::Builtin` would be more logical, but is not usually highlighted, so use `Name::Function` instead
|
|
137
|
+
rule %r/\b(#{PRIMITIVE_FUNCTIONS.join('|')})(?=\()/, Name::Function
|
|
138
|
+
|
|
139
|
+
# Matrix operator `..` (declare here instead of with other operators, in order to avoid conflict with numbers below)
|
|
140
|
+
rule %r/\.\.(?=.*\])/, Operator
|
|
141
|
+
|
|
142
|
+
# Numbers
|
|
143
|
+
rule %r/[+-]?(\d+([.]\d+)?|[.]\d+)([eE][+-]?\d+)?/, Num
|
|
144
|
+
|
|
145
|
+
# Factor variable and time series operators
|
|
146
|
+
rule %r/\b[ICOicoLFDSlfds]\w*\./, Operator
|
|
147
|
+
rule %r/\b[ICOicoLFDSlfds]\w*(?=\(.*\)\.)/, Operator
|
|
148
|
+
|
|
149
|
+
rule %r/\w+/ do |m|
|
|
150
|
+
if self.class.reserved_keywords.include? m[0]
|
|
151
|
+
token Keyword::Reserved
|
|
152
|
+
elsif self.class.type_keywords.include? m[0]
|
|
153
|
+
token Keyword::Type
|
|
154
|
+
else
|
|
155
|
+
token Name
|
|
156
|
+
end
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
rule %r/[\[\]{}();,]/, Punctuation
|
|
160
|
+
|
|
161
|
+
rule %r([-<>?*+'^/\\!#.=~:&|]), Operator
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
data/lib/rouge/lexers/toml.rb
CHANGED
|
@@ -11,14 +11,15 @@ module Rouge
|
|
|
11
11
|
filenames '*.toml', 'Pipfile'
|
|
12
12
|
mimetypes 'text/x-toml'
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
# bare keys and quoted keys
|
|
15
|
+
identifier = %r/(?:\S+|"[^"]+"|'[^']+')/
|
|
15
16
|
|
|
16
17
|
state :basic do
|
|
17
18
|
rule %r/\s+/, Text
|
|
18
19
|
rule %r/#.*?$/, Comment
|
|
19
20
|
rule %r/(true|false)/, Keyword::Constant
|
|
20
21
|
|
|
21
|
-
rule %r/(
|
|
22
|
+
rule %r/(#{identifier})(\s*)(=)(\s*)(\{)/ do
|
|
22
23
|
groups Name::Namespace, Text, Operator, Text, Punctuation
|
|
23
24
|
push :inline
|
|
24
25
|
end
|
|
@@ -48,6 +49,11 @@ module Rouge
|
|
|
48
49
|
|
|
49
50
|
state :content do
|
|
50
51
|
mixin :basic
|
|
52
|
+
|
|
53
|
+
rule %r/(#{identifier})(\s*)(=)/ do
|
|
54
|
+
groups Name::Property, Text, Punctuation
|
|
55
|
+
end
|
|
56
|
+
|
|
51
57
|
rule %r/"""/, Str, :mdq
|
|
52
58
|
rule %r/"/, Str, :dq
|
|
53
59
|
rule %r/'''/, Str, :msq
|
|
@@ -95,10 +101,6 @@ module Rouge
|
|
|
95
101
|
state :inline do
|
|
96
102
|
mixin :content
|
|
97
103
|
|
|
98
|
-
rule %r/(#{identifier})(\s*)(=)/ do
|
|
99
|
-
groups Name::Property, Text, Punctuation
|
|
100
|
-
end
|
|
101
|
-
|
|
102
104
|
rule %r/\}/, Punctuation, :pop!
|
|
103
105
|
end
|
|
104
106
|
end
|
data/lib/rouge/version.rb
CHANGED
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.
|
|
4
|
+
version: 3.28.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jeanine Adkisson
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2022-02-03 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:
|
|
@@ -80,6 +80,7 @@ files:
|
|
|
80
80
|
- lib/rouge/demos/erlang
|
|
81
81
|
- lib/rouge/demos/escape
|
|
82
82
|
- lib/rouge/demos/factor
|
|
83
|
+
- lib/rouge/demos/fluent
|
|
83
84
|
- lib/rouge/demos/fortran
|
|
84
85
|
- lib/rouge/demos/freefem
|
|
85
86
|
- lib/rouge/demos/fsharp
|
|
@@ -199,6 +200,8 @@ files:
|
|
|
199
200
|
- lib/rouge/demos/sqf
|
|
200
201
|
- lib/rouge/demos/sql
|
|
201
202
|
- lib/rouge/demos/ssh
|
|
203
|
+
- lib/rouge/demos/stan
|
|
204
|
+
- lib/rouge/demos/stata
|
|
202
205
|
- lib/rouge/demos/supercollider
|
|
203
206
|
- lib/rouge/demos/swift
|
|
204
207
|
- lib/rouge/demos/systemd
|
|
@@ -309,6 +312,7 @@ files:
|
|
|
309
312
|
- lib/rouge/lexers/erlang.rb
|
|
310
313
|
- lib/rouge/lexers/escape.rb
|
|
311
314
|
- lib/rouge/lexers/factor.rb
|
|
315
|
+
- lib/rouge/lexers/fluent.rb
|
|
312
316
|
- lib/rouge/lexers/fortran.rb
|
|
313
317
|
- lib/rouge/lexers/freefem.rb
|
|
314
318
|
- lib/rouge/lexers/fsharp.rb
|
|
@@ -440,6 +444,8 @@ files:
|
|
|
440
444
|
- lib/rouge/lexers/sqf/keywords.rb
|
|
441
445
|
- lib/rouge/lexers/sql.rb
|
|
442
446
|
- lib/rouge/lexers/ssh.rb
|
|
447
|
+
- lib/rouge/lexers/stan.rb
|
|
448
|
+
- lib/rouge/lexers/stata.rb
|
|
443
449
|
- lib/rouge/lexers/supercollider.rb
|
|
444
450
|
- lib/rouge/lexers/swift.rb
|
|
445
451
|
- lib/rouge/lexers/systemd.rb
|
|
@@ -504,7 +510,7 @@ metadata:
|
|
|
504
510
|
changelog_uri: https://github.com/rouge-ruby/rouge/blob/master/CHANGELOG.md
|
|
505
511
|
documentation_uri: https://rouge-ruby.github.io/docs/
|
|
506
512
|
source_code_uri: https://github.com/rouge-ruby/rouge
|
|
507
|
-
post_install_message:
|
|
513
|
+
post_install_message:
|
|
508
514
|
rdoc_options: []
|
|
509
515
|
require_paths:
|
|
510
516
|
- lib
|
|
@@ -519,8 +525,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
519
525
|
- !ruby/object:Gem::Version
|
|
520
526
|
version: '0'
|
|
521
527
|
requirements: []
|
|
522
|
-
rubygems_version: 3.
|
|
523
|
-
signing_key:
|
|
528
|
+
rubygems_version: 3.2.22
|
|
529
|
+
signing_key:
|
|
524
530
|
specification_version: 4
|
|
525
531
|
summary: A pure-ruby colorizer based on pygments
|
|
526
532
|
test_files: []
|