Skip to content

A HCL2 parser based on python-hcl2 that produces an Abstract Syntax Tree.

License

Notifications You must be signed in to change notification settings

NiklasRosenstein/python-hcl2-ast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hcl2-ast

A HCL2 parser and evaluator based on python-hcl2 that produces an Abstract Syntax Tree.

Note: This project is in an early stage. It does not currently cover all HCL2 syntax features and does not have good test coverage.

Usage

from hcl2_ast import parse_string

module = parse_string("""
  hello {
    name = "World"
  }
""")

print(module.pformat())

Outputs:

Module(body=[
  Block(
    name='hello',
    args=[],
    body=[
      Attribute(key='name', value=Literal(value='World')),
    ]
  ),
])

Also check out the hcl2-eval package to evaluate HCL2 configuration ASTs.

Compatibility

hcl2-ast requires Python 3.6 or higher.

Known issues

  • No understanding of operator precedence in expressions (grouping with parentheses works as expected)

About

A HCL2 parser based on python-hcl2 that produces an Abstract Syntax Tree.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages