mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
Minor code cleanup
This commit is contained in:
parent
4d62df0068
commit
5b50090b65
3 changed files with 11 additions and 23 deletions
|
@ -25,6 +25,11 @@ from .values import StringValue
|
|||
|
||||
|
||||
class Item(AstNode):
|
||||
grammar = [
|
||||
Optional([UseIdent("name"), ":"]),
|
||||
StringValue,
|
||||
]
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self.tokens["name"]
|
||||
|
@ -34,25 +39,11 @@ class Item(AstNode):
|
|||
return self.children[StringValue][0]
|
||||
|
||||
|
||||
item = Group(
|
||||
Item,
|
||||
[
|
||||
Optional(
|
||||
[
|
||||
UseIdent("name"),
|
||||
":",
|
||||
]
|
||||
),
|
||||
StringValue,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
class ExtComboBoxItems(AstNode):
|
||||
grammar = [
|
||||
Keyword("items"),
|
||||
"[",
|
||||
Delimited(item, ","),
|
||||
Delimited(Item, ","),
|
||||
"]",
|
||||
]
|
||||
|
||||
|
|
|
@ -42,7 +42,9 @@ class Filters(AstNode):
|
|||
|
||||
|
||||
class FilterString(AstNode):
|
||||
pass
|
||||
@property
|
||||
def item(self) -> str:
|
||||
return self.tokens["name"]
|
||||
|
||||
|
||||
def create_node(tag_name: str, singular: str):
|
||||
|
|
|
@ -25,6 +25,7 @@ from .values import Value
|
|||
|
||||
|
||||
class LayoutProperty(AstNode):
|
||||
grammar = Statement(UseIdent("name"), ":", Err(Value, "Expected a value"))
|
||||
tag_name = "property"
|
||||
|
||||
@property
|
||||
|
@ -48,17 +49,11 @@ class LayoutProperty(AstNode):
|
|||
)
|
||||
|
||||
|
||||
layout_prop = Group(
|
||||
LayoutProperty,
|
||||
Statement(UseIdent("name"), ":", Err(Value, "Expected a value")),
|
||||
)
|
||||
|
||||
|
||||
class ExtLayout(AstNode):
|
||||
grammar = Sequence(
|
||||
Keyword("layout"),
|
||||
"{",
|
||||
Until(layout_prop, "}"),
|
||||
Until(LayoutProperty, "}"),
|
||||
)
|
||||
|
||||
@validate("layout")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue