df_ls_structure 0.3.0-rc.1

A language server for Dwarf Fortress RAW files
Documentation
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
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
use df_ls_core::{Choose, Clamp, Reference, ReferenceTo};
use df_ls_lexical_analysis::test_utils::LexerTestBuilder;
use df_ls_structure::*;
use df_ls_syntax_analysis::test_utils::SyntaxTestBuilder;

#[test]
fn test_entity() {
    SyntaxTestBuilder::from_lexer_test_builder(
        LexerTestBuilder::test_source(
            "entity_default

            [OBJECT:ENTITY]

            [ENTITY:TEST]
                [SITE_CONTROLLABLE]
                [ALL_MAIN_POPS_CONTROLLABLE]
                [CREATURE:DWARF]
                [CREATURE:CRAB_MAN]
                [TRANSLATION:DWARF]
                [DIGGER:ITEM_WEAPON_PICK]
                [WEAPON:ITEM_WEAPON_AXE_BATTLE:COMMON]
                [WEAPON:ITEM_WEAPON_CROSSBOW]
                    [AMMO:ITEM_AMMO_BOLTS]
                [ARMOR:ITEM_ARMOR_BREASTPLATE:COMMON]
                [ARMOR:ITEM_ARMOR_MAIL_SHIRT:COMMON]
                [HELM:ITEM_HELM_HELM:COMMON]
                [HELM:ITEM_HELM_CAP]
                [GLOVES:ITEM_GLOVES_GAUNTLETS:COMMON]
                [GLOVES:ITEM_GLOVES_GLOVES]
                [SHOES:ITEM_SHOES_SHOES:COMMON]
                [SHOES:ITEM_SHOES_BOOTS]
                [PANTS:ITEM_PANTS_PANTS:COMMON]
                [PANTS:ITEM_PANTS_GREAVES]
                [SHIELD:ITEM_SHIELD_SHIELD]
                [SHIELD:ITEM_SHIELD_BUCKLER]
                [SIEGEAMMO:ITEM_SIEGEAMMO_BALLISTA]
                [SIEGEAMMO:ITEM_SIEGEAMMO_SHARK_LAZORS]
                [TRAPCOMP:ITEM_TRAPCOMP_GIANTAXEBLADE]
                [TRAPCOMP:ITEM_TRAPCOMP_ENORMOUSCORKSCREW]
                [TOY:ITEM_TOY_PUZZLEBOX]
                [TOY:ITEM_TOY_BOAT]
                [CLOTHING]
                [SUBTERRANEAN_CLOTHING]
                [CURRENCY_BY_YEAR]
                [CURRENCY:COPPER:1]
                [CURRENCY:GOLD:10000]
                [SELECT_SYMBOL:WAR:NAME_WAR]
                [SUBSELECT_SYMBOL:WAR:VIOLENT]
                [SELECT_SYMBOL:BATTLE:NAME_BATTLE]
                [SUBSELECT_SYMBOL:BATTLE:VIOLENT]
                [CULL_SYMBOL:ALL:EVIL]
                [CULL_SYMBOL:ALL:FLOWERY]
                [EQUIPMENT_IMPROVEMENTS]
                [ITEM_IMPROVEMENT_MODIFIER:RINGS_HANGING:64]
                [ITEM_IMPROVEMENT_MODIFIER:SPIKES:384]
                [FRIENDLY_COLOR:1:0:1]
                [DEFAULT_SITE_TYPE:CAVE_DETAILED]
                [LIKES_SITE:CAVE_DETAILED]
                [TOLERATES_SITE:CITY]
                [TOLERATES_SITE:CAVE_DETAILED]
                [EXCLUSIVE_START_BIOME:MOUNTAIN]
                [SETTLEMENT_BIOME:ANY_FOREST]
                [SETTLEMENT_BIOME:MOUNTAIN]
                [BIOME_SUPPORT:MOUNTAIN:3]
                [BIOME_SUPPORT:ANY_RIVER:1]
                [ACTIVE_SEASON:AUTUMN]
                [SIEGER]
                [MAX_STARTING_CIV_NUMBER:100]
                [MAX_POP_NUMBER:10000]
                [MAX_SITE_POP_NUMBER:120]
                [RELIGION:PANTHEON]
                [RELIGION_SPHERE:FORTRESSES]
                [RELIGION_SPHERE:OCEANS]
                can also use SCHOLAR:ALL
                [SCHOLAR:PHILOSOPHER]
                [SCHOLAR:MATHEMATICIAN]
                [PERMITTED_JOB:MINER]
                [PERMITTED_JOB:CARPENTER]
                [PERMITTED_BUILDING:SOAP_MAKER]
                [PERMITTED_BUILDING:SCREW_PRESS]
                [PERMITTED_REACTION:TAN_A_HIDE]
                [PERMITTED_REACTION:RENDER_FAT]
                [WORLD_CONSTRUCTION:TUNNEL]
                [WORLD_CONSTRUCTION:BRIDGE]
                [WORLD_CONSTRUCTION:ROAD]
                [ETHIC:KILL_ENTITY_MEMBER:PUNISH_CAPITAL]
                [ETHIC:KILL_NEUTRAL:ONLY_IF_SANCTIONED]
                [ETHIC:KILL_ENEMY:ACCEPTABLE]
                [VALUE:LAW:50]
                [VALUE:LOYALTY:0]
                [VALUE:FAMILY:-50]
                [WILL_ACCEPT_TRIBUTE]
                [STONE_SHAPE:OVAL_CABOCHON]
                [STONE_SHAPE:ROUND_CABOCHON]
                [GEM_SHAPE:OVAL_CABOCHON]
                [GEM_SHAPE:ROUND_CABOCHON]

                [LAND_HOLDER_TRIGGER:1:20:10000:100000]
                [LAND_HOLDER_TRIGGER:2:20:20000:200000]
                [LAND_HOLDER_TRIGGER:3:20:30000:300000]

                ---- Positions ----
                [POSITION:MONARCH]
                    [NAME_MALE:king:kings]
                    [NAME_FEMALE:queen:queens]
                    [NUMBER:1]
                    [SPOUSE_MALE:king consort:kings consort]
                    [SPOUSE_FEMALE:queen consort:queens consort]
                    [SUCCESSION:BY_HEIR]
                    [RESPONSIBILITY:LAW_MAKING]
                    [RESPONSIBILITY:RECEIVE_DIPLOMATS]
                    [RESPONSIBILITY:MILITARY_GOALS]
                    [PRECEDENCE:1]
                    [CHAT_WORTHY]
                    [DO_NOT_CULL]
                    [KILL_QUEST]
                    [EXPORTED_IN_LEGENDS]
                    [DETERMINES_COIN_DESIGN]
                    [COLOR:5:0:1]
                    [ACCOUNT_EXEMPT]
                    [DUTY_BOUND]
                    [DEMAND_MAX:10]
                    [MANDATE_MAX:5]
                    [REQUIRED_BOXES:10]
                    [REQUIRED_CABINETS:5]
                    [REQUIRED_RACKS:5]
                    [REQUIRED_STANDS:5]
                    [REQUIRED_OFFICE:10000]
                    [REQUIRED_BEDROOM:10000]
                    [REQUIRED_DINING:10000]
                    [REQUIRED_TOMB:10000]
                [POSITION:LIEUTENANT]
                    [NAME:lieutenant:lieutenants]
                    [NUMBER:AS_NEEDED]
                    [SQUAD:10:soldier:soldiers]
                    [APPOINTED_BY:MONARCH]
                    [COMMANDER:CAPTAIN:ALL]
                    [SUCCESSION:BY_POSITION:GENERAL]
                    [PRECEDENCE:100]

                ---- Tissue Styles ----
                [TISSUE_STYLE:MOUSTACHE]
                    [TS_MAINTAIN_LENGTH:100:NONE]
                    [TS_PREFERRED_SHAPING:STANDARD_MOUSTACHE_SHAPINGS]
                [TISSUE_STYLE:BEARD]
                    [TS_MAINTAIN_LENGTH:100:NONE]
                    [TS_PREFERRED_SHAPING:STANDARD_BEARD_SHAPINGS]

                ---- Animals ----
                [ANIMAL]
                    [ANIMAL_CLASS:CRUSTACEAN]
                    [ANIMAL_FORBIDDEN_CLASS:LOBSTER]
                    [ANIMAL_FORBIDDEN_CLASS:HERMIT]
                    [ANIMAL_NEVER_MOUNT]
                [ANIMAL]
                    [ANIMAL_CLASS:REPTILE]
            ",
        )
        .add_test_lexer_diagnostics_codes(vec![])
        .add_test_lexer_diagnostics_ranges(vec![]),
    )
    .add_test_structure(DFRaw {
        header: "entity_default".to_owned(),
        token_structure: vec![ObjectToken {
            entity_tokens: vec![EntityToken {
                reference: Some(ReferenceTo::new("TEST".to_owned())),
                animal: vec![
                    Animal {
                        reference: Some(()),
                        animal_class: vec![Reference("CRUSTACEAN".to_owned())],
                        animal_forbidden_class: vec![
                            Reference("LOBSTER".to_owned()),
                            Reference("HERMIT".to_owned()),
                        ],
                        animal_never_mount: Some(()),
                        ..Default::default()
                    },
                    Animal {
                        reference: Some(()),
                        animal_class: vec![Reference("REPTILE".to_owned())],
                        ..Default::default()
                    },
                ],
                tissue_style: vec![
                    TissueStyle {
                        reference: Some(ReferenceTo::new("MOUSTACHE".to_owned())),
                        ts_maintain_length: Some((
                            Choose::Choice1(100),
                            Choose::Choice2(NoneEnum::None),
                        )),
                        ts_preferred_shaping: vec![StylingEnum::StandardMoustacheShapings],
                    },
                    TissueStyle {
                        reference: Some(ReferenceTo::new("BEARD".to_owned())),
                        ts_maintain_length: Some((
                            Choose::Choice1(100),
                            Choose::Choice2(NoneEnum::None),
                        )),
                        ts_preferred_shaping: vec![StylingEnum::StandardBeardShapings],
                    },
                ],
                all_main_pops_controllable: Some(()),
                site_controllable: Some(()),
                creature: vec![
                    ReferenceTo::new("DWARF".to_owned()),
                    ReferenceTo::new("CRAB_MAN".to_owned()),
                ],
                biome_support: vec![(BiomeEnum::Mountain, 3), (BiomeEnum::AnyRiver, 1)],
                settlement_biome: vec![BiomeEnum::AnyForest, BiomeEnum::Mountain],
                exclusive_start_biome: Some(BiomeEnum::Mountain),
                default_site_type: Some(SiteTypeEnum::CaveDetailed),
                likes_site: vec![SiteTypeEnum::CaveDetailed],
                tolerates_site: vec![SiteTypeEnum::City, SiteTypeEnum::CaveDetailed],
                world_construction: vec![
                    ConstructionEnum::Tunnel,
                    ConstructionEnum::Bridge,
                    ConstructionEnum::Road,
                ],
                max_pop_number: Some(10000),
                max_site_pop_number: Some(120),
                max_starting_civ_number: Some(100),
                permitted_building: vec![
                    ReferenceTo::new("SOAP_MAKER".to_owned()),
                    ReferenceTo::new("SCREW_PRESS".to_owned()),
                ],
                permitted_job: vec![UnitTypeEnum::Miner, UnitTypeEnum::Carpenter],
                permitted_reaction: vec![
                    ReferenceTo::new("TAN_A_HIDE".to_owned()),
                    ReferenceTo::new("RENDER_FAT".to_owned()),
                ],
                currency_by_year: Some(()),
                currency: vec![
                    (ReferenceTo::new("COPPER".to_owned()), 1),
                    (ReferenceTo::new("GOLD".to_owned()), 10000),
                ],
                item_improvement_modifier: vec![
                    (ItemImprovementModifierEnum::RingsHanging, Clamp::new(64)),
                    (ItemImprovementModifierEnum::Spikes, Clamp::new(384)),
                ],
                translation: Some(ReferenceTo::new("DWARF".to_owned())),
                select_symbol: vec![
                    (SymbolNounEnum::War, ReferenceTo::new("NAME_WAR".to_owned())),
                    (
                        SymbolNounEnum::Battle,
                        ReferenceTo::new("NAME_BATTLE".to_owned()),
                    ),
                ],
                subselect_symbol: vec![
                    (SymbolNounEnum::War, ReferenceTo::new("VIOLENT".to_owned())),
                    (
                        SymbolNounEnum::Battle,
                        ReferenceTo::new("VIOLENT".to_owned()),
                    ),
                ],
                cull_symbol: vec![
                    (SymbolNounEnum::All, ReferenceTo::new("EVIL".to_owned())),
                    (SymbolNounEnum::All, ReferenceTo::new("FLOWERY".to_owned())),
                ],
                friendly_color: Some((1, 0, 1)),
                religion: Some(ReligionTypeEnum::Pantheon),
                religion_sphere: vec![SphereEnum::Fortresses, SphereEnum::Oceans],
                position: vec![
                    EntityPosition {
                        reference: Some(Reference("MONARCH".to_owned())),
                        responsibility: vec![
                            Responsibility {
                                reference: Some(ResponsibilityEnum::LawMaking),
                                execution_skill: None,
                            },
                            Responsibility {
                                reference: Some(ResponsibilityEnum::ReceiveDiplomats),
                                execution_skill: None,
                            },
                            Responsibility {
                                reference: Some(ResponsibilityEnum::MilitaryGoals),
                                execution_skill: None,
                            },
                        ],
                        account_exempt: Some(()),
                        chat_worthy: Some(()),
                        color: Some((5, 0, 1)),
                        demand_max: Some(Clamp::new(10)),
                        determines_coin_design: Some(()),
                        do_not_cull: Some(()),
                        duty_bound: Some(()),
                        exported_in_legends: Some(()),
                        kill_quest: Some(()),
                        mandate_max: Some(5),
                        name_male: Some(("king".to_owned(), "kings".to_owned())),
                        name_female: Some(("queen".to_owned(), "queens".to_owned())),
                        number: Some(Choose::Choice1(1)),
                        precedence: Some(Clamp::new(1)),
                        required_bedroom: Some(Clamp::new(10000)),
                        required_boxes: Some(Clamp::new(10)),
                        required_cabinets: Some(Clamp::new(5)),
                        required_dining: Some(Clamp::new(10000)),
                        required_office: Some(Clamp::new(10000)),
                        required_racks: Some(Clamp::new(5)),
                        required_stands: Some(Clamp::new(5)),
                        required_tomb: Some(Clamp::new(10000)),
                        spouse_female: Some((
                            "queen consort".to_owned(),
                            "queens consort".to_owned(),
                        )),
                        spouse_male: Some(("king consort".to_owned(), "kings consort".to_owned())),
                        succession: Some((SuccessionTypeEnum::ByHeir, None)),
                        ..Default::default()
                    },
                    EntityPosition {
                        reference: Some(Reference("LIEUTENANT".to_owned())),
                        appointed_by: vec![Reference("MONARCH".to_owned())],
                        commander: Some((Reference("CAPTAIN".to_owned()), AllEnum::All)),
                        name: Some(("lieutenant".to_owned(), "lieutenants".to_owned())),
                        number: Some(Choose::Choice2(AsNeededEnum::AsNeeded)),
                        precedence: Some(Clamp::new(100)),
                        squad: Some((Clamp::new(10), "soldier".to_owned(), "soldiers".to_owned())),
                        succession: Some((
                            SuccessionTypeEnum::ByPosition,
                            Some(Reference("GENERAL".to_owned())),
                        )),
                        ..Default::default()
                    },
                ],
                land_holder_trigger: vec![
                    (1, 20, 10000, 100000),
                    (2, 20, 20000, 200000),
                    (3, 20, 30000, 300000),
                ],
                ethic: vec![
                    (
                        EthicTypeEnum::KillEntityMember,
                        EthicReactionEnum::PunishCapital,
                    ),
                    (
                        EthicTypeEnum::KillNeutral,
                        EthicReactionEnum::OnlyIfSanctioned,
                    ),
                    (EthicTypeEnum::KillEnemy, EthicReactionEnum::Acceptable),
                ],
                value: vec![
                    (CulturalValueEnum::Law, Clamp::new(50)),
                    (CulturalValueEnum::Loyalty, Clamp::new(0)),
                    (CulturalValueEnum::Family, Clamp::new(-50)),
                ],
                will_accept_tribute: Some(()),
                active_season: vec![SeasonEnum::Autumn],
                sieger: Some(()),
                scholar: vec![ScholarTypeEnum::Philosopher, ScholarTypeEnum::Mathematician],
                weapon: vec![
                    Weapon {
                        reference: Some((
                            ReferenceTo::new("ITEM_WEAPON_AXE_BATTLE".to_owned()),
                            Some(RarityEnum::Common),
                        )),
                        ammo: None,
                    },
                    Weapon {
                        reference: Some((
                            ReferenceTo::new("ITEM_WEAPON_CROSSBOW".to_owned()),
                            None,
                        )),
                        ammo: Some((ReferenceTo::new("ITEM_AMMO_BOLTS".to_owned()), None)),
                    },
                ],
                armor: vec![
                    (
                        ReferenceTo::new("ITEM_ARMOR_BREASTPLATE".to_owned()),
                        Some(RarityEnum::Common),
                    ),
                    (
                        ReferenceTo::new("ITEM_ARMOR_MAIL_SHIRT".to_owned()),
                        Some(RarityEnum::Common),
                    ),
                ],
                digger: vec![ReferenceTo::new("ITEM_WEAPON_PICK".to_owned())],
                gloves: vec![
                    (
                        ReferenceTo::new("ITEM_GLOVES_GAUNTLETS".to_owned()),
                        Some(RarityEnum::Common),
                    ),
                    (ReferenceTo::new("ITEM_GLOVES_GLOVES".to_owned()), None),
                ],
                helm: vec![
                    (
                        ReferenceTo::new("ITEM_HELM_HELM".to_owned()),
                        Some(RarityEnum::Common),
                    ),
                    (ReferenceTo::new("ITEM_HELM_CAP".to_owned()), None),
                ],
                pants: vec![
                    (
                        ReferenceTo::new("ITEM_PANTS_PANTS".to_owned()),
                        Some(RarityEnum::Common),
                    ),
                    (ReferenceTo::new("ITEM_PANTS_GREAVES".to_owned()), None),
                ],
                shield: vec![
                    ReferenceTo::new("ITEM_SHIELD_SHIELD".to_owned()),
                    ReferenceTo::new("ITEM_SHIELD_BUCKLER".to_owned()),
                ],
                shoes: vec![
                    (
                        ReferenceTo::new("ITEM_SHOES_SHOES".to_owned()),
                        Some(RarityEnum::Common),
                    ),
                    (ReferenceTo::new("ITEM_SHOES_BOOTS".to_owned()), None),
                ],
                siegeammo: vec![
                    ReferenceTo::new("ITEM_SIEGEAMMO_BALLISTA".to_owned()),
                    ReferenceTo::new("ITEM_SIEGEAMMO_SHARK_LAZORS".to_owned()),
                ],
                toy: vec![
                    ReferenceTo::new("ITEM_TOY_PUZZLEBOX".to_owned()),
                    ReferenceTo::new("ITEM_TOY_BOAT".to_owned()),
                ],
                trapcomp: vec![
                    ReferenceTo::new("ITEM_TRAPCOMP_GIANTAXEBLADE".to_owned()),
                    ReferenceTo::new("ITEM_TRAPCOMP_ENORMOUSCORKSCREW".to_owned()),
                ],
                clothing: Some(()),
                subterranean_clothing: Some(()),
                equipment_improvements: Some(()),
                gem_shape: vec![
                    ReferenceTo::new("OVAL_CABOCHON".to_owned()),
                    ReferenceTo::new("ROUND_CABOCHON".to_owned()),
                ],
                stone_shape: vec![
                    ReferenceTo::new("OVAL_CABOCHON".to_owned()),
                    ReferenceTo::new("ROUND_CABOCHON".to_owned()),
                ],
                ..Default::default()
            }],
            ..Default::default()
        }],
    })
    .add_test_syntax_diagnostics_codes(vec![])
    .add_test_syntax_diagnostics_ranges(vec![])
    .run_test();
}