summaryrefslogtreecommitdiff
path: root/src/tparse/tree-value.go
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2022-07-13 02:44:41 -0400
committerKyle Gunger <kgunger12@gmail.com>2022-07-13 02:44:41 -0400
commit42a014c98797c7c4d78bfc3c2494a6ef0ce4e6be (patch)
treebb9e6310d2d973882f05011a3b0e82db34f13a37 /src/tparse/tree-value.go
parent81300fda909b260ff62ae1af9157cf0d097a47c0 (diff)
[AST] Fix an issue with parsing lists of values
Diffstat (limited to 'src/tparse/tree-value.go')
-rw-r--r--src/tparse/tree-value.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/tparse/tree-value.go b/src/tparse/tree-value.go
index 35e94d2..220687e 100644
--- a/src/tparse/tree-value.go
+++ b/src/tparse/tree-value.go
@@ -150,21 +150,27 @@ func parseUnaryOps(tokens *[]Token, tok, max int) (Node) {
var tmp Node
switch t.Type {
case DELIMIT:
+ mx := findClosing(tokens, tok)
+
+ if mx < 0 {
+ errOut("Unable to find closing delim when parsing a value", t)
+ }
+
switch t.Data {
case "(": // Function call
if comp {
errOut("Composite values can not be called as functions.", t)
}
- tmp, tok = parseValueList(tokens, tok + 1, max)
+ tmp, tok = parseValueList(tokens, tok + 1, mx + 1)
tmp.Data.Data = "call"
case "[": // Typecasting
- tmp, tok = parseTypeList(tokens, tok + 1, max)
+ tmp, tok = parseTypeList(tokens, tok + 1, mx + 1)
tmp.Data.Data = "cast"
case "{": // Indexing
if comp {
errOut("Inline composite values can not be indexed.", t)
}
- tmp, tok = parseValueList(tokens, tok + 1, max)
+ tmp, tok = parseValueList(tokens, tok + 1, mx + 1)
tmp.Data.Data = "index"
default:
errOut("Unexpected delimiter when parsing value", t)