-
Notifications
You must be signed in to change notification settings - Fork 0
/
ddmLang.g4
250 lines (202 loc) · 5.83 KB
/
ddmLang.g4
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
grammar ddmLang;
options {
language = Java;
}
@header{
package myLex;
}
BLANKSPACE: ' ';
WS: ((BLANKSPACE BLANKSPACE) | '\t')-> skip;
COMMENT: '/*' .*? '*/' -> skip;
LINE_COMMENT: '//' ~[\r\n]* -> skip;
DIGIT
: ('0'..'9')+
;
STR : ('STR')
;
DEX : ('DEX')
;
CHA : ('CHA')
;
INT : ('INT')
;
CON : ('CON')
;
WIS : ('WIS')
;
STARTENTITY : '{';
ENDENTITY : '}';
CREATE: 'create';
PLAYER: 'Player';
EQUIPMENT: 'Equipment';
IMPORT: 'import';
FROM: 'from';
SET : 'set';
FOR : 'for';
OF : 'of';
COLON : ':';
BL : ('\n' | '\r\n');
RACE: ('race');
HP: ('hp');
ARCHTYPE: ('archetype');
ABILITY: ('abilities');
ALIGN: ('alignment');
SKILLSID: ('skills');
LANG: ('languages');
ARMOR: 'armor';
WEAPON: 'weapon';
SHIELD: 'shield';
CONSUMABLES: 'consumables';
ARMORTYPE: (
'Padded'|
'Leather'|
'Studded leather'|
'Hide'|
'Chain shirt'|
'Scale mail'|
'Breastplate'|
'Half plate'|
'Ring mail'|
'Chain mail'|
'Splint'|
'Plate' |
NONE);
WEAPONTYPE: ('Bastard sword' | 'Axe' | 'Dagger' | 'Longbow' | NONE);
SHIELDPRESENCE: ('Yes' | 'No');
NONE: 'None';
CONSUMABLE: ('Health potion' | 'Mana potion' | 'Gold');
ALIGNMENT: 'lawful good' | 'lawful neutral' | 'lawful evil' |
'neutral good' | 'neutral' | 'neutral evil' |
'chaotic good' | 'chaotic neutral' | 'chaotic evil';
PGCLASS : ('Barbarian'|
'Bard'|
'Cleric'|
'Druid'|
'Monk'|
'Paladin'|
'Ranger'|
'Rogue'|
'Sorcerer'|
'Warlock'|
'Wizard');
SUBCLASS : ('Berserker'|
'Path of the Totem warrior'|
'College of Lore'|
'College of Valor'|
'Knowledge Domain'|
'Life Domain'|
'Light Domain'|
'Nature Domain'|
'Tempest Domain'|
'Trickery Domain'|
'War Domain'|
'Circle of the land'|
'Circle of the moon'|
'Champion'|
'Battle master'|
'Eldritch knight'|
'Way of the open hand'|
'Way of shadow'|
'Way of the four elements'|
'Oath of devotion'|
'Oath of the ancients'|
'Oath of vengeance'|
'Hunter'|
'Beast master'|
'Thief'|
'Assassin'|
'Arcane trickster'|
'Dragonic bloodline'|
'Wild magic'|
'The fiend'|
'The great old one'|
'the archfey'|
'School of abjuration'|
'School of conjuration'|
'School of divination'|
'School of enchantment'|
'School of evocation'|
'School of illusion'|
'School of necromancy'|
'School of transmutation');
SKILL:
'Acrobatics' |
'Animal Handling' |
'Arcana'|
'Athletics'|
'Deception' |
'History' |
'Insight' |
'Intimidation' |
'Investigation' |
'Medicine'|
'Nature' |
'Perception' |
'Performance'|
'Persuasion' |
'Religion' |
'Sleight of Hand' |
'Stealth' |
'Survival';
BACKGROUND:
'Acolyte' |
'Charlatan'|
'Criminal'|
'Entertainer'|
'Folk Hero'|
'Gladiator'|
'Guild Artisan'|
'Guild Merchant'|
'Hermit'|
'Knight'|
'Noble'|
'Outlander'|
'Pirate'|
'Sage'|
'Sailor'|
'Soldier'|
'Spy'|
'Urchin';
LANGUAGE: 'Common' | 'Draconic' | 'Infernal' | 'Dwarvish' | 'Elvish' | 'Gnomish' | 'Orc' | 'Halfling' ;
RACES : ('Dragonborn'|'Dwarf'|'Elf'|'Gnome' | 'Half Elf'| 'Halfling'|'Half Orc'|'Human'|'Tiefling');
OPTIONAL : ('Description' | 'Level' | 'Background' | 'Items' | 'Active Equipment');
ACCENT : ('\u00e1' | '\u00c1' |
'\u00e9' | '\u00c9' |
'\u00ed'| '\u00cd'|
'\u00f3' |'\u00d3'|
'\u00fa'| '\u00da' |
'\u00e0' |'\u00c0'|
'\u00e8' |'\u00c8'|
'\u00ec' |'\u00cc'|
'\u00f2' |'\u00d2'|
'\u00f9' |'\u00d9'
);
LETTER : ('a'..'z'|'A'..'Z')+ ;
optionalValue : (description | DIGIT | BACKGROUND | LETTER);
toSet : (PGCLASS);
description : '"'(.*? | ACCENT)'"';
piece: (ARMOR | WEAPON | SHIELD | CONSUMABLES);
pieceValue: (ARMORTYPE | WEAPONTYPE | SHIELDPRESENCE | consumableVector );
consumableVector: NONE |('(' consumableVectorElem ')' );
consumableVectorElem: (CONSUMABLE '*' DIGIT',' consumableVectorElem | CONSUMABLE '*' DIGIT);
value : (RACES | DIGIT | classVector | abilities |ALIGNMENT | skills | languages);
classVector: ('(' classVectorElem ')' );
classVectorElem: (PGCLASS ('->' SUBCLASS)? ',' classVectorElem | PGCLASS ('->' SUBCLASS)?);
abilities: '(' DIGIT ',' DIGIT ',' DIGIT ',' DIGIT ',' DIGIT ',' DIGIT ')';
skills: '(' SKILL ',' SKILL (',' SKILL)? (',' SKILL)? (',' SKILL)?')';
languages: '('(LANGUAGE)? (',' LANGUAGE)? (',' LANGUAGE)?')';
mandatory: ( RACE | HP | ARCHTYPE | ABILITY | ALIGN | SKILLSID | LANG | statID);
statID : (STR | DEX | INT | CHA | CON | WIS);
pgDefition : CREATE BLANKSPACE PLAYER BLANKSPACE LETTER STARTENTITY BL
property BL property BL property BL property BL property BL property BL property (BL property BL property BL property BL property BL property)?
BL ENDENTITY;
equipDefinition: CREATE BLANKSPACE EQUIPMENT BLANKSPACE LETTER STARTENTITY BL
equipPiece BL equipPiece BL equipPiece BL equipPiece
BL ENDENTITY;
equipPiece: (BLANKSPACE)* piece (BLANKSPACE)* COLON (BLANKSPACE)* pieceValue;
property: (BLANKSPACE)* mandatory (BLANKSPACE)* COLON (BLANKSPACE)* value;
importData: IMPORT BLANKSPACE LETTER BLANKSPACE FROM BLANKSPACE LETTER;
entity : (pgDefition | equipDefinition);
setting : SET BLANKSPACE OPTIONAL BLANKSPACE (OF BLANKSPACE toSet BLANKSPACE)? FOR BLANKSPACE LETTER (BLANKSPACE)*'='(BLANKSPACE)* optionalValue;
line : ((entity | importData | setting) BL) |BL;
start : (line)+EOF;