diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2021-10-31 21:51:47 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2021-10-31 21:51:47 -0400 |
commit | 564c35e9f890d86d9f69e975881bcda4c6761487 (patch) | |
tree | c7a2a8f0537517a7710ff7c20d221e4792b2a376 /src | |
parent | 664865e415bce4ade37add28e136db2f56e11e7b (diff) |
[AST] Enum and method blocks
Diffstat (limited to 'src')
-rw-r--r-- | src/tparse/tree-statement.go | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/tparse/tree-statement.go b/src/tparse/tree-statement.go index 546c833..718ad52 100644 --- a/src/tparse/tree-statement.go +++ b/src/tparse/tree-statement.go @@ -86,9 +86,9 @@ func parseBlock(tokens *[]Token, tok, max int) (Node, int) { case "export", "inline", "raw", "override": tmp.Data = t def.Sub = append(def.Sub, tmp) - case "module": + case "module", "method": if (*tokens)[tok+1].Type != DEFWORD && !name { - errOut("You must provide a name for a module.", t) + errOut("You must provide a name for a module or method.", t) } else if !name { tmp.Sub = append(tmp.Sub, Node{(*tokens)[tok+1], false, []Node{}}) tok++ @@ -207,7 +207,23 @@ func keywordStatement(tokens *[]Token, tok, max int) (Node, int) { } tmp, tok = parseParamList(tokens, tok + 1, max) + case "enum": + if (*tokens)[tok].Type != DEFWORD { + errOut("Expected defword after enum keyword.", (*tokens)[tok]) + } + tmp.Data = (*tokens)[tok] + out.Sub = append(out.Sub, tmp) + tok++ + if (*tokens)[tok].Data == "[" { + tmp, tok = parseTypeList(tokens, tok + 1, max) + out.Sub = append(out.Sub, tmp) + } + + if (*tokens)[tok].Data != "{" { + errOut("Could not find enum value list", (*tokens)[tok]) + } + tmp, tok = parseValueList(tokens, tok + 1, max) case "goto", "label": if (*tokens)[tok].Type != DEFWORD { errOut("Expected defword after goto or label keyword.", out.Data) |