-
Notifications
You must be signed in to change notification settings - Fork 37
/
Keycodes.g
110 lines (91 loc) · 1.75 KB
/
Keycodes.g
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
// Keycodes Grammar (X.org)
// Written by Simos Xenitellis <[email protected]>, 2008.
// Version 0.8
grammar Keycodes;
options
{
language = Python;
output = AST;
}
tokens
{
KEYCODEDOC;
KEYCODELIST;
KEYCODELISTTYPE;
KEYCODELISTOPTIONS;
KEYCODELISTOPTS;
KEYCODELISTNAME;
KEYCODEMATERIAL;
INCLUDE;
MINIMUM;
MAXIMUM;
ALIAS;
INDICATOR;
KEYCODE;
}
keycodedoc
: keycodelist+ EOF
-> ^(KEYCODEDOC keycodelist+)
;
keycodelist
: keycodelisttype '{' keycodeMaterial+ '}' ';'
-> ^(KEYCODELIST keycodelisttype ^(KEYCODEMATERIAL keycodeMaterial+))
;
keycodelisttype
: KEYCODELISTOPTS+ DQSTRING
-> ^(KEYCODELISTTYPE ^(KEYCODELISTOPTIONS KEYCODELISTOPTS+) ^(KEYCODELISTNAME DQSTRING))
;
keycodeMaterial
: line_include
| line_minmax ';'!
| line_alias ';'!
| line_keycode ';'!
| line_indicator ';'!
;
line_include
: 'include' DQSTRING
-> ^(INCLUDE DQSTRING)
;
line_minmax
: 'minimum' '=' NAME -> ^(MINIMUM NAME)
| 'maximum' '=' NAME -> ^(MAXIMUM NAME)
;
line_alias
: 'alias' '<' val+=NAME '>' '=' '<' val+=NAME '>'
-> ^(ALIAS $val+)
;
line_keycode
: '<' val+=NAME '>' '=' val+=NAME
-> ^(KEYCODE NAME+)
;
line_indicator
: 'indicator' NAME '=' DQSTRING
-> ^(INDICATOR NAME DQSTRING)
;
KEYCODELISTOPTS
: 'default'
| 'xkb_keycodes'
;
NAME
: ( 'a'..'z' | 'A'..'Z' | '_' | '0'..'9' | '+' | '-' )*
;
WS
:
( ' ' | '\r' | '\t' | '\u000C' | '\n')
{ $channel=HIDDEN; }
;
COMMENT
:
'/*' .* '*/' {$channel=HIDDEN;}
;
LINE_COMMENT
:
('//' | '#') ~('\n' | '\r')* '\r'? '\n'
{ $channel=HIDDEN; }
;
/** Match various string types. Note that greedy=false implies '''
* should make us exit loop not continue.
*/
DQSTRING
: '"' ((options {greedy=false;}:~('"'))*) '"'
;