From 628dd83397c47ff484f7c81b06dcd6d1e4af628b Mon Sep 17 00:00:00 2001 From: Kyle Gunger Date: Sun, 1 Aug 2021 16:37:02 -0400 Subject: Split main file --- src/tparse/token.go | 6 ++++++ src/tparse/tree-statement.go | 10 ++++++++-- src/tparse/tree.go | 2 +- src/tparse/type.go | 4 +--- 4 files changed, 16 insertions(+), 6 deletions(-) (limited to 'src/tparse') 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 { -- cgit v1.2.3