diff options
Diffstat (limited to 'src/tparse')
-rw-r--r-- | src/tparse/tokenize.go | 2 | ||||
-rw-r--r-- | src/tparse/tree-list.go | 30 | ||||
-rw-r--r-- | src/tparse/tree-statement.go | 8 |
3 files changed, 37 insertions, 3 deletions
diff --git a/src/tparse/tokenize.go b/src/tparse/tokenize.go index 31ae225..2b68a67 100644 --- a/src/tparse/tokenize.go +++ b/src/tparse/tokenize.go @@ -164,6 +164,8 @@ func stripBlockComments(t []Token) []Token { case "#/": bc = false continue + default: + continue } } else if bc { continue diff --git a/src/tparse/tree-list.go b/src/tparse/tree-list.go index 843ca9b..059ef0b 100644 --- a/src/tparse/tree-list.go +++ b/src/tparse/tree-list.go @@ -58,6 +58,36 @@ func parseValueList(tokens *[]Token, tok, max int) (Node, int) { return out, tok } +// Parse list of parameters +func parseParamList(tokens *[]Token, tok, max int) (Node, int) { + out := Node{} + out.Data = Token{Type: 10, Data: "param"} + var tmp Node + + c := getClosing((*tokens)[tok].Data) + + tok++ + + for ; tok < max; tok++ { + t := (*tokens)[tok] + + switch t.Data { + case c: + return out, tok + case ",": + tok++ + default: + errOut("Error: unexpected token when parsing a list of values", t) + } + + tmp, tok = parseValue(tokens, tok, max) + out.Sub = append(out.Sub, tmp) + } + + return out, tok +} + +// Parse a list of types func parseTypeList(tokens *[]Token, tok, max int) (Node, int) { out := Node{} out.Data = Token{Type: 10, Data: "type"} diff --git a/src/tparse/tree-statement.go b/src/tparse/tree-statement.go index 938e827..874528a 100644 --- a/src/tparse/tree-statement.go +++ b/src/tparse/tree-statement.go @@ -29,9 +29,11 @@ func parseBlock(tokens *[]Token, tok, max int) (Node, int) { switch t.Type { case DELIMIT: if t.Data == "(" { - - } else if t.Data == "(" { - + tmp, tok = parseParamList(tokens, tok, max) + out.Sub = append(out.Sub, tmp) + } else if t.Data == "[" { + tmp, tok = parseTypeList(tokens, tok, max) + out.Sub = append(out.Sub, tmp) } else { goto BREAK } |