Start on test framework to compile and run generated parser
This commit is contained in:
1 parent
93cb25df62
commit
a716dedeb6
2 files changed
+36
No files matched your search
@@ -7,3 +7,4 @@
|
||||
/spec/reports/
|
||||
/tmp/
|
||||
/.rspec_status
|
||||
/spec/run/
|
||||
@@ -0,0 +1,35 @@
|
||||
require "fileutils"
|
||||
|
||||
def write_grammar(grammar)
|
||||
File.write("spec/run/test.i", grammar)
|
||||
end
|
||||
|
||||
def build_parser
|
||||
result = system(*%w[./imbecile.sh spec/run/test.i spec/run/test.d])
|
||||
expect(result).to be_truthy
|
||||
end
|
||||
|
||||
def compile
|
||||
result = system(*%w[gdc -o spec/run/test spec/run/test.d])
|
||||
expect(result).to be_truthy
|
||||
end
|
||||
|
||||
describe Imbecile do
|
||||
before(:each) do
|
||||
FileUtils.rm_rf("spec/run")
|
||||
FileUtils.mkdir_p("spec/run")
|
||||
end
|
||||
|
||||
it "generates a D lexer" do
|
||||
write_grammar <<EOF
|
||||
token int \\d+
|
||||
token plus \\+
|
||||
token times \\*
|
||||
drop \\s+
|
||||
rule Start [] <<
|
||||
>>
|
||||
EOF
|
||||
build_parser
|
||||
compile
|
||||
end
|
||||
end
|
||||
Reference in new issue
Block a user