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
Mitchell Hashimoto 1150448982 Update README
2014-08-01 10:38:44 -07:00
test-fixtures Arrays, empty structures, assignment objects accepted 2014-08-01 08:14:57 -07:00
.gitignore The beginning of something 2014-07-31 13:56:51 -07:00
ast_test.go Fix some parsing bugs, add tests for visitor pattern 2014-08-01 08:31:17 -07:00
ast.go Fix some parsing bugs, add tests for visitor pattern 2014-08-01 08:31:17 -07:00
hcl_test.go The beginning of something 2014-07-31 13:56:51 -07:00
lex_test.go Commit things 2014-07-31 18:44:21 -07:00
lex.go Commit things 2014-07-31 18:44:21 -07:00
LICENSE LICENSE 2014-07-31 12:49:17 -07:00
Makefile The beginning of something 2014-07-31 13:56:51 -07:00
parse_test.go Fix some parsing bugs, add tests for visitor pattern 2014-08-01 08:31:17 -07:00
parse.go Arrays, empty structures, assignment objects accepted 2014-08-01 08:14:57 -07:00
parse.y Fix some parsing bugs, add tests for visitor pattern 2014-08-01 08:31:17 -07:00
README.md Update README 2014-08-01 10:38:44 -07:00
visitor_mock.go Fix some parsing bugs, add tests for visitor pattern 2014-08-01 08:31:17 -07:00

HCL

HCL (HashiCorp Configuration Language) is a configuration language built by HashiCorp. The goal of HCL is to build a structured configuration language that is both human and machine friendly for use with command-line tools, but specifically targeted towards DevOps tools, servers, etc.

HCL is heavily inspired by libucl, nginx configuration, and others similar.

Syntax

The complete grammar can be found here, if you're more comfortable reading specifics, but a high-level overview of the syntax and grammar are listed here.

  • Single line comments start with # or //

  • Multi-line comments are wrapped in /* and */

  • Values are assigned with the syntax key = value (whitespace doesn't matter). The value can be any primitive: a string, number, boolean, object, or list.

  • Strings are double-quoted and can continue any UTF-8 characters. Example: "Hello, World"

  • Numbers are assumed to be base 10. If you prefix a number with 0x, it is treated as a hexadecimal. If it is prefixed with 0, it is treated as an octal.

  • Boolean values: true, false, on, off, yes, no.

  • Arrays can be made by wrapping it in []. Example: ["foo", "bar", 42].

  • Objects (also known as maps) can be made with '{}'. Example: '{ foo = "bar" }'

In addition to these basics, the syntax supports hierarchies of sections. These sections are actually syntactic sugar over lists of maps, but visually end up looking much better from a configuration standpoint. For example, these are nearly equivalent:

variable "ami" {
    description = "the AMI to use"
}

# is equal to:

variable = [{
    "ami": {
        "description": "the AMI to use",
    }
}]