Skip to content

Commit 36c7227

Browse files
committed
DSL Items Parser: Fix incorrect parsing of tags as start of item definition
When specifying tag names that match one of the valid item types, e.g. `Switch`, the parser incorrectly treated it as a new start of an item definition. Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
1 parent a4c6b49 commit 36c7227

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

  • bundles/org.openhab.core.model.item/src/org/openhab/core/model

bundles/org.openhab.core.model.item/src/org/openhab/core/model/Items.xtext

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ ModelItem:
1717
(ModelNormalItem | ModelGroupItem) name=ID
1818
(label=STRING)?
1919
('<' icon=Icon '>')?
20-
('(' groups+=ID (',' groups+=ID)* ')')?
21-
('[' tags+=(ID|STRING) (',' tags+=(ID|STRING))* ']')?
22-
('{' bindings+=ModelBinding (',' bindings+=ModelBinding)* '}')?
20+
('(' groups+=ID (',' groups+=ID)* ')')?
21+
('[' tags+=TagValue (',' tags+=TagValue)* ']')?
22+
('{' bindings+=ModelBinding (',' bindings+=ModelBinding)* '}')?
2323
;
2424

2525
ModelGroupItem:
@@ -56,7 +56,7 @@ ValueType returns ecore::EJavaObject:
5656
STRING | NUMBER | BOOLEAN
5757
;
5858

59-
BOOLEAN returns ecore::EBoolean:
59+
BOOLEAN returns ecore::EBoolean:
6060
'true' | 'false'
6161
;
6262

@@ -68,6 +68,12 @@ Icon:
6868
(ID ':' (ID ':')?)? ID
6969
;
7070

71+
// Add BaseModelItemType here as valid tags
72+
// otherwise the parser thinks it's the start of an Item definition
73+
TagValue:
74+
ID | STRING | BaseModelItemType
75+
;
76+
7177
terminal ID: '^'?('a'..'z'|'A'..'Z'|'_'|'0'..'9') ('a'..'z'|'A'..'Z'|'_'|'-'|'0'..'9')*;
7278

7379
terminal STRING:

0 commit comments

Comments
 (0)