-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathSpecs.xtext
152 lines (116 loc) · 3.25 KB
/
Specs.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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
grammar com.galenframework.Specs with org.eclipse.xtext.common.Terminals
import "http://www.eclipse.org/emf/2002/Ecore" as ecore
generate specs "http://www.galenframework.com/Specs"
Model:
{Model}
objects=Objects?
imports+=Import*
groups=Groups?
imports+=Import*
layoutChecks+=LayoutCheck*;
Objects:
'@objects'
BEGIN
(elements+=Element)+
END;
Groups:
'@groups'
BEGIN
(groupEntries+=GroupEntry)+
END
;
Import:
'@import' fileName=ID;
LayoutCheck:
name=SECTION_LABEL
BEGIN
(
(generalRules+=LayoutRule)|(taggedRules+=TaggedRule)
)+
END;
LayoutRule:
applyTo=EntryReference':'
BEGIN
(specifications+=SpecsReference)+
END;
EntryReference returns SpecElementEntryReference:
ElementEntryReference|GroupEntryReference
;
ElementEntryReference returns ElementEntryReference:
elementEntryReference=[Element]
;
GroupEntryReference returns GroupEntryReference:
'&'groupEntryReference=[GroupEntry]
;
TaggedRule:
name=SECTION_TAG
BEGIN
rule=LayoutRule
END;
SpecsReference:
{SpecsReference} rule=Rule;
Rule:
(VisibilityRule | PlacementRule | AlignmentRule | SizeRule);
VisibilityRule:
{VisibilityRule} name=('visible' | 'absent');
PlacementRule:
{PlacementRule} name=('near' | 'below' | 'above') INT 'to' INT 'px';
SizeRule:
{SizeRule} ((name='height' ('<' | '>') (INT 'px' | 'screen/height')) |
(name='width' ('<' | '>') (INT 'px' | 'screen/width@')));
AlignmentRule:
name='aligned' type=AlignmentType
ref=[Element] (INT 'px')?;
AlignmentType:
('horizontally' ('all' | 'top' | 'bottom' | 'centered')) | ('vertically' ('all' | 'left' | 'bottom' | 'right'));
GroupEntry returns GroupEntry:
{GroupEntry}
name=ID consistsOf+=[Element] (','consistsOf+=[Element])*
;
Element returns Element:
{Element}
name=ID selector=Selector
(BEGIN
(children+=Element)+
END)?;
Selector:
(IdSelector | CssSelector | XpathSelector);
IdSelector:
'id' value=IdSelectorValue;
IdSelectorValue returns ecore::EString:
ID | INT;
CssSelector:
('css')? value=CssSelectorValue;
CssSelectorValue returns ecore::EString:
(CSSSELECTOR_VALUE | HTMLTAG_VALUE) (('>' | ',' | ':')? CSSSELECTOR_VALUE | HTMLTAG_VALUE)*;
XpathSelector:
'xpath' value=XpathSelectorValue;
XpathSelectorValue returns ecore::EString:
XPATH_VALUE;
terminal SECTION_TAG returns ecore::EString:
'@on' TEXT_VALUE;
terminal SECTION_LABEL returns ecore::EString:
'=' TEXT_VALUE '=';
terminal HTMLTAG_VALUE returns ecore::EString:
//PREFIXABLE_ID_START+
('body' | 'br' | 'li' | 'a' | 'div' | 'span') (CSSSELECTOR_VALUE)?;
terminal CSSSELECTOR_VALUE returns ecore::EString:
('#' | '.' | ':') PREFIXABLE_ID_START ('a'..'z' | 'A'..'Z' | '_' | '-' | INT)+;
terminal XPATH_VALUE returns ecore::EString:
'//' ('*' | ID) ('['->']')*;
// Single line comment
terminal SL_COMMENT:
'#' WS !('\n' | '\r')* NEW_LINE?;
terminal ID returns ecore::EString:
PREFIXABLE_ID_START ('a'..'z' | 'A'..'Z' | '-' | '*' | '.' | INT)+;
terminal fragment PREFIXABLE_ID_START:
('a'..'z' | 'A'..'Z');
terminal fragment NEW_LINE:
('\r'? '\n');
terminal fragment TEXT_VALUE:
('a'..'z' | 'A'..'Z' | ' ') ('a'..'z' | 'A'..'Z' | ' ' | '.' | INT)*;
// The following synthetic tokens are used for the indentation-aware blocks
terminal BEGIN:
'synthetic:BEGIN'; // increase indentation
terminal END:
'synthetic:END'; // decrease indentation