Reorganize the parser/AST code

The code is now organized by syntax: `menu {}` in one file, `style` in
another, etc. This should make it easier to add syntax in the future.
This commit is contained in:
James Westman 2021-10-31 21:41:44 -05:00
parent dc7c0cabd8
commit bfd9daf6a9
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
10 changed files with 486 additions and 344 deletions

View file

@ -197,3 +197,18 @@ def docs(*args, **kwargs):
return Docs(func, *args, **kwargs)
return decorator
class BaseAttribute(AstNode):
""" A helper class for attribute syntax of the form `name: literal_value;`"""
tag_name: str = ""
def emit_xml(self, xml: XmlEmitter):
xml.start_tag(
self.tag_name,
name=self.tokens["name"],
translatable="yes" if self.tokens["translatable"] else None,
)
xml.put_text(str(self.tokens["value"]))
xml.end_tag()