Skip to content

@blambeau /Gemfile
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Inheritance with multiple Citrus grammars
source :rubygems
gem "citrus"
gem "rspec"
require 'rubygems' unless RUBY_VERSION >= "1.9"
require 'citrus'
Citrus.eval <<-EOF
grammar WithPar
rule function
/[a-z]/+ parens
end
rule parens '()' end
end
grammar WithBrack
include WithPar
root function
rule parens '{}' end
end
EOF
describe "inheritance in Citrus" do
it 'WithPar should use parentheses' do
WithPar.parse("hello()").should_not be_nil
end
it 'WithBrack should not allow parentheses' do
lambda{ WithBrack.parse("hello()") }.should raise_error(Citrus::ParseError)
end
it 'WithBrack should use brackets' do
WithBrack.parse("hello{}").should_not be_nil
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.