Skip to content

Commit

Permalink
cmd/cue: add CUE_DEBUG_PARSER_TRACE environment variable
Browse files Browse the repository at this point in the history
Setting CUE_DEBUG_PARSER_TRACE to a non-empty value will cause the
parser to print a trace of parsed productions.

Change-Id: Ib5494fb31476a31d265e1e02353504ab71a3b986
Signed-off-by: Aram Hăvărneanu <aram@mgk.ro>
Reviewed-on: https://review.gerrithub.io/c/cue-lang/cue/+/551040
Reviewed-by: Marcel van Lohuizen <mpvl@gmail.com>
Unity-Result: CUEcueckoo <cueckoo@cuelang.org>
TryBot-Result: CUEcueckoo <cueckoo@cuelang.org>
  • Loading branch information
4ad committed Mar 16, 2023
1 parent 782cae0 commit 34a27bb
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions cmd/cue/cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,15 @@ var defaultConfig = config{
version = -1000 + 100
}
}
return parser.ParseFile(name, src,
options := []parser.Option{
parser.FromVersion(version),
parser.ParseComments,
)
}
// TODO: consolidate all options into a single CUE_DEBUG variable.
if os.Getenv("CUE_DEBUG_PARSER_TRACE") != "" {
options = append(options, parser.Trace)
}
return parser.ParseFile(name, src, options...)
},
},
}
Expand Down

0 comments on commit 34a27bb

Please sign in to comment.