oedipus_lex 2.5.0 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +2 -2
- data/History.rdoc +10 -0
- data/lib/oedipus_lex.rb +216 -13
- data/lib/oedipus_lex.rex.rb +54 -2
- metadata +29 -25
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 8cb423b537f9675d2c16f2dea13fe319f1a9201164e8eeefa9a4275640220607
|
4
|
+
data.tar.gz: b92269a7b11988954a9457a36df57c7199f1f95f74d862fbc20e7d6aec770ad6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9bd0f74cb429fd8f92b202a1dbaa38f4a69eab05da150801f59f36c2e7476b2d494304d17e8993ecbd563692dce0e7c15f20dfee5f4b0d6c92c5abc72d96b4b8
|
7
|
+
data.tar.gz: ba7831924e35607b5db556c42e7d0469c8f71d8c87feb67322b05599cfe83d8884f4559e5f068570dc7e36a1b8dcc92c17b2e148685742a45a199b04caf50bdc
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
�Lr�o��s�����_�d_ɢ��x��L�P��#�_�:�*���F�6W�bV�yi��N�=|Wzd)U��ϫ�s[b��3�]��4���U�7�=�;��%�����Lױ��t�KO�_m`hqa{�0vG]1Q %Uї�*N �Z��hk' ~wy�M�/m�8\��e@ �D�W�T(�V�O\R����Eq�b8�T0�g�0m��@���`z�'/���sGg�^M\��q�)�����E�������>�
|
2
|
+
Q�
|
data/History.rdoc
CHANGED
data/lib/oedipus_lex.rb
CHANGED
@@ -3,20 +3,85 @@ require 'strscan'
|
|
3
3
|
require "erb"
|
4
4
|
require "oedipus_lex.rex"
|
5
5
|
|
6
|
+
##
|
7
|
+
# Oedipus Lex is a lexer generator in the same family as Rexical and
|
8
|
+
# Rex. Oedipus Lex is my independent lexer fork of Rexical. Rexical
|
9
|
+
# was in turn a fork of Rex. We've been unable to contact the author
|
10
|
+
# of rex in order to take it over, fix it up, extend it, and relicense
|
11
|
+
# it to MIT. So, Oedipus was written clean-room in order to bypass
|
12
|
+
# licensing constraints (and because bootstrapping is fun).
|
13
|
+
#
|
14
|
+
# Oedipus brings a lot of extras to the table and at this point is
|
15
|
+
# only historically related to rexical. The syntax has changed enough
|
16
|
+
# that any rexical lexer will have to be tweaked to work inside of
|
17
|
+
# oedipus. At the very least, you need to add slashes to all your
|
18
|
+
# regexps.
|
19
|
+
#
|
20
|
+
# Oedipus, like rexical, is based primarily on generating code much
|
21
|
+
# like you would a hand-written lexer. It is _not_ a table or hash
|
22
|
+
# driven lexer. It uses StrScanner within a multi-level case
|
23
|
+
# statement. As such, Oedipus matches on the _first_ match, not the
|
24
|
+
# longest (like lex and its ilk).
|
25
|
+
#
|
26
|
+
# This documentation is not meant to bypass any prerequisite knowledge
|
27
|
+
# on lexing or parsing. If you'd like to study the subject in further
|
28
|
+
# detail, please try [TIN321] or the [LLVM Tutorial] or some other
|
29
|
+
# good resource for CS learning. Books... books are good. I like
|
30
|
+
# books.
|
31
|
+
|
6
32
|
class OedipusLex
|
7
|
-
VERSION = "2.5.
|
33
|
+
VERSION = "2.5.1" # :nodoc:
|
34
|
+
|
35
|
+
##
|
36
|
+
# The class name to generate.
|
8
37
|
|
9
38
|
attr_accessor :class_name
|
39
|
+
|
40
|
+
##
|
41
|
+
# An array of header lines to have before the lexer class.
|
42
|
+
|
10
43
|
attr_accessor :header
|
44
|
+
|
45
|
+
##
|
46
|
+
# An array of lines to have after the lexer class.
|
47
|
+
|
11
48
|
attr_accessor :ends
|
49
|
+
|
50
|
+
##
|
51
|
+
# An array of lines to have inside (but at the bottom of) the lexer
|
52
|
+
# class.
|
53
|
+
|
12
54
|
attr_accessor :inners
|
55
|
+
|
56
|
+
##
|
57
|
+
# An array of name/regexp pairs to generate constants inside the
|
58
|
+
# lexer class.
|
59
|
+
|
13
60
|
attr_accessor :macros
|
61
|
+
|
62
|
+
##
|
63
|
+
# A hash of options for the code generator. See README.rdoc for
|
64
|
+
# supported options.
|
65
|
+
|
14
66
|
attr_accessor :option
|
67
|
+
|
68
|
+
##
|
69
|
+
# The rules for the lexer.
|
70
|
+
|
15
71
|
attr_accessor :rules
|
72
|
+
|
73
|
+
##
|
74
|
+
# An array of lines of code to generate into the top of the lexer
|
75
|
+
# (next_token) loop.
|
76
|
+
|
16
77
|
attr_accessor :starts
|
78
|
+
|
79
|
+
##
|
80
|
+
# An array of all the groups within the lexer rules.
|
81
|
+
|
17
82
|
attr_accessor :group
|
18
83
|
|
19
|
-
DEFAULTS = {
|
84
|
+
DEFAULTS = { # :nodoc:
|
20
85
|
:debug => false,
|
21
86
|
:do_parse => false,
|
22
87
|
:lineno => false,
|
@@ -24,21 +89,39 @@ class OedipusLex
|
|
24
89
|
:stub => false,
|
25
90
|
}
|
26
91
|
|
92
|
+
##
|
93
|
+
# A Rule represents the main component of Oedipus Lex. These are the
|
94
|
+
# things that "get stuff done" at the lexical level. They consist of:
|
95
|
+
#
|
96
|
+
# + an optional required start state symbol or predicate method name
|
97
|
+
# + a regexp to match on
|
98
|
+
# + an optional action method or block
|
99
|
+
|
27
100
|
class Rule < Struct.new :start_state, :regexp, :action
|
101
|
+
##
|
102
|
+
# What group this rule is in, if any.
|
103
|
+
|
28
104
|
attr_accessor :group
|
29
|
-
|
105
|
+
|
106
|
+
alias :group? :group # :nodoc:
|
107
|
+
|
108
|
+
##
|
109
|
+
# A simple constructor
|
30
110
|
|
31
111
|
def self.[] start, regexp, action
|
32
112
|
new start, regexp.inspect, action
|
33
113
|
end
|
34
114
|
|
35
|
-
def initialize start_state, regexp, action
|
115
|
+
def initialize start_state, regexp, action # :nodoc:
|
36
116
|
super
|
37
117
|
self.group = nil
|
38
118
|
end
|
39
119
|
|
40
120
|
undef_method :to_a
|
41
121
|
|
122
|
+
##
|
123
|
+
# Generate equivalent ruby code for the rule.
|
124
|
+
|
42
125
|
def to_ruby state, predicates, exclusive
|
43
126
|
return unless group? or
|
44
127
|
start_state == state or
|
@@ -73,7 +156,7 @@ class OedipusLex
|
|
73
156
|
["when #{cond} then", body]
|
74
157
|
end
|
75
158
|
|
76
|
-
def pretty_print pp
|
159
|
+
def pretty_print pp # :nodoc:
|
77
160
|
pp.text "Rule"
|
78
161
|
pp.group 2, "[", "]" do
|
79
162
|
pp.pp start_state
|
@@ -85,25 +168,37 @@ class OedipusLex
|
|
85
168
|
end
|
86
169
|
end
|
87
170
|
|
171
|
+
##
|
172
|
+
# A group allows you to group up multiple rules under a single
|
173
|
+
# regular prefix expression, allowing optimized code to be generated
|
174
|
+
# that skips over all actions if the prefix isn't matched.
|
175
|
+
|
88
176
|
class Group < Struct.new :regex, :rules
|
89
177
|
alias :start_state :regex
|
90
178
|
|
179
|
+
##
|
180
|
+
# A convenience method to create a new group with a +start+ and
|
181
|
+
# given +subrules+.
|
182
|
+
|
91
183
|
def self.[] start, *subrules
|
92
184
|
r = new start.inspect
|
93
185
|
r.rules.concat subrules
|
94
186
|
r
|
95
187
|
end
|
96
188
|
|
97
|
-
def initialize start
|
189
|
+
def initialize start # :nodoc:
|
98
190
|
super(start, [])
|
99
191
|
end
|
100
192
|
|
193
|
+
##
|
194
|
+
# Add a rule to this group.
|
195
|
+
|
101
196
|
def << rule
|
102
197
|
rules << rule
|
103
198
|
nil
|
104
199
|
end
|
105
200
|
|
106
|
-
def to_ruby state, predicates, exclusive
|
201
|
+
def to_ruby state, predicates, exclusive # :nodoc:
|
107
202
|
[
|
108
203
|
"when ss.match?(#{regex}) then",
|
109
204
|
" case",
|
@@ -115,7 +210,7 @@ class OedipusLex
|
|
115
210
|
]
|
116
211
|
end
|
117
212
|
|
118
|
-
def pretty_print pp
|
213
|
+
def pretty_print pp # :nodoc:
|
119
214
|
pp.text "Group"
|
120
215
|
pp.group 2, "[", "]" do
|
121
216
|
pp.seplist([regex] + rules, lambda { pp.comma_breakable }, :each) { |v|
|
@@ -125,6 +220,10 @@ class OedipusLex
|
|
125
220
|
end
|
126
221
|
end
|
127
222
|
|
223
|
+
##
|
224
|
+
# A convenience method to create a new lexer with a +name+ and given
|
225
|
+
# +rules+.
|
226
|
+
|
128
227
|
def self.[](name, *rules)
|
129
228
|
r = new
|
130
229
|
r.class_name = name
|
@@ -132,7 +231,7 @@ class OedipusLex
|
|
132
231
|
r
|
133
232
|
end
|
134
233
|
|
135
|
-
def initialize opts = {}
|
234
|
+
def initialize opts = {} # :nodoc:
|
136
235
|
self.option = DEFAULTS.merge opts
|
137
236
|
self.class_name = nil
|
138
237
|
|
@@ -145,7 +244,7 @@ class OedipusLex
|
|
145
244
|
self.group = nil
|
146
245
|
end
|
147
246
|
|
148
|
-
def == o
|
247
|
+
def == o # :nodoc:
|
149
248
|
(o.class == self.class and
|
150
249
|
o.class_name == self.class_name and
|
151
250
|
o.header == self.header and
|
@@ -156,7 +255,7 @@ class OedipusLex
|
|
156
255
|
o.starts == self.starts)
|
157
256
|
end
|
158
257
|
|
159
|
-
def pretty_print pp
|
258
|
+
def pretty_print pp # :nodoc:
|
160
259
|
commas = lambda { pp.comma_breakable }
|
161
260
|
|
162
261
|
pp.text "Lexer"
|
@@ -165,67 +264,109 @@ class OedipusLex
|
|
165
264
|
end
|
166
265
|
end
|
167
266
|
|
267
|
+
##
|
268
|
+
# Process a +class+ lexeme.
|
269
|
+
|
168
270
|
def lex_class prefix, name
|
169
271
|
header.concat prefix.split(/\n/)
|
170
272
|
self.class_name = name
|
171
273
|
end
|
172
274
|
|
275
|
+
##
|
276
|
+
# Process a +comment+ lexeme.
|
277
|
+
|
173
278
|
def lex_comment line
|
174
279
|
# do nothing
|
175
280
|
end
|
176
281
|
|
282
|
+
##
|
283
|
+
# Process an +end+ lexeme.
|
284
|
+
|
177
285
|
def lex_end line
|
178
286
|
ends << line
|
179
287
|
end
|
180
288
|
|
289
|
+
##
|
290
|
+
# Process an +inner+ lexeme.
|
291
|
+
|
181
292
|
def lex_inner line
|
182
293
|
inners << line
|
183
294
|
end
|
184
295
|
|
296
|
+
##
|
297
|
+
# Process a +start+ lexeme.
|
298
|
+
|
185
299
|
def lex_start line
|
186
300
|
starts << line.strip
|
187
301
|
end
|
188
302
|
|
303
|
+
##
|
304
|
+
# Process a +macro+ lexeme.
|
305
|
+
|
189
306
|
def lex_macro name, value
|
190
307
|
macros << [name, value]
|
191
308
|
end
|
192
309
|
|
310
|
+
##
|
311
|
+
# Process an +option+ lexeme.
|
312
|
+
|
193
313
|
def lex_option option
|
194
314
|
self.option[option.to_sym] = true
|
195
315
|
end
|
196
316
|
|
317
|
+
##
|
318
|
+
# Process a +X+ lexeme.
|
319
|
+
|
197
320
|
def lex_rule start_state, regexp, action = nil
|
198
321
|
rules << Rule.new(start_state, regexp, action)
|
199
322
|
end
|
200
323
|
|
324
|
+
##
|
325
|
+
# Process a +group head+ lexeme.
|
326
|
+
|
201
327
|
def lex_grouphead re
|
202
328
|
end_group if group
|
203
329
|
self.state = :group
|
204
330
|
self.group = Group.new re
|
205
331
|
end
|
206
332
|
|
333
|
+
##
|
334
|
+
# Process a +group+ lexeme.
|
335
|
+
|
207
336
|
def lex_group start_state, regexp, action = nil
|
208
337
|
rule = Rule.new(start_state, regexp, action)
|
209
338
|
rule.group = group
|
210
339
|
self.group << rule
|
211
340
|
end
|
212
341
|
|
342
|
+
##
|
343
|
+
# End a group.
|
344
|
+
|
213
345
|
def end_group
|
214
346
|
rules << group
|
215
347
|
self.group = nil
|
216
348
|
self.state = :rule
|
217
349
|
end
|
218
350
|
|
351
|
+
##
|
352
|
+
# Process the end of a +group+ lexeme.
|
353
|
+
|
219
354
|
def lex_groupend start_state, regexp, action = nil
|
220
355
|
end_group
|
221
356
|
lex_rule start_state, regexp, action
|
222
357
|
end
|
223
358
|
|
359
|
+
##
|
360
|
+
# Process a +state+ lexeme.
|
361
|
+
|
224
362
|
def lex_state new_state
|
225
363
|
end_group if group
|
226
364
|
# do nothing -- lexer switches state for us
|
227
365
|
end
|
228
366
|
|
367
|
+
##
|
368
|
+
# Generate the lexer.
|
369
|
+
|
229
370
|
def generate
|
230
371
|
filter = lambda { |r| Rule === r && r.start_state || nil }
|
231
372
|
_mystates = rules.map(&filter).flatten.compact.uniq
|
@@ -241,9 +382,17 @@ class OedipusLex
|
|
241
382
|
encoding = header.shift if header.first =~ /encoding:/
|
242
383
|
encoding ||= "# encoding: UTF-8"
|
243
384
|
|
244
|
-
|
385
|
+
erb = if RUBY_VERSION >= "2.6.0" then
|
386
|
+
ERB.new(TEMPLATE, trim_mode:"%")
|
387
|
+
else
|
388
|
+
ERB.new(TEMPLATE, nil, "%")
|
389
|
+
end
|
390
|
+
|
391
|
+
erb.result binding
|
245
392
|
end
|
246
393
|
|
394
|
+
# :stopdoc:
|
395
|
+
|
247
396
|
TEMPLATE = <<-'REX'.gsub(/^ {6}/, '')
|
248
397
|
<%= encoding %>
|
249
398
|
#--
|
@@ -260,41 +409,74 @@ class OedipusLex
|
|
260
409
|
% end
|
261
410
|
|
262
411
|
% end
|
412
|
+
|
413
|
+
##
|
414
|
+
# The generated lexer <%= class_name %>
|
415
|
+
|
263
416
|
class <%= class_name %>
|
264
417
|
require 'strscan'
|
265
418
|
|
266
419
|
% unless macros.empty? then
|
420
|
+
# :stopdoc:
|
267
421
|
% max = macros.map { |(k,_)| k.size }.max
|
268
422
|
% macros.each do |(k,v)|
|
269
423
|
<%= "%-#{max}s = %s" % [k, v] %>
|
270
424
|
% end
|
271
|
-
|
425
|
+
# :startdoc:
|
272
426
|
% end
|
427
|
+
# :stopdoc:
|
273
428
|
class LexerError < StandardError ; end
|
274
429
|
class ScanError < LexerError ; end
|
430
|
+
# :startdoc:
|
275
431
|
|
276
432
|
% if option[:lineno] then
|
433
|
+
##
|
434
|
+
# The current line number.
|
435
|
+
|
277
436
|
attr_accessor :lineno
|
278
437
|
% end
|
438
|
+
##
|
439
|
+
# The file name / path
|
440
|
+
|
279
441
|
attr_accessor :filename
|
442
|
+
|
443
|
+
##
|
444
|
+
# The StringScanner for this lexer.
|
445
|
+
|
280
446
|
attr_accessor :ss
|
447
|
+
|
448
|
+
##
|
449
|
+
# The current lexical state.
|
450
|
+
|
281
451
|
attr_accessor :state
|
282
452
|
|
283
453
|
alias :match :ss
|
284
454
|
|
455
|
+
##
|
456
|
+
# The match groups for the current scan.
|
457
|
+
|
285
458
|
def matches
|
286
459
|
m = (1..9).map { |i| ss[i] }
|
287
460
|
m.pop until m[-1] or m.empty?
|
288
461
|
m
|
289
462
|
end
|
290
463
|
|
464
|
+
##
|
465
|
+
# Yields on the current action.
|
466
|
+
|
291
467
|
def action
|
292
468
|
yield
|
293
469
|
end
|
294
470
|
|
295
471
|
% if option[:column] then
|
472
|
+
##
|
473
|
+
# The previous position. Only available if the :column option is on.
|
474
|
+
|
296
475
|
attr_accessor :old_pos
|
297
476
|
|
477
|
+
##
|
478
|
+
# The current column. Only available if the :column option is on.
|
479
|
+
|
298
480
|
def column
|
299
481
|
idx = ss.string.rindex("\n", old_pos) || -1
|
300
482
|
old_pos - idx - 1
|
@@ -302,6 +484,9 @@ class OedipusLex
|
|
302
484
|
|
303
485
|
% end
|
304
486
|
% if option[:do_parse] then
|
487
|
+
##
|
488
|
+
# Parse the file by getting all tokens and calling lex_+type+ on them.
|
489
|
+
|
305
490
|
def do_parse
|
306
491
|
while token = next_token do
|
307
492
|
type, *vals = token
|
@@ -311,10 +496,17 @@ class OedipusLex
|
|
311
496
|
end
|
312
497
|
|
313
498
|
% end
|
499
|
+
|
500
|
+
##
|
501
|
+
# The current scanner class. Must be overridden in subclasses.
|
502
|
+
|
314
503
|
def scanner_class
|
315
504
|
StringScanner
|
316
505
|
end unless instance_methods(false).map(&:to_s).include?("scanner_class")
|
317
506
|
|
507
|
+
##
|
508
|
+
# Parse the given string.
|
509
|
+
|
318
510
|
def parse str
|
319
511
|
self.ss = scanner_class.new str
|
320
512
|
% if option[:lineno] then
|
@@ -325,6 +517,9 @@ class OedipusLex
|
|
325
517
|
do_parse
|
326
518
|
end
|
327
519
|
|
520
|
+
##
|
521
|
+
# Read in and parse the file at +path+.
|
522
|
+
|
328
523
|
def parse_file path
|
329
524
|
self.filename = path
|
330
525
|
open path do |f|
|
@@ -332,6 +527,9 @@ class OedipusLex
|
|
332
527
|
end
|
333
528
|
end
|
334
529
|
|
530
|
+
##
|
531
|
+
# The current location in the parse.
|
532
|
+
|
335
533
|
def location
|
336
534
|
[
|
337
535
|
(filename || "<input>"),
|
@@ -346,6 +544,9 @@ class OedipusLex
|
|
346
544
|
].compact.join(":")
|
347
545
|
end
|
348
546
|
|
547
|
+
##
|
548
|
+
# Lex the next token.
|
549
|
+
|
349
550
|
def next_token
|
350
551
|
% starts.each do |s|
|
351
552
|
<%= s %>
|
@@ -427,6 +628,8 @@ class OedipusLex
|
|
427
628
|
end
|
428
629
|
% end
|
429
630
|
REX
|
631
|
+
|
632
|
+
# :startdoc:
|
430
633
|
end
|
431
634
|
|
432
635
|
if $0 == __FILE__ then
|
data/lib/oedipus_lex.rex.rb
CHANGED
@@ -1,44 +1,80 @@
|
|
1
1
|
# encoding: UTF-8
|
2
2
|
#--
|
3
3
|
# This file is automatically generated. Do not modify it.
|
4
|
-
# Generated by: oedipus_lex version 2.
|
4
|
+
# Generated by: oedipus_lex version 2.5.0.
|
5
5
|
# Source: lib/oedipus_lex.rex
|
6
6
|
#++
|
7
7
|
|
8
|
+
|
9
|
+
##
|
10
|
+
# The generated lexer OedipusLex
|
11
|
+
|
8
12
|
class OedipusLex
|
9
13
|
require 'strscan'
|
10
14
|
|
15
|
+
# :stopdoc:
|
11
16
|
ST = /(?:(:\S+|\w+\??))/
|
12
17
|
RE = /(\/(?:\\.|[^\/])+\/[ion]?)/
|
13
18
|
ACT = /(\{.*|:?\w+)/
|
14
|
-
|
19
|
+
# :startdoc:
|
20
|
+
# :stopdoc:
|
15
21
|
class LexerError < StandardError ; end
|
16
22
|
class ScanError < LexerError ; end
|
23
|
+
# :startdoc:
|
24
|
+
|
25
|
+
##
|
26
|
+
# The current line number.
|
17
27
|
|
18
28
|
attr_accessor :lineno
|
29
|
+
##
|
30
|
+
# The file name / path
|
31
|
+
|
19
32
|
attr_accessor :filename
|
33
|
+
|
34
|
+
##
|
35
|
+
# The StringScanner for this lexer.
|
36
|
+
|
20
37
|
attr_accessor :ss
|
38
|
+
|
39
|
+
##
|
40
|
+
# The current lexical state.
|
41
|
+
|
21
42
|
attr_accessor :state
|
22
43
|
|
23
44
|
alias :match :ss
|
24
45
|
|
46
|
+
##
|
47
|
+
# The match groups for the current scan.
|
48
|
+
|
25
49
|
def matches
|
26
50
|
m = (1..9).map { |i| ss[i] }
|
27
51
|
m.pop until m[-1] or m.empty?
|
28
52
|
m
|
29
53
|
end
|
30
54
|
|
55
|
+
##
|
56
|
+
# Yields on the current action.
|
57
|
+
|
31
58
|
def action
|
32
59
|
yield
|
33
60
|
end
|
34
61
|
|
62
|
+
##
|
63
|
+
# The previous position. Only available if the :column option is on.
|
64
|
+
|
35
65
|
attr_accessor :old_pos
|
36
66
|
|
67
|
+
##
|
68
|
+
# The current column. Only available if the :column option is on.
|
69
|
+
|
37
70
|
def column
|
38
71
|
idx = ss.string.rindex("\n", old_pos) || -1
|
39
72
|
old_pos - idx - 1
|
40
73
|
end
|
41
74
|
|
75
|
+
##
|
76
|
+
# Parse the file by getting all tokens and calling lex_+type+ on them.
|
77
|
+
|
42
78
|
def do_parse
|
43
79
|
while token = next_token do
|
44
80
|
type, *vals = token
|
@@ -47,10 +83,17 @@ class OedipusLex
|
|
47
83
|
end
|
48
84
|
end
|
49
85
|
|
86
|
+
|
87
|
+
##
|
88
|
+
# The current scanner class. Must be overridden in subclasses.
|
89
|
+
|
50
90
|
def scanner_class
|
51
91
|
StringScanner
|
52
92
|
end unless instance_methods(false).map(&:to_s).include?("scanner_class")
|
53
93
|
|
94
|
+
##
|
95
|
+
# Parse the given string.
|
96
|
+
|
54
97
|
def parse str
|
55
98
|
self.ss = scanner_class.new str
|
56
99
|
self.lineno = 1
|
@@ -59,6 +102,9 @@ class OedipusLex
|
|
59
102
|
do_parse
|
60
103
|
end
|
61
104
|
|
105
|
+
##
|
106
|
+
# Read in and parse the file at +path+.
|
107
|
+
|
62
108
|
def parse_file path
|
63
109
|
self.filename = path
|
64
110
|
open path do |f|
|
@@ -66,6 +112,9 @@ class OedipusLex
|
|
66
112
|
end
|
67
113
|
end
|
68
114
|
|
115
|
+
##
|
116
|
+
# The current location in the parse.
|
117
|
+
|
69
118
|
def location
|
70
119
|
[
|
71
120
|
(filename || "<input>"),
|
@@ -74,6 +123,9 @@ class OedipusLex
|
|
74
123
|
].compact.join(":")
|
75
124
|
end
|
76
125
|
|
126
|
+
##
|
127
|
+
# Lex the next token.
|
128
|
+
|
77
129
|
def next_token
|
78
130
|
|
79
131
|
token = nil
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oedipus_lex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.5.
|
4
|
+
version: 2.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Davis
|
@@ -10,9 +10,9 @@ bindir: bin
|
|
10
10
|
cert_chain:
|
11
11
|
- |
|
12
12
|
-----BEGIN CERTIFICATE-----
|
13
|
-
|
13
|
+
MIIDPjCCAiagAwIBAgIBAzANBgkqhkiG9w0BAQsFADBFMRMwEQYDVQQDDApyeWFu
|
14
14
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
15
|
-
|
15
|
+
GRYDY29tMB4XDTE4MTIwNDIxMzAxNFoXDTE5MTIwNDIxMzAxNFowRTETMBEGA1UE
|
16
16
|
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
17
17
|
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
18
18
|
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
@@ -20,46 +20,51 @@ cert_chain:
|
|
20
20
|
oOvjtt5P8+GSK9zLzxQP0gVLS/D0FmoE44XuDr3iQkVS2ujU5zZL84mMNqNB1znh
|
21
21
|
GiadM9GHRaDiaxuX0cIUBj19T01mVE2iymf9I6bEsiayK/n6QujtyCbTWsAS9Rqt
|
22
22
|
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
23
|
-
gBEfoTEGr7Zii72cx+
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
fO6tdKQc/5RfA8oQEkg8hrxA5PQSz4TOFJGLpFvIapEk6tMruQ0bHgkhr9auXg==
|
23
|
+
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
24
|
+
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBCwUAA4IB
|
25
|
+
AQCbJwLmpJR2PomLU+Zzw3KRzH/hbyUWc/ftru71AopZ1fy4iY9J/BW5QYKVYwbP
|
26
|
+
V0FSBWtvfI/RdwfKGtuGhPKECZgmLieGuZ3XCc09qPu1bdg7i/tu1p0t0c6163ku
|
27
|
+
nDMDIC/t/DAFK0TY9I3HswuyZGbLW7rgF0DmiuZdN/RPhHq2pOLMLXJmFclCb/im
|
28
|
+
9yToml/06TJdUJ5p64mkBs0TzaK66DIB1Smd3PdtfZqoRV+EwaXMdx0Hb3zdR1JR
|
29
|
+
Em82dBUFsipwMLCYj39kcyHWAxyl6Ae1Cn9r/ItVBCxoeFdrHjfavnrIEoXUt4bU
|
30
|
+
UfBugfLD19bu3nvL+zTAGx/U
|
32
31
|
-----END CERTIFICATE-----
|
33
|
-
date:
|
32
|
+
date: 2019-06-04 00:00:00.000000000 Z
|
34
33
|
dependencies:
|
35
34
|
- !ruby/object:Gem::Dependency
|
36
35
|
name: rdoc
|
37
36
|
requirement: !ruby/object:Gem::Requirement
|
38
37
|
requirements:
|
39
|
-
- -
|
38
|
+
- - ">="
|
40
39
|
- !ruby/object:Gem::Version
|
41
40
|
version: '4.0'
|
41
|
+
- - "<"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '7'
|
42
44
|
type: :development
|
43
45
|
prerelease: false
|
44
46
|
version_requirements: !ruby/object:Gem::Requirement
|
45
47
|
requirements:
|
46
|
-
- -
|
48
|
+
- - ">="
|
47
49
|
- !ruby/object:Gem::Version
|
48
50
|
version: '4.0'
|
51
|
+
- - "<"
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '7'
|
49
54
|
- !ruby/object:Gem::Dependency
|
50
55
|
name: hoe
|
51
56
|
requirement: !ruby/object:Gem::Requirement
|
52
57
|
requirements:
|
53
|
-
- - ~>
|
58
|
+
- - "~>"
|
54
59
|
- !ruby/object:Gem::Version
|
55
|
-
version: '3.
|
60
|
+
version: '3.17'
|
56
61
|
type: :development
|
57
62
|
prerelease: false
|
58
63
|
version_requirements: !ruby/object:Gem::Requirement
|
59
64
|
requirements:
|
60
|
-
- - ~>
|
65
|
+
- - "~>"
|
61
66
|
- !ruby/object:Gem::Version
|
62
|
-
version: '3.
|
67
|
+
version: '3.17'
|
63
68
|
description: |-
|
64
69
|
Oedipus Lex is a lexer generator in the same family as Rexical and
|
65
70
|
Rex. Oedipus Lex is my independent lexer fork of Rexical. Rexical was
|
@@ -93,7 +98,7 @@ extra_rdoc_files:
|
|
93
98
|
- README.rdoc
|
94
99
|
- sample/error1.txt
|
95
100
|
files:
|
96
|
-
- .autotest
|
101
|
+
- ".autotest"
|
97
102
|
- History.rdoc
|
98
103
|
- Manifest.txt
|
99
104
|
- README.rdoc
|
@@ -126,23 +131,22 @@ licenses:
|
|
126
131
|
metadata: {}
|
127
132
|
post_install_message:
|
128
133
|
rdoc_options:
|
129
|
-
- --main
|
134
|
+
- "--main"
|
130
135
|
- README.rdoc
|
131
136
|
require_paths:
|
132
137
|
- lib
|
133
138
|
required_ruby_version: !ruby/object:Gem::Requirement
|
134
139
|
requirements:
|
135
|
-
- -
|
140
|
+
- - ">="
|
136
141
|
- !ruby/object:Gem::Version
|
137
142
|
version: '0'
|
138
143
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
144
|
requirements:
|
140
|
-
- -
|
145
|
+
- - ">="
|
141
146
|
- !ruby/object:Gem::Version
|
142
147
|
version: '0'
|
143
148
|
requirements: []
|
144
|
-
|
145
|
-
rubygems_version: 2.4.5
|
149
|
+
rubygems_version: 3.0.2
|
146
150
|
signing_key:
|
147
151
|
specification_version: 4
|
148
152
|
summary: Oedipus Lex is a lexer generator in the same family as Rexical and Rex
|
metadata.gz.sig
CHANGED
Binary file
|