summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2021-10-31 20:59:45 -0400
committerKyle Gunger <kgunger12@gmail.com>2021-10-31 20:59:45 -0400
commit83ddc2f1a6a2f05efba92eb9fb453032a2fb987d (patch)
tree93019b262bf61159fcfbb26dca932b85bf7ea089 /src
parenteb05a05ac4f10672c573dd53cb3aaa27deb4f6a3 (diff)
[AST] Add initial operator and module cases
+ Modules at least mostly parse properly. ~ I'm mostly just working tword a minimum viable program at this point.
Diffstat (limited to 'src')
-rw-r--r--src/tparse/tree-statement.go21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/tparse/tree-statement.go b/src/tparse/tree-statement.go
index 277cd95..546c833 100644
--- a/src/tparse/tree-statement.go
+++ b/src/tparse/tree-statement.go
@@ -60,6 +60,16 @@ func parseBlock(tokens *[]Token, tok, max int) (Node, int) {
errOut("Unexpected keyword, the block has already been given a name or keyword.", t)
}
switch t.Data {
+ case "operator":
+ name = true
+ if (*tokens)[tok+1].Type != AUGMENT {
+ errOut("You must supply an operator to overload.", t)
+ } else if (*tokens)[tok+1].Data == "`" || (*tokens)[tok+1].Data == "~" {
+ errOut("You may not overload the following operators: '~', '`'.", t)
+ }
+ tmp.Data = (*tokens)[tok+1]
+ def.Sub = append(def.Sub, tmp)
+ tok += 2
case "else":
name = true
sparse = true
@@ -76,6 +86,17 @@ 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":
+ if (*tokens)[tok+1].Type != DEFWORD && !name {
+ errOut("You must provide a name for a module.", t)
+ } else if !name {
+ tmp.Sub = append(tmp.Sub, Node{(*tokens)[tok+1], false, []Node{}})
+ tok++
+ }
+ tmp.Data = t
+ def.Sub = append(def.Sub, tmp)
+ tok++
+ goto BREAK
default:
errOut("Unexpected keyword in block definition.", t)
}