diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2021-10-30 02:22:35 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2021-10-30 02:22:35 -0400 |
commit | e7c01fe5ebcb8e30c229a41125cdb318e9adcf8a (patch) | |
tree | 738d0ee288471ce0d2981dd27e19d3b07607e1da | |
parent | be0f69df2c0fc4bc8f64e8d51aa06b4b56f3401d (diff) |
[AST] Properly address "return"
-rw-r--r-- | src/tparse/tree-statement.go | 4 | ||||
-rw-r--r-- | src/tparse/type.go | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/src/tparse/tree-statement.go b/src/tparse/tree-statement.go index 9280253..262bd6f 100644 --- a/src/tparse/tree-statement.go +++ b/src/tparse/tree-statement.go @@ -184,6 +184,10 @@ func keywordStatement(tokens *[]Token, tok, max int) (Node, int) { tmp.Data = (*tokens)[tok] tok++ // Check for a numerical value and dip + case "return": + if (*tokens)[tok].Type != DELIMIT || (*tokens)[tok].Data == "{" || (*tokens)[tok].Data == "(" { + tmp, tok = parseValue(tokens, tok, max) + } case "alloc", "salloc": // Parse value list tmp, tok = parseValueList(tokens, tok, max) diff --git a/src/tparse/type.go b/src/tparse/type.go index b4ab2fe..1e51889 100644 --- a/src/tparse/type.go +++ b/src/tparse/type.go @@ -102,6 +102,7 @@ var RESWORD = map[string]int{ "loop": KEYWORD, "continue": KEYWORD, "break": KEYWORD, + "return": KEYWORD, "match": KEYWORD, "case": KEYWORD, |