From 42a014c98797c7c4d78bfc3c2494a6ef0ce4e6be Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Wed, 13 Jul 2022 02:44:41 -0400 Subject: [AST] Fix an issue with parsing lists of values --- src/tparse/tree-list.go | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/tparse/tree-list.go') 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 -- cgit v1.2.3