diff options
author | Kyle Gunger <kgunger12@gmail.com> | 2021-08-01 16:37:02 -0400 |
---|---|---|
committer | Kyle Gunger <kgunger12@gmail.com> | 2021-08-01 16:37:02 -0400 |
commit | 628dd83397c47ff484f7c81b06dcd6d1e4af628b (patch) | |
tree | 64e213f3966149b424849b3216f78fac87948b4d /src/tparse | |
parent | 44862e37b5978da8e7af012bbb4b83edaff41299 (diff) |
Split main file
Diffstat (limited to 'src/tparse')
-rw-r--r-- | src/tparse/token.go | 6 | ||||
-rw-r--r-- | src/tparse/tree-statement.go | 10 | ||||
-rw-r--r-- | src/tparse/tree.go | 2 | ||||
-rw-r--r-- | src/tparse/type.go | 4 |
4 files changed, 16 insertions, 6 deletions
diff --git a/src/tparse/token.go b/src/tparse/token.go index 182b2e0..02502eb 100644 --- a/src/tparse/token.go +++ b/src/tparse/token.go @@ -27,6 +27,12 @@ type Token struct { // Node represents a node in an AST type Node struct { Data Token + + IsBlock bool + BlockQs []Token + BlockIn []Node + BlockOut []Node + Sub []Node } diff --git a/src/tparse/tree-statement.go b/src/tparse/tree-statement.go index 874528a..167cee2 100644 --- a/src/tparse/tree-statement.go +++ b/src/tparse/tree-statement.go @@ -23,6 +23,9 @@ func parseBlock(tokens *[]Token, tok, max int) (Node, int) { tok++ + def := Node{} + def.Data = Token{Type: 10, Data: "blockdef"} + for ;tok < max; tok++{ t := (*tokens)[tok] @@ -30,14 +33,15 @@ func parseBlock(tokens *[]Token, tok, max int) (Node, int) { case DELIMIT: if t.Data == "(" { tmp, tok = parseParamList(tokens, tok, max) - out.Sub = append(out.Sub, tmp) + def.Sub = append(out.Sub, tmp) } else if t.Data == "[" { tmp, tok = parseTypeList(tokens, tok, max) - out.Sub = append(out.Sub, tmp) + def.Sub = append(out.Sub, tmp) } else { goto BREAK } case DEFWORD: + case KEYWORD: case LINESEP: goto BREAK @@ -46,6 +50,8 @@ func parseBlock(tokens *[]Token, tok, max int) (Node, int) { BREAK: + out.Sub = append(out.Sub, def) + for ;tok < max; { t := (*tokens)[tok] diff --git a/src/tparse/tree.go b/src/tparse/tree.go index 9e9e554..08c94bf 100644 --- a/src/tparse/tree.go +++ b/src/tparse/tree.go @@ -19,7 +19,7 @@ package tparse import "fmt" // ID 9 = ast root -// ID 10 = ast list +// ID 10 = ast token func errOut(message string, token Token) { fmt.Println(message) diff --git a/src/tparse/type.go b/src/tparse/type.go index 73bb94d..b860f02 100644 --- a/src/tparse/type.go +++ b/src/tparse/type.go @@ -50,7 +50,7 @@ var PREWORDS = []string{ "extern", "size", "align", - "origin", + "address", "rootfile", "if", "else", @@ -130,8 +130,6 @@ var RESWORD = map[string]int{ "module": KEYWORD, "export": KEYWORD, - - "drop": KEYWORD, } func checkResWord(s string) int { |