oedipus_lex 2.4.0 → 2.4.1
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/History.rdoc +6 -0
- data/README.rdoc +1 -1
- data/Rakefile +9 -2
- data/lib/oedipus_lex.rb +17 -12
- data/test/test_oedipus_lex.rb +3 -4
- metadata +17 -19
- metadata.gz.sig +0 -0
- data/.gemtest +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab5673d633e7abae710deb96e4b764b2518bed0e
|
4
|
+
data.tar.gz: 9e16b31d4ffeaad609fe27812e69f8dfa3b0b8ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3948a898e603ccb19494bdcb753f1ae5f799d21660c42a8ba80611884e18a94f615ef1511c79d1ac5f592e6ea7288ab673b6729988e8f8a07d37c881e9f6c6f
|
7
|
+
data.tar.gz: 7876d02faa16c81ef199ceec5b342cf9bd69e9e0d6c4970328e8e92c49abc3904dd06e1b1a40734fe5cc80314030e2b5cc21d7a2ec60afb60ff66f532a93572c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -19,7 +19,7 @@ At the very least, you need to add slashes to all your regexps.
|
|
19
19
|
|
20
20
|
Oedipus, like rexical, is based primarily on generating code much like
|
21
21
|
you would a hand-written lexer. It is _not_ a table or hash driven
|
22
|
-
lexer. It
|
22
|
+
lexer. It uses StrScanner within a multi-level case statement. As such,
|
23
23
|
Oedipus matches on the _first_ match, not the longest (like lex and
|
24
24
|
its ilk).
|
25
25
|
|
data/Rakefile
CHANGED
@@ -3,8 +3,6 @@
|
|
3
3
|
require "rubygems"
|
4
4
|
require "hoe"
|
5
5
|
|
6
|
-
Hoe.plugin :debugging
|
7
|
-
Hoe.plugin :git
|
8
6
|
Hoe.plugin :isolate
|
9
7
|
Hoe.plugin :seattlerb
|
10
8
|
|
@@ -16,6 +14,10 @@ Hoe.spec "oedipus_lex" do
|
|
16
14
|
self.history_file = "History.rdoc"
|
17
15
|
end
|
18
16
|
|
17
|
+
Hoe.bad_plugins.each do |bad|
|
18
|
+
warn "BAD: Hoe.plugin :#{bad}"
|
19
|
+
end
|
20
|
+
|
19
21
|
task :bootstrap do
|
20
22
|
ruby "-Ilib lib/oedipus_lex.rb lib/oedipus_lex.rex > lib/oedipus_lex.rex.rb.new"
|
21
23
|
system "diff -uw lib/oedipus_lex.rex.rb lib/oedipus_lex.rex.rb.new"
|
@@ -78,4 +80,9 @@ task :debug do
|
|
78
80
|
puts rex.generate
|
79
81
|
end
|
80
82
|
|
83
|
+
task :wtf => :isolate do
|
84
|
+
puts `~/.rbenv/versions/2.2.0/bin/ruby -S gem env`
|
85
|
+
puts `~/.rbenv/versions/2.2.0/bin/ruby -S gem list`
|
86
|
+
end
|
87
|
+
|
81
88
|
# vim: syntax=ruby
|
data/lib/oedipus_lex.rb
CHANGED
@@ -4,7 +4,7 @@ require "erb"
|
|
4
4
|
require "oedipus_lex.rex"
|
5
5
|
|
6
6
|
class OedipusLex
|
7
|
-
VERSION = "2.4.
|
7
|
+
VERSION = "2.4.1"
|
8
8
|
|
9
9
|
attr_accessor :class_name
|
10
10
|
attr_accessor :header
|
@@ -44,28 +44,33 @@ class OedipusLex
|
|
44
44
|
start_state == state or
|
45
45
|
(state.nil? and predicates.include? start_state)
|
46
46
|
|
47
|
-
|
48
|
-
if exclusive or not start_state then
|
49
|
-
"when text = ss.scan(#{regexp}) then"
|
50
|
-
elsif start_state =~ /^:/ then
|
51
|
-
"when (state == #{start_state}) && (text = ss.scan(#{regexp})) then"
|
52
|
-
else
|
53
|
-
"when #{start_state} && (text = ss.scan(#{regexp})) then"
|
54
|
-
end
|
47
|
+
uses_text = false
|
55
48
|
|
56
49
|
body =
|
57
50
|
case action
|
58
51
|
when nil, false then
|
59
52
|
" # do nothing"
|
60
53
|
when /^\{/ then
|
54
|
+
uses_text = action =~ /\btext\b/
|
61
55
|
" action #{action}"
|
62
56
|
when /^:/, "nil" then
|
63
57
|
" [:state, #{action}]"
|
64
|
-
else
|
58
|
+
else # plain method name
|
59
|
+
uses_text = true
|
65
60
|
" #{action} text"
|
66
61
|
end
|
67
62
|
|
68
|
-
|
63
|
+
check = uses_text ? "text = ss.scan(#{regexp})" : "ss.skip(#{regexp})"
|
64
|
+
|
65
|
+
cond = if exclusive or not start_state then
|
66
|
+
check
|
67
|
+
elsif start_state =~ /^:/ then
|
68
|
+
"(state == #{start_state}) && (#{check})"
|
69
|
+
else # predicate method
|
70
|
+
"#{start_state} && (#{check})"
|
71
|
+
end
|
72
|
+
|
73
|
+
["when #{cond} then", body]
|
69
74
|
end
|
70
75
|
|
71
76
|
def pretty_print pp
|
@@ -100,7 +105,7 @@ class OedipusLex
|
|
100
105
|
|
101
106
|
def to_ruby state, predicates, exclusive
|
102
107
|
[
|
103
|
-
"when ss.
|
108
|
+
"when ss.match?(#{regex}) then",
|
104
109
|
" case",
|
105
110
|
rules.map { |subrule|
|
106
111
|
s = subrule.to_ruby(state, predicates, exclusive)
|
data/test/test_oedipus_lex.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
gem "minitest"
|
2
1
|
require "minitest/autorun"
|
3
2
|
require "oedipus_lex"
|
4
3
|
require "stringio"
|
@@ -458,7 +457,7 @@ class TestOedipusLex < Minitest::Test
|
|
458
457
|
|
459
458
|
ruby = generate_lexer src
|
460
459
|
|
461
|
-
assert_match "when ss.
|
460
|
+
assert_match "when ss.match?(/\\d/) then", ruby
|
462
461
|
assert_match "when text = ss.scan(/\\d+\\.\\d+/) then", ruby
|
463
462
|
assert_match "when text = ss.scan(/\\d+/) then", ruby
|
464
463
|
assert_match "end # group /\\d/", ruby
|
@@ -481,12 +480,12 @@ class TestOedipusLex < Minitest::Test
|
|
481
480
|
|
482
481
|
ruby = generate_lexer src
|
483
482
|
|
484
|
-
assert_match "when ss.
|
483
|
+
assert_match "when ss.match?(/\\d/) then", ruby
|
485
484
|
assert_match "when text = ss.scan(/\\d+\\.\\d+/) then", ruby
|
486
485
|
assert_match "when text = ss.scan(/\\d+/) then", ruby
|
487
486
|
assert_match "end # group /\\d/", ruby
|
488
487
|
|
489
|
-
assert_match "when ss.
|
488
|
+
assert_match "when ss.match?(/\\+/) then", ruby
|
490
489
|
assert_match "when xx? && (text = ss.scan(/\\+whatever/)) then", ruby
|
491
490
|
assert_match "when (state == :x) && (text = ss.scan(/\\+\\d+/)) then", ruby
|
492
491
|
assert_match "end # group /\\d/", ruby
|
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.4.
|
4
|
+
version: 2.4.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
|
+
MIIDPjCCAiagAwIBAgIBAzANBgkqhkiG9w0BAQUFADBFMRMwEQYDVQQDDApyeWFu
|
14
14
|
ZC1ydWJ5MRkwFwYKCZImiZPyLGQBGRYJemVuc3BpZGVyMRMwEQYKCZImiZPyLGQB
|
15
|
-
|
15
|
+
GRYDY29tMB4XDTE1MDkxOTIwNTEyMloXDTE2MDkxODIwNTEyMlowRTETMBEGA1UE
|
16
16
|
AwwKcnlhbmQtcnVieTEZMBcGCgmSJomT8ixkARkWCXplbnNwaWRlcjETMBEGCgmS
|
17
17
|
JomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBALda
|
18
18
|
b9DCgK+627gPJkB6XfjZ1itoOQvpqH1EXScSaba9/S2VF22VYQbXU1xQXL/WzCkx
|
@@ -22,14 +22,14 @@ cert_chain:
|
|
22
22
|
qhtV7HJxNKuPj/JFH0D2cswvzznE/a5FOYO68g+YCuFi5L8wZuuM8zzdwjrWHqSV
|
23
23
|
gBEfoTEGr7Zii72cx+sCAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAw
|
24
24
|
HQYDVR0OBBYEFEfFe9md/r/tj/Wmwpy+MI8d9k/hMA0GCSqGSIb3DQEBBQUAA4IB
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
25
|
+
AQB+Hx8xUgrpZa4P8H8gR8zme5kISwQrG80MbpqJV6/G3/ZicRFhN5sjwu0uHGue
|
26
|
+
bd9Cymf6oIRwHVarJux2M32T6bL07Hmi07w2QaPc3MnMKB/D46SRZ2JSSGPFRBTc
|
27
|
+
SilobMRoGs/7B15uGFUEnNrCB/ltMqhwwSx1r++UQPfeySHEV9uqu03E5Vb7J37O
|
28
|
+
2Er6PLXHRiYsIycD1LkMi6YnixdITRHmrqJYE2rsjaIfpIehiusVAPHkNf7qbpHq
|
29
|
+
qx3h45R1CAsObX0SQDIT+rRbQrtKz1GHIZTOFYvEJjUY1XmRTZupD3CJ8Q7sDqSy
|
30
|
+
NLq5jm1fq6Y9Uolu3RJbmycf
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date:
|
32
|
+
date: 2016-01-21 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: minitest
|
@@ -37,14 +37,14 @@ dependencies:
|
|
37
37
|
requirements:
|
38
38
|
- - ~>
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '5.
|
40
|
+
version: '5.8'
|
41
41
|
type: :development
|
42
42
|
prerelease: false
|
43
43
|
version_requirements: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '5.
|
47
|
+
version: '5.8'
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: rdoc
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -65,14 +65,14 @@ dependencies:
|
|
65
65
|
requirements:
|
66
66
|
- - ~>
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: '3.
|
68
|
+
version: '3.14'
|
69
69
|
type: :development
|
70
70
|
prerelease: false
|
71
71
|
version_requirements: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ~>
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '3.
|
75
|
+
version: '3.14'
|
76
76
|
description: |-
|
77
77
|
Oedipus Lex is a lexer generator in the same family as Rexical and
|
78
78
|
Rex. Oedipus Lex is my independent lexer fork of Rexical. Rexical was
|
@@ -88,7 +88,7 @@ description: |-
|
|
88
88
|
|
89
89
|
Oedipus, like rexical, is based primarily on generating code much like
|
90
90
|
you would a hand-written lexer. It is _not_ a table or hash driven
|
91
|
-
lexer. It
|
91
|
+
lexer. It uses StrScanner within a multi-level case statement. As such,
|
92
92
|
Oedipus matches on the _first_ match, not the longest (like lex and
|
93
93
|
its ilk).
|
94
94
|
|
@@ -107,7 +107,6 @@ extra_rdoc_files:
|
|
107
107
|
- sample/error1.txt
|
108
108
|
files:
|
109
109
|
- .autotest
|
110
|
-
- .gemtest
|
111
110
|
- History.rdoc
|
112
111
|
- Manifest.txt
|
113
112
|
- README.rdoc
|
@@ -156,9 +155,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
155
|
version: '0'
|
157
156
|
requirements: []
|
158
157
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
158
|
+
rubygems_version: 2.4.5
|
160
159
|
signing_key:
|
161
160
|
specification_version: 4
|
162
161
|
summary: Oedipus Lex is a lexer generator in the same family as Rexical and Rex
|
163
|
-
test_files:
|
164
|
-
- test/test_oedipus_lex.rb
|
162
|
+
test_files: []
|
metadata.gz.sig
CHANGED
Binary file
|
data/.gemtest
DELETED
File without changes
|