rexical 1.0.5.beta2 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of rexical might be problematic. Click here for more details.
- data/Rakefile +4 -0
- data/lib/rexical.rb +1 -1
- data/lib/rexical/generator.rb +8 -2
- data/test/test_generator.rb +17 -0
- metadata +10 -33
data/Rakefile
CHANGED
data/lib/rexical.rb
CHANGED
data/lib/rexical/generator.rb
CHANGED
@@ -400,7 +400,13 @@ REX_EOT
|
|
400
400
|
|
401
401
|
def next_token
|
402
402
|
return if @ss.eos?
|
403
|
+
|
404
|
+
# skips empty actions
|
405
|
+
until token = _next_token or @ss.eos?; end
|
406
|
+
token
|
407
|
+
end
|
403
408
|
|
409
|
+
def _next_token
|
404
410
|
text = @ss.peek(1)
|
405
411
|
@lineno += 1 if text == "\\n"
|
406
412
|
token = case @state
|
@@ -418,7 +424,7 @@ REX_EOT
|
|
418
424
|
if rule_action
|
419
425
|
if start_state
|
420
426
|
f.print <<-REX_EOT
|
421
|
-
when
|
427
|
+
when((state == #{start_state}) and (text = @ss.scan(/#{rule_expr}/#{flag})))
|
422
428
|
action #{rule_action}
|
423
429
|
|
424
430
|
REX_EOT
|
@@ -467,7 +473,7 @@ REX_EOT
|
|
467
473
|
end
|
468
474
|
f.print <<-REX_EOT
|
469
475
|
token
|
470
|
-
end # def
|
476
|
+
end # def _next_token
|
471
477
|
|
472
478
|
REX_EOT
|
473
479
|
|
data/test/test_generator.rb
CHANGED
@@ -90,6 +90,23 @@ end
|
|
90
90
|
[:NUMBER, 10]], calc
|
91
91
|
end
|
92
92
|
|
93
|
+
def test_simple_scanner_with_empty_action
|
94
|
+
m = build_lexer %q{
|
95
|
+
class Calculator
|
96
|
+
rule
|
97
|
+
\d+ { [:NUMBER, text.to_i] }
|
98
|
+
\s+ # skips whitespaces
|
99
|
+
end
|
100
|
+
}
|
101
|
+
|
102
|
+
calc = m::Calculator.new
|
103
|
+
calc.scan_setup('1 2 10')
|
104
|
+
|
105
|
+
assert_tokens [[:NUMBER, 1],
|
106
|
+
[:NUMBER, 2],
|
107
|
+
[:NUMBER, 10]], calc
|
108
|
+
end
|
109
|
+
|
93
110
|
def test_parses_macros_with_escapes
|
94
111
|
source = parse_lexer %q{
|
95
112
|
class Foo
|
metadata
CHANGED
@@ -1,14 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rexical
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease: true
|
4
|
+
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 1
|
8
7
|
- 0
|
9
8
|
- 5
|
10
|
-
|
11
|
-
version: 1.0.5.beta2
|
9
|
+
version: 1.0.5
|
12
10
|
platform: ruby
|
13
11
|
authors:
|
14
12
|
- Aaron Patterson
|
@@ -16,41 +14,24 @@ autorequire:
|
|
16
14
|
bindir: bin
|
17
15
|
cert_chain: []
|
18
16
|
|
19
|
-
date: 2010-
|
17
|
+
date: 2010-12-08 00:00:00 -08:00
|
20
18
|
default_executable:
|
21
19
|
dependencies:
|
22
|
-
- !ruby/object:Gem::Dependency
|
23
|
-
name: rubyforge
|
24
|
-
prerelease: false
|
25
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
26
|
-
none: false
|
27
|
-
requirements:
|
28
|
-
- - ">="
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
hash: 7
|
31
|
-
segments:
|
32
|
-
- 2
|
33
|
-
- 0
|
34
|
-
- 4
|
35
|
-
version: 2.0.4
|
36
|
-
type: :development
|
37
|
-
version_requirements: *id001
|
38
20
|
- !ruby/object:Gem::Dependency
|
39
21
|
name: hoe
|
40
22
|
prerelease: false
|
41
|
-
requirement: &
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
42
24
|
none: false
|
43
25
|
requirements:
|
44
26
|
- - ">="
|
45
27
|
- !ruby/object:Gem::Version
|
46
|
-
hash: 23
|
47
28
|
segments:
|
48
29
|
- 2
|
49
30
|
- 6
|
50
|
-
-
|
51
|
-
version: 2.6.
|
31
|
+
- 2
|
32
|
+
version: 2.6.2
|
52
33
|
type: :development
|
53
|
-
version_requirements: *
|
34
|
+
version_requirements: *id001
|
54
35
|
description: |-
|
55
36
|
Rexical is a lexical scanner generator.
|
56
37
|
It is written in Ruby itself, and generates Ruby program.
|
@@ -119,21 +100,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
119
100
|
requirements:
|
120
101
|
- - ">="
|
121
102
|
- !ruby/object:Gem::Version
|
122
|
-
hash: 3
|
123
103
|
segments:
|
124
104
|
- 0
|
125
105
|
version: "0"
|
126
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
127
107
|
none: false
|
128
108
|
requirements:
|
129
|
-
- - "
|
109
|
+
- - ">="
|
130
110
|
- !ruby/object:Gem::Version
|
131
|
-
hash: 25
|
132
111
|
segments:
|
133
|
-
-
|
134
|
-
|
135
|
-
- 1
|
136
|
-
version: 1.3.1
|
112
|
+
- 0
|
113
|
+
version: "0"
|
137
114
|
requirements: []
|
138
115
|
|
139
116
|
rubyforge_project: ruby-rex
|