hcl-checker 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +10 -10
- data/README.md +6 -8
- data/hcl-checker.gemspec +26 -2
- data/lib/hcl/checker/version.rb +1 -1
- data/lib/hcl1/checker.rb +21 -0
- data/lib/hcl1/checker/version.rb +5 -0
- data/lib/hcl1/lexer.rb +175 -0
- data/lib/hcl1/parser.rb +456 -0
- metadata +34 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 195128a0325ac3b7fa3add01a739dbe3ce0aeb5b3314edfc74d195caa3a0aa61
|
4
|
+
data.tar.gz: ab84f84386083bdbb9aaea917716ea7e8462eaed2b89a2ab4f887fb4c3b2ee93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b53587ad90fa9ed3cf6c2fbfd5cad15f6b526e62e5c63298fbd963a1629d6283a0bac0ab7276674acba8a1d67e38bc2118fe8f9a0a11a5d362afef4957cc745a
|
7
|
+
data.tar.gz: 4d908d23f548138a2e4e876709cda19321650203d13219f8ac8fe3748cd1427e628f9cb834f80bf684252a7d06d9a97d72663f3ac6c19699a0149593e3450a0d
|
data/Gemfile.lock
CHANGED
@@ -1,21 +1,21 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hcl-checker (1.
|
4
|
+
hcl-checker (1.4.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
|
-
diff-lcs (1.
|
9
|
+
diff-lcs (1.4.4)
|
10
10
|
filesize (0.2.0)
|
11
11
|
jsobfu (0.4.2)
|
12
12
|
rkelly-remix
|
13
|
-
json (2.3.
|
13
|
+
json (2.3.1)
|
14
14
|
metasm (1.0.4)
|
15
15
|
mini_portile2 (2.4.0)
|
16
|
-
nokogiri (1.10.
|
16
|
+
nokogiri (1.10.10)
|
17
17
|
mini_portile2 (~> 2.4.0)
|
18
|
-
racc (1.
|
18
|
+
racc (1.5.0)
|
19
19
|
rake (12.3.3)
|
20
20
|
rb-readline (0.5.5)
|
21
21
|
rex (2.0.12)
|
@@ -31,15 +31,15 @@ GEM
|
|
31
31
|
rspec-core (~> 3.9.0)
|
32
32
|
rspec-expectations (~> 3.9.0)
|
33
33
|
rspec-mocks (~> 3.9.0)
|
34
|
-
rspec-core (3.9.
|
35
|
-
rspec-support (~> 3.9.
|
36
|
-
rspec-expectations (3.9.
|
34
|
+
rspec-core (3.9.2)
|
35
|
+
rspec-support (~> 3.9.3)
|
36
|
+
rspec-expectations (3.9.2)
|
37
37
|
diff-lcs (>= 1.2.0, < 2.0)
|
38
38
|
rspec-support (~> 3.9.0)
|
39
39
|
rspec-mocks (3.9.1)
|
40
40
|
diff-lcs (>= 1.2.0, < 2.0)
|
41
41
|
rspec-support (~> 3.9.0)
|
42
|
-
rspec-support (3.9.
|
42
|
+
rspec-support (3.9.3)
|
43
43
|
|
44
44
|
PLATFORMS
|
45
45
|
ruby
|
@@ -48,7 +48,7 @@ DEPENDENCIES
|
|
48
48
|
bundler (~> 2.1.4)
|
49
49
|
hcl-checker!
|
50
50
|
nokogiri (>= 1.10.8)
|
51
|
-
racc (= 1.
|
51
|
+
racc (= 1.5.0)
|
52
52
|
rake (~> 12.3.3)
|
53
53
|
rex (= 2.0.12)
|
54
54
|
rexical (>= 1.0.7)
|
data/README.md
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# Hcl::Checker
|
2
2
|
|
3
|
-
**Hashicorp Configuration Language** syntax checker and parser.
|
3
|
+
**Hashicorp Configuration Language** syntax checker and parser.
|
4
4
|
|
5
5
|
Parser originally created by [Sikula](https://github.com/sikula) and available
|
6
6
|
at [Ruby HCL Repository](https://github.com/sikula/ruby-hcl). Only works with
|
7
|
-
[HCL Version 1](https://github.com/hashicorp/hcl).
|
7
|
+
[HCL Version 1](https://github.com/hashicorp/hcl).
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
@@ -47,21 +47,21 @@ You can validate the `hcl_string` contents with `valid?` method. This will
|
|
47
47
|
return `true` if is a valid HCL or `false` if not.
|
48
48
|
|
49
49
|
```
|
50
|
-
2.3.2 :014 >
|
50
|
+
2.3.2 :014 > HCL1::Checker.valid? hcl_string
|
51
51
|
=> true
|
52
52
|
```
|
53
53
|
|
54
54
|
You can parse the `hcl_string` into a `Hash` with `parse` method.
|
55
55
|
|
56
56
|
```
|
57
|
-
2.3.2 :015 >
|
57
|
+
2.3.2 :015 > HCL1::Checker.parse(hcl_string)
|
58
58
|
=> {"provider"=>{"aws"=>{"region"=>"${var.aws_region}", "access_key"=>"${var.aws_access_key}", "secret_key"=>"${var.aws_secret_key}"}}, "resource"=>{"aws_vpc"=>{"default"=>{"cidr_block"=>"10.0.0.0/16", "enable_dns_hostnames"=>true, "tags"=>{"Name"=>"Event Store VPC"}}}}}
|
59
59
|
```
|
60
60
|
|
61
61
|
If after a `parse` you got `false` you can check `last_error` with:
|
62
62
|
|
63
63
|
```
|
64
|
-
2.4.2 :063 >
|
64
|
+
2.4.2 :063 > HCL1::Checker.last_error
|
65
65
|
=> "Parse error at \"eec8b16c-ee89-4ea0-bdcc-d094300a42e8\" , (invalid token: ,)"
|
66
66
|
```
|
67
67
|
|
@@ -84,7 +84,7 @@ $ bundle exec rake build_grammar
|
|
84
84
|
Building Lexer....done
|
85
85
|
Building Parser....done
|
86
86
|
```
|
87
|
-
|
87
|
+
|
88
88
|
## Contributing
|
89
89
|
|
90
90
|
Bug reports and pull requests are welcome on GitHub at
|
@@ -96,5 +96,3 @@ to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
|
|
96
96
|
|
97
97
|
The gem is available as open source under the terms of the [MIT
|
98
98
|
License](https://opensource.org/licenses/MIT).
|
99
|
-
|
100
|
-
|
data/hcl-checker.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = 'hcl-checker'
|
7
7
|
spec.version = HCL::Checker::VERSION
|
8
8
|
spec.authors = ['Marcelo Castellani']
|
9
|
-
spec.email = ['
|
9
|
+
spec.email = ['marcelo@linux.com']
|
10
10
|
|
11
11
|
spec.summary = 'Hashicorp Configuration Language parser for Ruby'
|
12
12
|
spec.description = 'Hashicorp Configuration Language parser and checker for Ruby'
|
@@ -21,8 +21,32 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.add_development_dependency 'bundler', '~> 2.1.4'
|
22
22
|
spec.add_development_dependency 'rake', '~> 12.3.3'
|
23
23
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
24
|
-
spec.add_development_dependency 'racc', '1.
|
24
|
+
spec.add_development_dependency 'racc', '1.5.0'
|
25
25
|
spec.add_development_dependency 'rex', '2.0.12'
|
26
26
|
spec.add_development_dependency 'rexical', '>= 1.0.7'
|
27
27
|
|
28
|
+
spec.post_install_message = %q{
|
29
|
+
Hello, I am updating this Gem to support version 2.0 of the HCL.
|
30
|
+
|
31
|
+
In the meantime, it is important that you know that there will be a
|
32
|
+
compatibility break with the current version, for Gem to support both
|
33
|
+
versions.
|
34
|
+
|
35
|
+
Therefore, instead of using just HCL::Checker you must tell which
|
36
|
+
version you are using, like this:
|
37
|
+
|
38
|
+
HCL1::Checker
|
39
|
+
|
40
|
+
Or
|
41
|
+
|
42
|
+
HCL2::Checker
|
43
|
+
|
44
|
+
At the moment both HCL::Checker and HCL1::Checker will work, but with
|
45
|
+
the release of support for version 2 the HCL::Checker syntax will no
|
46
|
+
longer work.
|
47
|
+
|
48
|
+
So, update your code.
|
49
|
+
|
50
|
+
Thank you :)
|
51
|
+
}
|
28
52
|
end
|
data/lib/hcl/checker/version.rb
CHANGED
data/lib/hcl1/checker.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'hcl/checker/version'
|
2
|
+
require_relative 'lexer'
|
3
|
+
require_relative 'parser'
|
4
|
+
|
5
|
+
module HCL1
|
6
|
+
module Checker
|
7
|
+
def self.valid?(value)
|
8
|
+
ret = HCLParser.new.parse(value)
|
9
|
+
return true if ret.is_a? Hash
|
10
|
+
false
|
11
|
+
rescue
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.parse(value)
|
16
|
+
HCLParser.new.parse(value)
|
17
|
+
rescue Racc::ParseError => e
|
18
|
+
return e.message
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/hcl1/lexer.rb
ADDED
@@ -0,0 +1,175 @@
|
|
1
|
+
#--
|
2
|
+
# DO NOT MODIFY!!!!
|
3
|
+
# This file is automatically generated by rex 1.0.7
|
4
|
+
# from lexical definition file "./assets/lexer.rex".
|
5
|
+
#++
|
6
|
+
|
7
|
+
|
8
|
+
class HCLLexer
|
9
|
+
require 'strscan'
|
10
|
+
|
11
|
+
class ScanError < StandardError ; end
|
12
|
+
|
13
|
+
attr_reader :lineno
|
14
|
+
attr_reader :filename
|
15
|
+
attr_accessor :state
|
16
|
+
|
17
|
+
def scan_setup(str)
|
18
|
+
@ss = StringScanner.new(str)
|
19
|
+
@lineno = 1
|
20
|
+
@state = nil
|
21
|
+
end
|
22
|
+
|
23
|
+
def action
|
24
|
+
yield
|
25
|
+
end
|
26
|
+
|
27
|
+
def scan_str(str)
|
28
|
+
scan_setup(str)
|
29
|
+
do_parse
|
30
|
+
end
|
31
|
+
alias :scan :scan_str
|
32
|
+
|
33
|
+
def load_file( filename )
|
34
|
+
@filename = filename
|
35
|
+
File.open(filename, "r") do |f|
|
36
|
+
scan_setup(f.read)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def scan_file( filename )
|
41
|
+
load_file(filename)
|
42
|
+
do_parse
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
def next_token
|
47
|
+
return if @ss.eos?
|
48
|
+
|
49
|
+
# skips empty actions
|
50
|
+
until token = _next_token or @ss.eos?; end
|
51
|
+
token
|
52
|
+
end
|
53
|
+
|
54
|
+
def _next_token
|
55
|
+
text = @ss.peek(1)
|
56
|
+
@lineno += 1 if text == "\n"
|
57
|
+
token = case @state
|
58
|
+
when nil
|
59
|
+
case
|
60
|
+
when (text = @ss.scan(/\s+/))
|
61
|
+
;
|
62
|
+
|
63
|
+
when (text = @ss.scan(/\#.*|\/\/.*$/))
|
64
|
+
;
|
65
|
+
|
66
|
+
when (text = @ss.scan(/\n|\r/))
|
67
|
+
;
|
68
|
+
|
69
|
+
when (text = @ss.scan(/\/\*/))
|
70
|
+
action { consume_comment(text) }
|
71
|
+
|
72
|
+
when (text = @ss.scan(/true|false/))
|
73
|
+
action { [:BOOL, to_boolean(text)]}
|
74
|
+
|
75
|
+
when (text = @ss.scan(/\-?\d+\.\d+/))
|
76
|
+
action { [:FLOAT, text.to_f] }
|
77
|
+
|
78
|
+
when (text = @ss.scan(/-?\d+/))
|
79
|
+
action { [:NUMBER, text.to_i] }
|
80
|
+
|
81
|
+
when (text = @ss.scan(/\"/))
|
82
|
+
action { [:STRING, consume_string(text)] }
|
83
|
+
|
84
|
+
when (text = @ss.scan(/\<<\-?/))
|
85
|
+
action { [:STRING, consume_heredoc] }
|
86
|
+
|
87
|
+
when (text = @ss.scan(/\{/))
|
88
|
+
action { [:LEFTBRACE, text]}
|
89
|
+
|
90
|
+
when (text = @ss.scan(/\}/))
|
91
|
+
action { [:RIGHTBRACE, text]}
|
92
|
+
|
93
|
+
when (text = @ss.scan(/\[/))
|
94
|
+
action { [:LEFTBRACKET, text]}
|
95
|
+
|
96
|
+
when (text = @ss.scan(/\]/))
|
97
|
+
action { [:RIGHTBRACKET, text]}
|
98
|
+
|
99
|
+
when (text = @ss.scan(/\,/))
|
100
|
+
action { [:COMMA, text]}
|
101
|
+
|
102
|
+
when (text = @ss.scan(/[a-zA-Z_][a-zA-Z0-9_\-\.]*/))
|
103
|
+
action { [:IDENTIFIER, text]}
|
104
|
+
|
105
|
+
when (text = @ss.scan(/\=/))
|
106
|
+
action { [:EQUAL, text]}
|
107
|
+
|
108
|
+
when (text = @ss.scan(/\-/))
|
109
|
+
action { [:MINUS, text]}
|
110
|
+
|
111
|
+
|
112
|
+
else
|
113
|
+
text = @ss.string[@ss.pos .. -1]
|
114
|
+
raise ScanError, "can not match: '" + text + "'"
|
115
|
+
end # if
|
116
|
+
|
117
|
+
else
|
118
|
+
raise ScanError, "undefined state: '" + state.to_s + "'"
|
119
|
+
end # case state
|
120
|
+
token
|
121
|
+
end # def _next_token
|
122
|
+
|
123
|
+
def lex(input)
|
124
|
+
scan_setup(input)
|
125
|
+
tokens = []
|
126
|
+
while token = next_token
|
127
|
+
tokens << token
|
128
|
+
end
|
129
|
+
tokens
|
130
|
+
end
|
131
|
+
def to_boolean(input)
|
132
|
+
input =
|
133
|
+
if input =~ /true/
|
134
|
+
true
|
135
|
+
elsif input =~ /false/
|
136
|
+
false
|
137
|
+
end
|
138
|
+
return input
|
139
|
+
end
|
140
|
+
def consume_comment(input)
|
141
|
+
nested = 1
|
142
|
+
until nested.zero?
|
143
|
+
case(text = @ss.scan_until(%r{/\*|\*/|\z}) )
|
144
|
+
when %r{/\*\z}
|
145
|
+
nested =+ 1
|
146
|
+
when %r{\*/\z}
|
147
|
+
nested -= 1
|
148
|
+
else
|
149
|
+
break
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
def consume_string(input)
|
154
|
+
result = ''
|
155
|
+
nested = 0
|
156
|
+
begin
|
157
|
+
case(text = @ss.scan_until(%r{\"|\$\{|\}|\\}))
|
158
|
+
when %r{\$\{\z}
|
159
|
+
nested += 1
|
160
|
+
when %r{\}\z}
|
161
|
+
nested -= 1 if nested > 0
|
162
|
+
when %r{\\\z}
|
163
|
+
result += text.chop + @ss.getch
|
164
|
+
next
|
165
|
+
end
|
166
|
+
result += text.to_s
|
167
|
+
end until nested == 0 && text =~ %r{\"\z}
|
168
|
+
result.chop
|
169
|
+
end
|
170
|
+
def consume_heredoc
|
171
|
+
token = Regexp.new @ss.scan_until(%r{\n})
|
172
|
+
document = @ss.scan_until(token)
|
173
|
+
document.chop
|
174
|
+
end
|
175
|
+
end # class
|
data/lib/hcl1/parser.rb
ADDED
@@ -0,0 +1,456 @@
|
|
1
|
+
#
|
2
|
+
# DO NOT MODIFY!!!!
|
3
|
+
# This file is automatically generated by Racc 1.4.14
|
4
|
+
# from Racc grammer file "".
|
5
|
+
#
|
6
|
+
|
7
|
+
require 'racc/parser.rb'
|
8
|
+
|
9
|
+
require_relative './lexer'
|
10
|
+
|
11
|
+
class HCLParser < Racc::Parser
|
12
|
+
|
13
|
+
module_eval(<<'...end parse.y/module_eval...', 'parse.y', 123)
|
14
|
+
#//
|
15
|
+
#// HCL is unclear on what one should do when duplicate
|
16
|
+
#// keys are encountered.
|
17
|
+
#//
|
18
|
+
#// from decoder.go: if we're at the root or we're directly within
|
19
|
+
#// a list, decode to hashes, otherwise lists
|
20
|
+
#//
|
21
|
+
#// from object.go: there is a flattened list structure
|
22
|
+
#//
|
23
|
+
def flatten_objectlist(list)
|
24
|
+
(list || {}).each_with_object({}) do |a, h|
|
25
|
+
h[a.first] =
|
26
|
+
case a.last
|
27
|
+
when Hash
|
28
|
+
deep_merge(h[a.first] || {}, a.last)
|
29
|
+
else
|
30
|
+
h[a.first] = a.last
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
def on_error(error_token_id, error_value, value_stack)
|
37
|
+
error_message = value_stack.to_s.split(',').last.gsub(']', '')
|
38
|
+
header = "Parse error at #{error_message} #{error_value} (invalid token: #{error_value})"
|
39
|
+
raise Racc::ParseError, header
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
def parse(input)
|
44
|
+
@lexer = HCLLexer.new.lex(input)
|
45
|
+
do_parse
|
46
|
+
return @result
|
47
|
+
end
|
48
|
+
|
49
|
+
|
50
|
+
def next_token
|
51
|
+
@lexer.shift
|
52
|
+
end
|
53
|
+
|
54
|
+
def deep_merge(hash1, hash2)
|
55
|
+
hash2.keys.each do |key|
|
56
|
+
value1 = hash1[key]
|
57
|
+
value2 = hash2[key]
|
58
|
+
|
59
|
+
if value1.is_a?(Hash) && value2.is_a?(Hash)
|
60
|
+
hash1[key] = deep_merge(value1, value2)
|
61
|
+
else
|
62
|
+
hash1[key] = value2
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
hash1
|
67
|
+
end
|
68
|
+
...end parse.y/module_eval...
|
69
|
+
##### State transition tables begin ###
|
70
|
+
|
71
|
+
racc_action_table = [
|
72
|
+
22, 28, 27, 10, 28, 27, 5, 23, 6, 14,
|
73
|
+
35, 26, 14, 12, 26, 32, 28, 27, 40, 5,
|
74
|
+
-10, 6, 35, 5, 14, 6, 26, 39, 30, 5,
|
75
|
+
-11, 6, 13, 17, 38, 18, 19, 14, 20 ]
|
76
|
+
|
77
|
+
racc_action_check = [
|
78
|
+
13, 13, 13, 1, 26, 26, 0, 13, 0, 13,
|
79
|
+
26, 13, 26, 4, 26, 26, 40, 40, 31, 3,
|
80
|
+
5, 3, 40, 14, 40, 14, 40, 31, 14, 29,
|
81
|
+
6, 29, 7, 9, 29, 9, 10, 9, 11 ]
|
82
|
+
|
83
|
+
racc_action_pointer = [
|
84
|
+
-1, 3, nil, 12, 8, 12, 22, 24, nil, 26,
|
85
|
+
36, 33, nil, -2, 16, nil, nil, nil, nil, nil,
|
86
|
+
nil, nil, nil, nil, nil, nil, 1, nil, nil, 22,
|
87
|
+
nil, 13, nil, nil, nil, nil, nil, nil, nil, nil,
|
88
|
+
13, nil ]
|
89
|
+
|
90
|
+
racc_action_default = [
|
91
|
+
-2, -33, -1, -3, -5, -20, -21, -33, -17, -33,
|
92
|
+
-33, -7, -4, -33, -33, -18, -19, -20, -21, 42,
|
93
|
+
-6, -12, -13, -14, -15, -16, -33, -31, -32, -33,
|
94
|
+
-9, -33, -23, -24, -27, -28, -29, -30, -8, -22,
|
95
|
+
-26, -25 ]
|
96
|
+
|
97
|
+
racc_goto_table = [
|
98
|
+
11, 3, 33, 15, 1, 2, 21, 24, 25, 16,
|
99
|
+
31, nil, nil, nil, nil, 29, 41, nil, nil, nil,
|
100
|
+
nil, nil, nil, nil, nil, nil, 11 ]
|
101
|
+
|
102
|
+
racc_goto_check = [
|
103
|
+
4, 3, 12, 5, 1, 2, 7, 5, 8, 9,
|
104
|
+
11, nil, nil, nil, nil, 3, 12, nil, nil, nil,
|
105
|
+
nil, nil, nil, nil, nil, nil, 4 ]
|
106
|
+
|
107
|
+
racc_goto_pointer = [
|
108
|
+
nil, 4, 5, 1, -3, -6, nil, -7, -5, 0,
|
109
|
+
nil, -16, -24 ]
|
110
|
+
|
111
|
+
racc_goto_default = [
|
112
|
+
nil, nil, nil, nil, 4, 37, 7, 34, 36, 8,
|
113
|
+
9, nil, nil ]
|
114
|
+
|
115
|
+
racc_reduce_table = [
|
116
|
+
0, 0, :racc_error,
|
117
|
+
1, 19, :_reduce_1,
|
118
|
+
0, 20, :_reduce_2,
|
119
|
+
1, 20, :_reduce_none,
|
120
|
+
2, 21, :_reduce_4,
|
121
|
+
1, 21, :_reduce_5,
|
122
|
+
3, 21, :_reduce_6,
|
123
|
+
2, 21, :_reduce_7,
|
124
|
+
3, 23, :_reduce_8,
|
125
|
+
2, 23, :_reduce_9,
|
126
|
+
1, 24, :_reduce_10,
|
127
|
+
1, 24, :_reduce_11,
|
128
|
+
3, 22, :_reduce_12,
|
129
|
+
3, 22, :_reduce_13,
|
130
|
+
3, 22, :_reduce_14,
|
131
|
+
3, 22, :_reduce_15,
|
132
|
+
3, 22, :_reduce_16,
|
133
|
+
1, 22, :_reduce_17,
|
134
|
+
2, 27, :_reduce_18,
|
135
|
+
2, 27, :_reduce_19,
|
136
|
+
1, 28, :_reduce_20,
|
137
|
+
1, 28, :_reduce_21,
|
138
|
+
3, 26, :_reduce_22,
|
139
|
+
2, 26, :_reduce_23,
|
140
|
+
1, 29, :_reduce_24,
|
141
|
+
3, 29, :_reduce_25,
|
142
|
+
2, 29, :_reduce_26,
|
143
|
+
1, 30, :_reduce_27,
|
144
|
+
1, 30, :_reduce_28,
|
145
|
+
1, 30, :_reduce_29,
|
146
|
+
1, 30, :_reduce_30,
|
147
|
+
1, 25, :_reduce_31,
|
148
|
+
1, 25, :_reduce_32 ]
|
149
|
+
|
150
|
+
racc_reduce_n = 33
|
151
|
+
|
152
|
+
racc_shift_n = 42
|
153
|
+
|
154
|
+
racc_token_table = {
|
155
|
+
false => 0,
|
156
|
+
:error => 1,
|
157
|
+
:BOOL => 2,
|
158
|
+
:FLOAT => 3,
|
159
|
+
:NUMBER => 4,
|
160
|
+
:COMMA => 5,
|
161
|
+
:COMMAEND => 6,
|
162
|
+
:IDENTIFIER => 7,
|
163
|
+
:EQUAL => 8,
|
164
|
+
:STRING => 9,
|
165
|
+
:MINUS => 10,
|
166
|
+
:LEFTBRACE => 11,
|
167
|
+
:RIGHTBRACE => 12,
|
168
|
+
:LEFTBRACKET => 13,
|
169
|
+
:RIGHTBRACKET => 14,
|
170
|
+
:PERIOD => 15,
|
171
|
+
:EPLUS => 16,
|
172
|
+
:EMINUS => 17 }
|
173
|
+
|
174
|
+
racc_nt_base = 18
|
175
|
+
|
176
|
+
racc_use_result_var = true
|
177
|
+
|
178
|
+
Racc_arg = [
|
179
|
+
racc_action_table,
|
180
|
+
racc_action_check,
|
181
|
+
racc_action_default,
|
182
|
+
racc_action_pointer,
|
183
|
+
racc_goto_table,
|
184
|
+
racc_goto_check,
|
185
|
+
racc_goto_default,
|
186
|
+
racc_goto_pointer,
|
187
|
+
racc_nt_base,
|
188
|
+
racc_reduce_table,
|
189
|
+
racc_token_table,
|
190
|
+
racc_shift_n,
|
191
|
+
racc_reduce_n,
|
192
|
+
racc_use_result_var ]
|
193
|
+
|
194
|
+
Racc_token_to_s_table = [
|
195
|
+
"$end",
|
196
|
+
"error",
|
197
|
+
"BOOL",
|
198
|
+
"FLOAT",
|
199
|
+
"NUMBER",
|
200
|
+
"COMMA",
|
201
|
+
"COMMAEND",
|
202
|
+
"IDENTIFIER",
|
203
|
+
"EQUAL",
|
204
|
+
"STRING",
|
205
|
+
"MINUS",
|
206
|
+
"LEFTBRACE",
|
207
|
+
"RIGHTBRACE",
|
208
|
+
"LEFTBRACKET",
|
209
|
+
"RIGHTBRACKET",
|
210
|
+
"PERIOD",
|
211
|
+
"EPLUS",
|
212
|
+
"EMINUS",
|
213
|
+
"$start",
|
214
|
+
"target",
|
215
|
+
"top",
|
216
|
+
"objectlist",
|
217
|
+
"objectitem",
|
218
|
+
"object",
|
219
|
+
"objectkey",
|
220
|
+
"number",
|
221
|
+
"list",
|
222
|
+
"block",
|
223
|
+
"block_id",
|
224
|
+
"listitems",
|
225
|
+
"listitem" ]
|
226
|
+
|
227
|
+
Racc_debug_parser = false
|
228
|
+
|
229
|
+
##### State transition tables end #####
|
230
|
+
|
231
|
+
# reduce 0 omitted
|
232
|
+
|
233
|
+
module_eval(<<'.,.,', 'parse.y', 19)
|
234
|
+
def _reduce_1(val, _values, result)
|
235
|
+
@result = flatten_objectlist(val[0])
|
236
|
+
result
|
237
|
+
end
|
238
|
+
.,.,
|
239
|
+
|
240
|
+
module_eval(<<'.,.,', 'parse.y', 22)
|
241
|
+
def _reduce_2(val, _values, result)
|
242
|
+
result = val[0]
|
243
|
+
result
|
244
|
+
end
|
245
|
+
.,.,
|
246
|
+
|
247
|
+
# reduce 3 omitted
|
248
|
+
|
249
|
+
module_eval(<<'.,.,', 'parse.y', 29)
|
250
|
+
def _reduce_4(val, _values, result)
|
251
|
+
result = [val[0]]
|
252
|
+
result
|
253
|
+
end
|
254
|
+
.,.,
|
255
|
+
|
256
|
+
module_eval(<<'.,.,', 'parse.y', 31)
|
257
|
+
def _reduce_5(val, _values, result)
|
258
|
+
result = [val[0]]
|
259
|
+
result
|
260
|
+
end
|
261
|
+
.,.,
|
262
|
+
|
263
|
+
module_eval(<<'.,.,', 'parse.y', 33)
|
264
|
+
def _reduce_6(val, _values, result)
|
265
|
+
result = val[0] << val[1]
|
266
|
+
result
|
267
|
+
end
|
268
|
+
.,.,
|
269
|
+
|
270
|
+
module_eval(<<'.,.,', 'parse.y', 35)
|
271
|
+
def _reduce_7(val, _values, result)
|
272
|
+
result = val[0] << val[1]
|
273
|
+
result
|
274
|
+
end
|
275
|
+
.,.,
|
276
|
+
|
277
|
+
module_eval(<<'.,.,', 'parse.y', 40)
|
278
|
+
def _reduce_8(val, _values, result)
|
279
|
+
result = flatten_objectlist(val[1])
|
280
|
+
result
|
281
|
+
end
|
282
|
+
.,.,
|
283
|
+
|
284
|
+
module_eval(<<'.,.,', 'parse.y', 42)
|
285
|
+
def _reduce_9(val, _values, result)
|
286
|
+
return
|
287
|
+
result
|
288
|
+
end
|
289
|
+
.,.,
|
290
|
+
|
291
|
+
module_eval(<<'.,.,', 'parse.y', 47)
|
292
|
+
def _reduce_10(val, _values, result)
|
293
|
+
result = val[0]
|
294
|
+
result
|
295
|
+
end
|
296
|
+
.,.,
|
297
|
+
|
298
|
+
module_eval(<<'.,.,', 'parse.y', 49)
|
299
|
+
def _reduce_11(val, _values, result)
|
300
|
+
result = val[0]
|
301
|
+
result
|
302
|
+
end
|
303
|
+
.,.,
|
304
|
+
|
305
|
+
module_eval(<<'.,.,', 'parse.y', 54)
|
306
|
+
def _reduce_12(val, _values, result)
|
307
|
+
result = val[0], val[2]
|
308
|
+
result
|
309
|
+
end
|
310
|
+
.,.,
|
311
|
+
|
312
|
+
module_eval(<<'.,.,', 'parse.y', 56)
|
313
|
+
def _reduce_13(val, _values, result)
|
314
|
+
result = val[0], val[2]
|
315
|
+
result
|
316
|
+
end
|
317
|
+
.,.,
|
318
|
+
|
319
|
+
module_eval(<<'.,.,', 'parse.y', 58)
|
320
|
+
def _reduce_14(val, _values, result)
|
321
|
+
result = val[0], val[2]
|
322
|
+
result
|
323
|
+
end
|
324
|
+
.,.,
|
325
|
+
|
326
|
+
module_eval(<<'.,.,', 'parse.y', 60)
|
327
|
+
def _reduce_15(val, _values, result)
|
328
|
+
result = val[0], val[2]
|
329
|
+
result
|
330
|
+
end
|
331
|
+
.,.,
|
332
|
+
|
333
|
+
module_eval(<<'.,.,', 'parse.y', 62)
|
334
|
+
def _reduce_16(val, _values, result)
|
335
|
+
result = val[0], val[2]
|
336
|
+
result
|
337
|
+
end
|
338
|
+
.,.,
|
339
|
+
|
340
|
+
module_eval(<<'.,.,', 'parse.y', 64)
|
341
|
+
def _reduce_17(val, _values, result)
|
342
|
+
result = val[0]
|
343
|
+
result
|
344
|
+
end
|
345
|
+
.,.,
|
346
|
+
|
347
|
+
module_eval(<<'.,.,', 'parse.y', 69)
|
348
|
+
def _reduce_18(val, _values, result)
|
349
|
+
result = val[0], val[1]
|
350
|
+
result
|
351
|
+
end
|
352
|
+
.,.,
|
353
|
+
|
354
|
+
module_eval(<<'.,.,', 'parse.y', 71)
|
355
|
+
def _reduce_19(val, _values, result)
|
356
|
+
result = val[0], {val[1][0] => val[1][1]}
|
357
|
+
result
|
358
|
+
end
|
359
|
+
.,.,
|
360
|
+
|
361
|
+
module_eval(<<'.,.,', 'parse.y', 76)
|
362
|
+
def _reduce_20(val, _values, result)
|
363
|
+
result = val[0]
|
364
|
+
result
|
365
|
+
end
|
366
|
+
.,.,
|
367
|
+
|
368
|
+
module_eval(<<'.,.,', 'parse.y', 78)
|
369
|
+
def _reduce_21(val, _values, result)
|
370
|
+
result = val[0]
|
371
|
+
result
|
372
|
+
end
|
373
|
+
.,.,
|
374
|
+
|
375
|
+
module_eval(<<'.,.,', 'parse.y', 83)
|
376
|
+
def _reduce_22(val, _values, result)
|
377
|
+
result = val[1]
|
378
|
+
result
|
379
|
+
end
|
380
|
+
.,.,
|
381
|
+
|
382
|
+
module_eval(<<'.,.,', 'parse.y', 85)
|
383
|
+
def _reduce_23(val, _values, result)
|
384
|
+
return
|
385
|
+
result
|
386
|
+
end
|
387
|
+
.,.,
|
388
|
+
|
389
|
+
module_eval(<<'.,.,', 'parse.y', 90)
|
390
|
+
def _reduce_24(val, _values, result)
|
391
|
+
result = [val[0]]
|
392
|
+
result
|
393
|
+
end
|
394
|
+
.,.,
|
395
|
+
|
396
|
+
module_eval(<<'.,.,', 'parse.y', 92)
|
397
|
+
def _reduce_25(val, _values, result)
|
398
|
+
result = val[0] << val[2]
|
399
|
+
result
|
400
|
+
end
|
401
|
+
.,.,
|
402
|
+
|
403
|
+
module_eval(<<'.,.,', 'parse.y', 94)
|
404
|
+
def _reduce_26(val, _values, result)
|
405
|
+
result = val[0]
|
406
|
+
result
|
407
|
+
end
|
408
|
+
.,.,
|
409
|
+
|
410
|
+
module_eval(<<'.,.,', 'parse.y', 99)
|
411
|
+
def _reduce_27(val, _values, result)
|
412
|
+
result = val[0]
|
413
|
+
result
|
414
|
+
end
|
415
|
+
.,.,
|
416
|
+
|
417
|
+
module_eval(<<'.,.,', 'parse.y', 101)
|
418
|
+
def _reduce_28(val, _values, result)
|
419
|
+
result = val[0]
|
420
|
+
result
|
421
|
+
end
|
422
|
+
.,.,
|
423
|
+
|
424
|
+
module_eval(<<'.,.,', 'parse.y', 103)
|
425
|
+
def _reduce_29(val, _values, result)
|
426
|
+
result = val[0]
|
427
|
+
result
|
428
|
+
end
|
429
|
+
.,.,
|
430
|
+
|
431
|
+
module_eval(<<'.,.,', 'parse.y', 105)
|
432
|
+
def _reduce_30(val, _values, result)
|
433
|
+
result = val[0]
|
434
|
+
result
|
435
|
+
end
|
436
|
+
.,.,
|
437
|
+
|
438
|
+
module_eval(<<'.,.,', 'parse.y', 110)
|
439
|
+
def _reduce_31(val, _values, result)
|
440
|
+
result = val[0]
|
441
|
+
result
|
442
|
+
end
|
443
|
+
.,.,
|
444
|
+
|
445
|
+
module_eval(<<'.,.,', 'parse.y', 112)
|
446
|
+
def _reduce_32(val, _values, result)
|
447
|
+
result = val[0]
|
448
|
+
result
|
449
|
+
end
|
450
|
+
.,.,
|
451
|
+
|
452
|
+
def _reduce_none(val, _values, result)
|
453
|
+
val[0]
|
454
|
+
end
|
455
|
+
|
456
|
+
end # class HCLParser
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hcl-checker
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marcelo Castellani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-07-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 1.
|
61
|
+
version: 1.5.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.
|
68
|
+
version: 1.5.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rex
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -96,7 +96,7 @@ dependencies:
|
|
96
96
|
version: 1.0.7
|
97
97
|
description: Hashicorp Configuration Language parser and checker for Ruby
|
98
98
|
email:
|
99
|
-
-
|
99
|
+
- marcelo@linux.com
|
100
100
|
executables: []
|
101
101
|
extensions: []
|
102
102
|
extra_rdoc_files: []
|
@@ -119,11 +119,38 @@ files:
|
|
119
119
|
- lib/hcl/checker/version.rb
|
120
120
|
- lib/hcl/lexer.rb
|
121
121
|
- lib/hcl/parser.rb
|
122
|
+
- lib/hcl1/checker.rb
|
123
|
+
- lib/hcl1/checker/version.rb
|
124
|
+
- lib/hcl1/lexer.rb
|
125
|
+
- lib/hcl1/parser.rb
|
122
126
|
homepage: https://github.com/mfcastellani/hcl-checker
|
123
127
|
licenses:
|
124
128
|
- MIT
|
125
129
|
metadata: {}
|
126
|
-
post_install_message:
|
130
|
+
post_install_message: |2
|
131
|
+
|
132
|
+
Hello, I am updating this Gem to support version 2.0 of the HCL.
|
133
|
+
|
134
|
+
In the meantime, it is important that you know that there will be a
|
135
|
+
compatibility break with the current version, for Gem to support both
|
136
|
+
versions.
|
137
|
+
|
138
|
+
Therefore, instead of using just HCL::Checker you must tell which
|
139
|
+
version you are using, like this:
|
140
|
+
|
141
|
+
HCL1::Checker
|
142
|
+
|
143
|
+
Or
|
144
|
+
|
145
|
+
HCL2::Checker
|
146
|
+
|
147
|
+
At the moment both HCL::Checker and HCL1::Checker will work, but with
|
148
|
+
the release of support for version 2 the HCL::Checker syntax will no
|
149
|
+
longer work.
|
150
|
+
|
151
|
+
So, update your code.
|
152
|
+
|
153
|
+
Thank you :)
|
127
154
|
rdoc_options: []
|
128
155
|
require_paths:
|
129
156
|
- lib
|
@@ -138,7 +165,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
165
|
- !ruby/object:Gem::Version
|
139
166
|
version: '0'
|
140
167
|
requirements: []
|
141
|
-
rubygems_version: 3.
|
168
|
+
rubygems_version: 3.1.2
|
142
169
|
signing_key:
|
143
170
|
specification_version: 4
|
144
171
|
summary: Hashicorp Configuration Language parser for Ruby
|