From 41527d1a3cba04a3721829cbb47db868c45054a4 Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Thu, 18 May 2017 08:07:52 -0700 Subject: [PATCH] Retain the bytes used to construct a file Later on this will be useful when printing diagnostics with source code snippets as context. --- zcl/json/public.go | 1 + zcl/structure.go | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/zcl/json/public.go b/zcl/json/public.go index c2f0285..5d20467 100644 --- a/zcl/json/public.go +++ b/zcl/json/public.go @@ -33,6 +33,7 @@ func Parse(src []byte, filename string) (*zcl.File, zcl.Diagnostics) { Body: &body{ obj: rootNode.(*objectVal), }, + Bytes: src, } } return file, diags diff --git a/zcl/structure.go b/zcl/structure.go index ec1ac60..36e431f 100644 --- a/zcl/structure.go +++ b/zcl/structure.go @@ -6,7 +6,8 @@ import ( // File is the top-level node that results from parsing a ZCL file. type File struct { - Body Body + Body Body + Bytes []byte } // Block represents a nested block within a Body.