jievro-ast 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +3 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +32 -0
- data/LICENSE.txt +22 -0
- data/README.md +1 -0
- data/Rakefile +7 -0
- data/jievro-ast.gemspec +24 -0
- data/lib/jievro/ast/node.rb +106 -0
- data/lib/jievro/ast/version.rb +5 -0
- data/lib/jievro-ast.rb +1 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 50cd22e469c4b1fd0283aa7777c9d163032d02d7
|
4
|
+
data.tar.gz: e896e1c622d0a00f0d6cfec4d2fbcae9babac635
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 98929235e44c35a6cc6d8766c75b175d424d9f649915d0882f9f1011681a3221343c5ee295ac68b07b5e040a19c11ff9ccd805df299ed7374daa1a7b32affc04
|
7
|
+
data.tar.gz: bba3556c1357d212b787ccaada0d92d6cd37b97ef171b5dd561fed80f5758f30b7d45218926c76c834785fdd51a1518a7a5b664b5296c4aa8a5e3413ce61ca3b
|
data/.gitignore
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
/vendor/
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
jievro-ast (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
diff-lcs (1.2.5)
|
10
|
+
rake (10.4.2)
|
11
|
+
rspec (3.2.0)
|
12
|
+
rspec-core (~> 3.2.0)
|
13
|
+
rspec-expectations (~> 3.2.0)
|
14
|
+
rspec-mocks (~> 3.2.0)
|
15
|
+
rspec-core (3.2.3)
|
16
|
+
rspec-support (~> 3.2.0)
|
17
|
+
rspec-expectations (3.2.1)
|
18
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
19
|
+
rspec-support (~> 3.2.0)
|
20
|
+
rspec-mocks (3.2.1)
|
21
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
22
|
+
rspec-support (~> 3.2.0)
|
23
|
+
rspec-support (3.2.2)
|
24
|
+
|
25
|
+
PLATFORMS
|
26
|
+
ruby
|
27
|
+
|
28
|
+
DEPENDENCIES
|
29
|
+
bundler (~> 1.9)
|
30
|
+
jievro-ast!
|
31
|
+
rake (~> 10.0)
|
32
|
+
rspec (~> 3.2)
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2015 Stefano Azzalini
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
#jievro-ast
|
data/Rakefile
ADDED
data/jievro-ast.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
lib = File.expand_path('../lib', __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
|
4
|
+
require 'jievro/ast/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'jievro-ast'
|
8
|
+
spec.version = Jievro::Ast::VERSION
|
9
|
+
spec.authors = ['Stefano Azzalini']
|
10
|
+
spec.email = 'hi@jievro.io'
|
11
|
+
spec.homepage = 'http://jievro.io'
|
12
|
+
spec.summary = %q{AST model used internally by jievro-parser}
|
13
|
+
spec.license = 'MIT'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
16
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.required_ruby_version = '~> 2.0'
|
20
|
+
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.9'
|
22
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
23
|
+
spec.add_development_dependency 'rspec', '~> 3.2'
|
24
|
+
end
|
@@ -0,0 +1,106 @@
|
|
1
|
+
module Jievro
|
2
|
+
module Ast
|
3
|
+
class Node
|
4
|
+
|
5
|
+
def initialize(initializer, parent = nil, key = nil)
|
6
|
+
|
7
|
+
@parent = parent
|
8
|
+
@key = key
|
9
|
+
|
10
|
+
if initializer.is_a?(Hash)
|
11
|
+
initialize_using_hash(initializer)
|
12
|
+
return
|
13
|
+
end
|
14
|
+
|
15
|
+
if initializer.is_a?(Array)
|
16
|
+
initialize_using_array(initializer)
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
valid = [FalseClass, TrueClass, String, Fixnum, Float]
|
21
|
+
|
22
|
+
if valid.include? initializer.class
|
23
|
+
@value = initializer
|
24
|
+
@type = '__literal'
|
25
|
+
return
|
26
|
+
end
|
27
|
+
|
28
|
+
raise Exception, "The initializer must be #{valid.join(', ')}, Array or Hash. #{initializer.class} given"
|
29
|
+
end
|
30
|
+
|
31
|
+
def [] (key)
|
32
|
+
unless @value.has_key?(key)
|
33
|
+
raise Exception, "Key '#{key}' is invalid"
|
34
|
+
end
|
35
|
+
|
36
|
+
@value[key]
|
37
|
+
end
|
38
|
+
|
39
|
+
def parent
|
40
|
+
@parent
|
41
|
+
end
|
42
|
+
|
43
|
+
def type
|
44
|
+
@type
|
45
|
+
end
|
46
|
+
|
47
|
+
def key
|
48
|
+
@key
|
49
|
+
end
|
50
|
+
|
51
|
+
def keys
|
52
|
+
@value.keys
|
53
|
+
end
|
54
|
+
|
55
|
+
def value
|
56
|
+
@value
|
57
|
+
end
|
58
|
+
|
59
|
+
def to_hash
|
60
|
+
{}
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def initialize_using_hash(initializer)
|
66
|
+
|
67
|
+
unless initializer.is_a?(Hash)
|
68
|
+
raise Exception, 'The initializer is not a Hash'
|
69
|
+
end
|
70
|
+
|
71
|
+
unless initializer.has_key?(:__type)
|
72
|
+
raise Exception, 'Initializer is missing __type value'
|
73
|
+
end
|
74
|
+
|
75
|
+
@value = Hash.new
|
76
|
+
@type = initializer[:__type]
|
77
|
+
|
78
|
+
initializer.keys.each { |k|
|
79
|
+
|
80
|
+
key = k.to_s
|
81
|
+
|
82
|
+
# skip all the meta info
|
83
|
+
if key.to_s.start_with?('__')
|
84
|
+
next
|
85
|
+
end
|
86
|
+
|
87
|
+
@value[k] = Node.new(initializer[k], self, key)
|
88
|
+
}
|
89
|
+
end
|
90
|
+
|
91
|
+
def initialize_using_array(initializer)
|
92
|
+
|
93
|
+
unless initializer.is_a?(Array)
|
94
|
+
raise Exception, 'The initializer is not an Array'
|
95
|
+
end
|
96
|
+
|
97
|
+
@value = Hash.new
|
98
|
+
@type = '__collection'
|
99
|
+
|
100
|
+
initializer.each_with_index { |e, i|
|
101
|
+
@value[i] = Node.new(e, self, i)
|
102
|
+
}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
data/lib/jievro-ast.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'jievro/ast/node'
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jievro-ast
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Stefano Azzalini
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-07 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.9'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.9'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.2'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.2'
|
55
|
+
description:
|
56
|
+
email: hi@jievro.io
|
57
|
+
executables: []
|
58
|
+
extensions: []
|
59
|
+
extra_rdoc_files: []
|
60
|
+
files:
|
61
|
+
- ".gitignore"
|
62
|
+
- ".travis.yml"
|
63
|
+
- Gemfile
|
64
|
+
- Gemfile.lock
|
65
|
+
- LICENSE.txt
|
66
|
+
- README.md
|
67
|
+
- Rakefile
|
68
|
+
- jievro-ast.gemspec
|
69
|
+
- lib/jievro-ast.rb
|
70
|
+
- lib/jievro/ast/node.rb
|
71
|
+
- lib/jievro/ast/version.rb
|
72
|
+
homepage: http://jievro.io
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - "~>"
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '2.0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.4.6
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: AST model used internally by jievro-parser
|
96
|
+
test_files: []
|