diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2021-10-30 03:02:33 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2021-10-30 03:02:33 -0400 |
commit | 65eafdcefd5179eb767ce8886e19f30ea701385b (patch) | |
tree | d053f177b21e9c39e7c52d97a757b757826d4f5d /src/tparse/tree-value.go | |
parent | e7c01fe5ebcb8e30c229a41125cdb318e9adcf8a (diff) |
[AST] Bugfix 'void'
Basic bugfix to get void types parsing. Hopefuly this fixes other bugs too.
Diffstat (limited to 'src/tparse/tree-value.go')
-rw-r--r-- | src/tparse/tree-value.go | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/tparse/tree-value.go b/src/tparse/tree-value.go index b9796c8..edca103 100644 --- a/src/tparse/tree-value.go +++ b/src/tparse/tree-value.go @@ -98,7 +98,7 @@ func parseUnaryOps(tokens *[]Token, tok, max int) (Node) { var tmp Node switch t.Data { case "{", "(": // Array or struct evaluation, parenthetical value - tmp, tok = parseValueList(tokens, tok, max) + tmp, tok = parseValueList(tokens, tok + 1, max) out.Sub = append(out.Sub, tmp) val = true default: @@ -132,14 +132,14 @@ func parseUnaryOps(tokens *[]Token, tok, max int) (Node) { var tmp Node switch t.Data { case "(": // Function call - tmp, tok = parseValueList(tokens, tok, max) + tmp, tok = parseValueList(tokens, tok + 1, max) + tmp.Data.Data = "call" case "[": // Typecasting - tmp, tok = parseTypeList(tokens, tok, max) + tmp, tok = parseTypeList(tokens, tok + 1, max) + tmp.Data.Data = "cast" case "{": // Array indexing - tmp = Node{Data: Token{Type: 10, Data: "index"}} - var tmp2 Node - tmp2, tok = parseValue(tokens, tok + 1, max) - tmp.Sub = append(tmp.Sub, tmp2) + tmp, tok = parseValueList(tokens, tok + 1, max) + tmp.Data.Data = "index" default: errOut("Unexpected delimiter when parsing value", t) } @@ -305,12 +305,14 @@ func parseTypeParams(tokens *[]Token, tok, max int) (Node, int) { case DELIMIT: if tok < max-1 { if t.Data == "(" { - tmp, tok = parseValueList(tokens, tok, max) + tmp, tok = parseTypeList(tokens, tok + 1, max) + tmp.Data.Data = "()" } else if t.Data == "[" { - tmp, tok = parseTypeList(tokens, tok, max) + tmp, tok = parseTypeList(tokens, tok + 1, max) + tmp.Data.Data = "[]" } else if t.Data == ")" || t.Data == "]" || t.Data == "}" { // End of type - tok-- + tok++ goto VOIDDONE } else { errOut("Error: unexpected delimeter when parsing type", t) @@ -321,7 +323,6 @@ func parseTypeParams(tokens *[]Token, tok, max int) (Node, int) { default: // End of type - tok-- goto VOIDDONE } @@ -386,7 +387,7 @@ func parseType(tokens *[]Token, tok, max int, param bool) (Node, int) { } else { // Constant length array. Parse value for length and increment var tmp2 Node - tmp2, tok = parseValue(tokens, tok + 1, max) + tmp2, tok = parseValueList(tokens, tok + 1, max) tmp.Sub = append(tmp.Sub, tmp2) } } else if t.Data == ")" || t.Data == "]" || t.Data == "}"{ |