2014-07-31 20:56:51 +00:00
|
|
|
// This is the yacc input for creating the parser for HCL.
|
|
|
|
|
|
|
|
%{
|
|
|
|
package hcl
|
|
|
|
|
|
|
|
%}
|
|
|
|
|
|
|
|
%union {
|
|
|
|
num int
|
|
|
|
obj map[string]interface{}
|
|
|
|
str string
|
|
|
|
}
|
|
|
|
|
2014-07-31 21:50:53 +00:00
|
|
|
%type <obj> block object
|
|
|
|
%type <str> blockId
|
2014-07-31 20:56:51 +00:00
|
|
|
|
|
|
|
%token <num> NUMBER
|
|
|
|
%token <str> IDENTIFIER EQUAL SEMICOLON STRING
|
|
|
|
%token <str> LEFTBRACE RIGHTBRACE
|
|
|
|
|
|
|
|
%%
|
|
|
|
|
|
|
|
top:
|
|
|
|
object
|
|
|
|
{
|
2014-07-31 21:08:31 +00:00
|
|
|
hclResult = $1
|
2014-07-31 20:56:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
object:
|
2014-07-31 21:50:53 +00:00
|
|
|
object SEMICOLON
|
2014-07-31 20:56:51 +00:00
|
|
|
{
|
2014-07-31 21:50:53 +00:00
|
|
|
$$ = $1
|
|
|
|
}
|
|
|
|
| IDENTIFIER EQUAL NUMBER
|
|
|
|
{
|
|
|
|
$$ = map[string]interface{}{$1: []interface{}{$3}}
|
|
|
|
}
|
|
|
|
| IDENTIFIER EQUAL STRING
|
|
|
|
{
|
|
|
|
$$ = map[string]interface{}{$1: []interface{}{$3}}
|
|
|
|
}
|
|
|
|
| block
|
|
|
|
{
|
|
|
|
$$ = $1
|
|
|
|
}
|
|
|
|
|
|
|
|
block:
|
|
|
|
blockId LEFTBRACE object RIGHTBRACE
|
|
|
|
{
|
|
|
|
$$ = map[string]interface{}{$1: []interface{}{$3}}
|
|
|
|
}
|
|
|
|
| blockId block
|
|
|
|
{
|
|
|
|
$$ = map[string]interface{}{$1: []interface{}{$2}}
|
|
|
|
}
|
|
|
|
|
|
|
|
blockId:
|
|
|
|
IDENTIFIER
|
|
|
|
{
|
|
|
|
$$ = $1
|
|
|
|
}
|
|
|
|
| STRING
|
|
|
|
{
|
|
|
|
$$ = $1
|
2014-07-31 20:56:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
%%
|