Skip to main content

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)

Metadata

Release files for hcl2-ast 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hcl2-ast 0.4.0
File Size Uploaded
hcl2-ast-0.4.0.tar.gz 6.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for hcl2-ast 0.4.0
File Interpreter ABI Platform
hcl2_ast-0.4.0-py3-none-any.whl Python 3 none any Details

Total release size: 12.9 kB

Release files / hcl2-ast-0.4.0.tar.gz

Download URL hcl2-ast-0.4.0.tar.gz
Size 6.0 kB
Tags Source
SHA-256 checksum
How to use checksums
294c9b257e0c46d4270c3276e9cdbefcc4f9d6a005cf3869a858e8345f118f9f
BLAKE2b-256 checksum
How to use checksums
2a2d5b79a98a369b489f75d00de6ffdad4500c9f7b1421ee26eab2dea783ed8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release files / hcl2_ast-0.4.0-py3-none-any.whl

Download URL hcl2_ast-0.4.0-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0137c37ea356d9483adf0b7397a5dbb9aa9e465c3f9f8f6b93cdd9c70599dc5b
BLAKE2b-256 checksum
How to use checksums
22d6e310ca854290f5723ee870923f5c0d4b7e4e0c5c03ef7824116585fa9169
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.8.0 pkginfo/1.8.2 readme-renderer/34.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.9 tqdm/4.64.0 importlib-metadata/4.11.3 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page