zclparse: Stub API for HCL/HIL file parsing

This is intended as a backward-compatibility interface, allowing
applications that previously used HCL/HIL to adopt zcl while still being
able to parse their old HCL/HIL-based configuration file formats.
This commit is contained in:
Martin Atkins 2017-05-21 13:04:33 -07:00
parent 49641f2a9a
commit e765ff422a
2 changed files with 25 additions and 0 deletions

8
zcl/hclhil/doc.go Normal file
View File

@ -0,0 +1,8 @@
// Package hclhil adapts Hashicorp Configuration Language and Hashicorp
// Interpolation Language (HCL and HIL, respectively) to work within the
// ZCL API.
//
// This is intended to help applications that previously used HCL/HIL to
// gradually adopt hcl while remaining generally compatible with their
// previous configuration formats.
package hclhil

View File

@ -47,6 +47,23 @@ func (p *Parser) ParseJSONFile(filename string) (*zcl.File, zcl.Diagnostics) {
return file, diags
}
// ParseHCLHIL parses the given buffer (which is assumed to have been loaded
// from the given filename) using the HCL and HIL parsers, and returns the
// zcl.File object representing it.
//
// This HCL/HIL parser is a compatibility interface to ease migration for
// apps that previously used HCL and HIL directly.
func (p *Parser) ParseHCLHIL(src []byte, filename string) (*zcl.File, zcl.Diagnostics) {
return nil, nil
}
// ParseHCLHILFile reads the given filename and parses it as HCL/HIL, similarly
// to ParseHCLHIL. An error diagnostic is returned if the given file cannot be
// read.
func (p *Parser) ParseHCLHILFile(filename string) (*zcl.File, zcl.Diagnostics) {
return nil, nil
}
// AddFile allows a caller to record in a parser a file that was parsed some
// other way, thus allowing it to be included in the registry of sources.
func (p *Parser) AddFile(filename string, file *zcl.File) {