bracer 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8b71bbf9c678ae9d2e8a33ccc8dc54bb0a04683
4
- data.tar.gz: 2d7f04f3b5cf21afefe7a3ea9855f6be80d28ea2
3
+ metadata.gz: 68b7eba940ce5013a279f57a94cbba368add0d66
4
+ data.tar.gz: b63ea697d67a60f3b9a933db81b9c6b2a84dac38
5
5
  SHA512:
6
- metadata.gz: 58bea8f8543d81af5ecb11f3da3d2ca878ef75e99c3126f47bfaf19a129c7ccbe5c434cf52cca2410fa2de1fc005cccb332827c9c711f8bf034d4b8c2a991467
7
- data.tar.gz: 749658b045ace5f741332ed8ee5d1f127a1db8e9b1e38a885964a5eeeb6b97909b6564825024526373059a9357512b238d990c13280b9b7a8915c9016d7a137d
6
+ metadata.gz: ebed11cdb915de66cb9cfc24fbd18f3767740b15ab7a2f38e8eda5fcdf0d2c4572635754b2f574b41fa3f7012d576da9c27d67bbf01f6e364e9a866f56a3485f
7
+ data.tar.gz: e195bb00f717119b0102008927b6b24217366fdb00ebc03f8a0f415ea06da7c8dde06bf5a3cccb6c1a4500e52578f9f8ed0458a686ad00fdc1a35abb3f81e1f9
@@ -1,18 +1,18 @@
1
- = Sexpistol
1
+ = Bracer
2
2
 
3
- Sexpistol is a very fast and easy-to-use library for parsing S-Expressions in Ruby. Sexpistol takes an S-Expression in string form and turns it into a native Ruby data structure made up of nested sets of arrays.
3
+ Bracer is Sexpistol-with-braces, a very fast and easy-to-use library for parsing S-Expressions in Ruby. Bracer takes an S-Expression in string form and turns it into a native Ruby data structure made up of nested sets of arrays.
4
4
 
5
5
  === Example
6
6
 
7
- (define test (lambda () (
8
- (print "Hello world!\n")
9
- (print 1)
10
- (print 9.01)
11
- (print 2.0e10)
12
- (print (+ 10 12 13))
13
- )))
7
+ [define test [lambda [] [
8
+ [print "Hello world!\n"]
9
+ [print 1]
10
+ [print 9.01]
11
+ [print 2.0e10]
12
+ [print (+ 10 12 13]]
13
+ ]]]
14
14
 
15
- would be parsed by Sexpistol like so:
15
+ would be parsed by Bracer like so:
16
16
 
17
17
  [:define, :test, [:lambda, [], [
18
18
  [:print, "Hello world!\n"],
@@ -24,46 +24,46 @@ would be parsed by Sexpistol like so:
24
24
 
25
25
  === Type mappings
26
26
 
27
- Sexpistol supports all of the standard datatypes and converts them directly to their Ruby equivalents:
27
+ Bracer supports all of the standard datatypes and converts them directly to their Ruby equivalents:
28
28
 
29
- * Lists (a b c)
30
- * Integers (1 2 3)
31
- * Floats (1.0 2.0 42.9 3e6 1.2e2)
32
- * Strings ("\t\"Hello world!\"\n")
33
- * Symbols (symbol Symbol ____symbol____ symbo_l symbol? symbol! + - / ++ a+ e$, etc...)
29
+ * Lists [a b c]
30
+ * Integers [1 2 3]
31
+ * Floats [1.0 2.0 42.9 3e6 1.2e2]
32
+ * Strings ["\t\"Hello world!\"\n"]
33
+ * Symbols [symbol Symbol ____symbol____ symbo_l symbol? symbol! + - / ++ a+ e$, etc...]
34
34
 
35
- Sexpistol also supports mapping the Ruby keyword literals (nil, true, false) to their native Ruby types, although this is disabled by default for compatibility. To enable it use `@parser.ruby_keyword_literals = true`, eg:
35
+ Bracer also supports mapping the Ruby keyword literals [nil, true, false] to their native Ruby types, although this is disabled by default for compatibility. To enable it use `@parser.ruby_keyword_literals = true`, eg:
36
36
 
37
- @parser = Sexpistol.new
38
- @parser.parse_string("nil false true")
37
+ @parser = Bracer.new
38
+ @parser.parse_string "nil false true"
39
39
  #=> [:nil, :false, :true]
40
40
 
41
41
  @parser.ruby_keyword_literals = true
42
- @parser.parse_string("nil false true")
42
+ @parser.parse_string "nil false true"
43
43
  #=> [nil, false, true]
44
44
 
45
45
  == Scheme compatibility
46
46
 
47
- Above all Sexpistol strives to be compatible with Scheme-style S-Expressions. This means that Sexpistol supports comma quoting, though quasi-quoting is not yet implemented. Sexpistol can also generate Scheme compatible external representations when the 'scheme_compatability' options is set to true:
47
+ Above all Bracer strives to be compatible with Scheme-style S-Expressions. This means that Bracer supports comma quoting, though quasi-quoting is not yet implemented. Bracer can also generate Scheme compatible external representations when the 'scheme_compatability' options is set to true:
48
48
 
49
- @parser = Sexpistol.new
49
+ @parser = Bracer.new
50
50
  @parser.scheme_compatability = true
51
- @parser.to_sexp([:test, false, true, nil])
52
- #=> "(test #f #t ())"
51
+ @parser.to_sexp [:test, false, true, nil]
52
+ #=> "[test #f #t []]"
53
53
 
54
54
  === Installation
55
55
 
56
- For convenience Sexpistol is packaged as a RubyGem, to install it simply enter the following at your command line:
56
+ For convenience Bracer is packaged as a RubyGem, to install it simply enter the following at your command line:
57
57
 
58
- gem install sexpistol
58
+ gem install Bracer
59
59
 
60
60
  === Usage
61
61
 
62
62
  # Create a new parser instance
63
- @parser = Sexpistol.new
63
+ @parser = Bracer.new
64
64
 
65
65
  # Parse a string
66
- ast = @parser.parse_string("(string (to (parse)))")
66
+ ast = @parser.parse_string "[string [to [parse]]]"
67
67
  #=> [:string, [:to, [:parse]]]
68
68
 
69
69
  # Change the representation
@@ -72,18 +72,19 @@ For convenience Sexpistol is packaged as a RubyGem, to install it simply enter t
72
72
  #=> [:string, [:is, [:parsed]]]
73
73
 
74
74
  # Turn the array structure back into an S-Expression
75
- @parser.to_sexp( ast )
76
- #=> "( string ( is ( parsed ) ) )"
75
+ @parser.to_sexp[ ast ]
76
+ #=> "[ string [ is [ parsed ] ] ]"
77
77
 
78
78
  === Performance
79
79
 
80
- The core of Sexpistol was recently re-written using StringScanner and the new version is roughly twice as fast as the older ones.
80
+ The core of Bracer was recently re-written using StringScanner and the new version is roughly twice as fast as the older ones.
81
81
 
82
- Parsing throughput on my test machine (2Ghz Core 2 Duo, 4GB RAM, Ruby 1.9) is approximately 1 Megabytes/sec. This is fairly high given that Sexpistol is pure Ruby. Benchmarking Sexpistol against other popular S-Expression parser gems shows that it is roughly 8x faster than the nearest competitor.
82
+ Parsing throughput on my test machine [2Ghz Core 2 Duo, 4GB RAM, Ruby 1.9) is approximately 1 Megabytes/sec. This is fairly high given that Bracer is pure Ruby. Benchmarking Bracer against other popular S-Expression parser gems shows that it is roughly 8x faster than the nearest competitor.
83
83
 
84
84
  === Author & Credits
85
85
 
86
86
  Author:: {Aaron Gough}[mailto:aaron@aarongough.com]
87
87
  Contributors:: {Shane Hanna}[http://github.com/shanna]
88
+ Contributors:: {The Trung}[http://github.com/thetrung]
88
89
 
89
90
  Copyright (c) 2010 {Aaron Gough}[http://thingsaaronmade.com/] ({thingsaaronmade.com}[http://thingsaaronmade.com/]), released under the MIT license
data/Rakefile CHANGED
@@ -8,12 +8,12 @@ task :default => :test
8
8
  begin
9
9
  require 'jeweler'
10
10
  Jeweler::Tasks.new do |gemspec|
11
- gemspec.name = "sexpistol"
11
+ gemspec.name = "bracer"
12
12
  gemspec.summary = "An S-Expression Parser Library for Ruby"
13
- gemspec.description = "Sexpistol is an easy-to-use S-Expression parser for Ruby. It is fast and has no dependencies."
14
- gemspec.email = "aaron@aarongough.com"
15
- gemspec.homepage = "http://github.com/aarongough/sexpistol"
16
- gemspec.authors = ["Aaron Gough"]
13
+ gemspec.description = "Bracer is an easy-to-use S-Expression Sexpistol parser with braces for Ruby. It is fast and has no dependencies."
14
+ gemspec.email = "aaron@aarongough.com, deulamco@gmail.com"
15
+ gemspec.homepage = "http://github.com/thetrung/bracer"
16
+ gemspec.authors = ["Aaron Gough, The Trung"]
17
17
  gemspec.rdoc_options << '--line-numbers' << '--inline-source'
18
18
  gemspec.extra_rdoc_files = ['README.rdoc', 'MIT-LICENSE']
19
19
  end
@@ -22,7 +22,7 @@ rescue LoadError
22
22
  end
23
23
 
24
24
 
25
- desc 'Test sexpistol.'
25
+ desc 'Test bracer.'
26
26
  Rake::TestTask.new(:test) do |t|
27
27
  t.libs << 'lib/*.rb'
28
28
  t.libs << 'test'
@@ -31,7 +31,7 @@ Rake::TestTask.new(:test) do |t|
31
31
  end
32
32
 
33
33
 
34
- desc 'Generate documentation for sexpistol.'
34
+ desc 'Generate documentation for bracer.'
35
35
  Rake::RDocTask.new(:rdoc) do |rdoc|
36
36
  rdoc.rdoc_dir = 'rdoc'
37
37
  rdoc.title = 'Koi'
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{bracer}
8
- s.version = "0.0.1"
8
+ s.version = "0.0.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Aaron Gough","The Trung"]
12
- s.date = %q{2015-02-07}
13
- s.description = %q{Brace is Sexpistol with braces, an easy-to-use S-Expression parser for Ruby. It is fast and has no dependencies.}
11
+ s.authors = ["Aaron Gough, The Trung"]
12
+ s.date = %q{2010-10-15}
13
+ s.description = %q{bracer 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, deulamco@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "MIT-LICENSE",
@@ -22,10 +22,10 @@ Gem::Specification.new do |s|
22
22
  "README.rdoc",
23
23
  "Rakefile",
24
24
  "VERSION",
25
- "lib/sexpistol.rb",
26
- "lib/sexpistol/sexpistol.rb",
27
- "lib/sexpistol/sexpistol_parser.rb",
28
- "sexpistol.gemspec",
25
+ "lib/bracer.rb",
26
+ "lib/bracer/bracer.rb",
27
+ "lib/bracer/bracer_parser.rb",
28
+ "bracer.gemspec",
29
29
  "test/performance/benchmark_test.rb",
30
30
  "test/setup/test_unit_extensions.rb",
31
31
  "test/test_helper.rb",
@@ -38,11 +38,11 @@ Gem::Specification.new do |s|
38
38
  "test/unit/symbol_test.rb",
39
39
  "test/unit/to_sexp_test.rb"
40
40
  ]
41
- s.homepage = %q{http://github.com/thetrung/sexpistol}
41
+ s.homepage = %q{http://github.com/thetrung/bracer}
42
42
  s.rdoc_options = ["--charset=UTF-8", "--line-numbers", "--inline-source"]
43
43
  s.require_paths = ["lib"]
44
44
  s.rubygems_version = %q{1.3.7}
45
- s.summary = %q{An Braces S-Expression with Parser Library for Ruby}
45
+ s.summary = %q{An S-Expression Parser Library for Ruby}
46
46
  s.test_files = [
47
47
  "test/performance/benchmark_test.rb",
48
48
  "test/setup/test_unit_extensions.rb",
@@ -0,0 +1,2 @@
1
+ require File.expand_path(File.join(File.dirname(__FILE__), 'bracer', 'bracer_parser.rb'))
2
+ require File.expand_path(File.join(File.dirname(__FILE__), 'bracer', 'bracer.rb'))
@@ -4,7 +4,7 @@ class BracerParser < StringScanner
4
4
 
5
5
  def initialize(string)
6
6
  unless(string.count('[') == string.count(']'))
7
- raise Exception, "Missing closing braces"
7
+ raise Exception, "Missing closing parentheses"
8
8
  end
9
9
  super(string)
10
10
  end
@@ -19,7 +19,7 @@ class BenchmarkTest < Test::Unit::TestCase
19
19
  EOD
20
20
  end
21
21
 
22
- test "benchmark bracer" do
22
+ test "benchmark sexpistol's bracer" do
23
23
  puts "\nRunning performance test...\n"
24
24
 
25
25
  parser = Bracer.new
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'test/unit'
3
3
 
4
4
  require_files = []
5
- require_files << File.join(File.dirname(__FILE__), '..', 'lib', 'sexpistol.rb')
5
+ require_files << File.join(File.dirname(__FILE__), '..', 'lib', 'bracer.rb')
6
6
  require_files.concat Dir[File.join(File.dirname(__FILE__), 'setup', '*.rb')]
7
7
 
8
8
  require_files.each do |file|
@@ -8,37 +8,37 @@ class RubyKeywordLiteralsTest < Test::Unit::TestCase
8
8
 
9
9
  test "should parse nil as literal" do
10
10
  @parser.ruby_keyword_literals = true
11
- ast = @parser.parse_string("[nil]")
11
+ ast = @parser.parse_string('[nil]')
12
12
  assert_equal [[nil]], ast
13
13
  end
14
14
 
15
15
  test "should not parse nil as literal" do
16
16
  @parser.ruby_keyword_literals = false
17
- ast = @parser.parse_string("[nil]")
17
+ ast = @parser.parse_string('[nil]')
18
18
  assert_equal [[:nil]], ast
19
19
  end
20
20
 
21
21
  test "should parse true as literal" do
22
22
  @parser.ruby_keyword_literals = true
23
- ast = @parser.parse_string("[true]")
23
+ ast = @parser.parse_string('[true]')
24
24
  assert_equal [[true]], ast
25
25
  end
26
26
 
27
27
  test "should not parse true as literal" do
28
28
  @parser.ruby_keyword_literals = false
29
- ast = @parser.parse_string("[true]")
29
+ ast = @parser.parse_string('[true]')
30
30
  assert_equal [[:true]], ast
31
31
  end
32
32
 
33
33
  test "should parse false as literal" do
34
34
  @parser.ruby_keyword_literals = true
35
- ast = @parser.parse_string("[false]")
35
+ ast = @parser.parse_string('[false]')
36
36
  assert_equal [[false]], ast
37
37
  end
38
38
 
39
39
  test "should notparse false as literal" do
40
40
  @parser.ruby_keyword_literals = false
41
- ast = @parser.parse_string("[false]")
41
+ ast = @parser.parse_string('[false]')
42
42
  assert_equal [[:false]], ast
43
43
  end
44
44
 
@@ -23,12 +23,12 @@ class SchemeCompatabilityTest < Test::Unit::TestCase
23
23
  end
24
24
 
25
25
  test "should allow complicated comma quoting" do
26
- ast = @parser.parse_string("[this is '[ a test] [also]]")
26
+ ast = @parser.parse_string("[this is '[ a test] [also]]")
27
27
  assert_equal [[:this, :is, [:quote, [:a, :test]], [:also]]], ast
28
28
  end
29
29
 
30
30
  test "should allow comma quoting of integer literal" do
31
- ast = @parser.parse_string("[this is '1 [also]]")
31
+ ast = @parser.parse_string "[this is '1 [also]]"
32
32
  assert_equal [[:this, :is, [:quote, 1], [:also]]], ast
33
33
  end
34
34
 
@@ -67,7 +67,7 @@ class SymbolTest < Test::Unit::TestCase
67
67
  end
68
68
 
69
69
  test "should parse symbol containing any character except single and double quotes, backquote, parentheses and comma" do
70
- ast = @parser.parse_string("[~1!2@3#4$%5^6&7*890-_+=|)}({poiuytrewqasdfghjklmnbvcxzZXCVBNMLKJHGFDSAQWERTYUIOP:;/?><]")
70
+ ast = @parser.parse_string("[~1!2@3#4$%5^6&7*890-_+=|\)}({poiuytrewqasdfghjklmnbvcxzZXCVBNMLKJHGFDSAQWERTYUIOP:;/?><]")
71
71
  assert_equal [[:"~1!2@3#4$%5^6&7*890-_+=|\)}({poiuytrewqasdfghjklmnbvcxzZXCVBNMLKJHGFDSAQWERTYUIOP:;/?><"]], ast
72
72
  end
73
73
 
@@ -24,19 +24,19 @@ class ToSexpTest < Test::Unit::TestCase
24
24
  assert_equal "[true [false [true false]]]", sexp
25
25
  end
26
26
 
27
- test "when not passed array to_sexp should print value [integer]" do
27
+ test "when not passed array to_sexp should print value (integer)" do
28
28
  ast = 1
29
29
  sexp = @parser.to_sexp(ast)
30
30
  assert_equal "1", sexp
31
31
  end
32
32
 
33
- test "when not passed array to_sexp should print value [string]" do
33
+ test "when not passed array to_sexp should print value (string)" do
34
34
  ast = "test"
35
35
  sexp = @parser.to_sexp(ast)
36
36
  assert_equal "test", sexp
37
37
  end
38
38
 
39
- test "when not passed array to_sexp should print value [symbol]" do
39
+ test "when not passed array to_sexp should print value (symbol)" do
40
40
  ast = :test
41
41
  sexp = @parser.to_sexp(ast)
42
42
  assert_equal "test", sexp
metadata CHANGED
@@ -1,18 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bracer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
- - Aaron Gough
8
- - The Trung
7
+ - Aaron Gough, The Trung
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-02-07 00:00:00.000000000 Z
11
+ date: 2010-10-15 00:00:00.000000000 Z
13
12
  dependencies: []
14
- description: Brace is Sexpistol with braces, an easy-to-use S-Expression parser for
15
- Ruby. It is fast and has no dependencies.
13
+ description: bracer is an easy-to-use S-Expression parser for Ruby. It is fast and
14
+ has no dependencies.
16
15
  email: aaron@aarongough.com, deulamco@gmail.com
17
16
  executables: []
18
17
  extensions: []
@@ -25,10 +24,10 @@ files:
25
24
  - README.rdoc
26
25
  - Rakefile
27
26
  - VERSION
28
- - lib/sexpistol.rb
29
- - lib/sexpistol/sexpistol.rb
30
- - lib/sexpistol/sexpistol_parser.rb
31
- - sexpistol.gemspec
27
+ - bracer.gemspec
28
+ - lib/bracer.rb
29
+ - lib/bracer/bracer.rb
30
+ - lib/bracer/bracer_parser.rb
32
31
  - test/performance/benchmark_test.rb
33
32
  - test/setup/test_unit_extensions.rb
34
33
  - test/test_helper.rb
@@ -40,7 +39,7 @@ files:
40
39
  - test/unit/structure_test.rb
41
40
  - test/unit/symbol_test.rb
42
41
  - test/unit/to_sexp_test.rb
43
- homepage: http://github.com/thetrung/sexpistol
42
+ homepage: http://github.com/thetrung/bracer
44
43
  licenses: []
45
44
  metadata: {}
46
45
  post_install_message:
@@ -65,7 +64,7 @@ rubyforge_project:
65
64
  rubygems_version: 2.4.5
66
65
  signing_key:
67
66
  specification_version: 3
68
- summary: An Braces S-Expression with Parser Library for Ruby
67
+ summary: An S-Expression Parser Library for Ruby
69
68
  test_files:
70
69
  - test/performance/benchmark_test.rb
71
70
  - test/setup/test_unit_extensions.rb
@@ -1,2 +0,0 @@
1
- require File.expand_path(File.join(File.dirname(__FILE__), 'sexpistol', 'sexpistol_parser.rb'))
2
- require File.expand_path(File.join(File.dirname(__FILE__), 'sexpistol', 'sexpistol.rb'))