From 0de12784cfc54130e65812e64cbd9e975ceab9ff Mon Sep 17 00:00:00 2001 From: mryouse Date: Tue, 26 Jul 2022 01:03:57 +0000 Subject: parse single quotes, as well as defs and funcs --- neb/structs.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'neb/structs.py') diff --git a/neb/structs.py b/neb/structs.py index 27c7782..51cdb34 100644 --- a/neb/structs.py +++ b/neb/structs.py @@ -47,6 +47,8 @@ class TokenType(Enum): MANY = auto() COLON = auto() + APOSTROPHE = auto() + @dataclass class Token: type_: TokenType @@ -127,6 +129,25 @@ class Symbol: else: return f"{self.name}" +class NebDef: + def __init__(self, symbol, type_=ALL_TYPES[":any"]): + self.name = symbol.name + self.symbol = symbol + self.line = symbol.line + self.type_ = type_ + def __str__(self): + return f"{self.name} (def)" + +class NebFuncDef: + def __init__(self, symbol, return_type, args, many, body): + self.name = symbol.name + self.symbol = symbol + self.line = symbol.line + self.return_type = return_type + self.args = args + self.many = many + self.body = body + class Expr: def __init__(self, args): self.args = args -- cgit v1.2.3