Compile generated parser with a test file

This commit is contained in:
Josh Holtrop 2021-07-05 23:05:55 -04:00
parent 748c219625
commit 3c874ae4c1
2 changed files with 9 additions and 5 deletions

View File

@ -1,16 +1,16 @@
require "fileutils"
def write_grammar(grammar)
File.write("spec/run/test.i", grammar)
File.write("spec/run/testparser.i", grammar)
end
def build_parser
result = system(*%w[./imbecile.sh spec/run/test.i spec/run/test.d])
result = system(*%w[./imbecile.sh spec/run/testparser.i spec/run/testparser.d])
expect(result).to be_truthy
end
def compile
result = system(*%w[gdc -o spec/run/test spec/run/test.d])
def compile(test_file)
result = system(*%w[gdc -o spec/run/testparser spec/run/testparser.d], test_file)
expect(result).to be_truthy
end
@ -30,6 +30,6 @@ rule Start [] <<
>>
EOF
build_parser
compile
compile("spec/test_d_lexer.d")
end
end

4
spec/test_d_lexer.d Normal file
View File

@ -0,0 +1,4 @@
int main()
{
return 0;
}