diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2022-07-13 02:44:41 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2022-07-13 02:44:41 -0400 |
commit | 42a014c98797c7c4d78bfc3c2494a6ef0ce4e6be (patch) | |
tree | bb9e6310d2d973882f05011a3b0e82db34f13a37 /src/tparse/tree-list.go | |
parent | 81300fda909b260ff62ae1af9157cf0d097a47c0 (diff) |
[AST] Fix an issue with parsing lists of values
Diffstat (limited to 'src/tparse/tree-list.go')
-rw-r--r-- | src/tparse/tree-list.go | 24 |
1 files changed, 18 insertions, 6 deletions
diff --git a/src/tparse/tree-list.go b/src/tparse/tree-list.go index 3acc426..85f7134 100644 --- a/src/tparse/tree-list.go +++ b/src/tparse/tree-list.go @@ -34,21 +34,33 @@ func parseValueList(tokens *[]Token, tok, max int) (Node, int) { out := Node{Data: Token{Type: 10, Data: "vlist"}} var tmp Node - for ; tok < max; { + for ;tok < max; { t := (*tokens)[tok] switch t.Type { case LINESEP: - fallthrough - case DELIMIT: return out, tok + case DELIMIT: + switch t.Data { + case "}", ")", "]": + return out, tok + default: + mx := findClosing(tokens, tok) + if mx > -1 { + tmp, tok = parseValue(tokens, tok, mx + 1) + out.Sub = append(out.Sub, tmp) + } else { + errOut("Failed to find closing delim within list of values", t) + } + } case INLNSEP: tok++ + fallthrough + default: + tmp, tok = parseValue(tokens, tok, max) + out.Sub = append(out.Sub, tmp) } - - tmp, tok = parseValue(tokens, tok, max) - out.Sub = append(out.Sub, tmp) } return out, tok |