cmd/cue/cmd: allow overriding syntax limitation
This is a temporary measure and will go away
in later versions, especially once there is a backwards
compatibility guarantee.
Not all old syntax may be supported.
Change-Id: I5683516ff576123148b5ad8019a15161e10fb54c
Reviewed-on: https://cue-review.googlesource.com/c/cue/+/6583
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
Reviewed-by: CUE cueckoo <cueckoo@gmail.com>
diff --git a/cmd/cue/cmd/common.go b/cmd/cue/cmd/common.go
index 76ed429..2121d11 100644
--- a/cmd/cue/cmd/common.go
+++ b/cmd/cue/cmd/common.go
@@ -43,11 +43,20 @@
// - space separator syntax
const syntaxVersion = -1000 + 100*2 + 1
+var requestedVersion = os.Getenv("CUE_SYNTAX_OVERRIDE")
+
var defaultConfig = config{
loadCfg: &load.Config{
ParseFile: func(name string, src interface{}) (*ast.File, error) {
+ version := syntaxVersion
+ if requestedVersion != "" {
+ switch {
+ case strings.HasPrefix(requestedVersion, "v0.1"):
+ version = -1000 + 100
+ }
+ }
return parser.ParseFile(name, src,
- parser.FromVersion(syntaxVersion),
+ parser.FromVersion(version),
parser.ParseComments,
)
},