func (p *Parser) ParseHCLHILFile(filename string) (*zcl.File, zcl.Diagnostics) {
	if existing := p.files[filename]; existing != nil {
		return existing, nil
	}
	file, diags := hclhil.ParseFile(filename)
	p.files[filename] = file
	return file, diags
}
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.
package zclparse
import (
	"fmt"
	"io/ioutil"
	"github.com/zclconf/go-zcl/zcl"
	"github.com/zclconf/go-zcl/zcl/hclhil"
	"github.com/zclconf/go-zcl/zcl/json"
	"github.com/zclconf/go-zcl/zcl/zclsyntax"
)
type Parser struct {
	files map[string]*zcl.File
}
func NewParser() *Parser {
	return &Parser{
		files: map[string]*zcl.File{},
	}
}
func (p *Parser) ParseZCL(src []byte, filename string) (*zcl.File, zcl.Diagnostics) {
	if existing := p.files[filename]; existing != nil {
		return existing, nil
	}
	file, diags := zclsyntax.ParseConfig(src, filename, zcl.Pos{Byte: 0, Line: 1, Column: 1})
	p.files[filename] = file
	return file, diags
}
func (p *Parser) ParseZCLFile(filename string) (*zcl.File, zcl.Diagnostics) {
	if existing := p.files[filename]; existing != nil {
		return existing, nil
	}
	src, err := ioutil.ReadFile(filename)
	if err != nil {
		return nil, zcl.Diagnostics{
			{
				Severity: zcl.DiagError,
				Summary:  "Failed to read file",
				Detail:   fmt.Sprintf("The configuration file %q could not be read.", filename),
			},
		}
	}
	return p.ParseZCL(src, filename)
}
func (p *Parser) ParseJSON(src []byte, filename string) (*zcl.File, zcl.Diagnostics) {
	if existing := p.files[filename]; existing != nil {
		return existing, nil
	}
	file, diags := json.Parse(src, filename)
	p.files[filename] = file
	return file, diags
}
func (p *Parser) ParseJSONWithHIL(src []byte, filename string) (*zcl.File, zcl.Diagnostics) {
	if existing := p.files[filename]; existing != nil {
		return existing, nil
	}
	file, diags := json.ParseWithHIL(src, filename)
	p.files[filename] = file
	return file, diags
}
func (p *Parser) ParseJSONFile(filename string) (*zcl.File, zcl.Diagnostics) {
	if existing := p.files[filename]; existing != nil {
		return existing, nil
	}
	file, diags := json.ParseFile(filename)
	p.files[filename] = file
	return file, diags
}
func (p *Parser) ParseJSONFileWithHIL(filename string) (*zcl.File, zcl.Diagnostics) {
	if existing := p.files[filename]; existing != nil {
		return existing, nil
	}
	file, diags := json.ParseFileWithHIL(filename)
	p.files[filename] = file
	return file, diags
}
func (p *Parser) ParseHCLHIL(src []byte, filename string) (*zcl.File, zcl.Diagnostics) {
	if existing := p.files[filename]; existing != nil {
		return existing, nil
	}
	file, diags := hclhil.Parse(src, filename)
	p.files[filename] = file
	return file, diags
}