Skip to content

Commit

Permalink
Merge branch 'symbols-starting-with-true-false-nil' of https://github…
Browse files Browse the repository at this point in the history
….com/sumbach/edn-ruby into sumbach-symbols-starting-with-true-false-nil
  • Loading branch information
russolsen committed Apr 17, 2014
2 parents cc2354e + 2c9164d commit 4fa85d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/edn/parser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def parse_prefix(str, options={})
set |
map |
boolean |
str('nil').as(:nil) |
_nil |
keyword |
string |
character |
Expand Down Expand Up @@ -131,7 +131,11 @@ def parse_prefix(str, options={})
}

rule(:boolean) {
str('true').as(:true) | str('false').as(:false)
(str('true').as(:true) | str('false').as(:false)) >> valid_chars.absent?
}

rule(:_nil) {
str('nil').as(:nil) >> valid_chars.absent?
}

# Parts
Expand Down
14 changes: 14 additions & 0 deletions spec/edn_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,20 @@
end
end
end

context "allows symbols starting with a reserved word" do
it "reads true-foo" do
EDN.read('true-foo').should == EDN::Type::Symbol.new('true-foo')
end

it "reads falsey" do
EDN.read('falsey').should == EDN::Type::Symbol.new('falsey')
end

it "reads nillable" do
EDN.read('nillable').should == EDN::Type::Symbol.new('nillable')
end
end
end

context "#register" do
Expand Down

0 comments on commit 4fa85d4

Please sign in to comment.