summaryrefslogtreecommitdiff
path: root/src/tparse
diff options
context:
space:
mode:
Diffstat (limited to 'src/tparse')
-rw-r--r--src/tparse/tree-list.go24
-rw-r--r--src/tparse/tree-statement.go8
-rw-r--r--src/tparse/tree-value.go12
3 files changed, 34 insertions, 10 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
diff --git a/src/tparse/tree-statement.go b/src/tparse/tree-statement.go
index 6a5b6e3..5c6d912 100644
--- a/src/tparse/tree-statement.go
+++ b/src/tparse/tree-statement.go
@@ -193,7 +193,13 @@ func keywordStatement(tokens *[]Token, tok, max int) (Node, int) {
out.Sub = append(out.Sub, tmp)
tok++
if (*tokens)[tok].Data == "(" {
- tmp, tok = parseValueList(tokens, tok + 1, max)
+ mx := findClosing(tokens, tok)
+
+ if mx < 0 {
+ errOut("Failed to find closing paren when parsing a struct def", (*tokens)[tok])
+ }
+
+ tmp, tok = parseValueList(tokens, tok + 1, mx)
out.Sub = append(out.Sub, tmp)
tok++
}
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)