diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2021-10-30 16:36:17 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2021-10-30 16:36:17 -0400 |
commit | 61bd3b82b9d493bfb35fe5fef625c17ebf0c1fcb (patch) | |
tree | dcfdd4052e1e74c6b98f3e50139e3ebf30e09937 /src/tparse/tree-statement.go | |
parent | 051f325d54aad24233714aabb1d616411aea1d05 (diff) |
[AST] Refactor and unary fixes
+ clean up the output a bit
+ restructure the tree a bit with reguards to unary ops
+ better error checking for misuse of unary ops
Diffstat (limited to 'src/tparse/tree-statement.go')
-rw-r--r-- | src/tparse/tree-statement.go | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/tparse/tree-statement.go b/src/tparse/tree-statement.go index 2fb6b8a..110d859 100644 --- a/src/tparse/tree-statement.go +++ b/src/tparse/tree-statement.go @@ -112,16 +112,16 @@ func parseStatement(tokens *[]Token, tok, max int) (Node, int) { // Check for keyword, definition, then if none of those apply, assume it's a value. if (*tokens)[tok].Type == KEYWORD { - tmp, tok = keywordStatement(tokens, tok, max) - out.Sub = append(out.Sub, tmp) + return keywordStatement(tokens, tok, max) } else { // do check for definition if isTypeThenValue(tokens, tok, max) { // if not, parse a value - tmp, tok = parseDef(tokens, tok, max) + return parseDef(tokens, tok, max) } else { // if not, parse a value tmp, tok = parseValue(tokens, tok, max) + out.Data.Data = "value" } out.Sub = append(out.Sub, tmp) } @@ -203,7 +203,7 @@ func keywordStatement(tokens *[]Token, tok, max int) (Node, int) { // Should work, but none of this is tested. func parseDef(tokens *[]Token, tok, max int) (Node, int) { - out := Node{Data: Token{11, "vdef", 0, 0}} + out := Node{Data: Token{11, "define", 0, 0}} var tmp Node tmp, tok = parseType(tokens, tok, max, false) |