Change the way values work

Change the parsing for values to make them more reusable, in particular
for when I implement extensions.
This commit is contained in:
James Westman 2023-01-12 13:19:15 -06:00
parent 6938267952
commit 1df46b5a06
No known key found for this signature in database
GPG key ID: CE2DBA0ADB654EA6
30 changed files with 707 additions and 291 deletions

View file

@ -21,15 +21,22 @@
from .attributes import BaseTypedAttribute
from .gobject_object import ObjectContent, validate_parent_type
from .common import *
from .contexts import ValueTypeCtx
from .values import Value
class Item(BaseTypedAttribute):
tag_name = "item"
attr_name = "id"
class Item(AstNode):
@property
def name(self) -> str:
return self.tokens["name"]
@property
def value_type(self):
return StringType()
def value(self) -> Value:
return self.children[Value][0]
@context(ValueTypeCtx)
def value_type(self) -> ValueTypeCtx:
return ValueTypeCtx(StringType())
item = Group(
@ -41,7 +48,7 @@ item = Group(
":",
]
),
VALUE_HOOKS,
Value,
],
)