mirror of
https://gitlab.gnome.org/jwestman/blueprint-compiler.git
synced 2025-05-04 15:59:08 -04:00
add variant support for menus
This commit is contained in:
parent
f894301571
commit
a75adc7d1b
4 changed files with 39 additions and 13 deletions
|
@ -19,7 +19,7 @@
|
|||
|
||||
import typing as T
|
||||
|
||||
from blueprintcompiler.language.values import StringValue
|
||||
from blueprintcompiler.language.values import StringValue, VariantValue
|
||||
|
||||
from .common import *
|
||||
from .contexts import ValueTypeCtx
|
||||
|
@ -98,8 +98,12 @@ class MenuAttribute(AstNode):
|
|||
return self.tokens["name"]
|
||||
|
||||
@property
|
||||
def value(self) -> StringValue:
|
||||
return self.children[StringValue][0]
|
||||
def value(self) -> StringValue | VariantValue:
|
||||
if len(self.children[StringValue]) > 0:
|
||||
return self.children[StringValue][0]
|
||||
elif len(self.children[VariantValue]) > 0:
|
||||
return self.children[VariantValue][0]
|
||||
raise CompilerBugError()
|
||||
|
||||
@property
|
||||
def document_symbol(self) -> DocumentSymbol:
|
||||
|
@ -133,7 +137,7 @@ menu_attribute = Group(
|
|||
[
|
||||
UseIdent("name"),
|
||||
":",
|
||||
Err(StringValue, "Expected string or translated string"),
|
||||
Err(AnyOf(StringValue, VariantValue), "Expected string or translated string"),
|
||||
Match(";").expected(),
|
||||
],
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue