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

4
spec/test_d_lexer.d Normal file
View File

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