fork of https://github.com/hashicorp/hcl because issue : https://github.com/hashicorp/hcl/issues/290 these code permit use of "nested" field decoding which is just composite struct
Go to file
2015-11-04 17:21:17 +03:00
ast ast: we don't need zero node 2015-11-03 02:46:13 +03:00
parser printer: align comments in lists 2015-11-01 03:23:33 +03:00
printer printer: aligned adjacent attributes, closes #3 2015-11-04 17:21:17 +03:00
scanner scanner: negative float and int should be supported as well 2015-10-19 02:11:07 +03:00
token printer: implement standalone comments, still WIP 2015-10-31 15:01:49 +03:00
.travis.yml Add .travis.yml file 2015-11-03 02:41:11 +03:00
LICENSE BSD 3-clause license 2015-10-25 19:29:57 +03:00
README.md README.md: add note about development case 2015-11-03 02:21:28 +03:00

hcl GoDoc Build Status

HCL is a lexer and parser family written in Go for HCL (Hashicorp Configuration Language). It has several components, similar to Go's own parser family. It provides a set of packages to write tools and customize files written in HCL. For example both hclfmt and hcl2json (coming soon) is written based on these tools.

This package is still under heavy development. The next stable version will be released with version 0.1.

API

If you are already familiar with Go's own parser family it's really easy to dive. It basically resembles the same logic. However there are several differences and the implementation is completely different. Right now it contains the following packages:

  • token: defines constants representing the lexical tokens for a scanned HCL file.
  • scanner: scanner is a lexical scanner. It scans a given HCL file and returns a stream of tokens.
  • ast: declares the types used to represent the syntax tree for parsed HCL files.
  • parser: parses a given HCL file and creates a AST representation
  • printer: prints any given AST node and formats

Why

The whole parser family was created because I wanted a hclfmt command. This command would be just like gofmt, format an HCL file. I didn't want to use the package github/hashicorp/hcl in the first place, because the lexer and parser is generated and it doesn't expose the flexibility I wanted to have.

Another reason was that I wanted to learn and experience how to implement a proper lexer and parser in Go and how a formatter could be implemented from an AST. It was really fun and I think it was worth it.

License

The BSD 3-Clause License - see LICENSE for more details