mirror of
https://github.com/mikefarah/yq.git
synced 2026-07-10 08:35:42 +00:00
Quote Lua keywords in table keys
Keywords are not valid as unquoted keys, thus must be quoted
This commit is contained in:
parent
21fda2eb3d
commit
c8919f20da
@ -90,6 +90,16 @@ func (le *luaEncoder) encodeArray(writer io.Writer, node *yaml.Node) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func needsQuoting(s string) bool {
|
func needsQuoting(s string) bool {
|
||||||
|
// known keywords as of Lua 5.4
|
||||||
|
switch s {
|
||||||
|
case "do", "and", "else", "break",
|
||||||
|
"if", "end", "goto", "false",
|
||||||
|
"in", "for", "then", "local",
|
||||||
|
"or", "nil", "true", "until",
|
||||||
|
"elseif", "function", "not",
|
||||||
|
"repeat", "return", "while":
|
||||||
|
return true
|
||||||
|
}
|
||||||
// [%a_][%w_]*
|
// [%a_][%w_]*
|
||||||
for i, c := range s {
|
for i, c := range s {
|
||||||
if i == 0 {
|
if i == 0 {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user