From 61bd3b82b9d493bfb35fe5fef625c17ebf0c1fcb Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Sat, 30 Oct 2021 16:36:17 -0400 Subject: [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 --- src/tparse/tree-statement.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/tparse/tree-statement.go') 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) -- cgit v1.2.3