rouge 3.29.0 → 3.30.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: 15e78361e4f2dde8ae802ffcd36cc0b1e8e9124c2bbe0d3182a767244047a9e0
4
- data.tar.gz: 661838ffd5b8c6ff8ac894312293aa6c46b36abed76ccc8f0932358e6478c8b1
3
+ metadata.gz: acc37e14414bcaa3f67dda77f1b746f8035cfc972dc807610b4a1ef4fcffe848
4
+ data.tar.gz: 2380291e01345a7251f229dddf858d612f64d89f7ef93d7b75b2c44fa9a093a6
5
5
  SHA512:
6
- metadata.gz: 21f210c421a0a0137d57f2c7fd3b3d931a1b481a276e6fe6eb296a5e1572ccb7ffd3912a8455e98c362b863ab52773b27c7d9135e2cddaa7b75b5fa324f4036e
7
- data.tar.gz: 9bb3d495c856a8e790cc38736afb4e187b5b34fa8d1f0c1b99ff60af63cec60a9312ee4a69a642e31938dd4586647e224f311afdde6d343bcafa35b64110f2a3
6
+ metadata.gz: a4d60e1f37e66b4991b040ff82db8cc59983f37923a7f8b41a44a149407167467b443cd6ac8bb47f8800588e82301be1d58c14175bb1513a728952be21144ed8
7
+ data.tar.gz: 6f0e6ab3786ac315f0a2d658d02091bb3b8a0b6cd75ef3aac6dc2a116eee9dd5a45b1a4c9ef11f40f0f6338ae50d7c0f0b219e9ab20de950e4ae865f3824e002
data/lib/rouge/cli.rb CHANGED
@@ -174,35 +174,38 @@ module Rouge
174
174
  yield %[usage: rougify highlight <filename> [options...]]
175
175
  yield %[ rougify highlight [options...]]
176
176
  yield %[]
177
- yield %[--input-file|-i <filename> specify a file to read, or - to use stdin]
177
+ yield %[--input-file|-i <filename> specify a file to read, or - to use stdin]
178
178
  yield %[]
179
- yield %[--lexer|-l <lexer> specify the lexer to use.]
180
- yield %[ If not provided, rougify will try to guess]
181
- yield %[ based on --mimetype, the filename, and the]
182
- yield %[ file contents.]
179
+ yield %[--lexer|-l <lexer> specify the lexer to use.]
180
+ yield %[ If not provided, rougify will try to guess]
181
+ yield %[ based on --mimetype, the filename, and the]
182
+ yield %[ file contents.]
183
183
  yield %[]
184
- yield %[--formatter|-f <opts> specify the output formatter to use.]
185
- yield %[ If not provided, rougify will default to]
186
- yield %[ terminal256.]
184
+ yield %[--formatter-preset|-f <opts> specify the output formatter to use.]
185
+ yield %[ If not provided, rougify will default to]
186
+ yield %[ terminal256. options are: terminal256,]
187
+ yield %[ terminal-truecolor, html, html-pygments,]
188
+ yield %[ html-inline, html-line-table, html-table,]
189
+ yield %[ null/raw/tokens, or tex.]
187
190
  yield %[]
188
- yield %[--theme|-t <theme> specify the theme to use for highlighting]
189
- yield %[ the file. (only applies to some formatters)]
191
+ yield %[--theme|-t <theme> specify the theme to use for highlighting]
192
+ yield %[ the file. (only applies to some formatters)]
190
193
  yield %[]
191
- yield %[--mimetype|-m <mimetype> specify a mimetype for lexer guessing]
194
+ yield %[--mimetype|-m <mimetype> specify a mimetype for lexer guessing]
192
195
  yield %[]
193
- yield %[--lexer-opts|-L <opts> specify lexer options in CGI format]
194
- yield %[ (opt1=val1&opt2=val2)]
196
+ yield %[--lexer-opts|-L <opts> specify lexer options in CGI format]
197
+ yield %[ (opt1=val1&opt2=val2)]
195
198
  yield %[]
196
- yield %[--formatter-opts|-F <opts> specify formatter options in CGI format]
197
- yield %[ (opt1=val1&opt2=val2)]
199
+ yield %[--formatter-opts|-F <opts> specify formatter options in CGI format]
200
+ yield %[ (opt1=val1&opt2=val2)]
198
201
  yield %[]
199
- yield %[--require|-r <filename> require a filename or library before]
200
- yield %[ highlighting]
202
+ yield %[--require|-r <filename> require a filename or library before]
203
+ yield %[ highlighting]
201
204
  yield %[]
202
- yield %[--escape allow the use of escapes between <! and !>]
205
+ yield %[--escape allow the use of escapes between <! and !>]
203
206
  yield %[]
204
- yield %[--escape-with <l> <r> allow the use of escapes between custom]
205
- yield %[ delimiters. implies --escape]
207
+ yield %[--escape-with <l> <r> allow the use of escapes between custom]
208
+ yield %[ delimiters. implies --escape]
206
209
  end
207
210
 
208
211
  # There is no consistent way to do this, but this is used elsewhere,
@@ -0,0 +1,16 @@
1
+ theory demo imports Main begin
2
+
3
+ section ‹Inductive predicates for lists›
4
+
5
+ datatype 'a list = Nil ("[]") | Cons 'a "'a list" ("_ # _")
6
+
7
+ fun length :: "'a list ⇒ nat" where
8
+ "length [] = 0" | "length (x # xs) = 1 + length xs"
9
+
10
+ inductive ζ :: "'a list ⇒ nat ⇒ bool" where
11
+ Nil[intro!]: "ζ [] 0" |
12
+ Cons[intro]: "ζ xs l ⟹ ζ (x # xs) (1 + l)"
13
+
14
+ (* Not the answer? *)
15
+ lemma "ζ xs 42"
16
+ oops
@@ -0,0 +1,10 @@
1
+ project('tutorial', 'c', version: '0.2.3')
2
+ executable('demo', 'main.c')
3
+
4
+ version_array = meson.project_version().split('.')
5
+ api_version = '@0@.@1@'.format(version_array[0], version_array[1])
6
+
7
+ d = dependency('foo', required : get_option('myfeature'))
8
+ if d.found()
9
+ app = executable('app', 'app.c', dependencies : [d])
10
+ endif
@@ -0,0 +1,35 @@
1
+ % Functional Recursion: ;
2
+ fact IS RECUR [ 0 =, 1 first, pass, product, -1 +] % from wikipedia;
3
+
4
+ % Product of a range: ;
5
+ fact IS * count;
6
+
7
+ % Plain recursion: ;
8
+ fact IS OPERATION x {
9
+ if x = 0 then 1 else x * fact (x - 1) endif
10
+ };
11
+
12
+ % While loop: ;
13
+ fact IS OPERATION x {
14
+ prod := 1;
15
+ WHILE x > 0 DO
16
+ prod := prod * x;
17
+ x := x - 1;
18
+ ENDWHILE;
19
+ prod
20
+ }
21
+
22
+ % A basic divide by zero error: ;
23
+ 1 / 0
24
+ # OUTPUT:
25
+ ?div
26
+
27
+ % Errors are also values called faults, giving you their location: ;
28
+ 5 / 5 10 0 8
29
+ # OUTPUT:
30
+ 1. 0.5 ?div 0.625
31
+
32
+ % You can also define custom faults using 'fault': ;
33
+ fault 'this is an error'
34
+ # OUTPUT:
35
+ this is an error
@@ -131,6 +131,13 @@ module Rouge
131
131
  next TeX if matches?(/\A\s*(?:\\|%)/)
132
132
  next Apex
133
133
  end
134
+
135
+ disambiguate '*.pp' do
136
+ next Pascal if matches?(/\b(function|begin|var)\b/)
137
+ next Pascal if matches?(/\b(end(;|\.))/)
138
+
139
+ Puppet
140
+ end
134
141
  end
135
142
  end
136
143
  end
@@ -5,7 +5,7 @@ module Rouge
5
5
  module Lexers
6
6
  class AppleScript < RegexLexer
7
7
  title "AppleScript"
8
- desc "The AppleScript scripting language by Apple Inc. (http://developer.apple.com/applescript/)"
8
+ desc "The AppleScript scripting language by Apple Inc. (https://developer.apple.com/library/archive/documentation/AppleScript/Conceptual/AppleScriptLangGuide/introduction/ASLR_intro.html)"
9
9
 
10
10
  tag 'applescript'
11
11
  aliases 'applescript'
@@ -71,6 +71,7 @@ module Rouge
71
71
  rule %r/\bnullptr\b/, Name::Builtin
72
72
  rule %r/(?:u8|u|U|L)?R"([a-zA-Z0-9_{}\[\]#<>%:;.?*\+\-\/\^&|~!=,"']{,16})\(.*?\)\1"/m, Str
73
73
  rule %r/(::|<=>)/, Operator
74
+ rule %r/[{}]/, Punctuation
74
75
  end
75
76
 
76
77
  state :classname do
@@ -61,7 +61,8 @@ module Rouge
61
61
 
62
62
  rule %r/#{id}:/, Name::Label
63
63
  rule %r/\$?#{id}/, Name
64
- rule %r/[~^*!%&\[\](){}<>\|+=:;,.\/?-]/, Operator
64
+ rule %r/[~^*!%&\|+=:\/?-]/, Operator
65
+ rule %r/[\[\](){}<>\.,;]/, Punctuation
65
66
  rule %r/\d*\.\d+([eE]\-?\d+)?/, Num::Float
66
67
  rule %r/0x[\da-fA-F]+/, Num::Hex
67
68
  rule %r/\d+L?/, Num::Integer
@@ -7,7 +7,7 @@ module Rouge
7
7
  title "Groovy"
8
8
  desc 'The Groovy programming language (http://www.groovy-lang.org/)'
9
9
  tag 'groovy'
10
- filenames '*.groovy', 'Jenkinsfile'
10
+ filenames '*.groovy', 'Jenkinsfile', '*.Jenkinsfile'
11
11
  mimetypes 'text/x-groovy'
12
12
 
13
13
  def self.detect?(text)
@@ -0,0 +1,251 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+ # Lexer adapted from https://github.com/pygments/pygments/blob/ad55974ce83b85dbb333ab57764415ab84169461/pygments/lexers/theorem.py
4
+
5
+ module Rouge
6
+ module Lexers
7
+ class Isabelle < RegexLexer
8
+ title "Isabelle"
9
+ desc 'Isabelle theories (isabelle.in.tum.de)'
10
+ tag 'isabelle'
11
+ aliases 'isa', 'Isabelle'
12
+ filenames '*.thy'
13
+ mimetypes 'text/x-isabelle'
14
+
15
+ def self.keyword_minor
16
+ @keyword_minor ||= Set.new %w(
17
+ and assumes attach avoids binder checking
18
+ class_instance class_relation code_module congs
19
+ constant constrains datatypes defines file fixes
20
+ for functions hints identifier if imports in
21
+ includes infix infixl infixr is keywords lazy
22
+ module_name monos morphisms no_discs_sels notes
23
+ obtains open output overloaded parametric permissive
24
+ pervasive rep_compat shows structure type_class
25
+ type_constructor unchecked unsafe where
26
+ )
27
+ end
28
+
29
+ def self.keyword_diag
30
+ @keyword_diag ||= Set.new %w(
31
+ ML_command ML_val class_deps code_deps code_thms
32
+ display_drafts find_consts find_theorems find_unused_assms
33
+ full_prf help locale_deps nitpick pr prf
34
+ print_abbrevs print_antiquotations print_attributes
35
+ print_binds print_bnfs print_bundles
36
+ print_case_translations print_cases print_claset
37
+ print_classes print_codeproc print_codesetup
38
+ print_coercions print_commands print_context
39
+ print_defn_rules print_dependencies print_facts
40
+ print_induct_rules print_inductives print_interps
41
+ print_locale print_locales print_methods print_options
42
+ print_orders print_quot_maps print_quotconsts
43
+ print_quotients print_quotientsQ3 print_quotmapsQ3
44
+ print_rules print_simpset print_state print_statement
45
+ print_syntax print_theorems print_theory print_trans_rules
46
+ prop pwd quickcheck refute sledgehammer smt_status
47
+ solve_direct spark_status term thm thm_deps thy_deps
48
+ try try0 typ unused_thms value values welcome
49
+ print_ML_antiquotations print_term_bindings values_prolog
50
+ )
51
+ end
52
+
53
+ def self.keyword_thy
54
+ @keyword_thy ||= Set.new %w(theory begin end)
55
+ end
56
+
57
+ def self.keyword_section
58
+ @keyword_section ||= Set.new %w(header chapter)
59
+ end
60
+
61
+ def self.keyword_subsection
62
+ @keyword_subsection ||= Set.new %w(section subsection subsubsection sect subsect subsubsect)
63
+ end
64
+
65
+ def self.keyword_theory_decl
66
+ @keyword_theory_decl ||= Set.new %w(
67
+ ML ML_file abbreviation adhoc_overloading arities
68
+ atom_decl attribute_setup axiomatization bundle
69
+ case_of_simps class classes classrel codatatype
70
+ code_abort code_class code_const code_datatype
71
+ code_identifier code_include code_instance code_modulename
72
+ code_monad code_printing code_reflect code_reserved
73
+ code_type coinductive coinductive_set consts context
74
+ datatype datatype_new datatype_new_compat declaration
75
+ declare default_sort defer_recdef definition defs
76
+ domain domain_isomorphism domaindef equivariance
77
+ export_code extract extract_type fixrec fun
78
+ fun_cases hide_class hide_const hide_fact hide_type
79
+ import_const_map import_file import_tptp import_type_map
80
+ inductive inductive_set instantiation judgment lemmas
81
+ lifting_forget lifting_update local_setup locale
82
+ method_setup nitpick_params no_adhoc_overloading
83
+ no_notation no_syntax no_translations no_type_notation
84
+ nominal_datatype nonterminal notation notepad oracle
85
+ overloading parse_ast_translation parse_translation
86
+ partial_function primcorec primrec primrec_new
87
+ print_ast_translation print_translation quickcheck_generator
88
+ quickcheck_params realizability realizers recdef record
89
+ refute_params setup setup_lifting simproc_setup
90
+ simps_of_case sledgehammer_params spark_end spark_open
91
+ spark_open_siv spark_open_vcg spark_proof_functions
92
+ spark_types statespace syntax syntax_declaration text
93
+ text_raw theorems translations type_notation
94
+ type_synonym typed_print_translation typedecl hoarestate
95
+ install_C_file install_C_types wpc_setup c_defs c_types
96
+ memsafe SML_export SML_file SML_import approximate
97
+ bnf_axiomatization cartouche datatype_compat
98
+ free_constructors functor nominal_function
99
+ nominal_termination permanent_interpretation
100
+ binds defining smt2_status term_cartouche
101
+ boogie_file text_cartouche
102
+ )
103
+ end
104
+
105
+ def self.keyword_theory_script
106
+ @keyword_theory_script ||= Set.new %w(inductive_cases inductive_simps)
107
+ end
108
+
109
+ def self.keyword_theory_goal
110
+ @keyword_theory_goal ||= Set.new %w(
111
+ ax_specification bnf code_pred corollary cpodef
112
+ crunch crunch_ignore
113
+ enriched_type function instance interpretation lemma
114
+ lift_definition nominal_inductive nominal_inductive2
115
+ nominal_primrec pcpodef primcorecursive
116
+ quotient_definition quotient_type recdef_tc rep_datatype
117
+ schematic_corollary schematic_lemma schematic_theorem
118
+ spark_vc specification subclass sublocale termination
119
+ theorem typedef wrap_free_constructors
120
+ )
121
+ end
122
+
123
+ def self.keyword_qed
124
+ @keyword_qed ||= Set.new %w(by done qed)
125
+ end
126
+
127
+ def self.keyword_abandon_proof
128
+ @keyword_abandon_proof ||= Set.new %w(sorry oops)
129
+ end
130
+
131
+ def self.keyword_proof_goal
132
+ @keyword_proof_goal ||= Set.new %w(have hence interpret)
133
+ end
134
+
135
+ def self.keyword_proof_block
136
+ @keyword_proof_block ||= Set.new %w(next proof)
137
+ end
138
+
139
+ def self.keyword_proof_chain
140
+ @keyword_proof_chain ||= Set.new %w(finally from then ultimately with)
141
+ end
142
+
143
+ def self.keyword_proof_decl
144
+ @keyword_proof_decl ||= Set.new %w(
145
+ ML_prf also include including let moreover note
146
+ txt txt_raw unfolding using write
147
+ )
148
+ end
149
+
150
+ def self.keyword_proof_asm
151
+ @keyword_proof_asm ||= Set.new %w(assume case def fix presume)
152
+ end
153
+
154
+ def self.keyword_proof_asm_goal
155
+ @keyword_proof_asm_goal ||= Set.new %w(guess obtain show thus)
156
+ end
157
+
158
+ def self.keyword_proof_script
159
+ @keyword_proof_script ||= Set.new %w(apply apply_end apply_trace back defer prefer)
160
+ end
161
+
162
+ state :root do
163
+ rule %r/\s+/, Text::Whitespace
164
+ rule %r/\(\*/, Comment, :comment
165
+ rule %r/\{\*|‹/, Text, :text
166
+
167
+ rule %r/::|\[|\]|-|[:()_=,|+!?]/, Operator
168
+ rule %r/[{}.]|\.\./, Operator::Word
169
+
170
+ def word(keywords)
171
+ return %r/\b(#{keywords.join('|')})\b/
172
+ end
173
+
174
+ rule %r/[a-zA-Z]\w*/ do |m|
175
+ sym = m[0]
176
+
177
+ if self.class.keyword_minor.include?(sym) ||
178
+ self.class.keyword_proof_script.include?(sym)
179
+ token Keyword::Pseudo
180
+ elsif self.class.keyword_diag.include?(sym)
181
+ token Keyword::Type
182
+ elsif self.class.keyword_thy.include?(sym) ||
183
+ self.class.keyword_theory_decl.include?(sym) ||
184
+ self.class.keyword_qed.include?(sym) ||
185
+ self.class.keyword_proof_goal.include?(sym) ||
186
+ self.class.keyword_proof_block.include?(sym) ||
187
+ self.class.keyword_proof_decl.include?(sym) ||
188
+ self.class.keyword_proof_chain.include?(sym) ||
189
+ self.class.keyword_proof_asm.include?(sym) ||
190
+ self.class.keyword_proof_asm_goal.include?(sym)
191
+ token Keyword
192
+ elsif self.class.keyword_section.include?(sym)
193
+ token Generic::Heading
194
+ elsif self.class.keyword_subsection.include?(sym)
195
+ token Generic::Subheading
196
+ elsif self.class.keyword_theory_goal.include?(sym) ||
197
+ self.class.keyword_theory_script.include?(sym)
198
+ token Keyword::Namespace
199
+ elsif self.class.keyword_abandon_proof.include?(sym)
200
+ token Generic::Error
201
+ else
202
+ token Name
203
+ end
204
+ end
205
+
206
+ rule %r/\\<\w*>/, Str::Symbol
207
+
208
+ rule %r/'[^\W\d][.\w']*/, Name::Variable
209
+
210
+ rule %r/0[xX][\da-fA-F][\da-fA-F_]*/, Num::Hex
211
+ rule %r/0[oO][0-7][0-7_]*/, Num::Oct
212
+ rule %r/0[bB][01][01_]*/, Num::Bin
213
+
214
+ rule %r/"/, Str, :string
215
+ rule %r/`/, Str::Other, :fact
216
+ # Everything except for (most) operators whitespaces may be name
217
+ rule %r/[^\s:|\[\]\-()=,+!?{}._][^\s:|\[\]\-()=,+!?{}]*/, Name
218
+ end
219
+
220
+ state :comment do
221
+ rule %r/[^(*)]+/, Comment
222
+ rule %r/\(\*/, Comment, :comment
223
+ rule %r/\*\)/, Comment, :pop!
224
+ rule %r/[(*)]/, Comment
225
+ end
226
+
227
+ state :text do
228
+ rule %r/[^{*}‹›]+/, Text
229
+ rule %r/\{\*|‹/, Text, :text
230
+ rule %r/\*\}|›/, Text, :pop!
231
+ rule %r/[{*}]/, Text
232
+ end
233
+
234
+ state :string do
235
+ rule %r/[^"\\]+/, Str
236
+ rule %r/\\<\w*>/, Str::Symbol
237
+ rule %r/\\"/, Str
238
+ rule %r/\\/, Str
239
+ rule %r/"/, Str, :pop!
240
+ end
241
+
242
+ state :fact do
243
+ rule %r/[^`\\]+/, Str::Other
244
+ rule %r/\\<\w*>/, Str::Symbol
245
+ rule %r/\\`/, Str::Other
246
+ rule %r/\\/, Str::Other
247
+ rule %r/`/, Str::Other, :pop!
248
+ end
249
+ end
250
+ end
251
+ end
@@ -149,7 +149,7 @@ module Rouge
149
149
  rule %r/\A\s*#!.*?\n/m, Comment::Preproc, :statement
150
150
  rule %r((?<=\n)(?=\s|/|<!--)), Text, :expr_start
151
151
  mixin :comments_and_whitespace
152
- rule %r(\+\+ | -- | ~ | && | \|\| | \\(?=\n) | << | >>>? | ===
152
+ rule %r(\+\+ | -- | ~ | \?\?=? | && | \|\| | \\(?=\n) | << | >>>? | ===
153
153
  | !== )x,
154
154
  Operator, :expr_start
155
155
  rule %r([-<>+*%&|\^/!=]=?), Operator, :expr_start
@@ -0,0 +1,159 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Meson < RegexLexer
7
+ title "Meson"
8
+ desc "Meson's specification language (mesonbuild.com)"
9
+ tag 'meson'
10
+ filenames 'meson.build', 'meson_options.txt'
11
+ mimetypes 'text/x-meson'
12
+
13
+ def self.keywords
14
+ @keywords ||= %w(
15
+ continue break elif else endif
16
+ if true false foreach endforeach
17
+ )
18
+ end
19
+
20
+ def self.builtin_variables
21
+ @builtin_variables ||= %w(
22
+ meson host_machine build_machine target_machine
23
+ )
24
+ end
25
+
26
+ def self.builtin_functions
27
+ @builtin_functions ||= %w(
28
+ add_global_arguments add_project_arguments
29
+ add_global_link_arguments add_project_link_arguments add_test_setup add_languages
30
+ alias_target assert benchmark both_libraries build_target configuration_data configure_file
31
+ custom_target declare_dependency dependency disabler environment error executable
32
+ generator gettext get_option get_variable files find_library find_program
33
+ include_directories import install_data install_headers install_man install_subdir
34
+ is_disabler is_variable jar join_paths library message option project
35
+ run_target run_command set_variable subdir subdir_done
36
+ subproject summary shared_library shared_module static_library test vcs_tag warning
37
+ )
38
+ end
39
+
40
+ identifier = /[[:alpha:]_][[:alnum:]_]*/
41
+ dotted_identifier = /[[:alpha:]_.][[:alnum:]_.]*/
42
+
43
+ def current_string
44
+ @current_string ||= StringRegister.new
45
+ end
46
+
47
+ state :root do
48
+ rule %r/\n+/m, Text
49
+
50
+ rule %r/[^\S\n]+/, Text
51
+ rule %r(#(.*)?\n?), Comment::Single
52
+ rule %r/[\[\]{}:(),;.]/, Punctuation
53
+ rule %r/\\\n/, Text
54
+ rule %r/\\/, Text
55
+
56
+ rule %r/(in|and|or|not)\b/, Operator::Word
57
+ rule %r/[-+\/*%=<>]=?|!=/, Operator
58
+
59
+ rule %r/([f]?)('''|['])/i do |m|
60
+ groups Str::Affix, Str
61
+ current_string.register type: m[1].downcase, delim: m[2]
62
+ push :generic_string
63
+ end
64
+
65
+ rule %r/(?<!\.)#{identifier}\b\s*(?=\()/ do |m|
66
+ if self.class.builtin_functions.include? m[0]
67
+ token Name::Builtin
68
+ else
69
+ token Name
70
+ end
71
+ end
72
+
73
+ rule %r/(?<!\.)#{identifier}(?!\s*?:)/ do |m|
74
+ if self.class.builtin_variables.include? m[0]
75
+ token Name::Builtin
76
+ elsif self.class.keywords.include? m[0]
77
+ token Keyword
78
+ else
79
+ token Name
80
+ end
81
+ end
82
+
83
+ rule identifier, Name
84
+
85
+ rule %r/0b(_?[0-1])+/i, Num::Bin
86
+ rule %r/0o(_?[0-7])+/i, Num::Oct
87
+ rule %r/0x(_?[a-f0-9])+/i, Num::Hex
88
+ rule %r/([1-9](_?[0-9])*|0(_?0)*)/, Num::Integer
89
+ end
90
+
91
+ state :generic_string do
92
+ rule %r/[^'\\\@]+/, Str
93
+
94
+ rule %r/'''|[']/ do |m|
95
+ token Str
96
+ if current_string.delim? m[0]
97
+ current_string.remove
98
+ pop!
99
+ end
100
+ end
101
+
102
+ rule %r/(?=\\)/, Str, :generic_escape
103
+
104
+ rule %r/\@/ do |m|
105
+ if current_string.type? "f"
106
+ token Str::Interpol
107
+ push :generic_interpol
108
+ else
109
+ token Str
110
+ end
111
+ end
112
+ end
113
+
114
+ state :generic_escape do
115
+ rule %r(\\
116
+ ( [\\abfnrtv']
117
+ | N{[a-zA-Z][a-zA-Z ]+[a-zA-Z]}
118
+ | u[a-fA-F0-9]{4}
119
+ | U[a-fA-F0-9]{8}
120
+ | x[a-fA-F0-9]{2}
121
+ | [0-7]{1,3}
122
+ )
123
+ )x do
124
+ token(Str::Escape)
125
+ pop!
126
+ end
127
+
128
+ rule %r/\\./, Str, :pop!
129
+ end
130
+
131
+ state :generic_interpol do
132
+ rule %r/[^\@]+/ do |m|
133
+ recurse m[0]
134
+ end
135
+ rule %r/\@/, Str::Interpol, :pop!
136
+ end
137
+
138
+ class StringRegister < Array
139
+ def delim?(delim)
140
+ self.last[1] == delim
141
+ end
142
+
143
+ def register(type: "u", delim: "'")
144
+ self.push [type, delim]
145
+ end
146
+
147
+ def remove
148
+ self.pop
149
+ end
150
+
151
+ def type?(type)
152
+ self.last[0].include? type
153
+ end
154
+ end
155
+
156
+ private_constant :StringRegister
157
+ end
158
+ end
159
+ end
@@ -0,0 +1,166 @@
1
+ # -*- coding: utf-8 -*- #
2
+ # frozen_string_literal: true
3
+
4
+ module Rouge
5
+ module Lexers
6
+ class Nial < RegexLexer
7
+ title 'Nial'
8
+ desc 'The Nial programming language (nial-array-language.org)'
9
+ tag 'nial'
10
+ filenames '*.ndf', '*.nlg'
11
+
12
+ def self.keywords
13
+ @keywords ||= Set.new ["is", "gets", "op", "tr", ";",
14
+ "if", "then", "elseif", "else",
15
+ "endif", "case", "from", "endcase",
16
+ "begin", "end", "for", "with",
17
+ "endfor", "while", "do", "endwhile",
18
+ "repeat", "until", "endrepeat"]
19
+ end
20
+
21
+ def self.operators
22
+ @operators||= Set.new [".", "!", "#", "+", "*", "-", "<<",
23
+ "/", "<", ">>", "<=", ">", "=", ">=", "@", "|", "~="]
24
+ end
25
+
26
+ def self.punctuations
27
+ @punctuations ||= Set.new [ "{", "}", "[", "]", ",", "(", ")", ":=", ":", ";"]
28
+ end
29
+
30
+ def self.transformers
31
+ @transformers ||= Set.new ["accumulate", "across",
32
+ "bycols", "bykey", "byrows",
33
+ "converse", "down",
34
+ "eachboth", "eachall", "each",
35
+ "eachleft", "eachright",
36
+ "filter", "fold", "fork",
37
+ "grade", "inner", "iterate",
38
+ "leaf", "no_tr", "outer",
39
+ "partition", "rank", "recur",
40
+ "reduce", "reducecols", "reducerows",
41
+ "sort", "team", "timeit", "twig"]
42
+ end
43
+
44
+ def self.funcs
45
+ @funcs ||= Set.new ["operation", "expression", "and", "abs",
46
+ "allbools", "allints", "allchars", "allin",
47
+ "allreals", "allnumeric", "append",
48
+ "arcsin", "arccos", "appendfile", "apply",
49
+ "arctan", "atomic", "assign", "atversion",
50
+ "axes", "cart", "break", "blend", "breaklist",
51
+ "breakin", "bye", "callstack", "choose", "char",
52
+ "ceiling", "catenate", "charrep", "check_socket",
53
+ "cos", "content", "close", "clearws",
54
+ "clearprofile", "cols", "continue", "copyright",
55
+ "cosh", "cull", "count", "diverse", "deepplace",
56
+ "cutall", "cut", "display", "deparse",
57
+ "deepupdate", "descan", "depth", "diagram",
58
+ "div", "divide", "drop", "dropright", "edit",
59
+ "empty", "expression", "exit", "except", "erase",
60
+ "equal", "eval", "eraserecord", "execute", "exp",
61
+ "external", "exprs", "findall", "find",
62
+ "fault", "falsehood", "filestatus", "filelength",
63
+ "filepath", "filetally", "floor", "first",
64
+ "flip", "fuse", "fromraw", "front",
65
+ "gage", "getfile", "getdef", "getcommandline",
66
+ "getenv", "getname", "hitch", "grid", "getsyms",
67
+ "gradeup", "gt", "gte", "host", "in", "inverse",
68
+ "innerproduct", "inv", "ip", "ln", "link", "isboolean",
69
+ "isinteger", "ischar", "isfault", "isreal", "isphrase",
70
+ "isstring", "istruthvalue", "last", "laminate",
71
+ "like", "libpath", "library", "list", "load",
72
+ "loaddefs", "nonlocal", "max", "match", "log",
73
+ "lt", "lower", "lte", "mate", "min", "maxlength",
74
+ "mod", "mix", "minus", "nialroot", "mold", "not",
75
+ "numeric", "no_op", "no_expr", "notin",
76
+ "operation", "open", "or", "opposite", "opp",
77
+ "operators", "plus", "pick", "pack", "pass", "pair", "parse",
78
+ "paste", "phrase", "place", "picture", "placeall",
79
+ "power", "positions", "post", "quotient", "putfile",
80
+ "profile", "prod", "product", "profiletree",
81
+ "profiletable", "quiet_fault", "raise", "reach",
82
+ "random", "reciprocal", "read", "readfile",
83
+ "readchar", "readarray", "readfield",
84
+ "readscreen", "readrecord", "recip", "reshape",
85
+ "seek", "second", "rest", "reverse", "restart",
86
+ "return_status", "scan", "save", "rows", "rotate",
87
+ "seed", "see", "sublist", "sin", "simple", "shape",
88
+ "setformat", "setdeftrace", "set", "seeusercalls",
89
+ "seeprimcalls", "separator", "setwidth", "settrigger",
90
+ "setmessages", "setlogname", "setinterrupts",
91
+ "setprompt", "setprofile", "sinh", "single",
92
+ "sqrt", "solitary", "sketch", "sleep",
93
+ "socket_listen", "socket_accept", "socket_close",
94
+ "socket_bind", "socket_connect", "socket_getline",
95
+ "socket_receive", "socket_peek", "socket_read",
96
+ "socket_send", "socket_write", "solve", "split",
97
+ "sortup", "string", "status", "take", "symbols",
98
+ "sum", "system", "tan", "tally", "takeright",
99
+ "tanh", "tell", "tr", "times", "third", "time",
100
+ "toupper", "tolower", "timestamp", "tonumber",
101
+ "toraw", "toplevel", "transformer", "type",
102
+ "transpose", "trs", "truth", "unequal",
103
+ "variable", "valence", "up", "updateall",
104
+ "update", "vacate", "value", "version", "vars",
105
+ "void", "watch", "watchlist", "write", "writechars",
106
+ "writearray", "writefile", "writefield",
107
+ "writescreen", "writerecord"]
108
+ end
109
+
110
+ def self.consts
111
+ @consts ||= Set.new %w(false null pi true)
112
+ end
113
+
114
+ state :root do
115
+ rule %r/'/, Str::Single, :str
116
+ rule %r/\b[lo]+\b/, Num::Bin
117
+ rule %r/-?\d+((\.\d*)?[eE][+-]?\d|\.)\d*/, Num::Float
118
+ rule %r/\-?\d+/, Num::Integer
119
+ rule %r/`./, Str::Char
120
+ rule %r/"[^\s()\[\]{}#,;]*/, Str::Symbol
121
+ rule %r/\?[^\s()\[\]{}#,;]*/, Generic::Error
122
+ rule %r/%[^;]+;/, Comment::Multiline
123
+ rule %r/^#(.+\n)+\n/, Comment::Multiline
124
+ rule %r/:=|[\{\}\[\]\(\),:;]/ do |m|
125
+ if self.class.punctuations.include?(m[0])
126
+ token Punctuation
127
+ else
128
+ token Text
129
+ end
130
+ end
131
+ # [".", "!", "#", "+", "*", "-", "<<",
132
+ # "/", "<", ">>", "<=", ">", "=", ">=", "@", "|", "~="]
133
+ rule %r'>>|>=|<=|~=|[\.!#+*\-=></|@]' do |m|
134
+ if self.class.operators.include?(m[0])
135
+ token Operator
136
+ else
137
+ token Text
138
+ end
139
+ end
140
+
141
+ rule %r/\b[_A-Za-z]\w*\b/ do |m|
142
+ lower = m[0].downcase
143
+ if self.class.keywords.include?(lower)
144
+ token Keyword
145
+ elsif self.class.funcs.include?(lower)
146
+ token Keyword::Pseudo
147
+ elsif self.class.transformers.include?(lower)
148
+ token Name::Builtin
149
+ elsif self.class.consts.include?(lower)
150
+ token Keyword::Constant
151
+ else
152
+ token Name::Variable
153
+ end
154
+ end
155
+
156
+ rule %r/\s+/, Text
157
+ end
158
+
159
+ state :str do
160
+ rule %r/''/, Str::Escape
161
+ rule %r/[^']+/, Str::Single
162
+ rule %r/'|$/, Str::Single, :pop!
163
+ end
164
+ end
165
+ end
166
+ end
@@ -7,7 +7,7 @@ module Rouge
7
7
  tag 'pascal'
8
8
  title "Pascal"
9
9
  desc 'a procedural programming language commonly used as a teaching language.'
10
- filenames '*.pas', '*.lpr'
10
+ filenames '*.pas', '*.lpr', '*.pp'
11
11
 
12
12
  mimetypes 'text/x-pascal'
13
13
 
@@ -55,6 +55,7 @@ module Rouge
55
55
  mixin :whitespace
56
56
 
57
57
  rule %r{((0(x|X)[0-9a-fA-F]*)|(([0-9]+\.?[0-9]*)|(\.[0-9]+))((e|E)(\+|-)?[0-9]+)?)(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?}, Num
58
+ rule %r/\$[0-9A-Fa-f]+/, Num::Hex
58
59
  rule %r{[~!@#\$%\^&\*\(\)\+`\-={}\[\]:;<>\?,\.\/\|\\]}, Punctuation
59
60
  rule %r{'([^']|'')*'}, Str
60
61
  rule %r/(true|false|nil)\b/i, Name::Builtin
@@ -39,12 +39,12 @@ module Rouge
39
39
  old_function cfunction
40
40
  __class__ __dir__ __file__ __function__ __halt_compiler __line__
41
41
  __method__ __namespace__ __trait__ abstract and array as break case
42
- catch clone continue declare default die do echo else elseif
42
+ catch clone continue declare default die do echo else elseif empty
43
43
  enddeclare endfor endforeach endif endswitch endwhile eval exit
44
44
  extends final finally fn for foreach global goto if implements
45
- include include_once instanceof insteadof isset list new or parent
46
- print private protected public require require_once return self
47
- static switch throw try var while xor yield
45
+ include include_once instanceof insteadof isset list match new or
46
+ parent print private protected public readonly require require_once
47
+ return self static switch throw try unset var while xor yield
48
48
  )
49
49
  end
50
50
 
@@ -305,6 +305,7 @@ module Rouge
305
305
  rule %r/,/, Punctuation
306
306
  rule %r/[.]{3}/, Punctuation
307
307
  rule %r/=/, Operator, :in_assign
308
+ rule %r/\b(?:public|protected|private|readonly)\b/i, Keyword
308
309
  rule %r/\??#{id}/, Keyword::Type, :in_assign
309
310
  mixin :escape
310
311
  mixin :whitespace
@@ -366,7 +367,8 @@ module Rouge
366
367
  end
367
368
 
368
369
  state :in_visibility do
369
- rule %r/(?=(abstract|const|function|static)\b)/i, Keyword, :pop!
370
+ rule %r/\b(?:readonly|static)\b/i, Keyword
371
+ rule %r/(?=(abstract|const|function)\b)/i, Keyword, :pop!
370
372
  rule %r/\??#{id}/, Keyword::Type, :pop!
371
373
  mixin :escape
372
374
  mixin :whitespace
@@ -28,9 +28,14 @@ module Rouge
28
28
 
29
29
  rule %r/\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}Z/, Literal::Date
30
30
 
31
- rule %r/(\d+\.\d*|\d*\.\d+)([eE][+-]?[0-9]+)?j?/, Num::Float
32
- rule %r/\d+[eE][+-]?[0-9]+j?/, Num::Float
33
- rule %r/\-?\d+/, Num::Integer
31
+ rule %r/[+-]?\d+(?:_\d+)*\.\d+(?:_\d+)*(?:[eE][+-]?\d+(?:_\d+)*)?/, Num::Float
32
+ rule %r/[+-]?\d+(?:_\d+)*[eE][+-]?\d+(?:_\d+)*/, Num::Float
33
+ rule %r/[+-]?(?:nan|inf)/, Num::Float
34
+
35
+ rule %r/0x\h+(?:_\h+)*/, Num::Hex
36
+ rule %r/0o[0-7]+(?:_[0-7]+)*/, Num::Oct
37
+ rule %r/0b[01]+(?:_[01]+)*/, Num::Bin
38
+ rule %r/[+-]?\d+(?:_\d+)*/, Num::Integer
34
39
  end
35
40
 
36
41
  state :root do
data/lib/rouge/version.rb CHANGED
@@ -3,6 +3,6 @@
3
3
 
4
4
  module Rouge
5
5
  def self.version
6
- "3.29.0"
6
+ "3.30.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.29.0
4
+ version: 3.30.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: 2022-06-01 00:00:00.000000000 Z
11
+ date: 2022-07-30 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:
@@ -112,6 +112,7 @@ files:
112
112
  - lib/rouge/demos/io
113
113
  - lib/rouge/demos/irb
114
114
  - lib/rouge/demos/irb_output
115
+ - lib/rouge/demos/isabelle
115
116
  - lib/rouge/demos/isbl
116
117
  - lib/rouge/demos/j
117
118
  - lib/rouge/demos/janet
@@ -143,6 +144,7 @@ files:
143
144
  - lib/rouge/demos/mason
144
145
  - lib/rouge/demos/mathematica
145
146
  - lib/rouge/demos/matlab
147
+ - lib/rouge/demos/meson
146
148
  - lib/rouge/demos/minizinc
147
149
  - lib/rouge/demos/moonscript
148
150
  - lib/rouge/demos/mosel
@@ -151,6 +153,7 @@ files:
151
153
  - lib/rouge/demos/nasm
152
154
  - lib/rouge/demos/nesasm
153
155
  - lib/rouge/demos/nginx
156
+ - lib/rouge/demos/nial
154
157
  - lib/rouge/demos/nim
155
158
  - lib/rouge/demos/nix
156
159
  - lib/rouge/demos/objective_c
@@ -349,6 +352,7 @@ files:
349
352
  - lib/rouge/lexers/ini.rb
350
353
  - lib/rouge/lexers/io.rb
351
354
  - lib/rouge/lexers/irb.rb
355
+ - lib/rouge/lexers/isabelle.rb
352
356
  - lib/rouge/lexers/isbl.rb
353
357
  - lib/rouge/lexers/isbl/builtins.rb
354
358
  - lib/rouge/lexers/j.rb
@@ -387,6 +391,7 @@ files:
387
391
  - lib/rouge/lexers/matlab.rb
388
392
  - lib/rouge/lexers/matlab/builtins.rb
389
393
  - lib/rouge/lexers/matlab/keywords.rb
394
+ - lib/rouge/lexers/meson.rb
390
395
  - lib/rouge/lexers/minizinc.rb
391
396
  - lib/rouge/lexers/moonscript.rb
392
397
  - lib/rouge/lexers/mosel.rb
@@ -395,6 +400,7 @@ files:
395
400
  - lib/rouge/lexers/nasm.rb
396
401
  - lib/rouge/lexers/nesasm.rb
397
402
  - lib/rouge/lexers/nginx.rb
403
+ - lib/rouge/lexers/nial.rb
398
404
  - lib/rouge/lexers/nim.rb
399
405
  - lib/rouge/lexers/nix.rb
400
406
  - lib/rouge/lexers/objective_c.rb
@@ -520,7 +526,7 @@ metadata:
520
526
  changelog_uri: https://github.com/rouge-ruby/rouge/blob/master/CHANGELOG.md
521
527
  documentation_uri: https://rouge-ruby.github.io/docs/
522
528
  source_code_uri: https://github.com/rouge-ruby/rouge
523
- post_install_message:
529
+ post_install_message:
524
530
  rdoc_options: []
525
531
  require_paths:
526
532
  - lib
@@ -536,7 +542,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
536
542
  version: '0'
537
543
  requirements: []
538
544
  rubygems_version: 3.1.6
539
- signing_key:
545
+ signing_key:
540
546
  specification_version: 4
541
547
  summary: A pure-ruby colorizer based on pygments
542
548
  test_files: []