rouge 3.6.0 → 3.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/rouge/demos/ada +26 -0
  3. data/lib/rouge/demos/cuda +11 -0
  4. data/lib/rouge/demos/gdscript +18 -0
  5. data/lib/rouge/demos/hocon +8 -0
  6. data/lib/rouge/demos/mason +22 -0
  7. data/lib/rouge/demos/opentype_feature_file +6 -0
  8. data/lib/rouge/demos/reasonml +12 -0
  9. data/lib/rouge/demos/sas +13 -0
  10. data/lib/rouge/formatters/tex.rb +3 -0
  11. data/lib/rouge/guessers/disambiguation.rb +4 -0
  12. data/lib/rouge/lexers/ada.rb +162 -0
  13. data/lib/rouge/lexers/cuda.rb +35 -0
  14. data/lib/rouge/lexers/escape.rb +3 -0
  15. data/lib/rouge/lexers/gdscript.rb +171 -0
  16. data/lib/rouge/lexers/gherkin.rb +4 -2
  17. data/lib/rouge/lexers/graphql.rb +10 -3
  18. data/lib/rouge/lexers/handlebars.rb +14 -3
  19. data/lib/rouge/lexers/hocon.rb +86 -0
  20. data/lib/rouge/lexers/html.rb +2 -2
  21. data/lib/rouge/lexers/igorpro.rb +1 -1
  22. data/lib/rouge/lexers/json.rb +43 -5
  23. data/lib/rouge/lexers/mason.rb +115 -0
  24. data/lib/rouge/lexers/ocaml.rb +12 -48
  25. data/lib/rouge/lexers/ocaml/common.rb +53 -0
  26. data/lib/rouge/lexers/opentype_feature_file.rb +113 -0
  27. data/lib/rouge/lexers/php.rb +31 -9
  28. data/lib/rouge/lexers/php/builtins.rb +181 -174
  29. data/lib/rouge/lexers/reasonml.rb +65 -0
  30. data/lib/rouge/lexers/rust.rb +12 -9
  31. data/lib/rouge/lexers/sas.rb +563 -0
  32. data/lib/rouge/lexers/smarty.rb +10 -10
  33. data/lib/rouge/tex_theme_renderer.rb +3 -0
  34. data/lib/rouge/themes/magritte.rb +1 -1
  35. data/lib/rouge/themes/thankful_eyes.rb +1 -1
  36. data/lib/rouge/themes/tulip.rb +1 -1
  37. data/lib/rouge/version.rb +1 -1
  38. data/rouge.gemspec +0 -1
  39. metadata +19 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '0978a751e99189848662ab1f4d6b3763ff4ffc6bafa51d53f74a5f7d085492f5'
4
- data.tar.gz: 06b154a4db8264d688c8a279c04ca6d82f8f188ae184b75a4b75df8726af3b28
3
+ metadata.gz: 71832bb306e80d00d6416e2e0c7787810cee88f614afbf5e31264512fe7914e5
4
+ data.tar.gz: f7228f6567515239ade1d9de8c37e437ece59ba54bb81566d008df7db25545f7
5
5
  SHA512:
6
- metadata.gz: 1296057ef9206c038ba0da5a2c06e7e9658c95ece00bc98e8b5e22d53865930fd132ea5c3bbb9eaf6d1590c38b4680e9a83e5a7101e6a4ad5aab1be4910f01d2
7
- data.tar.gz: 34acb9f469772310659845294d8fd3adfe989102cc6533a9632e64f41f1f20ad42f2e3951a0377ce8380b83b3a886178829c70868df987eb7f16f02b5f131272
6
+ metadata.gz: f5441fc76804158ae89d9c05c11f430247c4966fccc4d12e5f6690d1081f9da6221a05b92d696022fa0b2b0655760f4cd6e86e27080556be41e995e47c15901f
7
+ data.tar.gz: 16a2988f811ff0eb93133ce6f812f7217d29d6f34ec7838211197ebf8db48bd8a84e7f8bf4d330d6be885f49d49a5b9ad94697144b2746aab5ca5d4f20bb5aba
@@ -0,0 +1,26 @@
1
+ with Ada.Directories;
2
+ with Ada.Direct_IO;
3
+ with Ada.Text_IO;
4
+
5
+ procedure Extra_IO.Read_File (Name : String) is
6
+
7
+ package Dirs renames Ada.Directories;
8
+ package Text_IO renames Ada.Text_IO;
9
+
10
+ -- Get the size of the file for a new string.
11
+ Size : Natural := Natural (Dirs.Size (Name));
12
+ subtype File_String is String (1 .. Size);
13
+
14
+ -- Instantiate Direct_IO for our file type.
15
+ package FIO is new Ada.Direct_IO (File_String);
16
+
17
+ File : FIO.File_Type;
18
+ Contents : File_String;
19
+
20
+ begin
21
+ FIO.Open (File, FIO.In_File, Name);
22
+ FIO.Read (File, Contents);
23
+ FIO.Close (File);
24
+
25
+ Text_IO.Put (Contents);
26
+ end Extra_IO.Read_File;
@@ -0,0 +1,11 @@
1
+ #include <cstdio>
2
+
3
+ __global__ void helloFromGPU() {
4
+ std::printf("Hello World\n");
5
+ __syncthreads();
6
+ }
7
+
8
+ int main() {
9
+ dim3 block(1, 10);
10
+ helloFromGPU<<<1, block>>>();
11
+ }
@@ -0,0 +1,18 @@
1
+ extends Node
2
+
3
+ # Variables & Built-in Types
4
+
5
+ var a = 5
6
+ var b = true
7
+ var s = "Hello"
8
+ var arr = [1, 2, 3]
9
+
10
+ # Constants & Enums
11
+
12
+ const ANSWER = 42
13
+ enum { UNIT_NEUTRAL, UNIT_ENEMY, UNIT_ALLY }
14
+
15
+ # Functions
16
+
17
+ func _ready():
18
+ print("Hello, World")
@@ -0,0 +1,8 @@
1
+ # These are our own config values defined by the app
2
+ simple-app {
3
+ answer = 42
4
+ }
5
+
6
+ # Here we override some values used by a library
7
+ simple-lib.foo = "This value comes from simple-app's application.conf"
8
+ simple-lib.whatever = "This value comes from simple-app's application.conf"
@@ -0,0 +1,22 @@
1
+ <%doc>
2
+ This is a mason component.
3
+ # This is a comment.
4
+ </%doc>
5
+
6
+ <%args>
7
+ $color # this argument is required!
8
+ $size => 20 # default size
9
+ $country => undef # this argument is optional, default value is 'undef'
10
+ @items => (1, 2, 'something else')
11
+ %pairs => (name => "John", age => 29)
12
+ </%args>
13
+
14
+ % # A random block of Perl code
15
+ <%perl>
16
+ my @people = ('mary' 'john' 'pete' 'david');
17
+ </%perl>
18
+
19
+ % # Note how each line of code begins with the mandatory %
20
+ % foreach my $person (@people) {
21
+ Name: <% $person %>
22
+ % }
@@ -0,0 +1,6 @@
1
+ languagesystem DFLT dflt;
2
+
3
+ feature liga {
4
+ sub f i by f_i;
5
+ } liga;
6
+
@@ -0,0 +1,12 @@
1
+ /* I like a teacher who gives you something to take
2
+ home to think about besides homework. */
3
+ let gpa_score = 5.0;
4
+ type schoolPerson = Teacher | Director | Student(string);
5
+
6
+ let greeting = person =>
7
+ switch (person) {
8
+ | Teacher => "Hey Professor!"
9
+ | Director => "Hello Director."
10
+ | Student("Richard") => "Still here Ricky?"
11
+ | Student(anyOtherName) => "Hey, " ++ anyOtherName ++ "."
12
+ };
@@ -0,0 +1,13 @@
1
+ data sim;
2
+ do i = 1 to 100;
3
+ x1 = rand("Normal");
4
+ x2 = rand("Binomial", 0.5, 100);
5
+ output;
6
+ end;
7
+ run;
8
+
9
+ proc means data=sashelp.class;
10
+ class sex;
11
+ var height weight;
12
+ output out = mean_by_sex;
13
+ run;
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
1
4
  module Rouge
2
5
  module Formatters
3
6
  class Tex < Formatter
@@ -86,7 +86,11 @@ module Rouge
86
86
  next Mathematica if contains?('(*')
87
87
  next Mathematica if contains?(':=')
88
88
 
89
+ next Mason if matches?(/<%(def|method|text|doc|args|flags|attr|init|once|shared|perl|cleanup|filter)([^>]*)(>)/)
90
+
89
91
  next Matlab if matches?(/^\s*?%/)
92
+
93
+ next Mason if matches? %r!(</?%|<&)!
90
94
  end
91
95
 
92
96
  disambiguate '*.php' do
@@ -0,0 +1,162 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Ada < RegexLexer
7
+ tag 'ada'
8
+ filenames '*.ada', '*.ads', '*.adb', '*.gpr'
9
+ mimetypes 'text/x-ada'
10
+
11
+ title 'Ada'
12
+ desc 'The Ada 2012 programming language'
13
+
14
+ # Ada identifiers are Unicode with underscores only allowed as separators.
15
+ ID = /\b[[:alpha:]](?:\p{Pc}?[[:alnum:]])*\b/
16
+
17
+ # Numerals can also contain underscores.
18
+ NUM = /\d(_?\d)*/
19
+ XNUM = /\h(_?\h)*/
20
+ EXP = /(E[-+]?#{NUM})?/i
21
+
22
+ # Return a hash mapping lower-case identifiers to token classes.
23
+ def self.idents
24
+ @idents ||= Hash.new(Name).tap do |h|
25
+ %w(
26
+ abort abstract accept access aliased all array at begin body
27
+ case constant declare delay delta digits do else elsif end
28
+ exception exit for generic goto if in interface is limited
29
+ loop new null of others out overriding pragma private
30
+ protected raise range record renames requeue return reverse
31
+ select separate some synchronized tagged task terminate then
32
+ until use when while with
33
+ ).each {|w| h[w] = Keyword}
34
+
35
+ %w(abs and mod not or rem xor).each {|w| h[w] = Operator::Word}
36
+
37
+ %w(
38
+ entry function package procedure subtype type
39
+ ).each {|w| h[w] = Keyword::Declaration}
40
+
41
+ %w(
42
+ boolean character constraint_error duration float integer
43
+ natural positive long_float long_integer long_long_float
44
+ long_long_integer program_error short_float short_integer
45
+ short_short_integer storage_error string tasking_error
46
+ wide_character wide_string wide_wide_character
47
+ wide_wide_string
48
+ ).each {|w| h[w] = Name::Builtin}
49
+ end
50
+ end
51
+
52
+ state :whitespace do
53
+ rule %r{\s+}m, Text
54
+ rule %r{--.*$}, Comment::Single
55
+ end
56
+
57
+ state :dquote_string do
58
+ rule %r{[^"\n]+}, Literal::String::Double
59
+ rule %r{""}, Literal::String::Escape
60
+ rule %r{"}, Literal::String::Double, :pop!
61
+ rule %r{\n}, Error, :pop!
62
+ end
63
+
64
+ state :attr do
65
+ mixin :whitespace
66
+ rule ID, Name::Attribute, :pop!
67
+ rule %r{}, Text, :pop!
68
+ end
69
+
70
+ # Handle a dotted name immediately following a declaration keyword.
71
+ state :decl_name do
72
+ mixin :whitespace
73
+ rule %r{body\b}i, Keyword::Declaration # package body Foo.Bar is...
74
+ rule %r{(#{ID})(\.)} do
75
+ groups Name::Namespace, Punctuation
76
+ end
77
+ # function "<=" (Left, Right: Type) is ...
78
+ rule %r{#{ID}|"(and|or|xor|/?=|<=?|>=?|\+|–|&\|/|mod|rem|\*?\*|abs|not)"},
79
+ Name::Function, :pop!
80
+ rule %r{}, Text, :pop!
81
+ end
82
+
83
+ # Handle a sequence of library unit names: with Ada.Foo, Ada.Bar;
84
+ #
85
+ # There's a chance we entered this state mistakenly since 'with'
86
+ # has multiple other uses in Ada (none of which are likely to
87
+ # appear at the beginning of a line). Try to bail as soon as
88
+ # possible if we see something suspicious like keywords.
89
+ #
90
+ # See ada_spec.rb for some examples.
91
+ state :libunit_name do
92
+ mixin :whitespace
93
+
94
+ rule ID do |m|
95
+ t = self.class.idents[m[0].downcase]
96
+ if t <= Name
97
+ # Convert all kinds of Name to namespaces in this context.
98
+ token Name::Namespace
99
+ else
100
+ # Yikes, we're not supposed to get a keyword in a library unit name!
101
+ # We probably entered this state by mistake, so try to fix it.
102
+ token t
103
+ if t == Keyword::Declaration
104
+ goto :decl_name
105
+ else
106
+ pop!
107
+ end
108
+ end
109
+ end
110
+
111
+ rule %r{[.,]}, Punctuation
112
+ rule %r{}, Text, :pop!
113
+ end
114
+
115
+ state :root do
116
+ mixin :whitespace
117
+
118
+ # String literals.
119
+ rule %r{'.'}, Literal::String::Char
120
+ rule %r{"[^"\n]*}, Literal::String::Double, :dquote_string
121
+
122
+ # Real literals.
123
+ rule %r{#{NUM}\.#{NUM}#{EXP}}, Literal::Number::Float
124
+ rule %r{#{NUM}##{XNUM}\.#{XNUM}##{EXP}}, Literal::Number::Float
125
+
126
+ # Integer literals.
127
+ rule %r{2#[01](_?[01])*##{EXP}}, Literal::Number::Bin
128
+ rule %r{8#[0-7](_?[0-7])*##{EXP}}, Literal::Number::Oct
129
+ rule %r{16##{XNUM}*##{EXP}}, Literal::Number::Hex
130
+ rule %r{#{NUM}##{XNUM}##{EXP}}, Literal::Number::Integer
131
+ rule %r{#{NUM}#\w+#}, Error
132
+ rule %r{#{NUM}#{EXP}}, Literal::Number::Integer
133
+
134
+ # Special constructs.
135
+ rule %r{'}, Punctuation, :attr
136
+ rule %r{<<#{ID}>>}, Name::Label
137
+
138
+ # Context clauses are tricky because the 'with' keyword is used
139
+ # for many purposes. Detect at beginning of the line only.
140
+ rule %r{^(?:(limited)(\s+))?(?:(private)(\s+))?(with)\b}i do
141
+ groups Keyword::Namespace, Text, Keyword::Namespace, Text, Keyword::Namespace
142
+ push :libunit_name
143
+ end
144
+
145
+ # Operators and punctuation characters.
146
+ rule %r{[+*/&<=>|]|-|=>|\.\.|\*\*|[:></]=|<<|>>|<>}, Operator
147
+ rule %r{[.,:;()]}, Punctuation
148
+
149
+ rule ID do |m|
150
+ t = self.class.idents[m[0].downcase]
151
+ token t
152
+ if t == Keyword::Declaration
153
+ push :decl_name
154
+ end
155
+ end
156
+
157
+ # Flag word-like things that don't match the ID pattern.
158
+ rule %r{\b(\p{Pc}|[[alpha]])\p{Word}*}, Error
159
+ end
160
+ end
161
+ end
162
+ end
@@ -0,0 +1,35 @@
1
+ # -*- coding: utf-8 -*- #
2
+
3
+ module Rouge
4
+ module Lexers
5
+ load_lexer 'cpp.rb'
6
+
7
+ class CUDA < Cpp
8
+ title "CUDA"
9
+ desc "Compute Unified Device Architecture, used for programming with NVIDIA GPU"
10
+
11
+ tag 'cuda'
12
+ filenames '*.cu', '*.cuh'
13
+
14
+ def self.keywords
15
+ @keywords ||= super + Set.new(%w(
16
+ __global__ __device__ __host__ __noinline__ __forceinline__
17
+ __constant__ __shared__ __managed__ __restrict__
18
+ ))
19
+ end
20
+
21
+ def self.keywords_type
22
+ @keywords_type ||= super + Set.new(%w(
23
+ char1 char2 char3 char4 uchar1 uchar2 uchar3 uchar4
24
+ short1 short2 short3 short4 ushort1 ushort2 ushort3 ushort4
25
+ int1 int2 int3 int4 uint1 uint2 uint3 uint4
26
+ long1 long2 long3 long4 ulong1 ulong2 ulong3 ulong4
27
+ longlong1 longlong2 longlong3 longlong4
28
+ ulonglong1 ulonglong2 ulonglong3 ulonglong4
29
+ float1 float2 float3 float4 double1 double2 double3 double4
30
+ dim3
31
+ ))
32
+ end
33
+ end
34
+ end
35
+ end
@@ -1,3 +1,6 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
1
4
  module Rouge
2
5
  module Lexers
3
6
  class Escape < Lexer
@@ -0,0 +1,171 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class GDScript < RegexLexer
7
+ title "GDScript"
8
+ desc "The Godot Engine programming language (https://godotengine.org/)"
9
+ tag 'gdscript'
10
+ aliases 'gd', 'gdscript'
11
+ filenames '*.gd'
12
+ mimetypes 'text/x-gdscript', 'application/x-gdscript'
13
+
14
+ def self.keywords
15
+ @keywords = %w(
16
+ and in not or as breakpoint class class_name extends is func setget
17
+ signal tool const enum export onready static var break continue
18
+ if elif else for pass return match while remote master puppet
19
+ remotesync mastersync puppetsync
20
+ ).join('|')
21
+ end
22
+
23
+ # Reserved for future implementation
24
+ def self.keywords_reserved
25
+ @keywords_reserved = %w(
26
+ do switch case
27
+ ).join('|')
28
+ end
29
+
30
+ def self.builtins
31
+ builtins = %w(
32
+ Color8 ColorN abs acos asin assert atan atan2 bytes2var ceil char
33
+ clamp convert cos cosh db2linear decimals dectime deg2rad dict2inst
34
+ ease exp floor fmod fposmod funcref hash inst2dict instance_from_id
35
+ is_inf is_nan lerp linear2db load log max min nearest_po2 pow
36
+ preload print print_stack printerr printraw prints printt rad2deg
37
+ rand_range rand_seed randf randi randomize range round seed sign
38
+ sin sinh sqrt stepify str str2var tan tan tanh type_exist typeof
39
+ var2bytes var2str weakref yield
40
+ ).join('|')
41
+ end
42
+
43
+ def self.builtins_type
44
+ @builtins_type = %w(
45
+ bool int float String Vector2 Rect2 Transform2D Vector3 AABB
46
+ Plane Quat Basis Transform Color RID Object NodePath Dictionary
47
+ Array PoolByteArray PoolIntArray PoolRealArray PoolStringArray
48
+ PoolVector2Array PoolVector3Array PoolColorArray null
49
+ ).join('|')
50
+ end
51
+
52
+ state :root do
53
+ rule %r/\n/, Text
54
+ rule %r/[^\S\n]+/, Text
55
+ rule %r/#.*/, Comment::Single
56
+ rule %r/[\[\]{}:(),;]/, Punctuation
57
+ rule %r/\\\n/, Text
58
+ rule %r/(in|and|or|not)\b/, Operator::Word
59
+ rule %r/!=|==|<<|>>|&&|\+=|-=|\*=|\/=|%=|&=|\|=|\|\||[-~+\/*%=<>&^.!|$]/, Operator
60
+ rule %r/(func)((?:\s|\\)+)/ do
61
+ groups Keyword, Text
62
+ push :funcname
63
+ end
64
+ rule %r/(class)((?:\s|\\)+)/ do
65
+ groups Keyword, Text
66
+ push :classname
67
+ end
68
+ mixin :keywords
69
+ mixin :builtins
70
+ rule %r/"""/, Str::Double, :escape_tdqs
71
+ rule %r/'''/, Str::Double, :escape_tsqs
72
+ rule %r/"/, Str::Double, :escape_dqs
73
+ rule %r/'/, Str::Double, :escape_sqs
74
+ mixin :name
75
+ mixin :numbers
76
+ end
77
+
78
+ state :keywords do
79
+ rule %r/\b(#{GDScript.keywords})\b/, Keyword
80
+ rule %r/\b(#{GDScript.keywords_reserved})\b/, Keyword::Reserved
81
+ end
82
+
83
+ state :builtins do
84
+ rule %r/\b(#{GDScript.builtins})\b/, Name::Builtin
85
+ rule %r/\b((self|false|true)|(PI|TAU|NAN|INF))\b/, Name::Builtin::Pseudo
86
+ rule %r/\b(#{GDScript.builtins_type})\b/, Keyword::Type
87
+ end
88
+
89
+ state :numbers do
90
+ rule %r/(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?/, Num::Float
91
+ rule %r/\d+[eE][+-]?[0-9]+j?/, Num::Float
92
+ rule %r/0[xX][a-fA-F0-9]+/, Num::Hex
93
+ rule %r/\d+j?/, Num::Integer
94
+ end
95
+
96
+ state :name do
97
+ rule %r/[a-zA-Z_]\w*/, Name
98
+ end
99
+
100
+ state :funcname do
101
+ rule %r/[a-zA-Z_]\w*/, Name::Function, :pop!
102
+ end
103
+
104
+ state :classname do
105
+ rule %r/[a-zA-Z_]\w*/, Name::Class, :pop!
106
+ end
107
+
108
+ state :string_escape do
109
+ rule %r/\\([\\abfnrtv"\']|\n|N\{.*?\}|u[a-fA-F0-9]{4}|U[a-fA-F0-9]{8}|x[a-fA-F0-9]{2}|[0-7]{1,3})/, Str::Escape
110
+ end
111
+
112
+ state :strings_single do
113
+ rule %r/%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]/, Str::Interpol
114
+ rule %r/[^\\'%\n]+/, Str::Single
115
+ rule %r/["\\]/, Str::Single
116
+ rule %r/%/, Str::Single
117
+ end
118
+
119
+ state :strings_double do
120
+ rule %r/%(\(\w+\))?[-#0 +]*([0-9]+|[*])?(\.([0-9]+|[*]))?[hlL]?[E-GXc-giorsux%]/, Str::Interpol
121
+ rule %r/[^\\"%\n]+/, Str::Double
122
+ rule %r/['\\]/, Str::Double
123
+ rule %r/%/, Str::Double
124
+ end
125
+
126
+ state :dqs do
127
+ rule %r/"/, Str::Double, :pop!
128
+ rule %r/\\\\|\\"|\\\n/, Str::Escape
129
+ mixin :strings_double
130
+ end
131
+
132
+ state :escape_dqs do
133
+ mixin :string_escape
134
+ mixin :dqs
135
+ end
136
+
137
+ state :sqs do
138
+ rule %r/'/, Str::Single, :pop!
139
+ rule %r/\\\\|\\'|\\\n/, Str::Escape
140
+ mixin :strings_single
141
+ end
142
+
143
+ state :escape_sqs do
144
+ mixin :string_escape
145
+ mixin :sqs
146
+ end
147
+
148
+ state :tdqs do
149
+ rule %r/"""/, Str::Double, :pop!
150
+ mixin :strings_double
151
+ rule %r/\n/, Str::Double
152
+ end
153
+
154
+ state :escape_tdqs do
155
+ mixin :string_escape
156
+ mixin :tdqs
157
+ end
158
+
159
+ state :tsqs do
160
+ rule %r/'''/, Str::Single, :pop!
161
+ mixin :strings_single
162
+ rule %r/\n/, Str::Single
163
+ end
164
+
165
+ state :escape_tsqs do
166
+ mixin :string_escape
167
+ mixin :tsqs
168
+ end
169
+ end
170
+ end
171
+ end