sexpistol 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -38,6 +38,7 @@ class Sexpistol
38
38
  tokens << true and next if(t == "true")
39
39
  tokens << false and next if(t == "false")
40
40
  end
41
+ tokens << "'" and next if(t == "'")
41
42
  tokens << t and next if(t == "(" || t == ")")
42
43
  tokens << t.to_f and next if( is_float?(t))
43
44
  tokens << t.to_i and next if( is_integer?(t))
@@ -56,6 +57,9 @@ class Sexpistol
56
57
  if( token_array[offset] == "(" )
57
58
  offset, array = structure( token_array, offset + 1, true )
58
59
  program << array
60
+ elsif( token_array[offset] == "'" )
61
+ offset, array = structure( token_array, offset + 1, true )
62
+ program << array.unshift( :quote )
59
63
  elsif( token_array[offset] == ")" )
60
64
  break
61
65
  else
data/sexpistol.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{sexpistol}
8
- s.version = "0.0.3"
8
+ s.version = "0.0.4"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Aaron Gough"]
12
- s.date = %q{2010-10-06}
12
+ s.date = %q{2010-10-11}
13
13
  s.description = %q{Sexpistol is an easy-to-use S-Expression parser for Ruby. It is fast and has no dependencies.}
14
14
  s.email = %q{aaron@aarongough.com}
15
15
  s.extra_rdoc_files = [
@@ -31,6 +31,7 @@ Gem::Specification.new do |s|
31
31
  "test/unit/float_literal_test.rb",
32
32
  "test/unit/integer_literal_test.rb",
33
33
  "test/unit/ruby_keyword_literals_test.rb",
34
+ "test/unit/scheme_compatability_test.rb",
34
35
  "test/unit/string_literal_test.rb",
35
36
  "test/unit/structure_test.rb",
36
37
  "test/unit/symbol_test.rb",
@@ -48,6 +49,7 @@ Gem::Specification.new do |s|
48
49
  "test/unit/float_literal_test.rb",
49
50
  "test/unit/integer_literal_test.rb",
50
51
  "test/unit/ruby_keyword_literals_test.rb",
52
+ "test/unit/scheme_compatability_test.rb",
51
53
  "test/unit/string_literal_test.rb",
52
54
  "test/unit/structure_test.rb",
53
55
  "test/unit/symbol_test.rb",
@@ -0,0 +1,29 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))
2
+
3
+ class SchemeCompatabilityTest < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @parser = Sexpistol.new
7
+ end
8
+
9
+ test "should parse #t as true" do
10
+ ast = @parser.parse_string('#t')
11
+ assert_equal [:"#t"], ast
12
+ end
13
+
14
+ test "should parse #f as false" do
15
+ ast = @parser.parse_string('#f')
16
+ assert_equal [:"#f"], ast
17
+ end
18
+
19
+ test "should allow comma quoting" do
20
+ ast = @parser.parse_string("(this is '( a test))")
21
+ assert_equal [[:this, :is, [:quote, [:a, :test]]]], ast
22
+ end
23
+
24
+ test "should allow complicated comma quoting" do
25
+ ast = @parser.parse_string("(this is '( a test (also)))")
26
+ assert_equal [[:this, :is, [:quote, [:a, :test, [:also]]]]], ast
27
+ end
28
+
29
+ end
@@ -1,6 +1,6 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__), '..', 'test_helper.rb'))
2
2
 
3
- class RubyKeywordLiteralsTest < Test::Unit::TestCase
3
+ class StructureTest < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
6
  @parser = Sexpistol.new
@@ -21,5 +21,10 @@ class RubyKeywordLiteralsTest < Test::Unit::TestCase
21
21
  ast = @parser.parse_string('(this (is (an (s_expression) too)')
22
22
  end
23
23
  end
24
+
25
+ test "should parser () as empty list" do
26
+ ast = @parser.parse_string('()')
27
+ assert_equal [[]], ast
28
+ end
24
29
 
25
30
  end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 3
9
- version: 0.0.3
8
+ - 4
9
+ version: 0.0.4
10
10
  platform: ruby
11
11
  authors:
12
12
  - Aaron Gough
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-06 00:00:00 -04:00
17
+ date: 2010-10-11 00:00:00 -04:00
18
18
  default_executable:
19
19
  dependencies: []
20
20
 
@@ -42,6 +42,7 @@ files:
42
42
  - test/unit/float_literal_test.rb
43
43
  - test/unit/integer_literal_test.rb
44
44
  - test/unit/ruby_keyword_literals_test.rb
45
+ - test/unit/scheme_compatability_test.rb
45
46
  - test/unit/string_literal_test.rb
46
47
  - test/unit/structure_test.rb
47
48
  - test/unit/symbol_test.rb
@@ -87,6 +88,7 @@ test_files:
87
88
  - test/unit/float_literal_test.rb
88
89
  - test/unit/integer_literal_test.rb
89
90
  - test/unit/ruby_keyword_literals_test.rb
91
+ - test/unit/scheme_compatability_test.rb
90
92
  - test/unit/string_literal_test.rb
91
93
  - test/unit/structure_test.rb
92
94
  - test/unit/symbol_test.rb