Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 125 lines (111 sloc) 4.371 kb
776f571 @ribrdb Add tests for Mirah parser
ribrdb authored
1 require 'ant'
2 require 'rake/testtask'
3
df548bb @ribrdb start conversion to ST
ribrdb authored
4 if File.exist?('../mirah/lib/mirah_task.rb')
d917bcc @headius Build of mirah-parser.jar has been moved to the mirah-parser project, so...
headius authored
5 $:.unshift '../mirah/lib'
776f571 @ribrdb Add tests for Mirah parser
ribrdb authored
6 end
517ca34 @ribrdb Bootstrap from the generated source instead of through rhino.
ribrdb authored
7 require 'mirah_task'
776f571 @ribrdb Add tests for Mirah parser
ribrdb authored
8
517ca34 @ribrdb Bootstrap from the generated source instead of through rhino.
ribrdb authored
9 task :default => :test
10 task :jar => 'dist/mmeta.jar'
776f571 @ribrdb Add tests for Mirah parser
ribrdb authored
11
12 task :clean do
13 ant.delete :quiet => true, :dir => 'build'
14 ant.delete :quiet => true, :dir => 'dist'
15 end
16
517ca34 @ribrdb Bootstrap from the generated source instead of through rhino.
ribrdb authored
17 task :bootstrap => ['dist/mmeta.jar'] do
a1655f6 @ribrdb Port the parser from jmeta to mmeta
ribrdb authored
18 runjava 'dist/mmeta.jar', '--auto_memo', 'boot/parser.mmeta', 'boot/parser.mirah'
946e057 @ribrdb Clean up scope syntax and get rid of ocaml style rules
ribrdb authored
19 runjava 'dist/mmeta.jar', 'boot/compiler.mmeta', 'boot/compiler.mirah'
776f571 @ribrdb Add tests for Mirah parser
ribrdb authored
20 end
21
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
22 file 'dist/mmeta-runtime.jar' => Dir.glob('mmeta/*.{java,mirah}') + ['build/runtime', 'dist'] do
09ef6eb @ribrdb assignment
ribrdb authored
23 ENV['BS_CHECK_CLASSES'] = 'true'
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
24 mirahc('mmeta/ast.mirah', :dest => 'build/runtime')
25 ant.javac :srcDir=>'mmeta', :destDir=>'build/runtime', :debug=>true
26 ant.jar :destfile=>'dist/mmeta-runtime.jar', :basedir=>'build/runtime'
776f571 @ribrdb Add tests for Mirah parser
ribrdb authored
27 end
28
000623c @ribrdb Type inference for rule return types
ribrdb authored
29 file 'build/boot/mmeta/MMetaParser.class' => ['boot/parser.mirah', 'build/boot/mmeta', 'dist/mmeta-runtime.jar' ] do
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
30 cp 'boot/parser.mirah', 'build/boot/mmeta/'
31 mirahc('mmeta/parser.mirah',
a1655f6 @ribrdb Port the parser from jmeta to mmeta
ribrdb authored
32 :dir => 'build/boot',
33 :dest => 'build/boot',
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
34 :options => ['--classpath', 'dist/mmeta-runtime.jar'])
a1655f6 @ribrdb Port the parser from jmeta to mmeta
ribrdb authored
35 end
36
946e057 @ribrdb Clean up scope syntax and get rid of ocaml style rules
ribrdb authored
37 file 'build/boot/mmeta/MMetaCompiler.class' => ['boot/compiler.mirah', 'build/boot/mmeta', 'dist/mmeta-runtime.jar' ] do
38 cp 'boot/compiler.mirah', 'build/boot/mmeta/'
39 mirahc('mmeta/compiler.mirah',
517ca34 @ribrdb Bootstrap from the generated source instead of through rhino.
ribrdb authored
40 :dir => 'build/boot',
41 :dest => 'build/boot',
f52c378 @ribrdb Switch templates to hapax2
ribrdb authored
42 :options => ['--classpath', 'build/boot:dist/mmeta-runtime.jar:javalib/hapax-2.3.5-autoindent.jar'])
c8290c8 @ribrdb Mostly finish move to ST
ribrdb authored
43 end
44
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
45 file 'dist/mmeta.jar' => ['dist/mmeta-runtime.jar',
46 'build/boot/mmeta/MMetaParser.class',
f52c378 @ribrdb Switch templates to hapax2
ribrdb authored
47 'build/boot/mmeta/MMetaCompiler.class'] + Dir['boot/templates/*.xtm'] do
48 cp_r 'boot/templates', 'build/boot/mmeta/'
517ca34 @ribrdb Bootstrap from the generated source instead of through rhino.
ribrdb authored
49 ant.jar :destfile=>'dist/mmeta.jar' do
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
50 fileset :dir=>"build/boot", :includes=>"mmeta/*.class"
f52c378 @ribrdb Switch templates to hapax2
ribrdb authored
51 fileset :dir=>"build/boot", :includes=>"mmeta/templates/*.xtm"
52 zipfileset :includes=>"**/*.class", :src=>"javalib/hapax-2.3.5-autoindent.jar"
000623c @ribrdb Type inference for rule return types
ribrdb authored
53 zipfileset :includes=>"mmeta/*.class", :src=>'dist/mmeta-runtime.jar'
517ca34 @ribrdb Bootstrap from the generated source instead of through rhino.
ribrdb authored
54 manifest do
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
55 attribute :name=>"Main-Class", :value=>"mmeta.MMetaCompiler"
517ca34 @ribrdb Bootstrap from the generated source instead of through rhino.
ribrdb authored
56 end
57 end
58 end
776f571 @ribrdb Add tests for Mirah parser
ribrdb authored
59
60 namespace :test do
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
61 task :compile => ['dist/mmeta.jar', 'build/test', 'build/test/MirahLexer.java']
62 file 'build/test/MirahLexer.java' => ['test/MirahLexer.java', 'test/Tokens.java'] do
4584f25 @ribrdb New lexer
ribrdb authored
63 cp "test/MirahLexer.java", "build/test/"
64 cp "test/Tokens.java", "build/test/"
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
65 ant.javac :srcDir => 'build/test', :classpath=>'dist/mmeta-runtime.jar', :debug=>true
4584f25 @ribrdb New lexer
ribrdb authored
66 mirahc 'test', :dir=>'build', :dest=>'build',
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
67 :options=>['--classpath', "dist/mmeta-runtime.jar:#{Dir.pwd}/build"]
776f571 @ribrdb Add tests for Mirah parser
ribrdb authored
68 end
69 task :calc => :'test:compile' do
f8b9a87 @ribrdb Switch to mirah output for the mirah parser
ribrdb authored
70 runjava('test.Calculator2', '4 * 3 - 2', :outputproperty=>'test.output2',
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
71 :classpath=>'dist/mmeta-runtime.jar:build', :failonerror=>false)
f8b9a87 @ribrdb Switch to mirah output for the mirah parser
ribrdb authored
72 if ant.properties['test.output2'].to_s.strip == '10'
73 puts "Mirah Calculator passed"
74 else
75 puts "Expected calculator result 10, got #{ant.properties['test.output2']}"
76 exit(1)
77 end
78 end
c8290c8 @ribrdb Mostly finish move to ST
ribrdb authored
79 Rake::TestTask.new :parser do |t|
776f571 @ribrdb Add tests for Mirah parser
ribrdb authored
80 t.libs << 'build/test'
c8290c8 @ribrdb Mostly finish move to ST
ribrdb authored
81 t.test_files = FileList['test/test_parser.rb']
776f571 @ribrdb Add tests for Mirah parser
ribrdb authored
82 end
83 end
84
c8290c8 @ribrdb Mostly finish move to ST
ribrdb authored
85 def test_grammar(name, *options)
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
86 task('build/test/MirahLexer.java').enhance ["build/test/#{name}.mirah"]
c8290c8 @ribrdb Mostly finish move to ST
ribrdb authored
87 file "build/test/#{name}.mirah" => ["test/#{name}.mmeta", 'dist/mmeta.jar', 'build/test'] do
517ca34 @ribrdb Bootstrap from the generated source instead of through rhino.
ribrdb authored
88 cp "test/#{name}.mmeta", "build/test/"
c8290c8 @ribrdb Mostly finish move to ST
ribrdb authored
89 args = ['dist/mmeta.jar', *options]
90 args.concat ["build/test/#{name}.mmeta", "build/test/#{name}.mirah"]
91 runjava *args
776f571 @ribrdb Add tests for Mirah parser
ribrdb authored
92 end
93 end
94
c8290c8 @ribrdb Mostly finish move to ST
ribrdb authored
95 test_grammar('MirahCalculator', '--auto_memo', '--recursion')
96 #test_grammar('Mirah')
97 test_grammar('TestParser')
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
98 test_grammar('Java')
99 test_grammar('Left', '--auto_memo', '--recursion')
c8290c8 @ribrdb Mostly finish move to ST
ribrdb authored
100
101 task :test => [:'test:calc',
102 :'test:parser',
103 ]
517ca34 @ribrdb Bootstrap from the generated source instead of through rhino.
ribrdb authored
104
105 directory 'dist'
106 directory 'build/test'
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
107 directory 'build/mmeta'
517ca34 @ribrdb Bootstrap from the generated source instead of through rhino.
ribrdb authored
108 directory 'build/runtime'
1b32bf7 @ribrdb Remove jmeta remnants
ribrdb authored
109 directory 'build/boot/mmeta'
517ca34 @ribrdb Bootstrap from the generated source instead of through rhino.
ribrdb authored
110
111 def runjava(jar, *args)
112 options = {:failonerror => true, :fork => true}
113 if jar =~ /\.jar$/
114 options[:jar] = jar
115 else
116 options[:classname] = jar
117 end
118 options.merge!(args.pop) if args[-1].kind_of?(Hash)
f8b9a87 @ribrdb Switch to mirah output for the mirah parser
ribrdb authored
119 puts "java #{jar} " + args.join(' ')
517ca34 @ribrdb Bootstrap from the generated source instead of through rhino.
ribrdb authored
120 ant.java options do
121 args.each do |value|
122 arg :value => value
123 end
124 end
125 end
Something went wrong with that request. Please try again.