Add properties to AST types

I want to have a cleaner API that relies less on the specifics of the
grammar and parser.
This commit is contained in:
James Westman 2023-01-09 21:55:14 -06:00
parent 0b7dbaf90d
commit 6938267952
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
4 changed files with 34 additions and 10 deletions

View file

@ -39,6 +39,10 @@ class Menu(AstNode):
def tag(self) -> str:
return self.tokens["tag"]
@property
def items(self) -> T.List[T.Union["Menu", "MenuAttribute"]]:
return self.children
@validate("menu")
def has_id(self):
if self.tokens["tag"] == "menu" and self.tokens["id"] is None: