aboutsummaryrefslogtreecommitdiff
path: root/neb/parser.py
diff options
context:
space:
mode:
authormryouse2022-07-01 02:45:23 +0000
committermryouse2022-07-02 03:15:45 +0000
commit2f43cbc79d5aa5d4677e44377492a3010840b58a (patch)
treeedd8f6b9202f59a406d57b11c586853bdd02bf11 /neb/parser.py
parent74a048dd493788bab9f9c93b0ed6d925a998822b (diff)
attempt to add a generic list type
Diffstat (limited to 'neb/parser.py')
-rw-r--r--neb/parser.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/neb/parser.py b/neb/parser.py
index bbaf7a8..d5712d2 100644
--- a/neb/parser.py
+++ b/neb/parser.py
@@ -47,6 +47,17 @@ def parseType(token, prev, tokens):
# if the next token is a symbol, combine for a type
if len(tokens) > 0 and tokens[0].type_ == TokenType.SYMBOL:
return Type(f":{tokens[0].text}"), 2
+ elif tokens[0].type_ == TokenType.OPEN_BRACKET:
+ # only format currently supported:
+ # [ <type> ]
+ if tokens[1].type_ != TokenType.COLON:
+ raise ParseError("invalid type definition (expecting colon)", tokens[1].line)
+ typ, counter = parseType(tokens[1], tokens[0], tokens[2:])
+ if tokens[1+counter].type_ != TokenType.CLOSE_BRACKET:
+ raise ParseError("invalid type definition (expecting close bracket)", tokens[1+counter].line)
+ return Type(f":[]", typ), counter + 3
+ else:
+ raise ParseError("invalid type definition!", tokens[0].line)
def parse(tokens):
idx = 0