summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2021-05-09 18:57:45 -0600
committermo khan <mo@mokhan.ca>2021-05-09 18:57:45 -0600
commit149b738ccdbd8769c525a0a74ae7d3570997bdc3 (patch)
tree37952d0b7926066873382d3b2797dda96853d4f0 /lib
parent1858fd10cb0989ea9155f13ba761c36cd92963cc (diff)
refactor: use generic name/types for blocks
Diffstat (limited to 'lib')
-rw-r--r--lib/spandx/terraform/parsers/hcl.rb23
1 files changed, 6 insertions, 17 deletions
diff --git a/lib/spandx/terraform/parsers/hcl.rb b/lib/spandx/terraform/parsers/hcl.rb
index 5788ab0..b120e34 100644
--- a/lib/spandx/terraform/parsers/hcl.rb
+++ b/lib/spandx/terraform/parsers/hcl.rb
@@ -36,7 +36,7 @@ module Spandx
end
rule :value do
- match('[0-9A-Za-z.~> ]')
+ match('[0-9A-Za-z.~> ]').repeat
end
rule(:version_constraint) do
@@ -68,37 +68,26 @@ module Spandx
end
rule :argument do
- (
- str('version') |
- str('constraints')
- ).as(:argument) >> whitespace >> assign >> whitespace >> quote >> (
- version |
- version_constraint
- ).as(:value) >> quote
+ alpha.repeat.as(:name) >> whitespace >> assign >> whitespace >> quote >> value.as(:value) >> quote
end
rule :arguments do
- #((version_assignment | constraint_assignment) >> eol).repeat
(argument >> eol).repeat
end
rule :block do
- whitespace >> lcurly >> eol >> arguments >> rcurly >> eol
+ (alpha.repeat).as(:type) >> identifier >> whitespace >> lcurly >> eol >> arguments.as(:arguments) >> rcurly >> eol
end
rule :identifier do
whitespace >> quote >> ((alpha | match('[./]')).repeat).as(:name) >> quote >> whitespace
end
- rule :provider do
- (str('provider') >> identifier >> block).as(:provider)
+ rule :blocks do
+ block.repeat.as(:blocks)
end
- rule :providers do
- provider.repeat
- end
-
- root(:providers)
+ root(:blocks)
end
end
end