blob: d7877511ec29cf6569174196279fdf4fbe336f62 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
#
# racc scanner tester
#
require 'racc/raccs'
class ScanError < StandardError; end
def testdata( dir, argv )
if argv.empty? then
Dir.glob( dir + '/*' ) -
Dir.glob( dir + '/*.swp' ) -
[ dir + '/CVS' ]
else
argv.collect {|i| dir + '/' + i }
end
end
if ARGV.delete '--print' then
$raccs_print_type = true
printonly = true
else
printonly = false
end
testdata( File.dirname($0) + '/scandata', ARGV ).each do |file|
$stderr.print File.basename(file) + ': '
begin
ok = File.read(file)
s = Racc::GrammarFileScanner.new( ok )
sym, (val, _lineno) = s.scan
if printonly then
$stderr.puts
$stderr.puts val
next
end
val = '{' + val + "}\n"
sym == :ACTION or raise ScanError, 'is not action!'
val == ok or raise ScanError, "\n>>>\n#{ok}----\n#{val}<<<"
$stderr.puts 'ok'
rescue => err
$stderr.puts 'fail (' + err.type.to_s + ')'
$stderr.puts err.message
$stderr.puts err.backtrace
$stderr.puts
end
end
|