kdl 0.1.2 → 1.0.0.rc1

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
  SHA256:
3
- metadata.gz: dfb8d87e0f543090b994347f56085b076d82ce8050f52e49e112a2e723aafc09
4
- data.tar.gz: 33443ec26405e8cd235275ab262378d2afc6bfebf4bf186a22580d6c62d8db07
3
+ metadata.gz: 1da5c7ecdbb21b75f621fbb6876fd46270c525311d9b34443ebbda8e715f6b0d
4
+ data.tar.gz: c8317287f0573c91b256d28ff902e3a38bd3275b009016ce0d41c631e7321303
5
5
  SHA512:
6
- metadata.gz: '0396991421855a4b2c9b40263a50b255c8ab78b493604254437a6fe2cae9a05d8ac967c6fa19893e8712f210d5e882d6f98338331d56fa2b80e01c24c33b980e'
7
- data.tar.gz: 9a3af62eae607011f76a1b154cf4604afd9d6cb38dacdaccc28f735720b8caec9789d6d75766904d395a4969a44b903e890363b7df17533349b8d8c2186a790e
6
+ metadata.gz: 549b4b676a95b83146647aca4dbbccf44463fbaa5cc0192dc7e0e1e8977e194bdc505c29edde3c71f5f225a22eb23ea2ba484d4a26c24cdbae152015dde99b77
7
+ data.tar.gz: 13520a974cb5e28658bebd7b09fa79bb13e40cf2c12f50e0a51408fef74ab756e314f7e6758a357b0ef82afdda3cfa7604197184dad45607296ffb7469507df3
@@ -17,18 +17,19 @@ jobs:
17
17
  test:
18
18
  strategy:
19
19
  matrix:
20
- ruby: [2.3, 2.4, 2.5, 2.6, 2.7, 3.0.0-preview1]
20
+ ruby: [2.3, 2.4, 2.5, 2.6, 2.7, 3.0, head]
21
21
 
22
22
  runs-on: ubuntu-latest
23
23
 
24
24
  steps:
25
25
  - uses: actions/checkout@v2
26
+ with:
27
+ submodules: true
26
28
  - name: Set up Ruby
27
29
  uses: ruby/setup-ruby@v1
28
30
  with:
29
31
  ruby-version: ${{ matrix.ruby }}
30
- - name: Install dependencies
31
- run: gem install bundler && bundle install
32
+ bundler-cache: true # install and cache dependencies
32
33
  - name: Build parser
33
34
  run: bundle exec racc lib/kdl/kdl.yy
34
35
  - name: Run tests
data/.gitmodules ADDED
@@ -0,0 +1,3 @@
1
+ [submodule "test/kdl-org"]
2
+ path = test/kdl-org
3
+ url = git@github.com:kdl-org/kdl
data/Rakefile CHANGED
@@ -1,10 +1,15 @@
1
- require "bundler/gem_tasks"
2
- require "rake/testtask"
1
+ require 'bundler/gem_tasks'
2
+ require 'rake/testtask'
3
3
 
4
- Rake::TestTask.new(:test) do |t|
5
- t.libs << "test"
6
- t.libs << "lib"
7
- t.test_files = FileList["test/**/*_test.rb"]
4
+ file 'lib/kdl/kdl.tab.rb' => ['lib/kdl/kdl.yy'] do
5
+ raise "racc command failed" unless system 'bin/racc lib/kdl/kdl.yy'
6
+ end
7
+ task :racc => 'lib/kdl/kdl.tab.rb'
8
+
9
+ Rake::TestTask.new(:test => :racc) do |t|
10
+ t.libs << 'test'
11
+ t.libs << 'lib'
12
+ t.test_files = FileList['test/**/*_test.rb']
8
13
  t.options = '--pride'
9
14
  end
10
15
 
data/bin/console CHANGED
@@ -10,5 +10,7 @@ require "kdl"
10
10
  # require "pry"
11
11
  # Pry.start
12
12
 
13
+ system 'bin/rake racc'
14
+
13
15
  require "irb"
14
16
  IRB.start(__FILE__)
data/bin/racc ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'racc' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("racc", "racc")
data/bin/rake ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ #
5
+ # This file was generated by Bundler.
6
+ #
7
+ # The application 'rake' is installed as part of a gem, and
8
+ # this file is here to facilitate running it.
9
+ #
10
+
11
+ require "pathname"
12
+ ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
+ Pathname.new(__FILE__).realpath)
14
+
15
+ bundle_binstub = File.expand_path("../bundle", __FILE__)
16
+
17
+ if File.file?(bundle_binstub)
18
+ if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
19
+ load(bundle_binstub)
20
+ else
21
+ abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
22
+ Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
23
+ end
24
+ end
25
+
26
+ require "rubygems"
27
+ require "bundler/setup"
28
+
29
+ load Gem.bin_path("rake", "rake")
data/bin/setup CHANGED
@@ -6,3 +6,4 @@ set -vx
6
6
  bundle install
7
7
 
8
8
  # Do any other automated setup that you need to do here
9
+ bin/rake racc
data/kdl.gemspec CHANGED
@@ -3,7 +3,7 @@ require_relative 'lib/kdl/version'
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = "kdl"
5
5
  spec.version = KDL::VERSION
6
- spec.authors = ["Daniel Smith"]
6
+ spec.authors = ["Danielle Smith"]
7
7
  spec.email = ["danini@hey.com"]
8
8
 
9
9
  spec.summary = %q{KDL Document Language}
@@ -13,8 +13,8 @@ Gem::Specification.new do |spec|
13
13
  spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
14
14
 
15
15
  spec.metadata["homepage_uri"] = spec.homepage
16
- spec.metadata["source_code_uri"] = "https://github.com/jellymann/kdl-rb"
17
- spec.metadata["changelog_uri"] = "https://github.com/jellymann/kdl-rb/releases"
16
+ spec.metadata["source_code_uri"] = "https://github.com/danini-the-panini/kdl-rb"
17
+ spec.metadata["changelog_uri"] = "https://github.com/danini-the-panini/kdl-rb/releases"
18
18
 
19
19
  # Specify which files should be added to the gem when it is released.
20
20
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
@@ -22,7 +22,6 @@ Gem::Specification.new do |spec|
22
22
  `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
23
23
  end + ['lib/kdl/kdl.tab.rb']
24
24
  spec.bindir = "exe"
25
- spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
25
  spec.require_paths = ["lib"]
27
26
 
28
27
  spec.add_development_dependency 'racc', '~> 1.5'
data/lib/kdl/document.rb CHANGED
@@ -7,9 +7,8 @@ module KDL
7
7
  end
8
8
 
9
9
  def to_s
10
- @nodes.map(&:to_s).join("\n")
10
+ @nodes.map(&:to_s).join("\n") + "\n"
11
11
  end
12
- alias inspect to_s
13
12
 
14
13
  def ==(other)
15
14
  return false unless other.is_a?(Document)
data/lib/kdl/kdl.tab.rb CHANGED
@@ -8,7 +8,7 @@ require 'racc/parser.rb'
8
8
  module KDL
9
9
  class Parser < Racc::Parser
10
10
 
11
- module_eval(<<'...end kdl.yy/module_eval...', 'kdl.yy', 59)
11
+ module_eval(<<'...end kdl.yy/module_eval...', 'kdl.yy', 68)
12
12
  def parse(str)
13
13
  @tokenizer = ::KDL::Tokenizer.new(str)
14
14
  do_parse
@@ -23,119 +23,139 @@ module_eval(<<'...end kdl.yy/module_eval...', 'kdl.yy', 59)
23
23
  ##### State transition tables begin ###
24
24
 
25
25
  racc_action_table = [
26
- -2, 10, 16, 17, 16, 17, 21, 25, 7, 33,
27
- 6, 7, 30, 8, 27, 50, 8, 15, 33, 15,
28
- 16, 41, 43, 44, 45, 48, 49, 47, 39, 39,
29
- -36, 16, 17, 6, 7, 37, 27, 6, 7, 8,
30
- 16, 17, 62, 8, 33, -25, 15, 16, 41, 43,
31
- 44, 45, 48, 49, 47, 6, 7, 50, 6, 7,
32
- 30, 8, 55, 30, 8, 6, 7, 6, 7, 6,
33
- 7, 8, nil, 8, nil, 8, 61, 43, 44, 45,
34
- 48, 49, 47, 6, 7, nil, nil, nil, nil, 8 ]
26
+ -2, 10, 18, 19, 20, 18, 19, 20, 6, 7,
27
+ 6, 7, 44, 24, 17, 37, 8, 17, 8, 16,
28
+ 57, 30, 16, 18, 46, 47, 51, 52, 55, 56,
29
+ 54, 44, 37, -42, 61, 17, 18, 19, 20, 37,
30
+ 42, -28, -29, 18, 19, 20, 63, 73, 17, 18,
31
+ 19, 20, nil, 16, 74, 17, 18, 19, 20, nil,
32
+ 16, 17, 18, 46, 47, 51, 52, 55, 56, 54,
33
+ nil, nil, 57, nil, 17, 65, 66, 51, 52, 55,
34
+ 56, 54, 28, 7, nil, nil, 17, 6, 7, 33,
35
+ 8, 30, 6, 7, 33, 8, 6, 7, nil, 33,
36
+ 8, 6, 7, nil, 8, 6, 7, 6, 7, 8,
37
+ 6, 7, nil, 8, nil, 8, nil, nil, 8, 65,
38
+ 66, 51, 52, 55, 56, 54, 18, 19, 20 ]
35
39
 
36
40
  racc_action_check = [
37
- 3, 1, 2, 2, 5, 5, 10, 13, 13, 15,
38
- 3, 3, 13, 13, 13, 26, 3, 2, 27, 5,
39
- 25, 25, 25, 25, 25, 25, 25, 25, 25, 39,
40
- 25, 56, 56, 0, 0, 25, 39, 28, 28, 0,
41
- 32, 32, 56, 28, 37, 41, 56, 54, 54, 54,
42
- 54, 54, 54, 54, 54, 23, 23, 54, 24, 24,
43
- 23, 23, 42, 24, 24, 30, 30, 50, 50, 52,
44
- 52, 30, nil, 50, nil, 52, 55, 55, 55, 55,
45
- 55, 55, 55, 57, 57, nil, nil, nil, nil, 57 ]
41
+ 3, 1, 2, 2, 2, 5, 5, 5, 0, 0,
42
+ 3, 3, 44, 10, 2, 16, 0, 5, 3, 2,
43
+ 29, 44, 5, 28, 28, 28, 28, 28, 28, 28,
44
+ 28, 28, 30, 28, 38, 28, 67, 67, 67, 42,
45
+ 28, 46, 47, 68, 68, 68, 48, 67, 67, 36,
46
+ 36, 36, nil, 67, 68, 68, 15, 15, 15, nil,
47
+ 68, 36, 62, 62, 62, 62, 62, 62, 62, 62,
48
+ nil, nil, 62, nil, 62, 63, 63, 63, 63, 63,
49
+ 63, 63, 13, 13, nil, nil, 63, 26, 26, 13,
50
+ 13, 13, 27, 27, 26, 26, 31, 31, nil, 27,
51
+ 27, 33, 33, nil, 31, 57, 57, 59, 59, 33,
52
+ 69, 69, nil, 57, nil, 59, nil, nil, 69, 50,
53
+ 50, 50, 50, 50, 50, 50, 17, 17, 17 ]
46
54
 
47
55
  racc_action_pointer = [
48
- 23, 1, 0, 0, nil, 2, nil, nil, nil, nil,
49
- 6, nil, nil, -3, nil, -1, nil, nil, nil, nil,
50
- nil, nil, nil, 45, 48, 18, 3, 8, 27, nil,
51
- 55, nil, 38, nil, nil, nil, nil, 34, nil, 19,
52
- nil, 31, 48, nil, nil, nil, nil, nil, nil, nil,
53
- 57, nil, 59, nil, 45, 73, 29, 73, nil, nil,
54
- nil, nil, nil ]
56
+ -2, 1, 0, 0, nil, 3, nil, nil, nil, nil,
57
+ 13, nil, nil, 72, nil, 54, 5, 124, nil, nil,
58
+ nil, nil, nil, nil, nil, nil, 77, 82, 21, 8,
59
+ 22, 86, nil, 91, nil, nil, 47, nil, 19, nil,
60
+ nil, nil, 29, nil, 2, nil, 25, 26, 30, nil,
61
+ 116, nil, nil, nil, nil, nil, nil, 95, nil, 97,
62
+ nil, nil, 60, 72, nil, nil, nil, 34, 41, 100,
63
+ nil, nil, nil, nil, nil ]
55
64
 
56
65
  racc_action_default = [
57
- -44, -45, -1, -43, -3, -45, -37, -38, -39, -40,
58
- -45, -6, -7, -44, -11, -44, -24, -25, -41, -4,
59
- -5, 63, -8, -45, -45, -37, -45, -44, -20, -21,
60
- -22, -35, -45, -36, -9, -10, -12, -44, -14, -45,
61
- -19, -27, -45, -28, -29, -30, -31, -32, -33, -34,
62
- -44, -18, -23, -16, -45, -45, -45, -43, -13, -15,
63
- -26, -27, -17 ]
66
+ -50, -51, -1, -49, -3, -51, -43, -44, -45, -46,
67
+ -51, -6, -7, -50, -11, -51, -50, -51, -27, -28,
68
+ -29, -47, -4, -5, 75, -8, -51, -51, -43, -51,
69
+ -50, -22, -23, -24, -41, -12, -51, -42, -51, -9,
70
+ -10, -13, -50, -15, -51, -21, -33, -34, -51, -31,
71
+ -51, -35, -36, -37, -38, -39, -40, -50, -20, -25,
72
+ -17, -26, -51, -51, -32, -33, -34, -51, -51, -49,
73
+ -14, -16, -30, -19, -18 ]
64
74
 
65
75
  racc_goto_table = [
66
- 18, 2, 3, 4, 36, 32, 42, 38, 22, 1,
67
- 19, 20, 23, 24, nil, nil, nil, nil, 34, 35,
68
- nil, nil, nil, nil, nil, 18, nil, 54, nil, nil,
69
- nil, nil, 52, 58, 60, 42, 59, 53, nil, nil,
70
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 18,
71
- nil, 56, 57, 4, 18 ]
76
+ 21, 22, 23, 2, 3, 4, 50, 35, 5, 38,
77
+ 41, 25, 43, 36, 1, 26, 27, 64, nil, nil,
78
+ 48, nil, nil, nil, 39, 40, nil, nil, 21, nil,
79
+ nil, nil, 60, nil, nil, nil, nil, 59, nil, 62,
80
+ 50, 50, nil, nil, 70, 72, 71, nil, nil, nil,
81
+ nil, nil, nil, nil, 48, nil, 21, nil, nil, nil,
82
+ 68, 69, 4, 22, 23, 67, 21 ]
72
83
 
73
84
  racc_goto_check = [
74
- 18, 2, 3, 4, 13, 14, 12, 15, 9, 1,
75
- 6, 7, 10, 11, nil, nil, nil, nil, 9, 9,
76
- nil, nil, nil, nil, nil, 18, nil, 14, nil, nil,
77
- nil, nil, 3, 13, 13, 12, 15, 6, nil, nil,
78
- nil, nil, nil, nil, nil, nil, nil, nil, nil, 18,
79
- nil, 2, 3, 4, 18 ]
85
+ 20, 6, 7, 2, 3, 4, 13, 12, 5, 12,
86
+ 14, 9, 16, 15, 1, 10, 11, 18, nil, nil,
87
+ 12, nil, nil, nil, 9, 9, nil, nil, 20, nil,
88
+ nil, nil, 6, nil, nil, nil, nil, 3, nil, 15,
89
+ 13, 13, nil, nil, 14, 14, 16, nil, nil, nil,
90
+ nil, nil, nil, nil, 12, nil, 20, nil, nil, nil,
91
+ 2, 3, 4, 6, 7, 5, 20 ]
80
92
 
81
93
  racc_goto_pointer = [
82
- nil, 9, 1, 2, 3, nil, 5, 6, nil, -5,
83
- -1, 0, -19, -21, -10, -18, nil, nil, -3 ]
94
+ nil, 14, 3, 4, 5, 8, -4, -3, nil, -2,
95
+ 2, 3, -8, -22, -18, -3, -16, nil, -33, nil,
96
+ -3 ]
84
97
 
85
98
  racc_goto_default = [
86
- nil, nil, nil, 28, 31, 5, 11, 12, 13, nil,
87
- 51, 40, 14, nil, 26, nil, 29, 46, 9 ]
99
+ nil, nil, nil, 31, 34, nil, 11, 12, 13, nil,
100
+ 58, 45, 14, 15, nil, 29, nil, 32, 49, 53,
101
+ 9 ]
88
102
 
89
103
  racc_reduce_table = [
90
104
  0, 0, :racc_error,
91
- 1, 19, :_reduce_1,
92
- 1, 19, :_reduce_2,
93
- 1, 20, :_reduce_3,
94
- 2, 20, :_reduce_4,
95
- 2, 20, :_reduce_5,
96
- 2, 20, :_reduce_6,
97
- 2, 20, :_reduce_7,
98
- 2, 24, :_reduce_8,
99
- 3, 24, :_reduce_9,
100
- 3, 24, :_reduce_10,
101
- 1, 26, :_reduce_11,
102
- 3, 26, :_reduce_12,
103
- 5, 26, :_reduce_13,
104
- 3, 26, :_reduce_14,
105
- 5, 26, :_reduce_15,
106
- 3, 25, :_reduce_none,
107
- 4, 28, :_reduce_17,
108
- 2, 29, :_reduce_none,
109
- 2, 29, :_reduce_none,
110
- 1, 27, :_reduce_none,
111
- 1, 27, :_reduce_none,
112
- 1, 34, :_reduce_none,
113
- 2, 34, :_reduce_none,
114
- 1, 30, :_reduce_24,
115
- 1, 30, :_reduce_25,
105
+ 1, 21, :_reduce_1,
106
+ 1, 21, :_reduce_2,
107
+ 1, 22, :_reduce_3,
108
+ 2, 22, :_reduce_4,
109
+ 2, 22, :_reduce_5,
110
+ 2, 22, :_reduce_6,
111
+ 2, 22, :_reduce_7,
112
+ 2, 26, :_reduce_8,
113
+ 3, 26, :_reduce_9,
114
+ 3, 26, :_reduce_10,
115
+ 1, 28, :_reduce_11,
116
+ 2, 28, :_reduce_12,
117
+ 3, 28, :_reduce_13,
118
+ 5, 28, :_reduce_14,
119
+ 3, 28, :_reduce_15,
120
+ 5, 28, :_reduce_16,
121
+ 3, 27, :_reduce_none,
122
+ 4, 30, :_reduce_18,
123
+ 4, 30, :_reduce_19,
124
+ 2, 31, :_reduce_none,
125
+ 2, 31, :_reduce_none,
126
+ 1, 29, :_reduce_none,
127
+ 1, 29, :_reduce_none,
128
+ 1, 37, :_reduce_none,
129
+ 2, 37, :_reduce_none,
116
130
  3, 33, :_reduce_26,
117
- 1, 31, :_reduce_27,
118
- 1, 31, :_reduce_28,
119
- 1, 31, :_reduce_29,
120
- 1, 31, :_reduce_30,
121
- 1, 31, :_reduce_31,
122
- 1, 31, :_reduce_32,
123
- 1, 35, :_reduce_33,
124
- 1, 35, :_reduce_34,
125
- 1, 32, :_reduce_none,
126
- 1, 32, :_reduce_none,
127
- 1, 36, :_reduce_none,
128
- 1, 36, :_reduce_none,
129
- 1, 36, :_reduce_none,
130
- 1, 21, :_reduce_none,
131
- 2, 21, :_reduce_none,
132
- 1, 23, :_reduce_none,
131
+ 1, 32, :_reduce_27,
132
+ 1, 32, :_reduce_28,
133
+ 1, 32, :_reduce_29,
134
+ 3, 36, :_reduce_30,
135
+ 1, 34, :_reduce_none,
136
+ 2, 34, :_reduce_32,
137
+ 1, 38, :_reduce_33,
138
+ 1, 38, :_reduce_34,
139
+ 1, 38, :_reduce_35,
140
+ 1, 38, :_reduce_36,
141
+ 1, 38, :_reduce_37,
142
+ 1, 38, :_reduce_38,
143
+ 1, 39, :_reduce_39,
144
+ 1, 39, :_reduce_40,
145
+ 1, 35, :_reduce_none,
146
+ 1, 35, :_reduce_none,
147
+ 1, 40, :_reduce_none,
148
+ 1, 40, :_reduce_none,
149
+ 1, 40, :_reduce_none,
133
150
  1, 23, :_reduce_none,
134
- 0, 22, :_reduce_44 ]
151
+ 2, 23, :_reduce_none,
152
+ 1, 25, :_reduce_none,
153
+ 1, 25, :_reduce_none,
154
+ 0, 24, :_reduce_50 ]
135
155
 
136
- racc_reduce_n = 45
156
+ racc_reduce_n = 51
137
157
 
138
- racc_shift_n = 63
158
+ racc_shift_n = 75
139
159
 
140
160
  racc_token_table = {
141
161
  false => 0,
@@ -150,14 +170,16 @@ racc_token_table = {
150
170
  :NULL => 9,
151
171
  :WS => 10,
152
172
  :NEWLINE => 11,
153
- :LPAREN => 12,
154
- :RPAREN => 13,
155
- :EQUALS => 14,
156
- :SEMICOLON => 15,
157
- :EOF => 16,
158
- :SLASHDASH => 17 }
173
+ :LBRACE => 12,
174
+ :RBRACE => 13,
175
+ :LPAREN => 14,
176
+ :RPAREN => 15,
177
+ :EQUALS => 16,
178
+ :SEMICOLON => 17,
179
+ :EOF => 18,
180
+ :SLASHDASH => 19 }
159
181
 
160
- racc_nt_base = 18
182
+ racc_nt_base = 20
161
183
 
162
184
  racc_use_result_var = false
163
185
 
@@ -190,6 +212,8 @@ Racc_token_to_s_table = [
190
212
  "NULL",
191
213
  "WS",
192
214
  "NEWLINE",
215
+ "LBRACE",
216
+ "RBRACE",
193
217
  "LPAREN",
194
218
  "RPAREN",
195
219
  "EQUALS",
@@ -209,10 +233,12 @@ Racc_token_to_s_table = [
209
233
  "node_children",
210
234
  "empty_children",
211
235
  "identifier",
236
+ "type",
212
237
  "value",
213
238
  "ws_star",
214
239
  "property",
215
240
  "semicolon_term",
241
+ "untyped_value",
216
242
  "boolean",
217
243
  "linespace" ]
218
244
 
@@ -222,107 +248,115 @@ Racc_debug_parser = false
222
248
 
223
249
  # reduce 0 omitted
224
250
 
225
- module_eval(<<'.,.,', 'kdl.yy', 12)
251
+ module_eval(<<'.,.,', 'kdl.yy', 13)
226
252
  def _reduce_1(val, _values)
227
253
  KDL::Document.new(val[0])
228
254
  end
229
255
  .,.,
230
256
 
231
- module_eval(<<'.,.,', 'kdl.yy', 13)
257
+ module_eval(<<'.,.,', 'kdl.yy', 14)
232
258
  def _reduce_2(val, _values)
233
259
  KDL::Document.new([])
234
260
  end
235
261
  .,.,
236
262
 
237
- module_eval(<<'.,.,', 'kdl.yy', 15)
263
+ module_eval(<<'.,.,', 'kdl.yy', 16)
238
264
  def _reduce_3(val, _values)
239
265
  []
240
266
  end
241
267
  .,.,
242
268
 
243
- module_eval(<<'.,.,', 'kdl.yy', 16)
269
+ module_eval(<<'.,.,', 'kdl.yy', 17)
244
270
  def _reduce_4(val, _values)
245
271
  [val[1]]
246
272
  end
247
273
  .,.,
248
274
 
249
- module_eval(<<'.,.,', 'kdl.yy', 17)
275
+ module_eval(<<'.,.,', 'kdl.yy', 18)
250
276
  def _reduce_5(val, _values)
251
277
  []
252
278
  end
253
279
  .,.,
254
280
 
255
- module_eval(<<'.,.,', 'kdl.yy', 18)
281
+ module_eval(<<'.,.,', 'kdl.yy', 19)
256
282
  def _reduce_6(val, _values)
257
283
  [*val[0], val[1]]
258
284
  end
259
285
  .,.,
260
286
 
261
- module_eval(<<'.,.,', 'kdl.yy', 19)
287
+ module_eval(<<'.,.,', 'kdl.yy', 20)
262
288
  def _reduce_7(val, _values)
263
289
  val[0]
264
290
  end
265
291
  .,.,
266
292
 
267
- module_eval(<<'.,.,', 'kdl.yy', 20)
293
+ module_eval(<<'.,.,', 'kdl.yy', 21)
268
294
  def _reduce_8(val, _values)
269
- val[0]
295
+ val[0].tap { |x| x.children = nil }
270
296
  end
271
297
  .,.,
272
298
 
273
- module_eval(<<'.,.,', 'kdl.yy', 21)
299
+ module_eval(<<'.,.,', 'kdl.yy', 22)
274
300
  def _reduce_9(val, _values)
275
301
  val[0].tap { |x| x.children = val[1] }
276
302
  end
277
303
  .,.,
278
304
 
279
- module_eval(<<'.,.,', 'kdl.yy', 22)
305
+ module_eval(<<'.,.,', 'kdl.yy', 23)
280
306
  def _reduce_10(val, _values)
281
- val[0]
307
+ val[0].tap { |x| x.children = nil }
282
308
  end
283
309
  .,.,
284
310
 
285
- module_eval(<<'.,.,', 'kdl.yy', 23)
311
+ module_eval(<<'.,.,', 'kdl.yy', 24)
286
312
  def _reduce_11(val, _values)
287
313
  KDL::Node.new(val[0])
288
314
  end
289
315
  .,.,
290
316
 
291
- module_eval(<<'.,.,', 'kdl.yy', 24)
317
+ module_eval(<<'.,.,', 'kdl.yy', 25)
292
318
  def _reduce_12(val, _values)
293
- val[0].tap { |x| x.arguments << val[2] }
319
+ KDL::Node.new(val[1], type: val[0])
294
320
  end
295
321
  .,.,
296
322
 
297
- module_eval(<<'.,.,', 'kdl.yy', 25)
323
+ module_eval(<<'.,.,', 'kdl.yy', 26)
298
324
  def _reduce_13(val, _values)
299
- val[0]
325
+ val[0].tap { |x| x.arguments << val[2] }
300
326
  end
301
327
  .,.,
302
328
 
303
- module_eval(<<'.,.,', 'kdl.yy', 26)
329
+ module_eval(<<'.,.,', 'kdl.yy', 27)
304
330
  def _reduce_14(val, _values)
305
- val[0].tap { |x| x.properties[val[2][0]] = val[2][1] }
331
+ val[0]
306
332
  end
307
333
  .,.,
308
334
 
309
- module_eval(<<'.,.,', 'kdl.yy', 27)
335
+ module_eval(<<'.,.,', 'kdl.yy', 28)
310
336
  def _reduce_15(val, _values)
337
+ val[0].tap { |x| x.properties[val[2][0]] = val[2][1] }
338
+ end
339
+ .,.,
340
+
341
+ module_eval(<<'.,.,', 'kdl.yy', 29)
342
+ def _reduce_16(val, _values)
311
343
  val[0]
312
344
  end
313
345
  .,.,
314
346
 
315
- # reduce 16 omitted
347
+ # reduce 17 omitted
316
348
 
317
- module_eval(<<'.,.,', 'kdl.yy', 29)
318
- def _reduce_17(val, _values)
349
+ module_eval(<<'.,.,', 'kdl.yy', 31)
350
+ def _reduce_18(val, _values)
319
351
  val[2]
320
352
  end
321
353
  .,.,
322
354
 
323
- # reduce 18 omitted
324
-
325
- # reduce 19 omitted
355
+ module_eval(<<'.,.,', 'kdl.yy', 32)
356
+ def _reduce_19(val, _values)
357
+ []
358
+ end
359
+ .,.,
326
360
 
327
361
  # reduce 20 omitted
328
362
 
@@ -332,92 +366,116 @@ module_eval(<<'.,.,', 'kdl.yy', 29)
332
366
 
333
367
  # reduce 23 omitted
334
368
 
335
- module_eval(<<'.,.,', 'kdl.yy', 35)
336
- def _reduce_24(val, _values)
369
+ # reduce 24 omitted
370
+
371
+ # reduce 25 omitted
372
+
373
+ module_eval(<<'.,.,', 'kdl.yy', 38)
374
+ def _reduce_26(val, _values)
375
+ val[1]
376
+ end
377
+ .,.,
378
+
379
+ module_eval(<<'.,.,', 'kdl.yy', 40)
380
+ def _reduce_27(val, _values)
337
381
  val[0].value
338
382
  end
339
383
  .,.,
340
384
 
341
- module_eval(<<'.,.,', 'kdl.yy', 36)
342
- def _reduce_25(val, _values)
385
+ module_eval(<<'.,.,', 'kdl.yy', 41)
386
+ def _reduce_28(val, _values)
343
387
  val[0].value
344
388
  end
345
389
  .,.,
346
390
 
347
- module_eval(<<'.,.,', 'kdl.yy', 38)
348
- def _reduce_26(val, _values)
391
+ module_eval(<<'.,.,', 'kdl.yy', 42)
392
+ def _reduce_29(val, _values)
393
+ val[0].value
394
+ end
395
+ .,.,
396
+
397
+ module_eval(<<'.,.,', 'kdl.yy', 44)
398
+ def _reduce_30(val, _values)
349
399
  [val[0], val[2]]
350
400
  end
351
401
  .,.,
352
402
 
353
- module_eval(<<'.,.,', 'kdl.yy', 40)
354
- def _reduce_27(val, _values)
403
+ # reduce 31 omitted
404
+
405
+ module_eval(<<'.,.,', 'kdl.yy', 47)
406
+ def _reduce_32(val, _values)
407
+ val[1].as_type(val[0])
408
+ end
409
+ .,.,
410
+
411
+ module_eval(<<'.,.,', 'kdl.yy', 49)
412
+ def _reduce_33(val, _values)
355
413
  KDL::Value::String.new(val[0].value)
356
414
  end
357
415
  .,.,
358
416
 
359
- module_eval(<<'.,.,', 'kdl.yy', 41)
360
- def _reduce_28(val, _values)
417
+ module_eval(<<'.,.,', 'kdl.yy', 50)
418
+ def _reduce_34(val, _values)
361
419
  KDL::Value::String.new(val[0].value)
362
420
  end
363
421
  .,.,
364
422
 
365
- module_eval(<<'.,.,', 'kdl.yy', 42)
366
- def _reduce_29(val, _values)
423
+ module_eval(<<'.,.,', 'kdl.yy', 51)
424
+ def _reduce_35(val, _values)
367
425
  KDL::Value::Int.new(val[0].value)
368
426
  end
369
427
  .,.,
370
428
 
371
- module_eval(<<'.,.,', 'kdl.yy', 43)
372
- def _reduce_30(val, _values)
373
- KDL::Value::Float.new(val[0].value)
429
+ module_eval(<<'.,.,', 'kdl.yy', 52)
430
+ def _reduce_36(val, _values)
431
+ KDL::Value::Float.new(val[0].value, format: val[0].meta[:format])
374
432
  end
375
433
  .,.,
376
434
 
377
- module_eval(<<'.,.,', 'kdl.yy', 44)
378
- def _reduce_31(val, _values)
435
+ module_eval(<<'.,.,', 'kdl.yy', 53)
436
+ def _reduce_37(val, _values)
379
437
  KDL::Value::Boolean.new(val[0])
380
438
  end
381
439
  .,.,
382
440
 
383
- module_eval(<<'.,.,', 'kdl.yy', 45)
384
- def _reduce_32(val, _values)
441
+ module_eval(<<'.,.,', 'kdl.yy', 54)
442
+ def _reduce_38(val, _values)
385
443
  KDL::Value::Null
386
444
  end
387
445
  .,.,
388
446
 
389
- module_eval(<<'.,.,', 'kdl.yy', 47)
390
- def _reduce_33(val, _values)
447
+ module_eval(<<'.,.,', 'kdl.yy', 56)
448
+ def _reduce_39(val, _values)
391
449
  true
392
450
  end
393
451
  .,.,
394
452
 
395
- module_eval(<<'.,.,', 'kdl.yy', 48)
396
- def _reduce_34(val, _values)
453
+ module_eval(<<'.,.,', 'kdl.yy', 57)
454
+ def _reduce_40(val, _values)
397
455
  false
398
456
  end
399
457
  .,.,
400
458
 
401
- # reduce 35 omitted
459
+ # reduce 41 omitted
402
460
 
403
- # reduce 36 omitted
461
+ # reduce 42 omitted
404
462
 
405
- # reduce 37 omitted
463
+ # reduce 43 omitted
406
464
 
407
- # reduce 38 omitted
465
+ # reduce 44 omitted
408
466
 
409
- # reduce 39 omitted
467
+ # reduce 45 omitted
410
468
 
411
- # reduce 40 omitted
469
+ # reduce 46 omitted
412
470
 
413
- # reduce 41 omitted
471
+ # reduce 47 omitted
414
472
 
415
- # reduce 42 omitted
473
+ # reduce 48 omitted
416
474
 
417
- # reduce 43 omitted
475
+ # reduce 49 omitted
418
476
 
419
- module_eval(<<'.,.,', 'kdl.yy', 55)
420
- def _reduce_44(val, _values)
477
+ module_eval(<<'.,.,', 'kdl.yy', 64)
478
+ def _reduce_50(val, _values)
421
479
  nil
422
480
  end
423
481
  .,.,
data/lib/kdl/kdl.yy CHANGED
@@ -4,6 +4,7 @@ class KDL::Parser
4
4
  STRING RAWSTRING
5
5
  INTEGER FLOAT TRUE FALSE NULL
6
6
  WS NEWLINE
7
+ LBRACE RBRACE
7
8
  LPAREN RPAREN
8
9
  EQUALS
9
10
  SEMICOLON
@@ -18,32 +19,40 @@ rule
18
19
  | linespace_star empty_node { [] }
19
20
  | nodes node { [*val[0], val[1]] }
20
21
  | nodes empty_node { val[0] }
21
- node : node_decl node_term { val[0] }
22
+ node : node_decl node_term { val[0].tap { |x| x.children = nil } }
22
23
  | node_decl node_children node_term { val[0].tap { |x| x.children = val[1] } }
23
- | node_decl empty_children node_term { val[0] }
24
+ | node_decl empty_children node_term { val[0].tap { |x| x.children = nil } }
24
25
  node_decl : identifier { KDL::Node.new(val[0]) }
26
+ | type identifier { KDL::Node.new(val[1], type: val[0]) }
25
27
  | node_decl WS value { val[0].tap { |x| x.arguments << val[2] } }
26
28
  | node_decl WS SLASHDASH ws_star value { val[0] }
27
29
  | node_decl WS property { val[0].tap { |x| x.properties[val[2][0]] = val[2][1] } }
28
30
  | node_decl WS SLASHDASH ws_star property { val[0] }
29
31
  empty_node: SLASHDASH ws_star node
30
- node_children: ws_star LPAREN nodes RPAREN { val[2] }
32
+ node_children: ws_star LBRACE nodes RBRACE { val[2] }
33
+ | ws_star LBRACE linespace_star RBRACE { [] }
31
34
  empty_children: SLASHDASH node_children
32
35
  | WS empty_children
33
36
  node_term: linespaces | semicolon_term
34
37
  semicolon_term: SEMICOLON | SEMICOLON linespaces
35
38
 
36
- identifier: IDENT { val[0].value }
37
- | STRING { val[0].value }
39
+ type : LPAREN identifier RPAREN { val[1] }
40
+
41
+ identifier: IDENT { val[0].value }
42
+ | STRING { val[0].value }
43
+ | RAWSTRING { val[0].value }
38
44
 
39
45
  property: identifier EQUALS value { [val[0], val[2]] }
40
46
 
41
- value : STRING { KDL::Value::String.new(val[0].value) }
42
- | RAWSTRING { KDL::Value::String.new(val[0].value) }
43
- | INTEGER { KDL::Value::Int.new(val[0].value) }
44
- | FLOAT { KDL::Value::Float.new(val[0].value) }
45
- | boolean { KDL::Value::Boolean.new(val[0]) }
46
- | NULL { KDL::Value::Null }
47
+ value : untyped_value
48
+ | type untyped_value { val[1].as_type(val[0]) }
49
+
50
+ untyped_value : STRING { KDL::Value::String.new(val[0].value) }
51
+ | RAWSTRING { KDL::Value::String.new(val[0].value) }
52
+ | INTEGER { KDL::Value::Int.new(val[0].value) }
53
+ | FLOAT { KDL::Value::Float.new(val[0].value, format: val[0].meta[:format]) }
54
+ | boolean { KDL::Value::Boolean.new(val[0]) }
55
+ | NULL { KDL::Value::Null }
47
56
 
48
57
  boolean : TRUE { true }
49
58
  | FALSE { false }
data/lib/kdl/node.rb CHANGED
@@ -1,31 +1,33 @@
1
1
  module KDL
2
2
  class Node
3
- attr_accessor :name, :arguments, :properties, :children
3
+ attr_accessor :name, :arguments, :properties, :children, :type
4
4
 
5
- def initialize(name, arguments = [], properties = {}, children = [])
5
+ def initialize(name, arguments = [], properties = {}, children = nil, type: nil)
6
6
  @name = name
7
7
  @arguments = arguments
8
8
  @properties = properties
9
9
  @children = children
10
+ @type = type
10
11
  end
11
12
 
12
13
  def to_s(level = 0)
13
14
  indent = ' ' * level
14
- s = "#{indent}#{name}"
15
+ s = "#{indent}#{type ? "(#{id_to_s type})" : ''}#{id_to_s name}"
15
16
  unless arguments.empty?
16
17
  s += " #{arguments.map(&:to_s).join(' ')}"
17
18
  end
18
19
  unless properties.empty?
19
- s += " #{properties.map { |k, v| "#{k}=#{v}" }.join(' ')}"
20
+ s += " #{properties.map { |k, v| "#{id_to_s k}=#{v}" }.join(' ')}"
20
21
  end
21
- unless children.empty?
22
+ unless children.nil?
22
23
  s += " {\n"
23
- s += children.map { |c| c.to_s(level + 1) }.join("\n")
24
- s += "\n#{indent}}"
24
+ unless children.empty?
25
+ s += children.map { |c| "#{c.to_s(level + 1)}\n" }.join("\n")
26
+ end
27
+ s += "#{indent}}"
25
28
  end
26
29
  s
27
30
  end
28
- alias inspect to_s
29
31
 
30
32
  def ==(other)
31
33
  return false unless other.is_a?(Node)
@@ -35,5 +37,11 @@ module KDL
35
37
  properties == other.properties &&
36
38
  children == other.children
37
39
  end
40
+
41
+ private
42
+
43
+ def id_to_s(id)
44
+ StringDumper.stringify_identifier(id)
45
+ end
38
46
  end
39
47
  end
@@ -0,0 +1,45 @@
1
+ module KDL
2
+ module StringDumper
3
+ class << self
4
+ def call(string)
5
+ %("#{string.each_char.map { |char| escape(char) }.join}")
6
+ end
7
+
8
+ def stringify_identifier(ident)
9
+ if bare_identifier?(ident)
10
+ ident
11
+ else
12
+ call(ident)
13
+ end
14
+ end
15
+
16
+ private
17
+
18
+ def print?(char)
19
+ ' ' <= char && char <= '\x7e'
20
+ end
21
+
22
+ def escape(char)
23
+ case char
24
+ when "\n" then '\n'
25
+ when "\r" then '\r'
26
+ when "\t" then '\t'
27
+ when '\\' then '\\\\'
28
+ when '"' then '\"'
29
+ when "\b" then '\b'
30
+ when "\f" then '\f'
31
+ else char
32
+ end
33
+ end
34
+
35
+ def unicode_escape(char)
36
+ "\\u{#{char.codepoints.first.to_s(16)}}"
37
+ end
38
+
39
+ def bare_identifier?(name)
40
+ escape_chars = '\\\/(){}<>;\[\]=,"'
41
+ name =~ /^([^0-9\-+\s#{escape_chars}][^\s#{escape_chars}]*|[\-+](?!true|false|null)[^0-9\s#{escape_chars}][^\s#{escape_chars}]*)$/
42
+ end
43
+ end
44
+ end
45
+ end
data/lib/kdl/tokenizer.rb CHANGED
@@ -1,3 +1,5 @@
1
+ require 'bigdecimal'
2
+
1
3
  module KDL
2
4
  class Tokenizer
3
5
  class Error < StandardError
@@ -7,13 +9,14 @@ module KDL
7
9
  end
8
10
 
9
11
  class Token
10
- attr_reader :type, :value, :line, :column
12
+ attr_reader :type, :value, :line, :column, :meta
11
13
 
12
- def initialize(type, value, line, column)
14
+ def initialize(type, value, line, column, meta = {})
13
15
  @type = type
14
16
  @value = value
15
17
  @line = line
16
18
  @column = column
19
+ @meta = meta
17
20
  end
18
21
 
19
22
  def ==(other)
@@ -31,8 +34,8 @@ module KDL
31
34
  attr_reader :index
32
35
 
33
36
  SYMBOLS = {
34
- '{' => :LPAREN,
35
- '}' => :RPAREN,
37
+ '{' => :LBRACE,
38
+ '}' => :RBRACE,
36
39
  '=' => :EQUALS,
37
40
  '=' => :EQUALS,
38
41
  ';' => :SEMICOLON
@@ -46,10 +49,13 @@ module KDL
46
49
 
47
50
  NEWLINES = ["\u000A", "\u0085", "\u000C", "\u2028", "\u2029"]
48
51
 
49
- NON_IDENTIFIER_CHARS = Regexp.escape "#{SYMBOLS.keys.join('')}\\<>[]\","
52
+ NON_IDENTIFIER_CHARS = Regexp.escape "#{SYMBOLS.keys.join('')}()/\\<>[]\","
50
53
  IDENTIFIER_CHARS = /[^#{NON_IDENTIFIER_CHARS}\x0-\x20]/
51
54
  INITIAL_IDENTIFIER_CHARS = /[^#{NON_IDENTIFIER_CHARS}0-9\x0-\x20]/
52
55
 
56
+ ALLOWED_IN_TYPE = [:ident, :string, :rawstring]
57
+ NOT_ALLOWED_AFTER_TYPE = [:single_line_comment, :multi_line_comment]
58
+
53
59
  def initialize(str, start = 0)
54
60
  @str = str
55
61
  @context = nil
@@ -60,6 +66,7 @@ module KDL
60
66
  @previous_context = nil
61
67
  @line = 1
62
68
  @column = 1
69
+ @type_context = false
63
70
  end
64
71
 
65
72
  def next_token
@@ -174,6 +181,12 @@ module KDL
174
181
  self.context = :ident
175
182
  @buffer = c
176
183
  traverse(1)
184
+ when '('
185
+ @type_context = true
186
+ return token(:LPAREN, c).tap { traverse(1) }
187
+ when ')'
188
+ @type_context = false
189
+ return token(:RPAREN, c).tap { traverse(1) }
177
190
  else
178
191
  raise_error "Unexpected character #{c.inspect}"
179
192
  end
@@ -304,8 +317,8 @@ module KDL
304
317
 
305
318
  private
306
319
 
307
- def token(type, value)
308
- [type, Token.new(type, value, @line_at_start, @column_at_start)]
320
+ def token(type, value, **meta)
321
+ @last_token = [type, Token.new(type, value, @line_at_start, @column_at_start, meta)]
309
322
  end
310
323
 
311
324
  def traverse(n = 1)
@@ -323,6 +336,11 @@ module KDL
323
336
  end
324
337
 
325
338
  def context=(val)
339
+ if @type_context && !ALLOWED_IN_TYPE.include?(val)
340
+ raise_error "#{val} context not allowed in type declaration"
341
+ elsif @last_token && @last_token[0] == :RPAREN && NOT_ALLOWED_AFTER_TYPE.include?(val)
342
+ raise_error 'Comments are not allowed after a type declaration'
343
+ end
326
344
  @previous_context = @context
327
345
  @context = val
328
346
  end
@@ -333,18 +351,35 @@ module KDL
333
351
  end
334
352
 
335
353
  def parse_decimal(s)
336
- return token(:FLOAT, Float(munch_underscores(s))) if s =~ /[.eE]/
337
- token(:INTEGER, Integer(munch_underscores(s), 10))
354
+ return parse_float(s) if s =~ /[.E]/i
355
+
356
+ token(:INTEGER, Integer(munch_underscores(s), 10), format: '%d')
357
+ end
358
+
359
+ def parse_float(s)
360
+ match, whole, fraction, exponent = *s.match(/^([-+]?[\d_]+)(?:\.(\d+))?(?:[eE]([-+]?[\d_]+))?$/)
361
+ raise_error "Invalid floating point value #{s}" if match.nil?
362
+
363
+ s = munch_underscores(s)
364
+
365
+ decimals = fraction.nil? ? 0 : fraction.size
366
+ value = Float(s)
367
+ scientific = value.abs >= 100 || (exponent && exponent.to_i.abs >= 2)
368
+ if value.infinite? || (value.zero? && exponent.to_i < 0)
369
+ token(:FLOAT, BigDecimal(s))
370
+ else
371
+ token(:FLOAT, value, format: scientific ? "%.#{decimals}E" : nil)
372
+ end
338
373
  end
339
-
374
+
340
375
  def parse_hexadecimal(s)
341
376
  token(:INTEGER, Integer(munch_underscores(s), 16))
342
377
  end
343
-
378
+
344
379
  def parse_octal(s)
345
380
  token(:INTEGER, Integer(munch_underscores(s), 8))
346
381
  end
347
-
382
+
348
383
  def parse_binary(s)
349
384
  token(:INTEGER, Integer(munch_underscores(s), 2))
350
385
  end
data/lib/kdl/value.rb CHANGED
@@ -1,15 +1,28 @@
1
1
  module KDL
2
2
  class Value
3
- attr_reader :value
3
+ attr_reader :value, :format, :type
4
4
 
5
- def initialize(value)
5
+ def initialize(value, format: nil, type: nil)
6
6
  @value = value
7
+ @format = format
8
+ @type = type
9
+ end
10
+
11
+ def as_type(type)
12
+ self.class.new(value, format: format, type: type)
7
13
  end
8
14
 
9
15
  def to_s
16
+ return stringify_value unless type
17
+
18
+ "(#{StringDumper.stringify_identifier type})#{stringify_value}"
19
+ end
20
+
21
+ def stringify_value
22
+ return format % value if format
23
+
10
24
  value.to_s
11
25
  end
12
- alias inspect to_s
13
26
 
14
27
  class Int < Value
15
28
  def ==(other)
@@ -21,6 +34,16 @@ module KDL
21
34
  def ==(other)
22
35
  other.is_a?(Float) && value == other.value
23
36
  end
37
+
38
+ def stringify_value
39
+ return super.upcase unless value.is_a?(BigDecimal)
40
+
41
+ sign, digits, _, exponent = value.split
42
+ s = sign.negative? ? '-' : ''
43
+ s += "#{digits[0]}.#{digits[1..-1]}"
44
+ s += "E#{exponent.negative? ? '' : '+'}#{exponent - 1}"
45
+ s
46
+ end
24
47
  end
25
48
 
26
49
  class Boolean < Value
@@ -30,10 +53,9 @@ module KDL
30
53
  end
31
54
 
32
55
  class String < Value
33
- def to_s
34
- value.inspect
56
+ def stringify_value
57
+ StringDumper.call(value)
35
58
  end
36
- alias inspect to_s
37
59
 
38
60
  def ==(other)
39
61
  other.is_a?(String) && value == other.value
@@ -41,14 +63,13 @@ module KDL
41
63
  end
42
64
 
43
65
  class NullImpl < Value
44
- def initialize
45
- super(nil)
66
+ def initialize(_=nil, format: nil, type: nil)
67
+ super(nil, type: type)
46
68
  end
47
69
 
48
- def to_s
70
+ def stringify_value
49
71
  "null"
50
72
  end
51
- alias inspect to_s
52
73
 
53
74
  def ==(other)
54
75
  other.is_a?(NullImpl)
data/lib/kdl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module KDL
2
- VERSION = "0.1.2"
2
+ VERSION = "1.0.0.rc1"
3
3
  end
data/lib/kdl.rb CHANGED
@@ -3,6 +3,7 @@ require "kdl/tokenizer"
3
3
  require "kdl/document"
4
4
  require "kdl/value"
5
5
  require "kdl/node"
6
+ require "kdl/string_dumper"
6
7
  require "kdl/kdl.tab"
7
8
 
8
9
  module KDL
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kdl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 1.0.0.rc1
5
5
  platform: ruby
6
6
  authors:
7
- - Daniel Smith
7
+ - Danielle Smith
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-01-02 00:00:00.000000000 Z
11
+ date: 2021-09-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: racc
@@ -33,12 +33,15 @@ extra_rdoc_files: []
33
33
  files:
34
34
  - ".github/workflows/ruby.yml"
35
35
  - ".gitignore"
36
+ - ".gitmodules"
36
37
  - CODE_OF_CONDUCT.md
37
38
  - Gemfile
38
39
  - LICENSE.txt
39
40
  - README.md
40
41
  - Rakefile
41
42
  - bin/console
43
+ - bin/racc
44
+ - bin/rake
42
45
  - bin/setup
43
46
  - kdl.gemspec
44
47
  - lib/kdl.rb
@@ -46,6 +49,7 @@ files:
46
49
  - lib/kdl/kdl.tab.rb
47
50
  - lib/kdl/kdl.yy
48
51
  - lib/kdl/node.rb
52
+ - lib/kdl/string_dumper.rb
49
53
  - lib/kdl/tokenizer.rb
50
54
  - lib/kdl/value.rb
51
55
  - lib/kdl/version.rb
@@ -54,8 +58,8 @@ licenses:
54
58
  - MIT
55
59
  metadata:
56
60
  homepage_uri: https://kdl.dev
57
- source_code_uri: https://github.com/jellymann/kdl-rb
58
- changelog_uri: https://github.com/jellymann/kdl-rb/releases
61
+ source_code_uri: https://github.com/danini-the-panini/kdl-rb
62
+ changelog_uri: https://github.com/danini-the-panini/kdl-rb/releases
59
63
  post_install_message:
60
64
  rdoc_options: []
61
65
  require_paths:
@@ -67,11 +71,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
67
71
  version: 2.3.0
68
72
  required_rubygems_version: !ruby/object:Gem::Requirement
69
73
  requirements:
70
- - - ">="
74
+ - - ">"
71
75
  - !ruby/object:Gem::Version
72
- version: '0'
76
+ version: 1.3.1
73
77
  requirements: []
74
- rubygems_version: 3.1.4
78
+ rubygems_version: 3.2.22
75
79
  signing_key:
76
80
  specification_version: 4
77
81
  summary: KDL Document Language