waxeye 0.6.0 → 0.7.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.
- data/README +2 -1
- data/lib/waxeye.rb +39 -39
- metadata +3 -3
data/README
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
============================================
|
3
3
|
| Waxeye Parser Generator |
|
4
|
-
| v 0.
|
4
|
+
| v 0.7.0 |
|
5
5
|
| www.waxeye.org |
|
6
6
|
| Copyright (C) 2008 Orlando D. A. R. Hill |
|
7
7
|
============================================
|
@@ -33,6 +33,7 @@ Features
|
|
33
33
|
* Choice of Programming Language
|
34
34
|
- C
|
35
35
|
- Java
|
36
|
+
- Python
|
36
37
|
- Ruby
|
37
38
|
- Scheme
|
38
39
|
|
data/lib/waxeye.rb
CHANGED
@@ -40,7 +40,7 @@ module Waxeye
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
-
class
|
43
|
+
class FA
|
44
44
|
attr_reader :type, :states, :mode
|
45
45
|
def initialize(type, states, mode)
|
46
46
|
@type = type
|
@@ -58,8 +58,8 @@ module Waxeye
|
|
58
58
|
@nt = nt
|
59
59
|
end
|
60
60
|
|
61
|
-
def
|
62
|
-
|
61
|
+
def to_s()
|
62
|
+
"parse error: failed to match '#{nt}' at line=#{line}, col=#{col}, pos=#{pos}\n"
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
@@ -71,70 +71,68 @@ module Waxeye
|
|
71
71
|
@pos = pos
|
72
72
|
end
|
73
73
|
|
74
|
-
def
|
75
|
-
|
76
|
-
|
74
|
+
def to_s_sexpr()
|
75
|
+
acc = []
|
76
|
+
display_sexpr_iter(self, acc)
|
77
|
+
acc.to_s
|
77
78
|
end
|
78
79
|
|
79
|
-
def
|
80
|
-
|
80
|
+
def to_s()
|
81
|
+
acc = []
|
82
|
+
to_s_iter(self, [0], acc)
|
83
|
+
acc.to_s
|
81
84
|
end
|
82
85
|
|
83
86
|
private
|
84
|
-
def
|
85
|
-
|
86
|
-
|
87
|
+
def to_s_sexpr_iter(ast, acc)
|
88
|
+
acc.push('(')
|
89
|
+
acc.push(ast.type)
|
87
90
|
ast.children.each do |a|
|
88
|
-
|
91
|
+
acc.push(" ")
|
89
92
|
if a.is_a?(Waxeye::AST)
|
90
|
-
display_sexpr_iter(a)
|
93
|
+
display_sexpr_iter(a, acc)
|
91
94
|
else
|
92
|
-
|
95
|
+
acc.push(a)
|
93
96
|
end
|
94
97
|
end
|
95
|
-
|
98
|
+
acc.push(')')
|
96
99
|
end
|
97
100
|
|
98
|
-
def
|
99
|
-
(indent[0] - 1).times {||
|
100
|
-
|
101
|
-
|
102
|
-
indent[0]
|
101
|
+
def to_s_iter(ast, indent, acc)
|
102
|
+
(indent[0] - 1).times {|| acc.push(' ') }
|
103
|
+
acc.push('-> ') if indent[0] > 0
|
104
|
+
acc.push(ast.type)
|
105
|
+
indent[0] += 1
|
103
106
|
ast.children.each do |a|
|
107
|
+
acc.push("\n")
|
104
108
|
if a.is_a?(Waxeye::AST)
|
105
|
-
|
109
|
+
to_s_iter(a, indent, acc)
|
106
110
|
else
|
107
|
-
(indent[0] - 1).times {||
|
108
|
-
|
109
|
-
|
111
|
+
(indent[0] - 1).times {|| acc.push(' ') }
|
112
|
+
acc.push('| ') if indent[0] > 0
|
113
|
+
acc.push(a)
|
110
114
|
end
|
111
115
|
end
|
112
|
-
indent[0]
|
116
|
+
indent[0] -= 1
|
113
117
|
end
|
114
118
|
end
|
115
119
|
|
116
120
|
class WaxeyeParser
|
117
|
-
def initialize(start, eof_check,
|
121
|
+
def initialize(start, eof_check, automata)
|
118
122
|
@start = start
|
119
123
|
@eof_check = eof_check
|
120
|
-
@line_counting = line_counting
|
121
|
-
@tab_width = tab_width
|
122
124
|
@automata = automata
|
123
125
|
end
|
124
126
|
|
125
127
|
def parse(input)
|
126
|
-
InnerParser.new(@start, @eof_check, @
|
128
|
+
InnerParser.new(@start, @eof_check, @automata, input).parse()
|
127
129
|
end
|
128
130
|
|
129
131
|
class InnerParser
|
130
|
-
def initialize(start, eof_check,
|
132
|
+
def initialize(start, eof_check, automata, input)
|
131
133
|
@start = start
|
132
134
|
@eof_check = eof_check
|
133
|
-
@line_counting = line_counting
|
134
|
-
@tab_width = tab_width
|
135
135
|
@automata = automata
|
136
|
-
@fa_stack = []
|
137
|
-
@cache = {}
|
138
136
|
@input = input
|
139
137
|
@input_len = input.length
|
140
138
|
@input_pos = 0
|
@@ -144,7 +142,9 @@ module Waxeye
|
|
144
142
|
@error_pos = 0
|
145
143
|
@error_line = 1
|
146
144
|
@error_col = 0
|
147
|
-
@error_nt =
|
145
|
+
@error_nt = automata[start].type
|
146
|
+
@fa_stack = []
|
147
|
+
@cache = {}
|
148
148
|
end
|
149
149
|
|
150
150
|
def parse()
|
@@ -279,20 +279,20 @@ module Waxeye
|
|
279
279
|
|
280
280
|
def mv()
|
281
281
|
ch = @input[@input_pos].chr()
|
282
|
-
@input_pos
|
282
|
+
@input_pos += 1
|
283
283
|
|
284
284
|
if ch == '\r'
|
285
|
-
@line
|
285
|
+
@line += 1
|
286
286
|
@column = 0
|
287
287
|
@last_cr = true
|
288
288
|
else
|
289
289
|
if ch == '\n'
|
290
290
|
if not @last_cr
|
291
|
-
@line
|
291
|
+
@line += 1
|
292
292
|
@column = 0
|
293
293
|
end
|
294
294
|
else
|
295
|
-
@column
|
295
|
+
@column += 1
|
296
296
|
end
|
297
297
|
@last_cr = false
|
298
298
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waxeye
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Orlando D. A. R. Hill
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-11-
|
12
|
+
date: 2008-11-23 00:00:00 +01:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -50,6 +50,6 @@ rubyforge_project: waxeye
|
|
50
50
|
rubygems_version: 1.1.1
|
51
51
|
signing_key:
|
52
52
|
specification_version: 2
|
53
|
-
summary:
|
53
|
+
summary: Ruby runtime for the Waxeye Parser Generator
|
54
54
|
test_files: []
|
55
55
|
|