Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

parse empty hashes

  • Loading branch information...
commit 56af24826bb922b09a1ed635e6830500a493f7d1 1 parent d68bb23
@alandipert authored
View
2  Gemfile.lock
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
- lector (0.0.6)
+ lector (0.0.7)
citrus
GEM
View
13 lib/lector/reader.citrus
@@ -83,12 +83,13 @@ grammar Lector::RubyParse
rule hash
#TODO: Spurious commas should be parse errors.
- ('{'
- (((space* form space* '=>' space* form space* ',') |
- (space* form ':' space* form space* ','))*
- ((space* form space* '=>' space* form space*) |
- (space* form ':' space* form space*)))
- '}') <Lector::Types::Hash>
+ (('{' space* '}') |
+ ('{'
+ (((space* form space* '=>' space* form space* ',') |
+ (space* form ':' space* form space* ','))*
+ ((space* form space* '=>' space* form space*) |
+ (space* form ':' space* form space*)))
+ '}')) <Lector::Types::Hash>
end
rule hashkey
View
8 spec/lector/reader_spec.rb
@@ -100,6 +100,10 @@
read_s("[ 42 ]").should == [42]
end
+ it 'parses empty arrays' do
+ read_s("[]").should == []
+ end
+
it 'parses arrays of multiple elements' do
read_s("[42, -1]").should == [42, -1]
end
@@ -119,6 +123,10 @@
read_s("{:a => 7, b: 6}").should == {:a => 7, :b => 6}
end
+ it 'parses empty hashes' do
+ read_s("{}").should == {}
+ end
+
it 'parses nested collections' do
read_s("[[1,2], 3, 4]").should == [[1, 2], 3, 4]
end
Please sign in to comment.
Something went wrong with that request. Please try again.