Start on test framework to compile and run generated parser
This commit is contained in:
parent
93cb25df62
commit
a716dedeb6
1
.gitignore
vendored
1
.gitignore
vendored
@ -7,3 +7,4 @@
|
|||||||
/spec/reports/
|
/spec/reports/
|
||||||
/tmp/
|
/tmp/
|
||||||
/.rspec_status
|
/.rspec_status
|
||||||
|
/spec/run/
|
||||||
|
35
spec/imbecile_spec.rb
Normal file
35
spec/imbecile_spec.rb
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user