hank 0.1.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 +7 -0
- data/.clodignore +32 -0
- data/.rubocop.yml +59 -0
- data/CLAUDE.md +22 -0
- data/Gemfile +11 -0
- data/LICENSE +21 -0
- data/README.md +70 -0
- data/Rakefile +17 -0
- data/bin/hank +7 -0
- data/hank.gemspec +55 -0
- data/lib/hank/cli.rb +162 -0
- data/lib/hank/file_selector.rb +204 -0
- data/lib/hank/hankfile.rb +70 -0
- data/lib/hank/path_utils.rb +47 -0
- data/lib/hank/symlink_manager.rb +94 -0
- data/lib/hank/validator.rb +65 -0
- data/lib/hank/version.rb +6 -0
- data/lib/hank.rb +25 -0
- data/sorbet/config +5 -0
- data/sorbet/rbi/annotations/.gitattributes +1 -0
- data/sorbet/rbi/annotations/colorize.rbi +121 -0
- data/sorbet/rbi/annotations/minitest.rbi +119 -0
- data/sorbet/rbi/annotations/rainbow.rbi +269 -0
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/ansi.rbi +398 -0
- data/sorbet/rbi/gems/ansi@1.5.0.rbi +688 -0
- data/sorbet/rbi/gems/ast.rbi +49 -0
- data/sorbet/rbi/gems/ast@2.4.3.rbi +585 -0
- data/sorbet/rbi/gems/benchmark@0.4.0.rbi +618 -0
- data/sorbet/rbi/gems/builder.rbi +58 -0
- data/sorbet/rbi/gems/builder@3.3.0.rbi +502 -0
- data/sorbet/rbi/gems/citrus.rbi +238 -0
- data/sorbet/rbi/gems/citrus@3.0.2.rbi +1234 -0
- data/sorbet/rbi/gems/colorize.rbi +82 -0
- data/sorbet/rbi/gems/colorize@0.8.1.rbi +152 -0
- data/sorbet/rbi/gems/curses.rbi +327 -0
- data/sorbet/rbi/gems/curses@1.4.7.rbi +894 -0
- data/sorbet/rbi/gems/diffy.rbi +56 -0
- data/sorbet/rbi/gems/diffy@3.4.3.rbi +184 -0
- data/sorbet/rbi/gems/docile.rbi +36 -0
- data/sorbet/rbi/gems/docile@1.4.1.rbi +377 -0
- data/sorbet/rbi/gems/erubi@1.13.1.rbi +155 -0
- data/sorbet/rbi/gems/fiddle.rbi +120 -0
- data/sorbet/rbi/gems/fiddle@1.1.6.rbi +9 -0
- data/sorbet/rbi/gems/hank.rbi +15 -0
- data/sorbet/rbi/gems/json@2.10.2.rbi +2112 -0
- data/sorbet/rbi/gems/language_server-protocol.rbi +2868 -0
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.4.rbi +9 -0
- data/sorbet/rbi/gems/lint_roller.rbi +75 -0
- data/sorbet/rbi/gems/lint_roller@1.1.0.rbi +86 -0
- data/sorbet/rbi/gems/logger.rbi +94 -0
- data/sorbet/rbi/gems/logger@1.7.0.rbi +963 -0
- data/sorbet/rbi/gems/minitest-reporters.rbi +104 -0
- data/sorbet/rbi/gems/minitest-reporters@1.7.1.rbi +1018 -0
- data/sorbet/rbi/gems/minitest.rbi +440 -0
- data/sorbet/rbi/gems/minitest@5.25.5.rbi +1547 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +159 -0
- data/sorbet/rbi/gems/parallel.rbi +88 -0
- data/sorbet/rbi/gems/parallel@1.26.3.rbi +291 -0
- data/sorbet/rbi/gems/parser.rbi +1545 -0
- data/sorbet/rbi/gems/parser@3.3.7.4.rbi +5535 -0
- data/sorbet/rbi/gems/prism.rbi +4090 -0
- data/sorbet/rbi/gems/prism@1.4.0.rbi +41732 -0
- data/sorbet/rbi/gems/racc.rbi +41 -0
- data/sorbet/rbi/gems/racc@1.8.1.rbi +160 -0
- data/sorbet/rbi/gems/rainbow.rbi +122 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +403 -0
- data/sorbet/rbi/gems/rake.rbi +649 -0
- data/sorbet/rbi/gems/rake@13.2.1.rbi +3033 -0
- data/sorbet/rbi/gems/rbi@0.3.1.rbi +6599 -0
- data/sorbet/rbi/gems/rbs@3.9.2.rbi +6978 -0
- data/sorbet/rbi/gems/regexp_parser.rbi +1039 -0
- data/sorbet/rbi/gems/regexp_parser@2.10.0.rbi +3795 -0
- data/sorbet/rbi/gems/rubocop-ast.rbi +1470 -0
- data/sorbet/rbi/gems/rubocop-ast@1.44.0.rbi +7716 -0
- data/sorbet/rbi/gems/rubocop.rbi +10557 -0
- data/sorbet/rbi/gems/rubocop@1.75.2.rbi +61860 -0
- data/sorbet/rbi/gems/ruby-filemagic.rbi +46 -0
- data/sorbet/rbi/gems/ruby-filemagic@0.7.3.rbi +168 -0
- data/sorbet/rbi/gems/ruby-progressbar.rbi +321 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1318 -0
- data/sorbet/rbi/gems/simplecov-html.rbi +36 -0
- data/sorbet/rbi/gems/simplecov-html@0.13.1.rbi +225 -0
- data/sorbet/rbi/gems/simplecov.rbi +435 -0
- data/sorbet/rbi/gems/simplecov@0.22.0.rbi +2149 -0
- data/sorbet/rbi/gems/simplecov_json_formatter.rbi +47 -0
- data/sorbet/rbi/gems/simplecov_json_formatter@0.1.4.rbi +9 -0
- data/sorbet/rbi/gems/spoom@1.6.1.rbi +7274 -0
- data/sorbet/rbi/gems/tapioca@0.16.11.rbi +3628 -0
- data/sorbet/rbi/gems/thor.rbi +583 -0
- data/sorbet/rbi/gems/thor@1.3.2.rbi +4378 -0
- data/sorbet/rbi/gems/toml-rb.rbi +136 -0
- data/sorbet/rbi/gems/toml-rb@2.2.0.rbi +419 -0
- data/sorbet/rbi/gems/unicode-display_width.rbi +28 -0
- data/sorbet/rbi/gems/unicode-display_width@3.1.4.rbi +132 -0
- data/sorbet/rbi/gems/unicode-emoji.rbi +18 -0
- data/sorbet/rbi/gems/unicode-emoji@4.0.4.rbi +251 -0
- data/sorbet/rbi/gems/yard-sorbet@0.9.0.rbi +435 -0
- data/sorbet/rbi/gems/yard@0.9.37.rbi +18379 -0
- data/sorbet/tapioca/config.yml +13 -0
- data/sorbet/tapioca/require.rb +4 -0
- metadata +399 -0
@@ -0,0 +1,1234 @@
|
|
1
|
+
# typed: true
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `citrus` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem citrus`.
|
6
|
+
|
7
|
+
|
8
|
+
# Citrus is a compact and powerful parsing library for Ruby that combines the
|
9
|
+
# elegance and expressiveness of the language with the simplicity and power of
|
10
|
+
# parsing expressions.
|
11
|
+
#
|
12
|
+
# http://mjackson.github.io/citrus
|
13
|
+
#
|
14
|
+
# source://citrus//lib/citrus/version.rb#1
|
15
|
+
module Citrus
|
16
|
+
class << self
|
17
|
+
# Returns a map of paths of files that have been loaded via #load to the
|
18
|
+
# result of #eval on the code in that file.
|
19
|
+
#
|
20
|
+
# Note: These paths are not absolute unless you pass an absolute path to
|
21
|
+
# #load. That means that if you change the working directory and try to
|
22
|
+
# #require the same file with a different relative path, it will be loaded
|
23
|
+
# twice.
|
24
|
+
#
|
25
|
+
# source://citrus//lib/citrus.rb#29
|
26
|
+
def cache; end
|
27
|
+
|
28
|
+
# Evaluates the given Citrus parsing expression grammar +code+ and returns an
|
29
|
+
# array of any grammar modules that are created. Accepts the same +options+ as
|
30
|
+
# GrammarMethods#parse.
|
31
|
+
#
|
32
|
+
# Citrus.eval(<<CITRUS)
|
33
|
+
# grammar MyGrammar
|
34
|
+
# rule abc
|
35
|
+
# "abc"
|
36
|
+
# end
|
37
|
+
# end
|
38
|
+
# CITRUS
|
39
|
+
# # => [MyGrammar]
|
40
|
+
#
|
41
|
+
# source://citrus//lib/citrus.rb#46
|
42
|
+
def eval(code, options = T.unsafe(nil)); end
|
43
|
+
|
44
|
+
# Loads the grammar(s) from the given +file+. Accepts the same +options+ as
|
45
|
+
# #eval, plus the following:
|
46
|
+
#
|
47
|
+
# force:: Normally this method will not reload a file that is already in
|
48
|
+
# the #cache. However, if this option is +true+ the file will be
|
49
|
+
# loaded, regardless of whether or not it is in the cache. Defaults
|
50
|
+
# to +false+.
|
51
|
+
#
|
52
|
+
# Citrus.load('mygrammar')
|
53
|
+
# # => [MyGrammar]
|
54
|
+
#
|
55
|
+
# source://citrus//lib/citrus.rb#71
|
56
|
+
def load(file, options = T.unsafe(nil)); end
|
57
|
+
|
58
|
+
# Searches the <tt>$LOAD_PATH</tt> for a +file+ with the .citrus suffix and
|
59
|
+
# attempts to load it via #load. Returns the path to the file that was loaded
|
60
|
+
# on success, +nil+ on failure. Accepts the same +options+ as #load.
|
61
|
+
#
|
62
|
+
# path = Citrus.require('mygrammar')
|
63
|
+
# # => "/path/to/mygrammar.citrus"
|
64
|
+
# Citrus.cache[path]
|
65
|
+
# # => [MyGrammar]
|
66
|
+
#
|
67
|
+
# source://citrus//lib/citrus.rb#96
|
68
|
+
def require(file, options = T.unsafe(nil)); end
|
69
|
+
|
70
|
+
# Evaluates the given expression and creates a new Rule object from it.
|
71
|
+
# Accepts the same +options+ as #eval.
|
72
|
+
#
|
73
|
+
# Citrus.rule('"a" | "b"')
|
74
|
+
# # => #<Citrus::Rule: ... >
|
75
|
+
#
|
76
|
+
# source://citrus//lib/citrus.rb#56
|
77
|
+
def rule(expr, options = T.unsafe(nil)); end
|
78
|
+
|
79
|
+
# Returns the current version of Citrus as a string.
|
80
|
+
#
|
81
|
+
# source://citrus//lib/citrus/version.rb#6
|
82
|
+
def version; end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# An Alias is a Proxy for a rule in the same grammar. It is used in rule
|
87
|
+
# definitions when a rule calls some other rule by name. The Citrus notation
|
88
|
+
# is simply the name of another rule without any other punctuation, e.g.:
|
89
|
+
#
|
90
|
+
# name
|
91
|
+
#
|
92
|
+
# source://citrus//lib/citrus.rb#809
|
93
|
+
class Citrus::Alias
|
94
|
+
include ::Citrus::Rule
|
95
|
+
include ::Citrus::Proxy
|
96
|
+
|
97
|
+
# Returns the Citrus notation of this rule as a string.
|
98
|
+
#
|
99
|
+
# source://citrus//lib/citrus.rb#813
|
100
|
+
def to_citrus; end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
# Searches this proxy's grammar and any included grammars for a rule with
|
105
|
+
# this proxy's #rule_name. Raises an error if one cannot be found.
|
106
|
+
#
|
107
|
+
# source://citrus//lib/citrus.rb#821
|
108
|
+
def resolve!; end
|
109
|
+
end
|
110
|
+
|
111
|
+
# An AndPredicate is a Nonterminal that contains a rule that must match. Upon
|
112
|
+
# success an empty match is returned and no input is consumed. The Citrus
|
113
|
+
# notation is any expression preceded by an ampersand, e.g.:
|
114
|
+
#
|
115
|
+
# &expr
|
116
|
+
#
|
117
|
+
# source://citrus//lib/citrus.rb#998
|
118
|
+
class Citrus::AndPredicate
|
119
|
+
include ::Citrus::Rule
|
120
|
+
include ::Citrus::Nonterminal
|
121
|
+
|
122
|
+
# @return [AndPredicate] a new instance of AndPredicate
|
123
|
+
#
|
124
|
+
# source://citrus//lib/citrus.rb#1001
|
125
|
+
def initialize(rule = T.unsafe(nil)); end
|
126
|
+
|
127
|
+
# Returns an array of events for this rule on the given +input+.
|
128
|
+
#
|
129
|
+
# source://citrus//lib/citrus.rb#1011
|
130
|
+
def exec(input, events = T.unsafe(nil)); end
|
131
|
+
|
132
|
+
# Returns the Rule object this rule uses to match.
|
133
|
+
#
|
134
|
+
# source://citrus//lib/citrus.rb#1006
|
135
|
+
def rule; end
|
136
|
+
|
137
|
+
# Returns the Citrus notation of this rule as a string.
|
138
|
+
#
|
139
|
+
# source://citrus//lib/citrus.rb#1022
|
140
|
+
def to_citrus; end
|
141
|
+
end
|
142
|
+
|
143
|
+
# A ButPredicate is a Nonterminal that consumes all characters until its rule
|
144
|
+
# matches. It must match at least one character in order to succeed. The
|
145
|
+
# Citrus notation is any expression preceded by a tilde, e.g.:
|
146
|
+
#
|
147
|
+
# ~expr
|
148
|
+
#
|
149
|
+
# source://citrus//lib/citrus.rb#1068
|
150
|
+
class Citrus::ButPredicate
|
151
|
+
include ::Citrus::Rule
|
152
|
+
include ::Citrus::Nonterminal
|
153
|
+
|
154
|
+
# @return [ButPredicate] a new instance of ButPredicate
|
155
|
+
#
|
156
|
+
# source://citrus//lib/citrus.rb#1073
|
157
|
+
def initialize(rule = T.unsafe(nil)); end
|
158
|
+
|
159
|
+
# Returns an array of events for this rule on the given +input+.
|
160
|
+
#
|
161
|
+
# source://citrus//lib/citrus.rb#1083
|
162
|
+
def exec(input, events = T.unsafe(nil)); end
|
163
|
+
|
164
|
+
# Returns the Rule object this rule uses to match.
|
165
|
+
#
|
166
|
+
# source://citrus//lib/citrus.rb#1078
|
167
|
+
def rule; end
|
168
|
+
|
169
|
+
# Returns the Citrus notation of this rule as a string.
|
170
|
+
#
|
171
|
+
# source://citrus//lib/citrus.rb#1102
|
172
|
+
def to_citrus; end
|
173
|
+
end
|
174
|
+
|
175
|
+
# source://citrus//lib/citrus.rb#1071
|
176
|
+
Citrus::ButPredicate::DOT_RULE = T.let(T.unsafe(nil), Citrus::Terminal)
|
177
|
+
|
178
|
+
# source://citrus//lib/citrus.rb#20
|
179
|
+
Citrus::CLOSE = T.let(T.unsafe(nil), Integer)
|
180
|
+
|
181
|
+
# A Choice is a Nonterminal where only one rule must match. The Citrus
|
182
|
+
# notation is two or more expressions separated by a vertical bar, e.g.:
|
183
|
+
#
|
184
|
+
# expr | expr
|
185
|
+
#
|
186
|
+
# source://citrus//lib/citrus.rb#1233
|
187
|
+
class Citrus::Choice
|
188
|
+
include ::Citrus::Rule
|
189
|
+
include ::Citrus::Nonterminal
|
190
|
+
|
191
|
+
# Returns +true+ if this rule should extend a match but should not appear in
|
192
|
+
# its event stream.
|
193
|
+
#
|
194
|
+
# @return [Boolean]
|
195
|
+
#
|
196
|
+
# source://citrus//lib/citrus.rb#1260
|
197
|
+
def elide?; end
|
198
|
+
|
199
|
+
# Returns an array of events for this rule on the given +input+.
|
200
|
+
#
|
201
|
+
# source://citrus//lib/citrus.rb#1237
|
202
|
+
def exec(input, events = T.unsafe(nil)); end
|
203
|
+
|
204
|
+
# Returns the Citrus notation of this rule as a string.
|
205
|
+
#
|
206
|
+
# source://citrus//lib/citrus.rb#1265
|
207
|
+
def to_citrus; end
|
208
|
+
end
|
209
|
+
|
210
|
+
# A pattern to match any character, including newline.
|
211
|
+
#
|
212
|
+
# source://citrus//lib/citrus.rb#16
|
213
|
+
Citrus::DOT = T.let(T.unsafe(nil), Regexp)
|
214
|
+
|
215
|
+
# A base class for all Citrus errors.
|
216
|
+
#
|
217
|
+
# source://citrus//lib/citrus.rb#117
|
218
|
+
class Citrus::Error < ::StandardError; end
|
219
|
+
|
220
|
+
# A grammar for Citrus grammar files. This grammar is used in Citrus.eval to
|
221
|
+
# parse and evaluate Citrus grammars and serves as a prime example of how to
|
222
|
+
# create a complex grammar complete with semantic interpretation in pure Ruby.
|
223
|
+
#
|
224
|
+
# source://citrus//lib/citrus/file.rb#0
|
225
|
+
module Citrus::File
|
226
|
+
include ::Citrus::Grammar
|
227
|
+
extend ::Citrus::GrammarMethods
|
228
|
+
|
229
|
+
class << self
|
230
|
+
# source://citrus//lib/citrus/file.rb#357
|
231
|
+
def parse(*_arg0); end
|
232
|
+
end
|
233
|
+
end
|
234
|
+
|
235
|
+
# Inclusion of this module into another extends the receiver with the grammar
|
236
|
+
# helper methods in GrammarMethods. Although this module does not actually
|
237
|
+
# provide any methods, constants, or variables to modules that include it, the
|
238
|
+
# mere act of inclusion provides a useful lookup mechanism to determine if a
|
239
|
+
# module is in fact a grammar.
|
240
|
+
#
|
241
|
+
# source://citrus//lib/citrus.rb#352
|
242
|
+
module Citrus::Grammar
|
243
|
+
mixes_in_class_methods ::Citrus::GrammarMethods
|
244
|
+
|
245
|
+
class << self
|
246
|
+
# Extends all modules that +include Grammar+ with GrammarMethods and
|
247
|
+
# exposes Module#include.
|
248
|
+
#
|
249
|
+
# source://citrus//lib/citrus.rb#368
|
250
|
+
def included(mod); end
|
251
|
+
|
252
|
+
# Creates a new anonymous module that includes Grammar. If a +block+ is
|
253
|
+
# provided, it is +module_eval+'d in the context of the new module. Grammars
|
254
|
+
# created with this method may be assigned a name by being assigned to some
|
255
|
+
# constant, e.g.:
|
256
|
+
#
|
257
|
+
# MyGrammar = Citrus::Grammar.new {}
|
258
|
+
#
|
259
|
+
# source://citrus//lib/citrus.rb#360
|
260
|
+
def new(&block); end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
# Contains methods that are available to Grammar modules at the class level.
|
265
|
+
#
|
266
|
+
# source://citrus//lib/citrus.rb#376
|
267
|
+
module Citrus::GrammarMethods
|
268
|
+
# Creates a new Sequence using all arguments. A block may be provided to
|
269
|
+
# specify semantic behavior (via #ext).
|
270
|
+
#
|
271
|
+
# source://citrus//lib/citrus.rb#549
|
272
|
+
def all(*args, &block); end
|
273
|
+
|
274
|
+
# Creates a new AndPredicate using the given +rule+. A block may be provided
|
275
|
+
# to specify semantic behavior (via #ext).
|
276
|
+
#
|
277
|
+
# source://citrus//lib/citrus.rb#509
|
278
|
+
def andp(rule, &block); end
|
279
|
+
|
280
|
+
# Creates a new Choice using all arguments. A block may be provided to
|
281
|
+
# specify semantic behavior (via #ext).
|
282
|
+
#
|
283
|
+
# source://citrus//lib/citrus.rb#555
|
284
|
+
def any(*args, &block); end
|
285
|
+
|
286
|
+
# Creates a new ButPredicate using the given +rule+. A block may be provided
|
287
|
+
# to specify semantic behavior (via #ext).
|
288
|
+
#
|
289
|
+
# source://citrus//lib/citrus.rb#521
|
290
|
+
def butp(rule, &block); end
|
291
|
+
|
292
|
+
# Creates a new rule that will match any single character. A block may be
|
293
|
+
# provided to specify semantic behavior (via #ext).
|
294
|
+
#
|
295
|
+
# source://citrus//lib/citrus.rb#497
|
296
|
+
def dot(&block); end
|
297
|
+
|
298
|
+
# Specifies a Module that will be used to extend all matches created with
|
299
|
+
# the given +rule+. A block may also be given that will be used to create
|
300
|
+
# an anonymous module. See Rule#extension=.
|
301
|
+
#
|
302
|
+
# source://citrus//lib/citrus.rb#570
|
303
|
+
def ext(rule, mod = T.unsafe(nil), &block); end
|
304
|
+
|
305
|
+
# Returns +true+ if this grammar has a rule with the given +name+.
|
306
|
+
#
|
307
|
+
# @return [Boolean]
|
308
|
+
#
|
309
|
+
# source://citrus//lib/citrus.rb#425
|
310
|
+
def has_rule?(name); end
|
311
|
+
|
312
|
+
# Returns an array of all grammars that have been included in this grammar
|
313
|
+
# in the reverse order they were included.
|
314
|
+
#
|
315
|
+
# source://citrus//lib/citrus.rb#409
|
316
|
+
def included_grammars; end
|
317
|
+
|
318
|
+
# Adds +label+ to the given +rule+. A block may be provided to specify
|
319
|
+
# semantic behavior (via #ext).
|
320
|
+
#
|
321
|
+
# source://citrus//lib/citrus.rb#561
|
322
|
+
def label(rule, label, &block); end
|
323
|
+
|
324
|
+
# Creates a new Module from the given +block+ and sets it to be the
|
325
|
+
# extension of the given +rule+. See Rule#extension=.
|
326
|
+
#
|
327
|
+
# source://citrus//lib/citrus.rb#579
|
328
|
+
def mod(rule, &block); end
|
329
|
+
|
330
|
+
# Returns the name of this grammar as a string.
|
331
|
+
#
|
332
|
+
# source://citrus//lib/citrus.rb#403
|
333
|
+
def name; end
|
334
|
+
|
335
|
+
# Creates a new NotPredicate using the given +rule+. A block may be provided
|
336
|
+
# to specify semantic behavior (via #ext).
|
337
|
+
#
|
338
|
+
# source://citrus//lib/citrus.rb#515
|
339
|
+
def notp(rule, &block); end
|
340
|
+
|
341
|
+
# An alias for #rep.
|
342
|
+
#
|
343
|
+
# source://citrus//lib/citrus.rb#533
|
344
|
+
def one_or_more(rule, &block); end
|
345
|
+
|
346
|
+
# Parses the given +source+ using this grammar's root rule. Accepts the same
|
347
|
+
# +options+ as Rule#parse, plus the following:
|
348
|
+
#
|
349
|
+
# root:: The name of the root rule to start parsing at. Defaults to this
|
350
|
+
# grammar's #root.
|
351
|
+
#
|
352
|
+
# @raise [Error]
|
353
|
+
#
|
354
|
+
# source://citrus//lib/citrus.rb#387
|
355
|
+
def parse(source, options = T.unsafe(nil)); end
|
356
|
+
|
357
|
+
# Parses the contents of the file at the given +path+ using this grammar's
|
358
|
+
# #root rule. Accepts the same +options+ as #parse.
|
359
|
+
#
|
360
|
+
# source://citrus//lib/citrus.rb#397
|
361
|
+
def parse_file(path, options = T.unsafe(nil)); end
|
362
|
+
|
363
|
+
# Creates a new Repeat using the given +rule+. +min+ and +max+ specify the
|
364
|
+
# minimum and maximum number of times the rule must match. A block may be
|
365
|
+
# provided to specify semantic behavior (via #ext).
|
366
|
+
#
|
367
|
+
# source://citrus//lib/citrus.rb#528
|
368
|
+
def rep(rule, min = T.unsafe(nil), max = T.unsafe(nil), &block); end
|
369
|
+
|
370
|
+
# Gets/sets the +name+ of the root rule of this grammar. If no root rule is
|
371
|
+
# explicitly specified, the name of this grammar's first rule is returned.
|
372
|
+
#
|
373
|
+
# source://citrus//lib/citrus.rb#482
|
374
|
+
def root(name = T.unsafe(nil)); end
|
375
|
+
|
376
|
+
# Gets/sets the rule with the given +name+. If +obj+ is given the rule
|
377
|
+
# will be set to the value of +obj+ passed through Rule.for. If a block is
|
378
|
+
# given, its return value will be used for the value of +obj+.
|
379
|
+
#
|
380
|
+
# It is important to note that this method will also check any included
|
381
|
+
# grammars for a rule with the given +name+ if one cannot be found in this
|
382
|
+
# grammar.
|
383
|
+
#
|
384
|
+
# source://citrus//lib/citrus.rb#459
|
385
|
+
def rule(name, obj = T.unsafe(nil), &block); end
|
386
|
+
|
387
|
+
# Returns an array of all names of rules in this grammar as symbols ordered
|
388
|
+
# in the same way they were declared.
|
389
|
+
#
|
390
|
+
# source://citrus//lib/citrus.rb#415
|
391
|
+
def rule_names; end
|
392
|
+
|
393
|
+
# Returns a hash of all Rule objects in this grammar, keyed by rule name.
|
394
|
+
#
|
395
|
+
# source://citrus//lib/citrus.rb#420
|
396
|
+
def rules; end
|
397
|
+
|
398
|
+
# Creates a new Super for the rule currently being defined in the grammar. A
|
399
|
+
# block may be provided to specify semantic behavior (via #ext).
|
400
|
+
#
|
401
|
+
# source://citrus//lib/citrus.rb#503
|
402
|
+
def sup(&block); end
|
403
|
+
|
404
|
+
# Searches the inheritance hierarchy of this grammar for a rule named +name+
|
405
|
+
# and returns it on success. Returns +nil+ on failure.
|
406
|
+
#
|
407
|
+
# source://citrus//lib/citrus.rb#443
|
408
|
+
def super_rule(name); end
|
409
|
+
|
410
|
+
# An alias for #rep with a minimum of 0.
|
411
|
+
#
|
412
|
+
# source://citrus//lib/citrus.rb#538
|
413
|
+
def zero_or_more(rule, &block); end
|
414
|
+
|
415
|
+
# An alias for #rep with a minimum of 0 and a maximum of 1.
|
416
|
+
#
|
417
|
+
# source://citrus//lib/citrus.rb#543
|
418
|
+
def zero_or_one(rule, &block); end
|
419
|
+
|
420
|
+
private
|
421
|
+
|
422
|
+
# Loops through the rule tree for the given +rule+ looking for any Super
|
423
|
+
# rules. When it finds one, it sets that rule's rule name to the given
|
424
|
+
# +name+.
|
425
|
+
#
|
426
|
+
# source://citrus//lib/citrus.rb#432
|
427
|
+
def setup_super(rule, name); end
|
428
|
+
|
429
|
+
class << self
|
430
|
+
# @raise [ArgumentError]
|
431
|
+
#
|
432
|
+
# source://citrus//lib/citrus.rb#377
|
433
|
+
def extend_object(obj); end
|
434
|
+
end
|
435
|
+
end
|
436
|
+
|
437
|
+
# source://citrus//lib/citrus.rb#18
|
438
|
+
Citrus::Infinity = T.let(T.unsafe(nil), Float)
|
439
|
+
|
440
|
+
# An Input is a scanner that is responsible for executing rules at different
|
441
|
+
# positions in the input string and persisting event streams.
|
442
|
+
#
|
443
|
+
# source://citrus//lib/citrus.rb#172
|
444
|
+
class Citrus::Input < ::StringScanner
|
445
|
+
# @return [Input] a new instance of Input
|
446
|
+
#
|
447
|
+
# source://citrus//lib/citrus.rb#173
|
448
|
+
def initialize(source); end
|
449
|
+
|
450
|
+
# Returns an array of events for the given +rule+ at the current pointer
|
451
|
+
# position. Objects in this array may be one of three types: a Rule,
|
452
|
+
# Citrus::CLOSE, or a length (integer).
|
453
|
+
#
|
454
|
+
# source://citrus//lib/citrus.rb#246
|
455
|
+
def exec(rule, events = T.unsafe(nil)); end
|
456
|
+
|
457
|
+
# Returns the text of the line that contains the character at the given
|
458
|
+
# +pos+. +pos+ defaults to the current pointer position.
|
459
|
+
#
|
460
|
+
# source://citrus//lib/citrus.rb#234
|
461
|
+
def line(pos = T.unsafe(nil)); end
|
462
|
+
|
463
|
+
# Returns the 0-based number of the line that contains the character at the
|
464
|
+
# given +pos+. +pos+ defaults to the current pointer position.
|
465
|
+
#
|
466
|
+
# source://citrus//lib/citrus.rb#214
|
467
|
+
def line_index(pos = T.unsafe(nil)); end
|
468
|
+
|
469
|
+
# Returns the 1-based number of the line that contains the character at the
|
470
|
+
# given +pos+. +pos+ defaults to the current pointer position.
|
471
|
+
#
|
472
|
+
# source://citrus//lib/citrus.rb#226
|
473
|
+
def line_number(pos = T.unsafe(nil)); end
|
474
|
+
|
475
|
+
# Returns the 0-based offset of the given +pos+ in the input on the line
|
476
|
+
# on which it is found. +pos+ defaults to the current pointer position.
|
477
|
+
#
|
478
|
+
# source://citrus//lib/citrus.rb#202
|
479
|
+
def line_offset(pos = T.unsafe(nil)); end
|
480
|
+
|
481
|
+
# Returns the 1-based number of the line that contains the character at the
|
482
|
+
# given +pos+. +pos+ defaults to the current pointer position.
|
483
|
+
#
|
484
|
+
# source://citrus//lib/citrus.rb#226
|
485
|
+
def lineno(pos = T.unsafe(nil)); end
|
486
|
+
|
487
|
+
# Returns an array containing the lines of text in the input.
|
488
|
+
#
|
489
|
+
# source://citrus//lib/citrus.rb#192
|
490
|
+
def lines; end
|
491
|
+
|
492
|
+
# The maximum offset in the input that was successfully parsed.
|
493
|
+
#
|
494
|
+
# source://citrus//lib/citrus.rb#180
|
495
|
+
def max_offset; end
|
496
|
+
|
497
|
+
# Returns +true+ when using memoization to cache match results.
|
498
|
+
#
|
499
|
+
# @return [Boolean]
|
500
|
+
#
|
501
|
+
# source://citrus//lib/citrus.rb#239
|
502
|
+
def memoized?; end
|
503
|
+
|
504
|
+
# source://citrus//lib/citrus.rb#186
|
505
|
+
def reset; end
|
506
|
+
|
507
|
+
# The initial source passed at construction. Typically a String
|
508
|
+
# or a Pathname.
|
509
|
+
#
|
510
|
+
# source://citrus//lib/citrus.rb#184
|
511
|
+
def source; end
|
512
|
+
|
513
|
+
# Returns the length of a match for the given +rule+ at the current pointer
|
514
|
+
# position, +nil+ if none can be made.
|
515
|
+
#
|
516
|
+
# source://citrus//lib/citrus.rb#261
|
517
|
+
def test(rule); end
|
518
|
+
|
519
|
+
# Returns the scanned string.
|
520
|
+
def to_str; end
|
521
|
+
|
522
|
+
private
|
523
|
+
|
524
|
+
# Appends all events for +rule+ at the given +position+ to +events+.
|
525
|
+
#
|
526
|
+
# source://citrus//lib/citrus.rb#287
|
527
|
+
def apply_rule(rule, position, events); end
|
528
|
+
|
529
|
+
# Returns the text to parse from +source+.
|
530
|
+
#
|
531
|
+
# source://citrus//lib/citrus.rb#274
|
532
|
+
def source_text(source); end
|
533
|
+
end
|
534
|
+
|
535
|
+
# Raised when Citrus.require can't find the file to load.
|
536
|
+
#
|
537
|
+
# source://citrus//lib/citrus.rb#120
|
538
|
+
class Citrus::LoadError < ::Citrus::Error; end
|
539
|
+
|
540
|
+
# The base class for all matches. Matches are organized into a tree where any
|
541
|
+
# match may contain any number of other matches. Nodes of the tree are lazily
|
542
|
+
# instantiated as needed. This class provides several convenient tree
|
543
|
+
# traversal methods that help when examining and interpreting parse results.
|
544
|
+
#
|
545
|
+
# source://citrus//lib/citrus.rb#1274
|
546
|
+
class Citrus::Match
|
547
|
+
# @return [Match] a new instance of Match
|
548
|
+
#
|
549
|
+
# source://citrus//lib/citrus.rb#1275
|
550
|
+
def initialize(input, events = T.unsafe(nil), offset = T.unsafe(nil)); end
|
551
|
+
|
552
|
+
# source://citrus//lib/citrus.rb#1381
|
553
|
+
def ==(other); end
|
554
|
+
|
555
|
+
# Returns the capture at the given +key+. If it is an Integer (and an
|
556
|
+
# optional length) or a Range, the result of #to_a with the same arguments
|
557
|
+
# is returned. Otherwise, the value at +key+ in #captures is returned.
|
558
|
+
#
|
559
|
+
# source://citrus//lib/citrus.rb#1372
|
560
|
+
def [](key, *args); end
|
561
|
+
|
562
|
+
# Convenient method for captures[name].first.
|
563
|
+
#
|
564
|
+
# source://citrus//lib/citrus.rb#1335
|
565
|
+
def capture(name); end
|
566
|
+
|
567
|
+
# Returns a hash of capture names to arrays of matches with that name,
|
568
|
+
# in the order they appeared in the input.
|
569
|
+
#
|
570
|
+
# source://citrus//lib/citrus.rb#1329
|
571
|
+
def captures(name = T.unsafe(nil)); end
|
572
|
+
|
573
|
+
# Prints the entire subtree of this match using the given +indent+ to
|
574
|
+
# indicate nested match levels. Useful for debugging.
|
575
|
+
#
|
576
|
+
# source://citrus//lib/citrus.rb#1400
|
577
|
+
def dump(indent = T.unsafe(nil)); end
|
578
|
+
|
579
|
+
# source://citrus//lib/citrus.rb#1381
|
580
|
+
def eql?(other); end
|
581
|
+
|
582
|
+
# The array of events for this match.
|
583
|
+
#
|
584
|
+
# source://citrus//lib/citrus.rb#1310
|
585
|
+
def events; end
|
586
|
+
|
587
|
+
# A shortcut for retrieving the first immediate submatch of this match.
|
588
|
+
#
|
589
|
+
# source://citrus//lib/citrus.rb#1346
|
590
|
+
def first; end
|
591
|
+
|
592
|
+
# The original Input this Match was generated on.
|
593
|
+
#
|
594
|
+
# source://citrus//lib/citrus.rb#1304
|
595
|
+
def input; end
|
596
|
+
|
597
|
+
# source://citrus//lib/citrus.rb#1394
|
598
|
+
def inspect; end
|
599
|
+
|
600
|
+
# Returns the length of this match.
|
601
|
+
#
|
602
|
+
# source://citrus//lib/citrus.rb#1313
|
603
|
+
def length; end
|
604
|
+
|
605
|
+
# Returns an array of all immediate submatches of this match.
|
606
|
+
#
|
607
|
+
# source://citrus//lib/citrus.rb#1340
|
608
|
+
def matches; end
|
609
|
+
|
610
|
+
# The index of this match in the #input.
|
611
|
+
#
|
612
|
+
# source://citrus//lib/citrus.rb#1307
|
613
|
+
def offset; end
|
614
|
+
|
615
|
+
# Convenient shortcut for +input.source+
|
616
|
+
#
|
617
|
+
# source://citrus//lib/citrus.rb#1318
|
618
|
+
def source; end
|
619
|
+
|
620
|
+
# Returns the slice of the source text that this match captures.
|
621
|
+
#
|
622
|
+
# source://citrus//lib/citrus.rb#1323
|
623
|
+
def string; end
|
624
|
+
|
625
|
+
# Returns this match plus all sub #matches in an array.
|
626
|
+
#
|
627
|
+
# source://citrus//lib/citrus.rb#1365
|
628
|
+
def to_a; end
|
629
|
+
|
630
|
+
# Returns the slice of the source text that this match captures.
|
631
|
+
#
|
632
|
+
# source://citrus//lib/citrus.rb#1323
|
633
|
+
def to_s; end
|
634
|
+
|
635
|
+
# Returns the slice of the source text that this match captures.
|
636
|
+
# This alias allows strings to be compared to the string value of Match
|
637
|
+
# objects. It is most useful in assertions in unit tests, e.g.:
|
638
|
+
#
|
639
|
+
# assert_equal("a string", match)
|
640
|
+
#
|
641
|
+
# source://citrus//lib/citrus.rb#1323
|
642
|
+
def to_str; end
|
643
|
+
|
644
|
+
# Returns the slice of the source text that this match captures.
|
645
|
+
# The default value for a match is its string value. This method is
|
646
|
+
# overridden in most cases to be more meaningful according to the desired
|
647
|
+
# interpretation.
|
648
|
+
#
|
649
|
+
# source://citrus//lib/citrus.rb#1323
|
650
|
+
def value; end
|
651
|
+
|
652
|
+
private
|
653
|
+
|
654
|
+
# source://citrus//lib/citrus.rb#1511
|
655
|
+
def capture!(rule, match); end
|
656
|
+
|
657
|
+
# Returns a new Hash that is to be used for @captures. This hash normalizes
|
658
|
+
# String keys to Symbols, returns +nil+ for unknown Numeric keys, and an
|
659
|
+
# empty Array for all other unknown keys.
|
660
|
+
#
|
661
|
+
# source://citrus//lib/citrus.rb#1536
|
662
|
+
def captures_hash; end
|
663
|
+
|
664
|
+
# Initializes both the @captures and @matches instance variables.
|
665
|
+
#
|
666
|
+
# source://citrus//lib/citrus.rb#1445
|
667
|
+
def process_events!; end
|
668
|
+
end
|
669
|
+
|
670
|
+
# A MemoizedInput is an Input that caches segments of the event stream for
|
671
|
+
# particular rules in a parse. This technique (also known as "Packrat"
|
672
|
+
# parsing) guarantees parsers will operate in linear time but costs
|
673
|
+
# significantly more in terms of time and memory required to perform a parse.
|
674
|
+
# For more information, please read the paper on Packrat parsing at
|
675
|
+
# http://pdos.csail.mit.edu/~baford/packrat/icfp02/.
|
676
|
+
#
|
677
|
+
# source://citrus//lib/citrus.rb#298
|
678
|
+
class Citrus::MemoizedInput < ::Citrus::Input
|
679
|
+
# @return [MemoizedInput] a new instance of MemoizedInput
|
680
|
+
#
|
681
|
+
# source://citrus//lib/citrus.rb#299
|
682
|
+
def initialize(string); end
|
683
|
+
|
684
|
+
# A nested hash of rules to offsets and their respective matches.
|
685
|
+
#
|
686
|
+
# source://citrus//lib/citrus.rb#306
|
687
|
+
def cache; end
|
688
|
+
|
689
|
+
# The number of times the cache was hit.
|
690
|
+
#
|
691
|
+
# source://citrus//lib/citrus.rb#309
|
692
|
+
def cache_hits; end
|
693
|
+
|
694
|
+
# Returns +true+ when using memoization to cache match results.
|
695
|
+
#
|
696
|
+
# @return [Boolean]
|
697
|
+
#
|
698
|
+
# source://citrus//lib/citrus.rb#318
|
699
|
+
def memoized?; end
|
700
|
+
|
701
|
+
# source://citrus//lib/citrus.rb#311
|
702
|
+
def reset; end
|
703
|
+
|
704
|
+
private
|
705
|
+
|
706
|
+
# source://citrus//lib/citrus.rb#324
|
707
|
+
def apply_rule(rule, position, events); end
|
708
|
+
end
|
709
|
+
|
710
|
+
# Some helper methods for rules that alias +module_name+ and don't want to
|
711
|
+
# use +Kernel#eval+ to retrieve Module objects.
|
712
|
+
#
|
713
|
+
# source://citrus//lib/citrus/file.rb#8
|
714
|
+
module Citrus::ModuleNameHelpers
|
715
|
+
# source://citrus//lib/citrus/file.rb#23
|
716
|
+
def module_basename; end
|
717
|
+
|
718
|
+
# source://citrus//lib/citrus/file.rb#9
|
719
|
+
def module_name; end
|
720
|
+
|
721
|
+
# source://citrus//lib/citrus/file.rb#17
|
722
|
+
def module_namespace; end
|
723
|
+
|
724
|
+
# source://citrus//lib/citrus/file.rb#13
|
725
|
+
def module_segments; end
|
726
|
+
end
|
727
|
+
|
728
|
+
# A Nonterminal is a Rule that augments the matching behavior of one or more
|
729
|
+
# other rules. Nonterminals may not match directly on the input, but instead
|
730
|
+
# invoke the rule(s) they contain to determine if a match can be made from
|
731
|
+
# the collective result.
|
732
|
+
#
|
733
|
+
# source://citrus//lib/citrus.rb#976
|
734
|
+
module Citrus::Nonterminal
|
735
|
+
include ::Citrus::Rule
|
736
|
+
|
737
|
+
# source://citrus//lib/citrus.rb#979
|
738
|
+
def initialize(rules = T.unsafe(nil)); end
|
739
|
+
|
740
|
+
# source://citrus//lib/citrus.rb#986
|
741
|
+
def grammar=(grammar); end
|
742
|
+
|
743
|
+
# An array of the actual Rule objects this rule uses to match.
|
744
|
+
#
|
745
|
+
# source://citrus//lib/citrus.rb#984
|
746
|
+
def rules; end
|
747
|
+
end
|
748
|
+
|
749
|
+
# A NotPredicate is a Nonterminal that contains a rule that must not match.
|
750
|
+
# Upon success an empty match is returned and no input is consumed. The Citrus
|
751
|
+
# notation is any expression preceded by an exclamation mark, e.g.:
|
752
|
+
#
|
753
|
+
# !expr
|
754
|
+
#
|
755
|
+
# source://citrus//lib/citrus.rb#1033
|
756
|
+
class Citrus::NotPredicate
|
757
|
+
include ::Citrus::Rule
|
758
|
+
include ::Citrus::Nonterminal
|
759
|
+
|
760
|
+
# @return [NotPredicate] a new instance of NotPredicate
|
761
|
+
#
|
762
|
+
# source://citrus//lib/citrus.rb#1036
|
763
|
+
def initialize(rule = T.unsafe(nil)); end
|
764
|
+
|
765
|
+
# Returns an array of events for this rule on the given +input+.
|
766
|
+
#
|
767
|
+
# source://citrus//lib/citrus.rb#1046
|
768
|
+
def exec(input, events = T.unsafe(nil)); end
|
769
|
+
|
770
|
+
# Returns the Rule object this rule uses to match.
|
771
|
+
#
|
772
|
+
# source://citrus//lib/citrus.rb#1041
|
773
|
+
def rule; end
|
774
|
+
|
775
|
+
# Returns the Citrus notation of this rule as a string.
|
776
|
+
#
|
777
|
+
# source://citrus//lib/citrus.rb#1057
|
778
|
+
def to_citrus; end
|
779
|
+
end
|
780
|
+
|
781
|
+
# Raised when a parse fails.
|
782
|
+
#
|
783
|
+
# source://citrus//lib/citrus.rb#123
|
784
|
+
class Citrus::ParseError < ::Citrus::Error
|
785
|
+
# The +input+ given here is an instance of Citrus::Input.
|
786
|
+
#
|
787
|
+
# @return [ParseError] a new instance of ParseError
|
788
|
+
#
|
789
|
+
# source://citrus//lib/citrus.rb#125
|
790
|
+
def initialize(input); end
|
791
|
+
|
792
|
+
# Returns a string that, when printed, gives a visual representation of
|
793
|
+
# exactly where the error occurred on its line in the input.
|
794
|
+
#
|
795
|
+
# source://citrus//lib/citrus.rb#154
|
796
|
+
def detail; end
|
797
|
+
|
798
|
+
# The text of the line in the input where the error occurred.
|
799
|
+
#
|
800
|
+
# source://citrus//lib/citrus.rb#150
|
801
|
+
def line; end
|
802
|
+
|
803
|
+
# The 1-based number of the line in the input where the error occurred.
|
804
|
+
#
|
805
|
+
# source://citrus//lib/citrus.rb#147
|
806
|
+
def line_number; end
|
807
|
+
|
808
|
+
# The 0-based offset at which the error occurred on the line on which it
|
809
|
+
# occurred in the input.
|
810
|
+
#
|
811
|
+
# source://citrus//lib/citrus.rb#144
|
812
|
+
def line_offset; end
|
813
|
+
|
814
|
+
# The 0-based offset at which the error occurred in the input, i.e. the
|
815
|
+
# maximum offset in the input that was successfully parsed before the error
|
816
|
+
# occurred.
|
817
|
+
#
|
818
|
+
# source://citrus//lib/citrus.rb#140
|
819
|
+
def offset; end
|
820
|
+
end
|
821
|
+
|
822
|
+
# A Proxy is a Rule that is a placeholder for another rule. It stores the
|
823
|
+
# name of some other rule in the grammar internally and resolves it to the
|
824
|
+
# actual Rule object at runtime. This lazy evaluation permits creation of
|
825
|
+
# Proxy objects for rules that may not yet be defined.
|
826
|
+
#
|
827
|
+
# source://citrus//lib/citrus.rb#756
|
828
|
+
module Citrus::Proxy
|
829
|
+
include ::Citrus::Rule
|
830
|
+
|
831
|
+
# source://citrus//lib/citrus.rb#759
|
832
|
+
def initialize(rule_name = T.unsafe(nil)); end
|
833
|
+
|
834
|
+
# Returns +true+ if this rule should extend a match but should not appear in
|
835
|
+
# its event stream.
|
836
|
+
#
|
837
|
+
# @return [Boolean]
|
838
|
+
#
|
839
|
+
# source://citrus//lib/citrus.rb#791
|
840
|
+
def elide?; end
|
841
|
+
|
842
|
+
# Returns an array of events for this rule on the given +input+.
|
843
|
+
#
|
844
|
+
# source://citrus//lib/citrus.rb#777
|
845
|
+
def exec(input, events = T.unsafe(nil)); end
|
846
|
+
|
847
|
+
# source://citrus//lib/citrus.rb#795
|
848
|
+
def extend_match(match); end
|
849
|
+
|
850
|
+
# Returns the underlying Rule for this proxy.
|
851
|
+
#
|
852
|
+
# source://citrus//lib/citrus.rb#772
|
853
|
+
def rule; end
|
854
|
+
|
855
|
+
# The name of this proxy's rule.
|
856
|
+
#
|
857
|
+
# source://citrus//lib/citrus.rb#769
|
858
|
+
def rule_name; end
|
859
|
+
|
860
|
+
# Sets the name of the rule this rule is proxy for.
|
861
|
+
#
|
862
|
+
# source://citrus//lib/citrus.rb#764
|
863
|
+
def rule_name=(rule_name); end
|
864
|
+
end
|
865
|
+
|
866
|
+
# A Repeat is a Nonterminal that specifies a minimum and maximum number of
|
867
|
+
# times its rule must match. The Citrus notation is an integer, +N+, followed
|
868
|
+
# by an asterisk, followed by another integer, +M+, all of which follow any
|
869
|
+
# other expression, e.g.:
|
870
|
+
#
|
871
|
+
# expr N*M
|
872
|
+
#
|
873
|
+
# In this notation +N+ specifies the minimum number of times the preceding
|
874
|
+
# expression must match and +M+ specifies the maximum. If +N+ is ommitted,
|
875
|
+
# it is assumed to be 0. Likewise, if +M+ is omitted, it is assumed to be
|
876
|
+
# infinity (no maximum). Thus, an expression followed by only an asterisk may
|
877
|
+
# match any number of times, including zero.
|
878
|
+
#
|
879
|
+
# The shorthand notation <tt>+</tt> and <tt>?</tt> may be used for the common
|
880
|
+
# cases of <tt>1*</tt> and <tt>*1</tt> respectively, e.g.:
|
881
|
+
#
|
882
|
+
# expr+
|
883
|
+
# expr?
|
884
|
+
#
|
885
|
+
# source://citrus//lib/citrus.rb#1126
|
886
|
+
class Citrus::Repeat
|
887
|
+
include ::Citrus::Rule
|
888
|
+
include ::Citrus::Nonterminal
|
889
|
+
|
890
|
+
# @raise [ArgumentError]
|
891
|
+
# @return [Repeat] a new instance of Repeat
|
892
|
+
#
|
893
|
+
# source://citrus//lib/citrus.rb#1129
|
894
|
+
def initialize(rule = T.unsafe(nil), min = T.unsafe(nil), max = T.unsafe(nil)); end
|
895
|
+
|
896
|
+
# Returns an array of events for this rule on the given +input+.
|
897
|
+
#
|
898
|
+
# source://citrus//lib/citrus.rb#1142
|
899
|
+
def exec(input, events = T.unsafe(nil)); end
|
900
|
+
|
901
|
+
# The maximum number of times this rule may match.
|
902
|
+
#
|
903
|
+
# source://citrus//lib/citrus.rb#1169
|
904
|
+
def max; end
|
905
|
+
|
906
|
+
# The minimum number of times this rule must match.
|
907
|
+
#
|
908
|
+
# source://citrus//lib/citrus.rb#1166
|
909
|
+
def min; end
|
910
|
+
|
911
|
+
# Returns the operator this rule uses as a string. Will be one of
|
912
|
+
# <tt>+</tt>, <tt>?</tt>, or <tt>N*M</tt>.
|
913
|
+
#
|
914
|
+
# source://citrus//lib/citrus.rb#1173
|
915
|
+
def operator; end
|
916
|
+
|
917
|
+
# Returns the Rule object this rule uses to match.
|
918
|
+
#
|
919
|
+
# source://citrus//lib/citrus.rb#1137
|
920
|
+
def rule; end
|
921
|
+
|
922
|
+
# Returns the Citrus notation of this rule as a string.
|
923
|
+
#
|
924
|
+
# source://citrus//lib/citrus.rb#1184
|
925
|
+
def to_citrus; end
|
926
|
+
end
|
927
|
+
|
928
|
+
# A Rule is an object that is used by a grammar to create matches on an
|
929
|
+
# Input during parsing.
|
930
|
+
#
|
931
|
+
# source://citrus//lib/citrus.rb#587
|
932
|
+
module Citrus::Rule
|
933
|
+
# source://citrus//lib/citrus.rb#732
|
934
|
+
def ==(other); end
|
935
|
+
|
936
|
+
# Tests the given +obj+ for case equality with this rule.
|
937
|
+
#
|
938
|
+
# source://citrus//lib/citrus.rb#685
|
939
|
+
def ===(obj); end
|
940
|
+
|
941
|
+
# The default set of options to use when calling #parse.
|
942
|
+
#
|
943
|
+
# source://citrus//lib/citrus.rb#641
|
944
|
+
def default_options; end
|
945
|
+
|
946
|
+
# Returns +true+ if this rule should extend a match but should not appear in
|
947
|
+
# its event stream.
|
948
|
+
#
|
949
|
+
# @return [Boolean]
|
950
|
+
#
|
951
|
+
# source://citrus//lib/citrus.rb#696
|
952
|
+
def elide?; end
|
953
|
+
|
954
|
+
# source://citrus//lib/citrus.rb#732
|
955
|
+
def eql?(other); end
|
956
|
+
|
957
|
+
# source://citrus//lib/citrus.rb#747
|
958
|
+
def extend_match(match); end
|
959
|
+
|
960
|
+
# The module this rule uses to extend new matches.
|
961
|
+
#
|
962
|
+
# source://citrus//lib/citrus.rb#638
|
963
|
+
def extension; end
|
964
|
+
|
965
|
+
# Specifies a module that will be used to extend all Match objects that
|
966
|
+
# result from this rule. If +mod+ is a Proc, it is used to create an
|
967
|
+
# anonymous module with a +value+ method.
|
968
|
+
#
|
969
|
+
# @raise [ArgumentError]
|
970
|
+
#
|
971
|
+
# source://citrus//lib/citrus.rb#627
|
972
|
+
def extension=(mod); end
|
973
|
+
|
974
|
+
# The grammar this rule belongs to, if any.
|
975
|
+
#
|
976
|
+
# source://citrus//lib/citrus.rb#604
|
977
|
+
def grammar; end
|
978
|
+
|
979
|
+
# The grammar this rule belongs to, if any.
|
980
|
+
#
|
981
|
+
# source://citrus//lib/citrus.rb#604
|
982
|
+
def grammar=(_arg0); end
|
983
|
+
|
984
|
+
# source://citrus//lib/citrus.rb#743
|
985
|
+
def inspect; end
|
986
|
+
|
987
|
+
# A label for this rule. If a rule has a label, all matches that it creates
|
988
|
+
# will be accessible as named captures from the scope of their parent match
|
989
|
+
# using that label.
|
990
|
+
#
|
991
|
+
# source://citrus//lib/citrus.rb#622
|
992
|
+
def label; end
|
993
|
+
|
994
|
+
# Sets the label of this rule.
|
995
|
+
#
|
996
|
+
# source://citrus//lib/citrus.rb#615
|
997
|
+
def label=(label); end
|
998
|
+
|
999
|
+
# The name of this rule.
|
1000
|
+
#
|
1001
|
+
# source://citrus//lib/citrus.rb#612
|
1002
|
+
def name; end
|
1003
|
+
|
1004
|
+
# Sets the name of this rule.
|
1005
|
+
#
|
1006
|
+
# source://citrus//lib/citrus.rb#607
|
1007
|
+
def name=(name); end
|
1008
|
+
|
1009
|
+
# Returns +true+ if this rule needs to be surrounded by parentheses when
|
1010
|
+
# using #to_embedded_s.
|
1011
|
+
#
|
1012
|
+
# @return [Boolean]
|
1013
|
+
#
|
1014
|
+
# source://citrus//lib/citrus.rb#702
|
1015
|
+
def needs_paren?; end
|
1016
|
+
|
1017
|
+
# Attempts to parse the given +string+ and return a Match if any can be
|
1018
|
+
# made. +options+ may contain any of the following keys:
|
1019
|
+
#
|
1020
|
+
# consume:: If this is +true+ a ParseError will be raised unless the
|
1021
|
+
# entire input string is consumed. Defaults to +true+.
|
1022
|
+
# memoize:: If this is +true+ the matches generated during a parse are
|
1023
|
+
# memoized. See MemoizedInput for more information. Defaults to
|
1024
|
+
# +false+.
|
1025
|
+
# offset:: The offset in +string+ at which to start parsing. Defaults
|
1026
|
+
# to 0.
|
1027
|
+
#
|
1028
|
+
# source://citrus//lib/citrus.rb#658
|
1029
|
+
def parse(source, options = T.unsafe(nil)); end
|
1030
|
+
|
1031
|
+
# Returns +true+ if this rule is a Terminal.
|
1032
|
+
#
|
1033
|
+
# @return [Boolean]
|
1034
|
+
#
|
1035
|
+
# source://citrus//lib/citrus.rb#690
|
1036
|
+
def terminal?; end
|
1037
|
+
|
1038
|
+
# Tests whether or not this rule matches on the given +string+. Returns the
|
1039
|
+
# length of the match if any can be made, +nil+ otherwise. Accepts the same
|
1040
|
+
# +options+ as #parse.
|
1041
|
+
#
|
1042
|
+
# source://citrus//lib/citrus.rb#678
|
1043
|
+
def test(string, options = T.unsafe(nil)); end
|
1044
|
+
|
1045
|
+
# Returns the Citrus notation of this rule as a string that is suitable to
|
1046
|
+
# be embedded in the string representation of another rule.
|
1047
|
+
#
|
1048
|
+
# source://citrus//lib/citrus.rb#724
|
1049
|
+
def to_embedded_s; end
|
1050
|
+
|
1051
|
+
# Returns the Citrus notation of this rule as a string.
|
1052
|
+
#
|
1053
|
+
# source://citrus//lib/citrus.rb#707
|
1054
|
+
def to_s; end
|
1055
|
+
|
1056
|
+
# Returns the Citrus notation of this rule as a string.
|
1057
|
+
# This alias allows strings to be compared to the string representation of
|
1058
|
+
# Rule objects. It is most useful in assertions in unit tests, e.g.:
|
1059
|
+
#
|
1060
|
+
# assert_equal('"a" | "b"', rule)
|
1061
|
+
#
|
1062
|
+
# source://citrus//lib/citrus.rb#707
|
1063
|
+
def to_str; end
|
1064
|
+
|
1065
|
+
class << self
|
1066
|
+
# Returns a new Rule object depending on the type of object given.
|
1067
|
+
#
|
1068
|
+
# source://citrus//lib/citrus.rb#589
|
1069
|
+
def for(obj); end
|
1070
|
+
end
|
1071
|
+
end
|
1072
|
+
|
1073
|
+
# A Sequence is a Nonterminal where all rules must match. The Citrus notation
|
1074
|
+
# is two or more expressions separated by a space, e.g.:
|
1075
|
+
#
|
1076
|
+
# expr expr
|
1077
|
+
#
|
1078
|
+
# source://citrus//lib/citrus.rb#1194
|
1079
|
+
class Citrus::Sequence
|
1080
|
+
include ::Citrus::Rule
|
1081
|
+
include ::Citrus::Nonterminal
|
1082
|
+
|
1083
|
+
# Returns an array of events for this rule on the given +input+.
|
1084
|
+
#
|
1085
|
+
# source://citrus//lib/citrus.rb#1198
|
1086
|
+
def exec(input, events = T.unsafe(nil)); end
|
1087
|
+
|
1088
|
+
# Returns the Citrus notation of this rule as a string.
|
1089
|
+
#
|
1090
|
+
# source://citrus//lib/citrus.rb#1223
|
1091
|
+
def to_citrus; end
|
1092
|
+
end
|
1093
|
+
|
1094
|
+
# A StringTerminal is a Terminal that may be instantiated from a String
|
1095
|
+
# object. The Citrus notation is any sequence of characters enclosed in either
|
1096
|
+
# single or double quotes, e.g.:
|
1097
|
+
#
|
1098
|
+
# 'expr'
|
1099
|
+
# "expr"
|
1100
|
+
#
|
1101
|
+
# This notation works the same as it does in Ruby; i.e. strings in double
|
1102
|
+
# quotes may contain escape sequences while strings in single quotes may not.
|
1103
|
+
# In order to specify that a string should ignore case when matching, enclose
|
1104
|
+
# it in backticks instead of single or double quotes, e.g.:
|
1105
|
+
#
|
1106
|
+
# `expr`
|
1107
|
+
#
|
1108
|
+
# Besides case sensitivity, case-insensitive strings have the same semantics
|
1109
|
+
# as double-quoted strings.
|
1110
|
+
#
|
1111
|
+
# source://citrus//lib/citrus.rb#944
|
1112
|
+
class Citrus::StringTerminal < ::Citrus::Terminal
|
1113
|
+
# The +flags+ will be passed directly to Regexp#new.
|
1114
|
+
#
|
1115
|
+
# @return [StringTerminal] a new instance of StringTerminal
|
1116
|
+
#
|
1117
|
+
# source://citrus//lib/citrus.rb#946
|
1118
|
+
def initialize(rule = T.unsafe(nil), flags = T.unsafe(nil)); end
|
1119
|
+
|
1120
|
+
# source://citrus//lib/citrus.rb#951
|
1121
|
+
def ==(other); end
|
1122
|
+
|
1123
|
+
# source://citrus//lib/citrus.rb#951
|
1124
|
+
def eql?(other); end
|
1125
|
+
|
1126
|
+
# Returns the Citrus notation of this rule as a string.
|
1127
|
+
#
|
1128
|
+
# source://citrus//lib/citrus.rb#963
|
1129
|
+
def to_citrus; end
|
1130
|
+
end
|
1131
|
+
|
1132
|
+
# A Super is a Proxy for a rule of the same name that was defined previously
|
1133
|
+
# in the grammar's inheritance chain. Thus, Super's work like Ruby's +super+,
|
1134
|
+
# only for rules in a grammar instead of methods in a module. The Citrus
|
1135
|
+
# notation is the word +super+ without any other punctuation, e.g.:
|
1136
|
+
#
|
1137
|
+
# super
|
1138
|
+
#
|
1139
|
+
# source://citrus//lib/citrus.rb#839
|
1140
|
+
class Citrus::Super
|
1141
|
+
include ::Citrus::Rule
|
1142
|
+
include ::Citrus::Proxy
|
1143
|
+
|
1144
|
+
# Returns the Citrus notation of this rule as a string.
|
1145
|
+
#
|
1146
|
+
# source://citrus//lib/citrus.rb#843
|
1147
|
+
def to_citrus; end
|
1148
|
+
|
1149
|
+
private
|
1150
|
+
|
1151
|
+
# Searches this proxy's included grammars for a rule with this proxy's
|
1152
|
+
# #rule_name. Raises an error if one cannot be found.
|
1153
|
+
#
|
1154
|
+
# source://citrus//lib/citrus.rb#851
|
1155
|
+
def resolve!; end
|
1156
|
+
end
|
1157
|
+
|
1158
|
+
# Raised when Citrus::File.parse fails.
|
1159
|
+
#
|
1160
|
+
# source://citrus//lib/citrus.rb#160
|
1161
|
+
class Citrus::SyntaxError < ::Citrus::Error
|
1162
|
+
# The +error+ given here is an instance of Citrus::ParseError.
|
1163
|
+
#
|
1164
|
+
# @return [SyntaxError] a new instance of SyntaxError
|
1165
|
+
#
|
1166
|
+
# source://citrus//lib/citrus.rb#162
|
1167
|
+
def initialize(error); end
|
1168
|
+
end
|
1169
|
+
|
1170
|
+
# A Terminal is a Rule that matches directly on the input stream and may not
|
1171
|
+
# contain any other rule. Terminals are essentially wrappers for regular
|
1172
|
+
# expressions. As such, the Citrus notation is identical to Ruby's regular
|
1173
|
+
# expression notation, e.g.:
|
1174
|
+
#
|
1175
|
+
# /expr/
|
1176
|
+
#
|
1177
|
+
# Character classes and the dot symbol may also be used in Citrus notation for
|
1178
|
+
# compatibility with other parsing expression implementations, e.g.:
|
1179
|
+
#
|
1180
|
+
# [a-zA-Z]
|
1181
|
+
# .
|
1182
|
+
#
|
1183
|
+
# Character classes have the same semantics as character classes inside Ruby
|
1184
|
+
# regular expressions. The dot matches any character, including newlines.
|
1185
|
+
#
|
1186
|
+
# source://citrus//lib/citrus.rb#878
|
1187
|
+
class Citrus::Terminal
|
1188
|
+
include ::Citrus::Rule
|
1189
|
+
|
1190
|
+
# @return [Terminal] a new instance of Terminal
|
1191
|
+
#
|
1192
|
+
# source://citrus//lib/citrus.rb#881
|
1193
|
+
def initialize(regexp = T.unsafe(nil)); end
|
1194
|
+
|
1195
|
+
# source://citrus//lib/citrus.rb#906
|
1196
|
+
def ==(other); end
|
1197
|
+
|
1198
|
+
# Returns +true+ if this rule is case sensitive.
|
1199
|
+
#
|
1200
|
+
# @return [Boolean]
|
1201
|
+
#
|
1202
|
+
# source://citrus//lib/citrus.rb#902
|
1203
|
+
def case_sensitive?; end
|
1204
|
+
|
1205
|
+
# source://citrus//lib/citrus.rb#906
|
1206
|
+
def eql?(other); end
|
1207
|
+
|
1208
|
+
# Returns an array of events for this rule on the given +input+.
|
1209
|
+
#
|
1210
|
+
# source://citrus//lib/citrus.rb#889
|
1211
|
+
def exec(input, events = T.unsafe(nil)); end
|
1212
|
+
|
1213
|
+
# The actual Regexp object this rule uses to match.
|
1214
|
+
#
|
1215
|
+
# source://citrus//lib/citrus.rb#886
|
1216
|
+
def regexp; end
|
1217
|
+
|
1218
|
+
# Returns +true+ if this rule is a Terminal.
|
1219
|
+
#
|
1220
|
+
# @return [Boolean]
|
1221
|
+
#
|
1222
|
+
# source://citrus//lib/citrus.rb#918
|
1223
|
+
def terminal?; end
|
1224
|
+
|
1225
|
+
# Returns the Citrus notation of this rule as a string.
|
1226
|
+
#
|
1227
|
+
# source://citrus//lib/citrus.rb#923
|
1228
|
+
def to_citrus; end
|
1229
|
+
end
|
1230
|
+
|
1231
|
+
# The current version of Citrus as [major, minor, patch].
|
1232
|
+
#
|
1233
|
+
# source://citrus//lib/citrus/version.rb#3
|
1234
|
+
Citrus::VERSION = T.let(T.unsafe(nil), Array)
|