-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstylo.xtext
63 lines (42 loc) · 1.36 KB
/
stylo.xtext
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
grammar org.xtext.stylodesign.stylo.Stylo with org.eclipse.xtext.common.Terminals
generate stylo "http://www.example.org/Stylo"
Model:
elements+=Element*;
Element:
Import | Parameter | ClassDeclaration | ComponentDeclaration | Render;
Import:
'import' importURI=STRING;
Parameter:
'param' name=ID '=' value=STRING;
ClassDeclaration:
'class' name=ID '{' properties+=Property* '}';
Property:
name=ID ':' value=STRING ';';
ComponentDeclaration:
'component' name=ID ('(' (parameters+=ComponentParameter (',' parameters+=ComponentParameter)*)? ')')? '{' content=Content '}';
ComponentParameter:
name=ID ('=' defaultValue=STRING)?;
Content:
(items+=ContentItem)*;
ContentItem:
ComponentReference | HTMLElement | Text | Slot;
ComponentReference:
component=[ComponentDeclaration] ('(' (arguments+=ComponentArgument (',' arguments+=ComponentArgument)*)? ')')?;
ComponentArgument:
value=STRING;
HTMLElement:
name=ID_LOWER ('(' (attributes+=Attribute*)')')? '{' content=Content '}';
Attribute:
name=ID ('=' value=STRING)?;
Text:
value=STRING;
Slot:
'Slot' ('(' 'name' '=' name=STRING ')')?;
Render:
'render' name=ID '(' parameters+=RenderParameter (',' parameters+=RenderParameter)* ')' '{' content=Content '}';
RenderParameter:
value=STRING;
terminal ID_UPPER:
('A'..'Z');
terminal ID_LOWER:
('a'..'z');