Sha256: 4061b879cf2db701e9ffedcb726e85042cec730e4c2e2363cc5cf0ecd7223f34

Contents?: true

Size: 776 Bytes

Versions: 3

Compression:

Stored size: 776 Bytes

Contents

describe Ace::Compiler do
  let :file do
    <<-DOC
    %{
      test
    %}

    %require "0.0.1"
    %type "ruby"

    %terminal NUMBER
    %terminal SEMICOLON ";"
    %terminal ADD "+"
    %terminal LPAREN "("
    %terminal RPAREN ")"

    %%

    s: e
    e: t ADD e
    t: NUMBER | LPAREN e RPAREN

    %%

    hello
    DOC
  end

  let :tokens do
    Ace::Scanner.scan(file)
  end

  let :compiler do
    Ace::Compiler.new(tokens)
  end

  subject do
    compiler.compile
    compiler
  end

  its(:body) { should =~ /test/  }
  its(:body) { should =~ /hello/ }
  its(:options) { should have_key :type }

  it "should have the proper terminals" do
    expect(subject.options[:terminals].map(&:first)).to eq [:NUMBER,
      :SEMICOLON, :ADD, :LPAREN, :RPAREN]
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
antelope-0.1.1 spec/antelope/ace/compiler_spec.rb
antelope-0.1.0 spec/antelope/ace/compiler_spec.rb
antelope-0.0.1 spec/antelope/ace/compiler_spec.rb