Minor code cleanup

This commit is contained in:
James Westman 2023-05-02 09:28:42 -05:00
parent 4d62df0068
commit 5b50090b65
3 changed files with 11 additions and 23 deletions

View file

@ -25,6 +25,11 @@ from .values import StringValue
class Item(AstNode): class Item(AstNode):
grammar = [
Optional([UseIdent("name"), ":"]),
StringValue,
]
@property @property
def name(self) -> str: def name(self) -> str:
return self.tokens["name"] return self.tokens["name"]
@ -34,25 +39,11 @@ class Item(AstNode):
return self.children[StringValue][0] return self.children[StringValue][0]
item = Group(
Item,
[
Optional(
[
UseIdent("name"),
":",
]
),
StringValue,
],
)
class ExtComboBoxItems(AstNode): class ExtComboBoxItems(AstNode):
grammar = [ grammar = [
Keyword("items"), Keyword("items"),
"[", "[",
Delimited(item, ","), Delimited(Item, ","),
"]", "]",
] ]

View file

@ -42,7 +42,9 @@ class Filters(AstNode):
class FilterString(AstNode): class FilterString(AstNode):
pass @property
def item(self) -> str:
return self.tokens["name"]
def create_node(tag_name: str, singular: str): def create_node(tag_name: str, singular: str):

View file

@ -25,6 +25,7 @@ from .values import Value
class LayoutProperty(AstNode): class LayoutProperty(AstNode):
grammar = Statement(UseIdent("name"), ":", Err(Value, "Expected a value"))
tag_name = "property" tag_name = "property"
@property @property
@ -48,17 +49,11 @@ class LayoutProperty(AstNode):
) )
layout_prop = Group(
LayoutProperty,
Statement(UseIdent("name"), ":", Err(Value, "Expected a value")),
)
class ExtLayout(AstNode): class ExtLayout(AstNode):
grammar = Sequence( grammar = Sequence(
Keyword("layout"), Keyword("layout"),
"{", "{",
Until(layout_prop, "}"), Until(LayoutProperty, "}"),
) )
@validate("layout") @validate("layout")