waxeye 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README +15 -6
  2. data/lib/waxeye.rb +16 -14
  3. metadata +2 -2
data/README CHANGED
@@ -1,7 +1,7 @@
1
1
 
2
2
  ============================================
3
3
  | Waxeye Parser Generator |
4
- | v 0.5.0 |
4
+ | v 0.6.0 |
5
5
  | www.waxeye.org |
6
6
  | Copyright (C) 2008 Orlando D. A. R. Hill |
7
7
  ============================================
@@ -31,6 +31,7 @@ Features
31
31
  * Automatic AST Generation
32
32
 
33
33
  * Choice of Programming Language
34
+ - C
34
35
  - Java
35
36
  - Ruby
36
37
  - Scheme
@@ -65,7 +66,7 @@ Windows:
65
66
  Building
66
67
  ========
67
68
 
68
- 1. Install MzScheme v372; either with DrScheme or alone.
69
+ 1. Install MzScheme v4; either with DrScheme or alone.
69
70
  http://download.plt-scheme.org
70
71
 
71
72
  2. Install Waxeye's backend for PLT Scheme.
@@ -81,9 +82,15 @@ Building
81
82
  ./build/unix
82
83
 
83
84
  Windows:
84
- From your Waxeye installation directory, run the 'build\exe.bat' script in a
85
- command prompt. If your PLT-Scheme installation isn't 'C:\Program Files\PLT'
86
- then you will need to modify 'build\exe.bat' to use the correct path.
85
+
86
+ - If your PLT-Scheme installation isn't 'C:\Program Files\PLT' then you will
87
+ need to modify 'build\exe.bat' to use the correct path.
88
+
89
+ - From your Waxeye installation directory, run the 'build\exe.bat' script in a
90
+ command prompt.
91
+
92
+ - When the script has finished, press 'y' then 'Enter' to remove the
93
+ temporary files.
87
94
 
88
95
 
89
96
  Running
@@ -93,7 +100,9 @@ Unix, OSX:
93
100
  Use 'waxeye'.
94
101
 
95
102
  Windows:
96
- Use a command prompt to run `waxeye.exe`.
103
+ Use a command prompt to run `waxeye.exe`. Note: If using the interpreter under
104
+ Windows, you will need to press 'Ctrl-z' and then 'Enter' after the input you
105
+ want to interpret.
97
106
 
98
107
 
99
108
  License
data/lib/waxeye.rb CHANGED
@@ -50,15 +50,16 @@ module Waxeye
50
50
  end
51
51
 
52
52
  class ParseError
53
- attr_reader :pos, :line, :col
54
- def initialize(pos, line, col)
53
+ attr_reader :pos, :line, :col, :nt
54
+ def initialize(pos, line, col, nt)
55
55
  @pos = pos
56
56
  @line = line
57
57
  @col = col
58
+ @nt = nt
58
59
  end
59
60
 
60
61
  def display()
61
- print "parse error at pos=#{pos}, line=#{line}, col=#{col}\n"
62
+ print "parse error: failed to match '#{nt}' at line=#{line}, col=#{col}, pos=#{pos}\n"
62
63
  end
63
64
  end
64
65
 
@@ -132,17 +133,18 @@ module Waxeye
132
133
  @line_counting = line_counting
133
134
  @tab_width = tab_width
134
135
  @automata = automata
135
- @states_stack = []
136
+ @fa_stack = []
136
137
  @cache = {}
137
138
  @input = input
138
139
  @input_len = input.length
139
140
  @input_pos = 0
140
- @line = 0
141
+ @line = 1
141
142
  @column = 0
142
143
  @last_cr = false
143
144
  @error_pos = 0
144
- @error_line = 0
145
+ @error_line = 1
145
146
  @error_col = 0
147
+ @error_nt = @automata[start].type
146
148
  end
147
149
 
148
150
  def parse()
@@ -166,12 +168,11 @@ module Waxeye
166
168
  start_cr = @last_cr
167
169
  automaton = @automata[index]
168
170
  type = automaton.type
169
- states = automaton.states
170
171
  mode = automaton.mode
171
172
 
172
- @states_stack.push(states)
173
+ @fa_stack.push(automaton)
173
174
  res = match_state(0)
174
- @states_stack.pop()
175
+ @fa_stack.pop()
175
176
 
176
177
  value = if type == :_and
177
178
  restore_pos(start_pos, start_line, start_col, start_cr)
@@ -195,10 +196,10 @@ module Waxeye
195
196
  when 1
196
197
  res[0]
197
198
  else
198
- AST.new(type, res, :pos)
199
+ AST.new(type, res, [start_pos, @input_pos])
199
200
  end
200
201
  else
201
- AST.new(type, res, :pos)
202
+ AST.new(type, res, [start_pos, @input_pos])
202
203
  end
203
204
  else
204
205
  update_error()
@@ -210,7 +211,7 @@ module Waxeye
210
211
  end
211
212
 
212
213
  def match_state(index)
213
- state = @states_stack.last[index]
214
+ state = @fa_stack.last.states[index]
214
215
  res = match_edges(state.edges)
215
216
  res ? res : (state.match and [])
216
217
  end
@@ -271,6 +272,7 @@ module Waxeye
271
272
  @error_pos = @input_pos
272
273
  @error_line = @line
273
274
  @error_col = @column
275
+ @error_nt = @fa_stack.last.type
274
276
  end
275
277
  false
276
278
  end
@@ -302,13 +304,13 @@ module Waxeye
302
304
  if res
303
305
  if @eof_check and @input_pos < @input_len
304
306
  # Create a parse error - Not all input consumed
305
- ParseError.new(@error_pos, @error_line, @error_col)
307
+ ParseError.new(@error_pos, @error_line, @error_col, @error_nt)
306
308
  else
307
309
  res
308
310
  end
309
311
  else
310
312
  # Create a parse error
311
- ParseError.new(@error_pos, @error_line, @error_col)
313
+ ParseError.new(@error_pos, @error_line, @error_col, @error_nt)
312
314
  end
313
315
  end
314
316
 
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.5.0
4
+ version: 0.6.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-08-24 00:00:00 +02:00
12
+ date: 2008-11-17 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15