aboutsummaryrefslogtreecommitdiff
path: root/neb/parser.py
diff options
context:
space:
mode:
authormryouse2022-07-27 00:43:17 +0000
committermryouse2022-07-27 00:43:17 +0000
commitaa52ae991cd7bfaebd358f7d1a9482613b82396c (patch)
treeddfe4fe51bc5280a59df970f2b13d75cf5215128 /neb/parser.py
parentf2125f46a689abd037b081a17c112ec3170ee0e4 (diff)
implement {} syntax for non-empty lists
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 930e77e..81f7672 100644
--- a/neb/parser.py
+++ b/neb/parser.py
@@ -160,6 +160,17 @@ def parseType(token, prev, tokens):
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
+
+ elif tokens[0].type_ == TokenType.OPEN_BRACE:
+ # 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_BRACE:
+ raise ParseError("invalid type definition (expecting close brace)", tokens[1+counter].line)
+ return Type(":{}", typ), counter + 3
+
else:
raise ParseError("invalid type definition!", tokens[0].line)