Merge branch 'variant-literal' into 'main'

Draft: Syntax for variants

See merge request jwestman/blueprint-compiler!224
This commit is contained in:
jgcodes2020 2025-01-01 20:19:39 +00:00
commit 235de0fed8
9 changed files with 338 additions and 14 deletions

View file

@ -22,12 +22,14 @@ from .binding import Binding
from .common import *
from .contexts import ValueTypeCtx
from .gtkbuilder_template import Template
from .values import ArrayValue, ObjectValue, Value
from .values import ArrayValue, ObjectValue, Value, VariantValue
class Property(AstNode):
grammar = Statement(
UseIdent("name"), ":", AnyOf(Binding, ObjectValue, Value, ArrayValue)
UseIdent("name"),
":",
AnyOf(Binding, VariantValue, ObjectValue, Value, ArrayValue),
)
@property
@ -35,7 +37,7 @@ class Property(AstNode):
return self.tokens["name"]
@property
def value(self) -> T.Union[Binding, ObjectValue, Value, ArrayValue]:
def value(self) -> T.Union[Binding, VariantValue, ObjectValue, Value, ArrayValue]:
return self.children[0]
@property