rouge 3.20.0 → 3.21.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: a0ad085dddf353cc95e795e5f556b4f2d9821068cceeeaab4cb34cb11f3ad776
4
- data.tar.gz: f70271022198b1d7e95df35d856274234720d54d4ef3f1a42c782246e2cf4c47
3
+ metadata.gz: 8ef1072cc2523dba637a191d195865b0b2fb9f38c4f6d9961fb58748306f6cd1
4
+ data.tar.gz: 4cd1b0d5262fa8a1d4ddb564cf4e9a185d6e8043bee0261f119e7a8ccb81e1fd
5
5
  SHA512:
6
- metadata.gz: 473cfdc4ce0c458d0a7b0c3b1e6684723ceb7c15dea4d1080baf201786ecd149e9d21cd25f65735edbbf4b4f763a5d7d1854a4d909bef6902b7d609d30ebcc2b
7
- data.tar.gz: 579d31241b2fe8d4f2b9471dd6bb97b5621051811260d02b21a012e9e35ccf34d83e0e998981e959aa0ce6a1b00932c06f7ed8b8b093fde95d53c7a8ebbb67ce
6
+ metadata.gz: 04a39cda7513ce8084b6cdddd3016e7ca679218688dfb2dcb6f6fd8a0e627ec189f38a31ba2c44bd2a8c5b16191e24d0f343f860db5dfbcbb7ca49b92aaff197
7
+ data.tar.gz: 50172d87860fa9fb4b187dee66c72954ce926e0d73f3e78e1a15a7f3437e749d48b2f935fa6ad08be457a6dd317a3c5c20340a7f7cc1621825b97887e82822c1
@@ -0,0 +1,6 @@
1
+ function main(args as dynamic) as void
2
+ screen = CreateObject("roSGScreen")
3
+ 'Create a scene and load /components/helloworld.xml'
4
+ scene = screen.CreateScene("HelloWorld")
5
+ screen.show()
6
+ end function
@@ -0,0 +1,3 @@
1
+ (defn a-fun
2
+ "A function"
3
+ (do-something))
@@ -0,0 +1,4 @@
1
+ Host example
2
+ Hostname example.com
3
+ User user
4
+ Port 1234
@@ -78,7 +78,7 @@ module Rouge
78
78
 
79
79
  state :basic do
80
80
  # Comments
81
- rule %r/\brem\b.*$/i, Comment
81
+ rule %r/@?\brem\b.*$/i, Comment
82
82
  # Empty Labels
83
83
  rule %r/^::.*$/, Comment
84
84
 
@@ -0,0 +1,147 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Brightscript < RegexLexer
7
+ title "BrightScript"
8
+ desc "BrightScript Programming Language (https://developer.roku.com/en-ca/docs/references/brightscript/language/brightscript-language-reference.md)"
9
+ tag 'brightscript'
10
+ aliases 'bs', 'brs'
11
+ filenames '*.brs'
12
+
13
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/global-utility-functions.md
14
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/global-string-functions.md
15
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/global-math-functions.md
16
+ def self.name_builtin
17
+ @name_builtin ||= Set.new %w(
18
+ ABS ASC ATN CDBL CHR CINT CONTROL COPYFILE COS CREATEDIRECTORY CSNG
19
+ DELETEDIRECTORY DELETEFILE EXP FINDMEMBERFUNCTION FINDNODE FIX
20
+ FORMATDRIVEFORMATJSON GETINTERFACE INSTR INT LCASE LEFT LEN LISTDIR
21
+ LOG MATCHFILES MID MOVEFILE OBSERVEFIELD PARSEJSON PARSEXML
22
+ READASCIIFILE REBOOTSYSTEM RIGHT RND RUNGARBAGECOLLECTOR SGN SIN
23
+ SLEEP SQR STR STRI STRING STRINGI STRTOI SUBSTITUTE TANTEXTTOP TEXT
24
+ TRUCASE UPTIME VALVISIBLE VISIBLE WAIT
25
+ )
26
+ end
27
+
28
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/reserved-words.md
29
+ def self.keyword_reserved
30
+ @keyword_reserved ||= Set.new %w(
31
+ BOX CREATEOBJECT DIM EACH ELSE ELSEIF END ENDFUNCTION ENDIF ENDSUB
32
+ ENDWHILE EVAL EXIT EXITWHILE FALSE FOR FUNCTION GETGLOBALAA
33
+ GETLASTRUNCOMPILEERROR GETLASTRUNRUNTIMEERROR GOTO IF IN INVALID LET
34
+ LINE_NUM M NEXT OBJFUN POS PRINT REM RETURN RUN STEP STOP SUB TAB TO
35
+ TRUE TYPE WHILE
36
+ )
37
+ end
38
+
39
+ # These keywords are present in BrightScript, but not supported in standard .brs files
40
+ def self.keyword_reserved_unsupported
41
+ @keyword_reserved_unsupported ||= Set.new %w(
42
+ CLASS CONST IMPORT LIBRARY NAMESPACE PRIVATE PROTECTED PUBLIC
43
+ )
44
+ end
45
+
46
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md
47
+ def self.keyword_type
48
+ @keyword_type ||= Set.new %w(
49
+ BOOLEAN DIM DOUBLE DYNAMIC FLOAT FUNCTION INTEGER INTERFACE INVALID
50
+ LONGINTEGER OBJECT STRING VOID
51
+ )
52
+ end
53
+
54
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#operators
55
+ def self.operator_word
56
+ @operator_word ||= Set.new %w(
57
+ AND AS MOD NOT OR THEN
58
+ )
59
+ end
60
+
61
+ # Scene graph components configured as builtins. See BrightScript component documentation e.g.
62
+ # https://developer.roku.com/en-ca/docs/references/brightscript/components/roappinfo.md
63
+ def self.builtins
64
+ @builtins ||= Set.new %w(
65
+ roAppendFile roAppInfo roAppManager roArray roAssociativeArray
66
+ roAudioGuide roAudioMetadata roAudioPlayer roAudioPlayerEvent
67
+ roAudioResourceroBitmap roBoolean roBoolean roBrightPackage roBrSub
68
+ roButton roByteArray roCaptionRenderer roCaptionRendererEvent
69
+ roCecInterface roCECStatusEvent roChannelStore roChannelStoreEvent
70
+ roClockWidget roCodeRegistrationScreen
71
+ roCodeRegistrationScreenEventroCompositor roControlDown roControlPort
72
+ roControlPort roControlUp roCreateFile roDatagramReceiver
73
+ roDatagramSender roDataGramSocket roDateTime roDeviceInfo
74
+ roDeviceInfoEvent roDoubleroEVPCipher roEVPDigest roFileSystem
75
+ roFileSystemEvent roFloat roFont roFontMetrics roFontRegistry
76
+ roFunction roGlobal roGpio roGridScreen roGridScreenEvent
77
+ roHdmiHotPlugEventroHdmiStatus roHdmiStatusEvent roHMAC roHttpAgent
78
+ roImageCanvas roImageCanvasEvent roImageMetadata roImagePlayer
79
+ roImageWidgetroInput roInputEvent roInt roInt roInvalid roInvalid
80
+ roIRRemote roKeyboard roKeyboardPress roKeyboardScreen
81
+ roKeyboardScreenEventroList roListScreen roListScreenEvent
82
+ roLocalization roLongInteger roMessageDialog roMessageDialogEvent
83
+ roMessagePort roMicrophone roMicrophoneEvent roNetworkConfiguration
84
+ roOneLineDialog roOneLineDialogEventroParagraphScreen
85
+ roParagraphScreenEvent roPath roPinEntryDialog roPinEntryDialogEvent
86
+ roPinentryScreen roPosterScreen roPosterScreenEventroProgramGuide
87
+ roQuadravoxButton roReadFile roRectangleroRegexroRegion roRegistry
88
+ roRegistrySection roResourceManager roRSA roRssArticle roRssParser
89
+ roScreen roSearchHistory roSearchScreen roSearchScreenEvent
90
+ roSerialPort roSGNode roSGNodeEvent roSGScreenroSGScreenEvent
91
+ roSlideShowroSlideShowEvent roSNS5 roSocketAddress roSocketEvent
92
+ roSpringboardScreen roSpringboardScreenEventroSprite roStorageInfo
93
+ roStreamSocket roStringroSystemLogroSystemLogEvent roSystemTime
94
+ roTextFieldroTextScreen roTextScreenEvent roTextToSpeech
95
+ roTextToSpeechEvent roTextureManager roTextureRequest
96
+ roTextureRequestEventroTextWidget roTimer roTimespan roTouchScreen
97
+ roTunerroTunerEvent roUniversalControlEvent roUrlEvent roUrlTransfer
98
+ roVideoEvent roVideoInput roVideoMode roVideoPlayer roVideoPlayerEvent
99
+ roVideoScreen roVideoScreenEventroWriteFile roXMLElement roXMLList
100
+ )
101
+ end
102
+
103
+ id = /[$a-z_][a-z0-9_]*/io
104
+
105
+ state :root do
106
+ rule %r/\s+/m, Text::Whitespace
107
+
108
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#comments
109
+ rule %r/\'.*/, Comment::Single
110
+ rule %r/REM.*/i, Comment::Single
111
+
112
+ # https://developer.roku.com/en-ca/docs/references/brightscript/language/expressions-variables-types.md#operators
113
+ rule %r([~!%^&*+=\|?:<>/-]), Operator
114
+
115
+ rule %r/\d*\.\d+(e-?\d+)?/i, Num::Float
116
+ rule %r/\d+[lu]*/i, Num::Integer
117
+
118
+ rule %r/".*?"/, Str::Double
119
+
120
+ rule %r/#{id}(?=\s*[(])/, Name::Function
121
+
122
+ rule %r/[()\[\],.;{}]/, Punctuation
123
+
124
+ rule id do |m|
125
+ caseSensitiveChunk = m[0]
126
+ caseInsensitiveChunk = m[0].upcase
127
+
128
+ if self.class.builtins.include?(caseSensitiveChunk)
129
+ token Keyword::Reserved
130
+ elsif self.class.keyword_reserved.include?(caseInsensitiveChunk)
131
+ token Keyword::Reserved
132
+ elsif self.class.keyword_reserved_unsupported.include?(caseInsensitiveChunk)
133
+ token Keyword::Reserved
134
+ elsif self.class.keyword_type.include?(caseInsensitiveChunk)
135
+ token Keyword::Type
136
+ elsif self.class.name_builtin.include?(caseInsensitiveChunk)
137
+ token Name::Builtin
138
+ elsif self.class.operator_word.include?(caseInsensitiveChunk)
139
+ token Operator::Word
140
+ else
141
+ token Name
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
147
+ end
@@ -75,15 +75,16 @@ module Rouge
75
75
  rule id, Name::Class, :pop!
76
76
 
77
77
  # template specification
78
- rule %r/\s*(?=>)/m, Text, :pop!
79
- rule %r/[.]{3}/, Operator
80
78
  mixin :whitespace
79
+ rule %r/[.]{3}/, Operator
80
+ rule %r/,/, Punctuation, :pop!
81
+ rule(//) { pop! }
81
82
  end
82
83
 
83
84
  state :template do
84
- rule %r/>/, Punctuation, :pop!
85
+ rule %r/[>;]/, Punctuation, :pop!
85
86
  rule %r/typename\b/, Keyword, :classname
86
- mixin :root
87
+ mixin :statements
87
88
  end
88
89
 
89
90
  state :case do
@@ -11,7 +11,9 @@ module Rouge
11
11
  filenames '*.css'
12
12
  mimetypes 'text/css'
13
13
 
14
- identifier = /[a-zA-Z0-9_-]+/
14
+ # Documentation: https://www.w3.org/TR/CSS21/syndata.html#characters
15
+
16
+ identifier = /[\p{L}_-][\p{Word}\p{Cf}-]*/
15
17
  number = /-?(?:[0-9]+(\.[0-9]+)?|\.[0-9]+)/
16
18
 
17
19
  def self.attributes
@@ -8,7 +8,7 @@ module Rouge
8
8
  desc "Dockerfile syntax"
9
9
  tag 'docker'
10
10
  aliases 'dockerfile'
11
- filenames 'Dockerfile', '*.Dockerfile', '*.docker', 'Dockerfile_*'
11
+ filenames 'Dockerfile', '*.Dockerfile', '*.docker'
12
12
  mimetypes 'text/x-dockerfile-config'
13
13
 
14
14
  KEYWORDS = %w(
@@ -47,13 +47,13 @@ module Rouge
47
47
  rule %r(</), Name::Tag, :tag_end
48
48
  rule %r/</, Name::Tag, :tag_start
49
49
 
50
- rule %r(<\s*[a-zA-Z0-9:-]+), Name::Tag, :tag # opening tags
51
- rule %r(<\s*/\s*[a-zA-Z0-9:-]+\s*>), Name::Tag # closing tags
50
+ rule %r(<\s*[\p{L}:_-][\p{Word}\p{Cf}:.·-]*), Name::Tag, :tag # opening tags
51
+ rule %r(<\s*/\s*[\p{L}:_-][\p{Word}\p{Cf}:.·-]*\s*>), Name::Tag # closing tags
52
52
  end
53
53
 
54
54
  state :tag_end do
55
55
  mixin :tag_end_end
56
- rule %r/[a-zA-Z0-9:-]+/ do
56
+ rule %r/[\p{L}:_-][\p{Word}\p{Cf}:.·-]*/ do
57
57
  token Name::Tag
58
58
  goto :tag_end_end
59
59
  end
@@ -67,7 +67,7 @@ module Rouge
67
67
  state :tag_start do
68
68
  rule %r/\s+/, Text
69
69
 
70
- rule %r/[a-zA-Z0-9:-]+/ do
70
+ rule %r/[\p{L}:_-][\p{Word}\p{Cf}:.·-]*/ do
71
71
  token Name::Tag
72
72
  goto :tag
73
73
  end
@@ -83,8 +83,8 @@ module Rouge
83
83
 
84
84
  state :tag do
85
85
  rule %r/\s+/m, Text
86
- rule %r/[a-zA-Z0-9_:\[\]()*.-]+\s*=\s*/m, Name::Attribute, :attr
87
- rule %r/[a-zA-Z0-9_:#*-]+/, Name::Attribute
86
+ rule %r/[\p{L}:_\[\]()*.-][\p{Word}\p{Cf}:.·\[\]()*-]*\s*=\s*/m, Name::Attribute, :attr
87
+ rule %r/[\p{L}:_*#-][\p{Word}\p{Cf}:.·*#-]*/, Name::Attribute
88
88
  rule %r(/?\s*>)m, Name::Tag, :pop!
89
89
  end
90
90
 
@@ -0,0 +1,217 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Janet < RegexLexer
7
+ title "Janet"
8
+ desc "The Janet programming language (janet-lang.org)"
9
+
10
+ tag 'janet'
11
+ aliases 'jdn'
12
+
13
+ filenames '*.janet', '*.jdn'
14
+
15
+ mimetypes 'text/x-janet', 'application/x-janet'
16
+
17
+ def self.specials
18
+ @specials ||= Set.new %w(
19
+ break def do fn if quote quasiquote splice set unquote var while
20
+ )
21
+ end
22
+
23
+ def self.bundled
24
+ @bundled ||= Set.new %w(
25
+ % %= * *= + ++ += - -- -= -> ->> -?> -?>> / /= < <= = > >=
26
+ abstract? accumulate accumulate2 all all-bindings
27
+ all-dynamics and apply array array/concat array/ensure
28
+ array/fill array/insert array/new array/new-filled
29
+ array/peek array/pop array/push array/remove array/slice
30
+ array? as-> as?-> asm assert bad-compile bad-parse band
31
+ blshift bnot boolean? bor brshift brushift buffer buffer/bit
32
+ buffer/bit-clear buffer/bit-set buffer/bit-toggle
33
+ buffer/blit buffer/clear buffer/fill buffer/format
34
+ buffer/new buffer/new-filled buffer/popn buffer/push-byte
35
+ buffer/push-string buffer/push-word buffer/slice buffer?
36
+ bxor bytes? case cfunction? chr cli-main comment comp
37
+ compare compare= compare< compare<= compare> compare>=
38
+ compile complement comptime cond coro count debug
39
+ debug/arg-stack debug/break debug/fbreak debug/lineage
40
+ debug/stack debug/stacktrace debug/step debug/unbreak
41
+ debug/unfbreak debugger-env dec deep-not= deep= default
42
+ default-peg-grammar def- defer defmacro defmacro- defn defn-
43
+ defglobal describe dictionary? disasm distinct doc doc*
44
+ doc-format dofile drop drop-until drop-while dyn each eachk
45
+ eachp eachy edefer eflush empty? env-lookup eprin eprinf
46
+ eprint eprintf error errorf eval eval-string even? every?
47
+ extreme false? fiber/can-resume? fiber/current fiber/getenv
48
+ fiber/maxstack fiber/new fiber/root fiber/setenv
49
+ fiber/setmaxstack fiber/status fiber? file/close file/flush
50
+ file/open file/popen file/read file/seek file/temp
51
+ file/write filter find find-index first flatten flatten-into
52
+ flush for forv freeze frequencies function? gccollect
53
+ gcinterval gcsetinterval generate gensym get get-in getline
54
+ hash idempotent? identity import import* if-let if-not
55
+ if-with in inc indexed? int/s64 int/u64 int? interleave
56
+ interpose invert janet/build janet/config-bits janet/version
57
+ juxt juxt* keep keys keyword keyword? kvs label last length
58
+ let load-image load-image-dict loop macex macex1 make-env
59
+ make-image make-image-dict map mapcat marshal math/-inf
60
+ math/abs math/acos math/acosh math/asin math/asinh math/atan
61
+ math/atan2 math/atanh math/cbrt math/ceil math/cos math/cosh
62
+ math/e math/erf math/erfc math/exp math/exp2 math/expm1
63
+ math/floor math/gamma math/hypot math/inf math/log
64
+ math/log10 math/log1p math/log2 math/next math/pi math/pow
65
+ math/random math/rng math/rng-buffer math/rng-int
66
+ math/rng-uniform math/round math/seedrandom math/sin
67
+ math/sinh math/sqrt math/tan math/tanh math/trunc match max
68
+ mean merge merge-into min mod module/add-paths module/cache
69
+ module/expand-path module/find module/loaders module/loading
70
+ module/paths nan? nat? native neg? net/chunk net/close
71
+ net/connect net/read net/server net/write next nil? not not=
72
+ number? odd? one? or os/arch os/cd os/chmod os/clock
73
+ os/cryptorand os/cwd os/date os/dir os/environ os/execute
74
+ os/exit os/getenv os/link os/lstat os/mkdir os/mktime
75
+ os/perm-int os/perm-string os/readlink os/realpath os/rename
76
+ os/rm os/rmdir os/setenv os/shell os/sleep os/stat
77
+ os/symlink os/time os/touch os/umask os/which pairs parse
78
+ parser/byte parser/clone parser/consume parser/eof
79
+ parser/error parser/flush parser/has-more parser/insert
80
+ parser/new parser/produce parser/state parser/status
81
+ parser/where partial partition peg/compile peg/match pos?
82
+ postwalk pp prewalk prin prinf print printf product prompt
83
+ propagate protect put put-in quit range reduce reduce2
84
+ repeat repl require resume return reverse reversed root-env
85
+ run-context scan-number seq setdyn shortfn signal slice
86
+ slurp some sort sort-by sorted sorted-by spit stderr stdin
87
+ stdout string string/ascii-lower string/ascii-upper
88
+ string/bytes string/check-set string/find string/find-all
89
+ string/format string/from-bytes string/has-prefix?
90
+ string/has-suffix? string/join string/repeat string/replace
91
+ string/replace-all string/reverse string/slice string/split
92
+ string/trim string/triml string/trimr string? struct struct?
93
+ sum symbol symbol? table table/clone table/getproto
94
+ table/new table/rawget table/setproto table/to-struct table?
95
+ take take-until take-while tarray/buffer tarray/copy-bytes
96
+ tarray/length tarray/new tarray/properties tarray/slice
97
+ tarray/swap-bytes thread/close thread/current thread/new
98
+ thread/receive thread/send trace tracev true? truthy? try
99
+ tuple tuple/brackets tuple/setmap tuple/slice
100
+ tuple/sourcemap tuple/type tuple? type unless unmarshal
101
+ untrace update update-in use values var- varfn varglobal
102
+ walk walk-ind walk-dict when when-let when-with with
103
+ with-dyns with-syms with-vars yield zero? zipcoll
104
+ )
105
+ end
106
+
107
+ def name_token(name)
108
+ if self.class.specials.include? name
109
+ Keyword
110
+ elsif self.class.bundled.include? name
111
+ Keyword::Reserved
112
+ else
113
+ Name::Function
114
+ end
115
+ end
116
+
117
+ punctuation = %r/[_!@$%^&*+=~<>.?\/-]/o
118
+ symbol = %r/([[:alpha:]]|#{punctuation})([[:word:]]|#{punctuation}|:)*/o
119
+
120
+ state :root do
121
+ rule %r/#.*?$/, Comment::Single
122
+ rule %r/\s+/m, Text::Whitespace
123
+
124
+ rule %r/(true|false|nil)\b/, Name::Constant
125
+ rule %r/(['~])(#{symbol})/ do
126
+ groups Operator, Str::Symbol
127
+ end
128
+ rule %r/:([[:word:]]|#{punctuation}|:)*/, Keyword::Constant
129
+
130
+ # radix-specified numbers
131
+ rule %r/[+-]?\d{1,2}r[\w.]+(&[+-]?\w+)?/, Num::Float
132
+
133
+ # hex numbers
134
+ rule %r/[+-]?0x\h[\h_]*(\.\h[\h_]*)?/, Num::Hex
135
+ rule %r/[+-]?0x\.\h[\h_]*/, Num::Hex
136
+
137
+ # decimal numbers (Janet treats all decimals as floats)
138
+ rule %r/[+-]?\d[\d_]*(\.\d[\d_]*)?([e][+-]?\d+)?/i, Num::Float
139
+ rule %r/[+-]?\.\d[\d_]*([e][+-]?\d+)?/i, Num::Float
140
+
141
+ rule %r/@?"/, Str::Double, :string
142
+ rule %r/@?(`+).*?\1/m, Str::Heredoc
143
+
144
+ rule %r/\(/, Punctuation, :function
145
+
146
+ rule %r/(')([\(\[])/ do
147
+ groups Operator, Punctuation
148
+ push :quote
149
+ end
150
+
151
+ rule %r/(~)([\(\[])/ do
152
+ groups Operator, Punctuation
153
+ push :quasiquote
154
+ end
155
+
156
+ rule %r/[\#~,';\|]/, Operator
157
+
158
+ rule %r/@?[({\[]/, Punctuation, :push
159
+ rule %r/[)}\]]/, Punctuation, :pop!
160
+
161
+ rule symbol, Name
162
+ end
163
+
164
+ state :string do
165
+ rule %r/"/, Str::Double, :pop!
166
+ rule %r/\\(u\h{4}|U\h{6})/, Str::Escape
167
+ rule %r/\\./, Str::Escape
168
+ rule %r/[^"\\]+/, Str::Double
169
+ end
170
+
171
+ state :function do
172
+ rule symbol do |m|
173
+ case m[0]
174
+ when "quote"
175
+ token Keyword
176
+ goto :quote
177
+ when "quasiquote"
178
+ token Keyword
179
+ goto :quasiquote
180
+ else
181
+ token name_token(m[0])
182
+ goto :root
183
+ end
184
+ end
185
+
186
+ mixin :root
187
+ end
188
+
189
+ state :quote do
190
+ rule %r/[\(\[]/, Punctuation, :push
191
+ rule symbol, Str::Symbol
192
+ mixin :root
193
+ end
194
+
195
+ state :quasiquote do
196
+ rule %r/(,)(\()/ do
197
+ groups Operator, Punctuation
198
+ push :function
199
+ end
200
+ rule %r/(\()(\s*)(unquote)(\s+)(\()/ do
201
+ groups Punctuation, Text, Keyword, Text, Punctuation
202
+ push :root
203
+ push :function
204
+ end
205
+
206
+ rule %r/(,)(#{symbol})/ do
207
+ groups Operator, Name
208
+ end
209
+ rule %r/(\()(\s*)(unquote)(\s+)(#{symbol})/ do
210
+ groups Punctuation, Text, Keyword, Text, Name
211
+ end
212
+
213
+ mixin :quote
214
+ end
215
+ end
216
+ end
217
+ end
@@ -19,6 +19,8 @@ module Rouge
19
19
  mimetypes 'application/javascript', 'application/x-javascript',
20
20
  'text/javascript', 'text/x-javascript'
21
21
 
22
+ # Pseudo-documentation: https://stackoverflow.com/questions/1661197/what-characters-are-valid-for-javascript-variable-names
23
+
22
24
  def self.detect?(text)
23
25
  return 1 if text.shebang?('node')
24
26
  return 1 if text.shebang?('jsc')
@@ -138,7 +140,7 @@ module Rouge
138
140
  end
139
141
 
140
142
  def self.id_regex
141
- /[$a-z_][a-z0-9_]*/io
143
+ /[\p{L}\p{Nl}$_][\p{Word}]*/io
142
144
  end
143
145
 
144
146
  id = self.id_regex
@@ -40,6 +40,17 @@ module Rouge
40
40
  rule %r/{#/, Comment, :comment
41
41
  rule %r/##.*/, Comment
42
42
 
43
+ # Raw and verbatim
44
+ rule %r/({%-?)(\s*)(raw|verbatim)(\s*)(-?%})/ do |m|
45
+ groups Comment::Preproc, Text, Keyword, Text, Comment::Preproc
46
+ case m[3]
47
+ when "raw"
48
+ push :raw
49
+ when "verbatim"
50
+ push :verbatim
51
+ end
52
+ end
53
+
43
54
  # Statements
44
55
  rule %r/\{\%/ do
45
56
  token Comment::Preproc
@@ -114,11 +125,6 @@ module Rouge
114
125
  end
115
126
 
116
127
  state :statement do
117
- rule %r/(raw|verbatim)(\s+)(\%\})/ do
118
- groups Keyword, Text, Comment::Preproc
119
- goto :raw
120
- end
121
-
122
128
  rule %r/(\w+\.?)/ do |m|
123
129
  if self.class.keywords.include?(m[0])
124
130
  groups Keyword
@@ -142,12 +148,21 @@ module Rouge
142
148
  end
143
149
 
144
150
  state :raw do
145
- rule %r{(\{\%)(\s+)(endverbatim|endraw)(\s+)(\%\})} do
151
+ rule %r/({%-?)(\s*)(endraw)(\s*)(-?%})/ do
146
152
  groups Comment::Preproc, Text, Keyword, Text, Comment::Preproc
147
153
  pop!
148
154
  end
155
+ rule %r/[^{]+/, Text
156
+ rule %r/{/, Text
157
+ end
149
158
 
150
- rule %r/(.+?)/m, Text
159
+ state :verbatim do
160
+ rule %r/({%-?)(\s*)(endverbatim)(\s*)(-?%})/ do
161
+ groups Comment::Preproc, Text, Keyword, Text, Comment::Preproc
162
+ pop!
163
+ end
164
+ rule %r/[^{]+/, Text
165
+ rule %r/{/, Text
151
166
  end
152
167
  end
153
168
  end
@@ -11,6 +11,8 @@ module Rouge
11
11
  filenames '*.jl'
12
12
  mimetypes 'text/x-julia', 'application/x-julia'
13
13
 
14
+ # Documentation: https://docs.julialang.org/en/v1/manual/variables/#Allowed-Variable-Names-1
15
+
14
16
  def self.detect?(text)
15
17
  return true if text.shebang? 'julia'
16
18
  end
@@ -252,13 +254,13 @@ module Rouge
252
254
 
253
255
 
254
256
  state :funcname do
255
- rule %r/[a-zA-Z_]\w*/, Name::Function, :pop!
257
+ rule %r/[\p{L}\p{Nl}\p{S}_][\p{Word}\p{S}\p{Po}!]*/, Name::Function, :pop!
256
258
  rule %r/\([^\s\w{]{1,2}\)/, Operator, :pop!
257
259
  rule %r/[^\s\w{]{1,2}/, Operator, :pop!
258
260
  end
259
261
 
260
262
  state :typename do
261
- rule %r/[a-zA-Z_]\w*/, Name::Class, :pop!
263
+ rule %r/[\p{L}\p{Nl}\p{S}_][\p{Word}\p{S}\p{Po}!]*/, Name::Class, :pop!
262
264
  end
263
265
 
264
266
  state :stringescape do
@@ -65,7 +65,7 @@ module Rouge
65
65
  end
66
66
 
67
67
  state :root do
68
- rule %r/#.*?$/, Comment::Single
68
+ rule %r/#.*/, Comment::Single
69
69
  rule %r/^=[a-zA-Z0-9]+\s+.*?\n=cut/m, Comment::Multiline
70
70
  rule %r/(?:#{keywords.join('|')})\b/, Keyword
71
71
 
@@ -99,6 +99,9 @@ module Rouge
99
99
  re_tok, :balanced_regex
100
100
 
101
101
  rule %r/\s+/, Text
102
+
103
+ rule(/(?=[a-z_]\w*(\s*#.*\n)*\s*=>)/i) { push :fat_comma }
104
+
102
105
  rule %r/(?:#{builtins.join('|')})\b/, Name::Builtin
103
106
  rule %r/((__(DIE|WARN)__)|(DATA|STD(IN|OUT|ERR)))\b/,
104
107
  Name::Builtin::Pseudo
@@ -142,6 +145,13 @@ module Rouge
142
145
  rule %r/.*?\n/, Str::Interpol
143
146
  end
144
147
 
148
+ state :fat_comma do
149
+ rule %r/#.*/, Comment::Single
150
+ rule %r/\w+/, Str
151
+ rule %r/\s+/, Text
152
+ rule %r/=>/, Operator, :pop!
153
+ end
154
+
145
155
  state :name_common do
146
156
  rule %r/\w+::/, Name::Namespace
147
157
  rule %r/[\w:]+/, Name::Variable, :pop!
@@ -178,16 +188,24 @@ module Rouge
178
188
  end
179
189
 
180
190
  state :sq do
181
- rule %r/\\[']/, Str::Escape
191
+ rule %r/\\[\\']/, Str::Escape
182
192
  rule %r/[^\\']+/, Str::Single
183
193
  rule %r/'/, Punctuation, :pop!
194
+ rule %r/\\/, Str::Single
184
195
  end
185
196
 
186
197
  state :dq do
187
198
  mixin :string_intp
188
- rule %r/\\[\\tnr"]/, Str::Escape
199
+ rule %r/\\[\\tnrabefluLUE"$@]/, Str::Escape
200
+ rule %r/\\0\d{2}/, Str::Escape
201
+ rule %r/\\o\{\d+\}/, Str::Escape
202
+ rule %r/\\x\h{2}/, Str::Escape
203
+ rule %r/\\x\{\h+\}/, Str::Escape
204
+ rule %r/\\c./, Str::Escape
205
+ rule %r/\\N\{[^\}]+\}/, Str::Escape
189
206
  rule %r/[^\\"]+?/, Str::Double
190
207
  rule %r/"/, Punctuation, :pop!
208
+ rule %r/\\/, Str::Escape
191
209
  end
192
210
 
193
211
  state :bq do
@@ -165,6 +165,7 @@ module Rouge
165
165
  end
166
166
 
167
167
  state :parameters do
168
+ rule %r/`./m, Str::Escape
168
169
  rule %r/\s*?\n/, Text::Whitespace, :pop!
169
170
  rule %r/[;(){}\]]/, Punctuation, :pop!
170
171
  rule %r/[|=]/, Operator, :pop!
@@ -217,6 +218,7 @@ module Rouge
217
218
  push :parameters unless m[3].nil?
218
219
  end
219
220
 
221
+ rule %r/\?/, Name::Function, :parameters
220
222
  rule %r/[-+*\/%=!.&|]/, Operator
221
223
  rule %r/@\{/, Punctuation, :hasht
222
224
  rule %r/@\(/, Punctuation, :array
@@ -9,36 +9,51 @@ module Rouge
9
9
  tag 'rego'
10
10
  filenames '*.rego'
11
11
 
12
+ def self.constants
13
+ @constants ||= Set.new %w(
14
+ true false null
15
+ )
16
+ end
17
+
18
+ def self.operators
19
+ @operators ||= Set.new %w(
20
+ as default else import not package some with
21
+ )
22
+ end
23
+
12
24
  state :basic do
13
25
  rule %r/\s+/, Text
14
26
  rule %r/#.*/, Comment::Single
15
-
27
+
16
28
  rule %r/[\[\](){}|.,;!]/, Punctuation
17
-
29
+
18
30
  rule %r/"[^"]*"/, Str::Double
19
-
31
+
20
32
  rule %r/-?\d+\.\d+([eE][+-]?\d+)?/, Num::Float
21
33
  rule %r/-?\d+([eE][+-]?\d+)?/, Num
22
34
 
23
35
  rule %r/\\u[0-9a-fA-F]{4}/, Num::Hex
24
36
  rule %r/\\["\/bfnrt]/, Str::Escape
25
37
  end
26
-
27
- state :atoms do
28
- rule %r/(true|false|null)/, Keyword::Constant
29
- rule %r/[[:word:]]*/, Str::Symbol
30
- end
31
-
38
+
32
39
  state :operators do
33
40
  rule %r/(=|!=|>=|<=|>|<|\+|-|\*|%|\/|\||&|:=)/, Operator
34
- rule %r/(default|not|package|import|as|with|else|some)/, Operator
35
41
  rule %r/[\/:?@^~]+/, Operator
36
42
  end
37
-
43
+
38
44
  state :root do
39
45
  mixin :basic
40
46
  mixin :operators
41
- mixin :atoms
47
+
48
+ rule %r/[[:word:]]+/ do |m|
49
+ if self.class.constants.include? m[0]
50
+ token Keyword::Constant
51
+ elsif self.class.operators.include? m[0]
52
+ token Operator::Word
53
+ else
54
+ token Name
55
+ end
56
+ end
42
57
  end
43
58
  end
44
59
  end
@@ -29,6 +29,7 @@ module Rouge
29
29
  end
30
30
 
31
31
  rule %r/@#{id}/, Keyword, :selector
32
+ rule %r/&/, Keyword, :selector
32
33
 
33
34
  # $variable: assignment
34
35
  rule %r/([$]#{id})([ \t]*)(:)/ do
@@ -0,0 +1,33 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class SSH < RegexLexer
7
+ tag 'ssh'
8
+
9
+ title "SSH Config File"
10
+ desc 'A lexer for SSH configuration files'
11
+ filenames 'ssh_config'
12
+
13
+ state :root do
14
+ rule %r/[a-z0-9]+/i, Keyword, :statement
15
+ mixin :base
16
+ end
17
+
18
+ state :statement do
19
+ rule %r/\n/, Text, :pop!
20
+ rule %r/(?:yes|no|confirm|ask|always|auto|none|force)\b/, Name::Constant
21
+
22
+ rule %r/\d+/, Num
23
+ rule %r/[^#\s;{}$\\]+/, Text
24
+ mixin :base
25
+ end
26
+
27
+ state :base do
28
+ rule %r/\s+/, Text
29
+ rule %r/#.*/, Comment::Single
30
+ end
31
+ end
32
+ end
33
+ end
@@ -17,10 +17,10 @@ module Rouge
17
17
 
18
18
  def self.keywords
19
19
  @@keywords ||= %w(as do extends flush from import include use else starts
20
- ends with without autoescape endautoescape block endblock
21
- embed endembed filter endfilter for endfor if endif
22
- macro endmacro sandbox endsandbox set endset
23
- spaceless endspaceless verbatim endverbatim)
20
+ ends with without autoescape endautoescape block
21
+ endblock embed endembed filter endfilter for endfor
22
+ if endif macro endmacro sandbox endsandbox set endset
23
+ spaceless endspaceless)
24
24
  end
25
25
 
26
26
  def self.tests
@@ -12,6 +12,8 @@ module Rouge
12
12
  mimetypes 'text/xml', 'application/xml', 'image/svg+xml',
13
13
  'application/rss+xml', 'application/atom+xml'
14
14
 
15
+ # Documentation: https://www.w3.org/TR/xml11/#charsets and https://www.w3.org/TR/xml11/#sec-suggested-names
16
+
15
17
  def self.detect?(text)
16
18
  return false if text.doctype?(/html/)
17
19
  return true if text =~ /\A<\?xml\b/
@@ -27,10 +29,10 @@ module Rouge
27
29
  rule %r/<![^>]*>/, Comment::Preproc
28
30
 
29
31
  # open tags
30
- rule %r(<\s*[\w:.-]+)m, Name::Tag, :tag
32
+ rule %r(<\s*[\p{L}:_][\p{Word}\p{Cf}:.·-]*)m, Name::Tag, :tag
31
33
 
32
34
  # self-closing tags
33
- rule %r(<\s*/\s*[\w:.-]+\s*>)m, Name::Tag
35
+ rule %r(<\s*/\s*[\p{L}:_][\p{Word}\p{Cf}:.·-]*\s*>)m, Name::Tag
34
36
  end
35
37
 
36
38
  state :comment do
@@ -41,7 +43,7 @@ module Rouge
41
43
 
42
44
  state :tag do
43
45
  rule %r/\s+/m, Text
44
- rule %r/[\w.:-]+\s*=/m, Name::Attribute, :attr
46
+ rule %r/[\p{L}:_][\p{Word}\p{Cf}:.·-]*\s*=/m, Name::Attribute, :attr
45
47
  rule %r(/?\s*>), Name::Tag, :pop!
46
48
  end
47
49
 
@@ -11,6 +11,8 @@ module Rouge
11
11
  aliases 'yml'
12
12
  filenames '*.yaml', '*.yml'
13
13
 
14
+ # Documentation: https://yaml.org/spec/1.2/spec.html
15
+
14
16
  def self.detect?(text)
15
17
  # look for the %YAML directive
16
18
  return true if text =~ /\A\s*%YAML/m
@@ -165,15 +167,15 @@ module Rouge
165
167
  )x, Keyword::Type
166
168
 
167
169
  # an anchor
168
- rule %r/&[\w-]+/, Name::Label
170
+ rule %r/&[\p{L}\p{Nl}\p{Nd}_-]+/, Name::Label
169
171
 
170
172
  # an alias
171
- rule %r/\*[\w-]+/, Name::Variable
173
+ rule %r/\*[\p{L}\p{Nl}\p{Nd}_-]+/, Name::Variable
172
174
  end
173
175
 
174
176
  state :block_nodes do
175
177
  # implicit key
176
- rule %r/((?:\w[\w -]*)?)(:)(?=\s|$)/ do |m|
178
+ rule %r/((?:[\p{L}\p{Nl}\p{Nd}_][\p{L}\p{Nl}\p{Nd}\p{Blank}_-]*)?)(:)(?=\s|$)/ do |m|
177
179
  groups Name::Attribute, Punctuation::Indicator
178
180
  set_indent m[0], :implicit => true
179
181
  end
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Rouge
5
5
  def self.version
6
- "3.20.0"
6
+ "3.21.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.20.0
4
+ version: 3.21.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: 2020-06-09 00:00:00.000000000 Z
11
+ date: 2020-07-14 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:
@@ -39,6 +39,7 @@ files:
39
39
  - lib/rouge/demos/biml
40
40
  - lib/rouge/demos/bpf
41
41
  - lib/rouge/demos/brainfuck
42
+ - lib/rouge/demos/brightscript
42
43
  - lib/rouge/demos/bsl
43
44
  - lib/rouge/demos/c
44
45
  - lib/rouge/demos/ceylon
@@ -108,6 +109,7 @@ files:
108
109
  - lib/rouge/demos/irb
109
110
  - lib/rouge/demos/irb_output
110
111
  - lib/rouge/demos/isbl
112
+ - lib/rouge/demos/janet
111
113
  - lib/rouge/demos/java
112
114
  - lib/rouge/demos/javascript
113
115
  - lib/rouge/demos/jinja
@@ -190,6 +192,7 @@ files:
190
192
  - lib/rouge/demos/sparql
191
193
  - lib/rouge/demos/sqf
192
194
  - lib/rouge/demos/sql
195
+ - lib/rouge/demos/ssh
193
196
  - lib/rouge/demos/supercollider
194
197
  - lib/rouge/demos/swift
195
198
  - lib/rouge/demos/tap
@@ -257,6 +260,7 @@ files:
257
260
  - lib/rouge/lexers/biml.rb
258
261
  - lib/rouge/lexers/bpf.rb
259
262
  - lib/rouge/lexers/brainfuck.rb
263
+ - lib/rouge/lexers/brightscript.rb
260
264
  - lib/rouge/lexers/bsl.rb
261
265
  - lib/rouge/lexers/c.rb
262
266
  - lib/rouge/lexers/ceylon.rb
@@ -327,6 +331,7 @@ files:
327
331
  - lib/rouge/lexers/irb.rb
328
332
  - lib/rouge/lexers/isbl.rb
329
333
  - lib/rouge/lexers/isbl/builtins.rb
334
+ - lib/rouge/lexers/janet.rb
330
335
  - lib/rouge/lexers/java.rb
331
336
  - lib/rouge/lexers/javascript.rb
332
337
  - lib/rouge/lexers/jinja.rb
@@ -420,6 +425,7 @@ files:
420
425
  - lib/rouge/lexers/sqf.rb
421
426
  - lib/rouge/lexers/sqf/keywords.rb
422
427
  - lib/rouge/lexers/sql.rb
428
+ - lib/rouge/lexers/ssh.rb
423
429
  - lib/rouge/lexers/supercollider.rb
424
430
  - lib/rouge/lexers/swift.rb
425
431
  - lib/rouge/lexers/tap.rb