Commit a83d745b62ea8ec89e939b00bb3754ad54280942

Pierre Le Marre 2023-09-21T20:06:27

Messages: add new messages to registry This commit is another step to identify and document the maximum number of logging messages. Bulk changes: - Rename `conflicting-key-type` to `conflicting-key-type-merging-groups`. Giving more context in the name allow us to introduce `conflicting-key-type-definitions` later. - Add conflicting-key-type-definitions - Add conflicting-key-type-map-entry - Add undeclared-modifiers-in-key-type Also improve the log messages. - Add conflicting-key-type-preserve-entries - Use XKB_ERROR_UNSUPPORTED_MODIFIER_MASK - Add illegal-key-type-preserve-result - Add conflicting-key-type-level-names - Add duplicate-entry - Add unsupported-symbols-field - Add missing-symbols-group-name-index - Use XKB_ERROR_WRONG_FIELD_TYPE - Add conflicting-key-name - Use XKB_WARNING_UNDEFINED_KEYCODE - Add illegal-keycode-alias - Add unsupported-geometry-section - Add missing-default-section - Add XKB_LOG_MESSAGE_NO_ID - Rename log_vrb_with_code to log_vrb - Use ERROR_WRONG_FIELD_TYPE & ERROR_INVALID_SYNTAX - Add unknown-identifier - Add invalid-expression-type - Add invalid-operation + fixes - Add unknown-operator - Rename ERROR_UNKNOWN_IDENTIFIER to ERROR_INVALID_IDENTIFIER - Add undeclared-virtual-modifier - Add expected-array-entry - Add invalid-include-statement - Add included-file-not-found - Add allocation-error - Add invalid-included-file - Process symbols.c - Add invalid-value - Add invalid-real-modifier - Add unknown-field - Add wrong-scope - Add invalid-modmap-entry - Add wrong-statement-type - Add conflicting-key-symbols-entry - Add invalid-set-default-statement

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
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
1918
1919
1920
1921
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1932
1933
1934
1935
1936
1937
1938
1939
1940
1941
1942
1943
1944
1945
1946
1947
1948
1949
1950
1951
1952
1953
1954
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
2027
2028
2029
2030
2031
2032
2033
2034
2035
2036
2037
2038
2039
2040
2041
2042
2043
2044
2045
2046
2047
2048
2049
2050
2051
2052
2053
2054
2055
2056
2057
2058
2059
2060
2061
2062
2063
2064
2065
2066
2067
2068
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
2090
2091
2092
2093
2094
2095
diff --git a/doc/message-registry.md b/doc/message-registry.md
index dac4175..a3be5c1 100644
--- a/doc/message-registry.md
+++ b/doc/message-registry.md
@@ -6,7 +6,7 @@ NOTE: This file has been generated automatically by “update-message-registry.p
 -->
 
 This page lists the warnings and errors generated by xkbcommon.
-There are currently 21 entries.
+There are currently 52 entries.
 
 @todo The documentation of the log messages is a work in progress.
 
@@ -15,26 +15,57 @@ There are currently 21 entries.
 | Code      | Identifier                   | Description | Type |
 | --------- | ---------------------------- | ----------- | ---- |
 | [XKB-034] | `malformed-number-literal` | Warn on malformed number literals | Error |
+| [XKB-043] | `conflicting-key-type-preserve-entries` | Conflicting “preserve” entries in a key type | Warning |
 | [XKB-060] | `unsupported-modifier-mask` | Warn on unsupported modifier mask | Error |
+| [XKB-077] | `expected-array-entry` | Expected an array entry, but the index is missing | Error |
+| [XKB-101] | `illegal-keycode-alias` | Illegal keycode alias with the name of a real key | Warning |
 | [XKB-107] | `unrecognized-keysym` | Warn on unrecognized keysyms | Warning |
+| [XKB-123] | `undeclared-virtual-modifier` | A virtual modifier is used before being declared | Error |
+| [XKB-150] | `wrong-statement-type` | The type of the statement is not allowed in the context | Error |
+| [XKB-172] | `unsupported-geometry-section` | Geometry sections are not supported | Warning |
 | [XKB-183] | `cannot-infer-key-type` | Warn if no key type can be inferred | Warning |
+| [XKB-195] | `illegal-key-type-preserve-result` | The result of a key type “preserve” entry must be a subset of its input modifiers. | Warning |
+| [XKB-203] | `invalid-include-statement` | Syntax error in the include statement | Error |
+| [XKB-206] | `invalid-modmap-entry` | A modmap entry is invalid | Error |
 | [XKB-237] | `unsupported-group-index` | Warn when a group index is not supported | Error |
+| [XKB-239] | `conflicting-key-type-level-names` | The name of a key type level is defined multiple times. | Warning |
+| [XKB-254] | `invalid-set-default-statement` | Invalid statement setting default values | Error |
+| [XKB-266] | `conflicting-key-type-map-entry` | Conflicting “map” entries in type definition | Warning |
 | [XKB-286] | `undefined-key-type` | Warn if using an undefined key type | Warning |
 | [XKB-305] | `non-base-group-name` | Warn if a group name was defined for group other than the first one | Warning |
 | [XKB-312] | `unsupported-shift-level` | Warn when a shift level is not supported | Error |
+| [XKB-338] | `included-file-not-found` | Could not find a file used in an include statement | Error |
+| [XKB-345] | `unknown-operator` | Use of an operator that is unknown and thus unsupported | Error |
+| [XKB-378] | `duplicate-entry` | An entry is duplicated and will be ignored | Warning |
+| [XKB-407] | `conflicting-key-type-definitions` | Conflicting definitions of a key type | Warning |
+| [XKB-428] | `wrong-scope` | A statement is in a wrong scope and should be moved | Error |
+| [XKB-433] | `missing-default-section` | Missing default section in included file | Warning |
 | [XKB-461] | `conflicting-key-symbol` | Warn if there are conflicting keysyms while merging keys | Warning |
+| [XKB-478] | `invalid-operation` | The operation is invalid in the context | Error |
 | [XKB-489] | `numeric-keysym` | Warn on numeric keysym (other than 0-9) | Warning |
 | [XKB-516] | `extra-symbols-ignored` | <span class="todo">TODO:</span> add description | Warning |
+| [XKB-523] | `conflicting-key-name` | Conflicting definitions of a key name or alias | Warning |
+| [XKB-550] | `allocation-error` | Cannot allocate memory | Error |
 | [XKB-578] | `wrong-field-type` | Warn when a field has not the expected type | Error |
+| [XKB-623] | `invalid-real-modifier` | Invalid _real_ modifier | Error |
 | [XKB-645] | `unknown-char-escape-sequence` | Warn on unknown escape sequence in string literal | Warning |
+| [XKB-661] | `invalid-included-file` | The target file of an include statement could not be processed | Error |
 | [XKB-700] | `multiple-groups-at-once` | Warn if a key defines multiple groups at once | Warning |
+| [XKB-711] | `unsupported-symbols-field` | A legacy X11 symbol field is not supported | Warning |
 | [XKB-769] | `invalid-syntax` | The syntax is invalid and the file cannot be parsed | Error |
-| [XKB-770] | `undefined-keycode` | <span class="todo">TODO:</span> add description | Warning |
+| [XKB-770] | `undefined-keycode` | Reference to an undefined keycode | Warning |
+| [XKB-784] | `invalid-expression-type` | An expression has not the expected type | Error |
+| [XKB-796] | `invalid-value` | A value is invalid and will be ignored | Error |
 | [XKB-800] | `conflicting-modmap` | Warn if there are conflicting modmap definitions | Warning |
+| [XKB-812] | `unknown-field` | A field is unknown and will be ignored | Error |
 | [XKB-883] | `conflicting-key-action` | Warn if there are conflicting actions while merging keys | Warning |
-| [XKB-893] | `conflicting-key-type` | Warn if there are conflicting key types while merging groups | Warning |
+| [XKB-893] | `conflicting-key-type-merging-groups` | Warn if there are conflicting key types while merging groups | Warning |
+| [XKB-901] | `conflicting-key-symbols-entry` | Conflicting symbols entry for a key | Error |
+| [XKB-903] | `missing-symbols-group-name-index` | Missing group index in a group name entry | Warning |
 | [XKB-935] | `conflicting-key-fields` | Warn if there are conflicting fields while merging keys | Warning |
+| [XKB-949] | `invalid-identifier` | An identifier is used but is not built-in | Error |
 | [XKB-965] | `unresolved-keymap-symbol` | Warn if using a symbol not defined in the keymap | Warning |
+| [XKB-971] | `undeclared-modifiers-in-key-type` | Some modifiers used in a key type “map” or “preserve” entry are not declared | Warning |
 
 ## Details
 
@@ -53,6 +84,14 @@ xkbcommon can parse the following number literal formats:
 - *hexadecimal integer:* prefixed with “0x”: 0x123, 0xff, 0xAB, etc.
 
 
+### XKB-043 – Conflicting key type preserve entries {#XKB-043}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Warning</dd>
+  <dt>Summary</dt><dd>Conflicting “preserve” entries in a key type</dd>
+</dl>
+
 ### XKB-060 – Unsupported modifier mask {#XKB-060}
 
 <dl>
@@ -61,6 +100,22 @@ xkbcommon can parse the following number literal formats:
   <dt>Summary</dt><dd>Warn on unsupported modifier mask</dd>
 </dl>
 
+### XKB-077 – Expected array entry {#XKB-077}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>Expected an array entry, but the index is missing</dd>
+</dl>
+
+### XKB-101 – Illegal keycode alias {#XKB-101}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Warning</dd>
+  <dt>Summary</dt><dd>Illegal keycode alias with the name of a real key</dd>
+</dl>
+
 ### XKB-107 – Unrecognized keysym {#XKB-107}
 
 <dl>
@@ -111,6 +166,30 @@ key <AB08> {[ comma, semicolon, periodcentered, multiply ]};
   </div>
 </details>
 
+### XKB-123 – Undeclared virtual modifier {#XKB-123}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>A virtual modifier is used before being declared</dd>
+</dl>
+
+### XKB-150 – Wrong statement type {#XKB-150}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>The type of the statement is not allowed in the context</dd>
+</dl>
+
+### XKB-172 – Unsupported geometry section {#XKB-172}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Warning</dd>
+  <dt>Summary</dt><dd>Geometry sections are not supported</dd>
+</dl>
+
 ### XKB-183 – Cannot infer key type {#XKB-183}
 
 <dl>
@@ -119,6 +198,30 @@ key <AB08> {[ comma, semicolon, periodcentered, multiply ]};
   <dt>Summary</dt><dd>Warn if no key type can be inferred</dd>
 </dl>
 
+### XKB-195 – Illegal key type preserve result {#XKB-195}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Warning</dd>
+  <dt>Summary</dt><dd>The result of a key type “preserve” entry must be a subset of its input modifiers.</dd>
+</dl>
+
+### XKB-203 – Invalid include statement {#XKB-203}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>Syntax error in the include statement</dd>
+</dl>
+
+### XKB-206 – Invalid modmap entry {#XKB-206}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>A modmap entry is invalid</dd>
+</dl>
+
 ### XKB-237 – Unsupported group index {#XKB-237}
 
 <dl>
@@ -130,6 +233,30 @@ key <AB08> {[ comma, semicolon, periodcentered, multiply ]};
 xkbcommon supports group index in the range (1..4).
 
 
+### XKB-239 – Conflicting key type level names {#XKB-239}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Warning</dd>
+  <dt>Summary</dt><dd>The name of a key type level is defined multiple times.</dd>
+</dl>
+
+### XKB-254 – Invalid set default statement {#XKB-254}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>Invalid statement setting default values</dd>
+</dl>
+
+### XKB-266 – Conflicting key type map entry {#XKB-266}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Warning</dd>
+  <dt>Summary</dt><dd>Conflicting “map” entries in type definition</dd>
+</dl>
+
 ### XKB-286 – Undefined key type {#XKB-286}
 
 <dl>
@@ -158,6 +285,66 @@ Shift levels are _one_-indexed. xkbcommon supports two formats of shift levels:
 as numbers and as identifiers `LevelN`, where `N` is in the range (1..8).
 
 
+### XKB-338 – Included file not found {#XKB-338}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>Could not find a file used in an include statement</dd>
+</dl>
+
+### XKB-345 – Unknown operator {#XKB-345}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>Use of an operator that is unknown and thus unsupported</dd>
+</dl>
+
+### XKB-378 – Duplicate entry {#XKB-378}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Warning</dd>
+  <dt>Summary</dt><dd>An entry is duplicated and will be ignored</dd>
+</dl>
+
+### XKB-407 – Conflicting key type definitions {#XKB-407}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Warning</dd>
+  <dt>Summary</dt><dd>Conflicting definitions of a key type</dd>
+</dl>
+
+The given key type is defined multiple times, but only one definition is kept.
+
+
+### XKB-428 – Wrong scope {#XKB-428}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>A statement is in a wrong scope and should be moved</dd>
+</dl>
+
+### XKB-433 – Missing default section {#XKB-433}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Warning</dd>
+  <dt>Summary</dt><dd>Missing default section in included file</dd>
+</dl>
+
+When using an include statement, the included file may contains multiple sections.
+The include statement may specify the name of the section to include, or leave it
+unspecified. In the latter case, the included file must then define a *default* section.
+The present warning is shown when no default section is defined.
+
+To solve this, either fix the include statement by specifying the exact section to
+include, or declare a default section in the included file.
+
+
 ### XKB-461 – Conflicting key symbol {#XKB-461}
 
 <dl>
@@ -166,6 +353,14 @@ as numbers and as identifiers `LevelN`, where `N` is in the range (1..8).
   <dt>Summary</dt><dd>Warn if there are conflicting keysyms while merging keys</dd>
 </dl>
 
+### XKB-478 – Invalid operation {#XKB-478}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>The operation is invalid in the context</dd>
+</dl>
+
 ### XKB-489 – Numeric keysym {#XKB-489}
 
 <dl>
@@ -221,6 +416,22 @@ key <AE01> { [ U1ED0 ] };
   <dt>Summary</dt><dd><span class="todo">TODO:</span> add description</dd>
 </dl>
 
+### XKB-523 – Conflicting key name {#XKB-523}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Warning</dd>
+  <dt>Summary</dt><dd>Conflicting definitions of a key name or alias</dd>
+</dl>
+
+### XKB-550 – Allocation error {#XKB-550}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>Cannot allocate memory</dd>
+</dl>
+
 ### XKB-578 – Wrong field type {#XKB-578}
 
 <dl>
@@ -229,6 +440,14 @@ key <AE01> { [ U1ED0 ] };
   <dt>Summary</dt><dd>Warn when a field has not the expected type</dd>
 </dl>
 
+### XKB-623 – Invalid real modifier {#XKB-623}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>Invalid _real_ modifier</dd>
+</dl>
+
 ### XKB-645 – Unknown char escape sequence {#XKB-645}
 
 <dl>
@@ -252,6 +471,14 @@ xkbcommon support the following escape sequences in string literals:
 | `\NNN`          | _Octal_ escape, from `\0` to `\777` |
 
 
+### XKB-661 – Invalid included file {#XKB-661}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>The target file of an include statement could not be processed</dd>
+</dl>
+
 ### XKB-700 – Multiple groups at once {#XKB-700}
 
 <dl>
@@ -260,6 +487,14 @@ xkbcommon support the following escape sequences in string literals:
   <dt>Summary</dt><dd>Warn if a key defines multiple groups at once</dd>
 </dl>
 
+### XKB-711 – Unsupported symbols field {#XKB-711}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Warning</dd>
+  <dt>Summary</dt><dd>A legacy X11 symbol field is not supported</dd>
+</dl>
+
 ### XKB-769 – Invalid syntax {#XKB-769}
 
 <dl>
@@ -273,7 +508,23 @@ xkbcommon support the following escape sequences in string literals:
 <dl>
   <dt>Since</dt><dd>1.0.0</dd>
   <dt>Type</dt><dd>Warning</dd>
-  <dt>Summary</dt><dd><span class="todo">TODO:</span> add description</dd>
+  <dt>Summary</dt><dd>Reference to an undefined keycode</dd>
+</dl>
+
+### XKB-784 – Invalid expression type {#XKB-784}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>An expression has not the expected type</dd>
+</dl>
+
+### XKB-796 – Invalid value {#XKB-796}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>A value is invalid and will be ignored</dd>
 </dl>
 
 ### XKB-800 – Conflicting modmap {#XKB-800}
@@ -287,6 +538,14 @@ xkbcommon support the following escape sequences in string literals:
 @todo detailed explanation and examples
 
 
+### XKB-812 – Unknown field {#XKB-812}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>A field is unknown and will be ignored</dd>
+</dl>
+
 ### XKB-883 – Conflicting key action {#XKB-883}
 
 <dl>
@@ -295,7 +554,7 @@ xkbcommon support the following escape sequences in string literals:
   <dt>Summary</dt><dd>Warn if there are conflicting actions while merging keys</dd>
 </dl>
 
-### XKB-893 – Conflicting key type {#XKB-893}
+### XKB-893 – Conflicting key type merging groups {#XKB-893}
 
 <dl>
   <dt>Since</dt><dd>1.0.0</dd>
@@ -303,6 +562,22 @@ xkbcommon support the following escape sequences in string literals:
   <dt>Summary</dt><dd>Warn if there are conflicting key types while merging groups</dd>
 </dl>
 
+### XKB-901 – Conflicting key symbols entry {#XKB-901}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>Conflicting symbols entry for a key</dd>
+</dl>
+
+### XKB-903 – Missing symbols group name index {#XKB-903}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Warning</dd>
+  <dt>Summary</dt><dd>Missing group index in a group name entry</dd>
+</dl>
+
 ### XKB-935 – Conflicting key fields {#XKB-935}
 
 <dl>
@@ -311,6 +586,14 @@ xkbcommon support the following escape sequences in string literals:
   <dt>Summary</dt><dd>Warn if there are conflicting fields while merging keys</dd>
 </dl>
 
+### XKB-949 – Invalid identifier {#XKB-949}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Error</dd>
+  <dt>Summary</dt><dd>An identifier is used but is not built-in</dd>
+</dl>
+
 ### XKB-965 – Unresolved keymap symbol {#XKB-965}
 
 <dl>
@@ -319,24 +602,67 @@ xkbcommon support the following escape sequences in string literals:
   <dt>Summary</dt><dd>Warn if using a symbol not defined in the keymap</dd>
 </dl>
 
+### XKB-971 – Undeclared modifiers in key type {#XKB-971}
+
+<dl>
+  <dt>Since</dt><dd>1.0.0</dd>
+  <dt>Type</dt><dd>Warning</dd>
+  <dt>Summary</dt><dd>Some modifiers used in a key type “map” or “preserve” entry are not declared</dd>
+</dl>
+
+The modifiers used in `map` or `preserve` entries should be declared using the entry
+`modifiers` in the key type.
+
+
 [XKB-034]: @ref XKB-034
+[XKB-043]: @ref XKB-043
 [XKB-060]: @ref XKB-060
+[XKB-077]: @ref XKB-077
+[XKB-101]: @ref XKB-101
 [XKB-107]: @ref XKB-107
+[XKB-123]: @ref XKB-123
+[XKB-150]: @ref XKB-150
+[XKB-172]: @ref XKB-172
 [XKB-183]: @ref XKB-183
+[XKB-195]: @ref XKB-195
+[XKB-203]: @ref XKB-203
+[XKB-206]: @ref XKB-206
 [XKB-237]: @ref XKB-237
+[XKB-239]: @ref XKB-239
+[XKB-254]: @ref XKB-254
+[XKB-266]: @ref XKB-266
 [XKB-286]: @ref XKB-286
 [XKB-305]: @ref XKB-305
 [XKB-312]: @ref XKB-312
+[XKB-338]: @ref XKB-338
+[XKB-345]: @ref XKB-345
+[XKB-378]: @ref XKB-378
+[XKB-407]: @ref XKB-407
+[XKB-428]: @ref XKB-428
+[XKB-433]: @ref XKB-433
 [XKB-461]: @ref XKB-461
+[XKB-478]: @ref XKB-478
 [XKB-489]: @ref XKB-489
 [XKB-516]: @ref XKB-516
+[XKB-523]: @ref XKB-523
+[XKB-550]: @ref XKB-550
 [XKB-578]: @ref XKB-578
+[XKB-623]: @ref XKB-623
 [XKB-645]: @ref XKB-645
+[XKB-661]: @ref XKB-661
 [XKB-700]: @ref XKB-700
+[XKB-711]: @ref XKB-711
 [XKB-769]: @ref XKB-769
 [XKB-770]: @ref XKB-770
+[XKB-784]: @ref XKB-784
+[XKB-796]: @ref XKB-796
 [XKB-800]: @ref XKB-800
+[XKB-812]: @ref XKB-812
 [XKB-883]: @ref XKB-883
 [XKB-893]: @ref XKB-893
+[XKB-901]: @ref XKB-901
+[XKB-903]: @ref XKB-903
 [XKB-935]: @ref XKB-935
+[XKB-949]: @ref XKB-949
 [XKB-965]: @ref XKB-965
+[XKB-971]: @ref XKB-971
diff --git a/doc/message-registry.yaml b/doc/message-registry.yaml
index f7e0c2e..880c2f6 100644
--- a/doc/message-registry.yaml
+++ b/doc/message-registry.yaml
@@ -30,11 +30,26 @@
     - *decimal integer:* 1, 123, etc.
     - *decimal floating-point number:* 1.23, etc.
     - *hexadecimal integer:* prefixed with “0x”: 0x123, 0xff, 0xAB, etc.
+- id: "conflicting-key-type-preserve-entries"
+  code: 43
+  added: ALWAYS
+  type: warning
+  description: "Conflicting “preserve” entries in a key type"
 - id: "unsupported-modifier-mask"
   code: 60
   added: ALWAYS
   type: error
   description: "Warn on unsupported modifier mask"
+- id: "expected-array-entry"
+  code: 77
+  added: ALWAYS
+  type: error
+  description: "Expected an array entry, but the index is missing"
+- id: "illegal-keycode-alias"
+  code: 101
+  added: ALWAYS
+  type: warning
+  description: "Illegal keycode alias with the name of a real key"
 - id: "unrecognized-keysym"
   code: 107
   added: ALWAYS
@@ -65,11 +80,41 @@
         ```c
         key <AB08> {[ comma, semicolon, periodcentered, multiply ]};
         ```
+- id: "undeclared-virtual-modifier"
+  code: 123
+  added: ALWAYS
+  type: error
+  description: "A virtual modifier is used before being declared"
+- id: "wrong-statement-type"
+  code: 150
+  added: ALWAYS
+  type: error
+  description: "The type of the statement is not allowed in the context"
+- id: "unsupported-geometry-section"
+  code: 172
+  added: ALWAYS
+  type: warning
+  description: "Geometry sections are not supported"
 - id: "cannot-infer-key-type"
   code: 183
   added: ALWAYS
   type: warning
   description: "Warn if no key type can be inferred"
+- id: "illegal-key-type-preserve-result"
+  code: 195
+  added: ALWAYS
+  type: warning
+  description: "The result of a key type “preserve” entry must be a subset of its input modifiers."
+- id: "invalid-include-statement"
+  code: 203
+  added: ALWAYS
+  type: error
+  description: "Syntax error in the include statement"
+- id: "invalid-modmap-entry"
+  code: 206
+  added: ALWAYS
+  type: error
+  description: "A modmap entry is invalid"
 - id: "unsupported-group-index"
   code: 237
   added: ALWAYS
@@ -77,6 +122,21 @@
   description: "Warn when a group index is not supported"
   details: |
     xkbcommon supports group index in the range (1..{{XKB_MAX_GROUPS}}).
+- id: "conflicting-key-type-level-names"
+  code: 239
+  added: ALWAYS
+  type: warning
+  description: "The name of a key type level is defined multiple times."
+- id: "invalid-set-default-statement"
+  code: 254
+  added: ALWAYS
+  type: error
+  description: "Invalid statement setting default values"
+- id: "conflicting-key-type-map-entry"
+  code: 266
+  added: ALWAYS
+  type: warning
+  description: "Conflicting “map” entries in type definition"
 - id: "undefined-key-type"
   code: 286
   added: ALWAYS
@@ -95,11 +155,56 @@
   details: |
     Shift levels are _one_-indexed. xkbcommon supports two formats of shift levels:
     as numbers and as identifiers `LevelN`, where `N` is in the range (1..8).
+- id: "included-file-not-found"
+  code: 338
+  added: ALWAYS
+  type: error
+  description: "Could not find a file used in an include statement"
+- id: "unknown-operator"
+  code: 345
+  added: ALWAYS
+  type: error
+  description: "Use of an operator that is unknown and thus unsupported"
+- id: "duplicate-entry"
+  code: 378
+  added: ALWAYS
+  type: warning
+  description: "An entry is duplicated and will be ignored"
+- id: "conflicting-key-type-definitions"
+  code: 407
+  added: ALWAYS
+  type: warning
+  description: "Conflicting definitions of a key type"
+  details: |
+    The given key type is defined multiple times, but only one definition is kept.
+- id: "wrong-scope"
+  code: 428
+  added: ALWAYS
+  type: error
+  description: "A statement is in a wrong scope and should be moved"
+- id: "missing-default-section"
+  code: 433
+  added: ALWAYS
+  type: warning
+  description: "Missing default section in included file"
+  details: |
+    When using an include statement, the included file may contains multiple sections.
+    The include statement may specify the name of the section to include, or leave it
+    unspecified. In the latter case, the included file must then define a *default* section.
+    The present warning is shown when no default section is defined.
+
+    To solve this, either fix the include statement by specifying the exact section to
+    include, or declare a default section in the included file.
 - id: "conflicting-key-symbol"
   code: 461
   added: ALWAYS
   type: warning
   description: "Warn if there are conflicting keysyms while merging keys"
+- id: "invalid-operation"
+  code: 478
+  added: ALWAYS
+  type: error
+  description: "The operation is invalid in the context"
 - id: "numeric-keysym"
   code: 489
   added: 1.6.0
@@ -132,11 +237,26 @@
   added: ALWAYS
   type: warning
   description: "TODO: add description"
+- id: "conflicting-key-name"
+  code: 523
+  added: ALWAYS
+  type: warning
+  description: "Conflicting definitions of a key name or alias"
+- id: "allocation-error"
+  code: 550
+  added: ALWAYS
+  type: error
+  description: "Cannot allocate memory"
 - id: "wrong-field-type"
   code: 578
   added: ALWAYS
   type: error
   description: "Warn when a field has not the expected type"
+- id: "invalid-real-modifier"
+  code: 623
+  added: ALWAYS
+  type: error
+  description: "Invalid _real_ modifier"
 - id: "unknown-char-escape-sequence"
   code: 645
   added: ALWAYS
@@ -156,11 +276,21 @@
     | `\e`            | `U+001B` Escape                     |
     | `\\`            | `U+005C` Backslash                  |
     | `\NNN`          | _Octal_ escape, from `\0` to `\777` |
+- id: "invalid-included-file"
+  code: 661
+  added: ALWAYS
+  type: error
+  description: "The target file of an include statement could not be processed"
 - id: "multiple-groups-at-once"
   code: 700
   added: ALWAYS
   type: warning
   description: "Warn if a key defines multiple groups at once"
+- id: "unsupported-symbols-field"
+  code: 711
+  added: ALWAYS
+  type: warning
+  description: "A legacy X11 symbol field is not supported"
 - id: "invalid-syntax"
   code: 769
   added: ALWAYS
@@ -170,7 +300,17 @@
   code: 770
   added: ALWAYS
   type: warning
-  description: "TODO: add description"
+  description: "Reference to an undefined keycode"
+- id: "invalid-expression-type"
+  code: 784
+  added: ALWAYS
+  type: error
+  description: "An expression has not the expected type"
+- id: "invalid-value"
+  code: 796
+  added: ALWAYS
+  type: error
+  description: "A value is invalid and will be ignored"
 - id: "conflicting-modmap"
   code: 800
   added: ALWAYS
@@ -178,26 +318,54 @@
   description: "Warn if there are conflicting modmap definitions"
   details: |
     @todo detailed explanation and examples
+- id: "unknown-field"
+  code: 812
+  added: ALWAYS
+  type: error
+  description: "A field is unknown and will be ignored"
 - id: "conflicting-key-action"
   code: 883
   added: ALWAYS
   type: warning
   description: "Warn if there are conflicting actions while merging keys"
-- id: "conflicting-key-type"
+- id: "conflicting-key-type-merging-groups"
   code: 893
   added: ALWAYS
   type: warning
   description: "Warn if there are conflicting key types while merging groups"
+- id: "conflicting-key-symbols-entry"
+  code: 901
+  added: ALWAYS
+  type: error
+  description: "Conflicting symbols entry for a key"
+- id: "missing-symbols-group-name-index"
+  code: 903
+  added: ALWAYS
+  type: warning
+  description: "Missing group index in a group name entry"
 - id: "conflicting-key-fields"
   code: 935
   added: ALWAYS
   type: warning
   description: "Warn if there are conflicting fields while merging keys"
+- id: "invalid-identifier"
+  code: 949
+  added: ALWAYS
+  type: error
+  description: "An identifier is used but is not built-in"
 - id: "unresolved-keymap-symbol"
   code: 965
   added: ALWAYS
   type: warning
   description: "Warn if using a symbol not defined in the keymap"
+- id: "undeclared-modifiers-in-key-type"
+  code: 971
+  added: ALWAYS
+  type: warning
+  description: "Some modifiers used in a key type “map” or “preserve” entry are not declared"
+  details: |
+    The modifiers used in `map` or `preserve` entries should be declared using the entry
+    `modifiers` in the key type.
 
 # TODO: deprecated keysym
 # TODO: unicode keysym when named and recommended keysym exists
diff --git a/src/context.h b/src/context.h
index d5fa117..53d6e2f 100644
--- a/src/context.h
+++ b/src/context.h
@@ -138,10 +138,8 @@ xkb_context_sanitize_rule_names(struct xkb_context *ctx,
     xkb_log_with_code((ctx), XKB_LOG_LEVEL_CRITICAL, 0, (id), __VA_ARGS__)
 #define log_wsgo(ctx, ...) \
     xkb_log((ctx), XKB_LOG_LEVEL_CRITICAL, 0, __VA_ARGS__)
-#define log_vrb_with_code(ctx, vrb, id, ...) \
+#define log_vrb(ctx, vrb, id, ...) \
     xkb_log_with_code((ctx), XKB_LOG_LEVEL_WARNING, (vrb), (id), __VA_ARGS__)
-#define log_vrb(ctx, vrb, ...) \
-    xkb_log((ctx), XKB_LOG_LEVEL_WARNING, (vrb), __VA_ARGS__)
 
 /*
  * Variants which are prefixed by the name of the function they're
diff --git a/src/messages-codes.h b/src/messages-codes.h
index 1ba568c..3f117e1 100644
--- a/src/messages-codes.h
+++ b/src/messages-codes.h
@@ -7,6 +7,14 @@
 #include <stdint.h>
 
 /**
+ * Special case when no message identifier is defined.
+ *
+ * @added 1.6.0
+ *
+ */
+#define XKB_LOG_MESSAGE_NO_ID 0
+
+/**
  * @name Codes of the log messages
  *
  * @added 1.6.0
@@ -16,47 +24,109 @@ enum xkb_message_code {
     _XKB_LOG_MESSAGE_MIN_CODE = 34,
     /** Warn on malformed number literals */
     XKB_ERROR_MALFORMED_NUMBER_LITERAL = 34,
+    /** Conflicting “preserve” entries in a key type */
+    XKB_WARNING_CONFLICTING_KEY_TYPE_PRESERVE_ENTRIES = 43,
     /** Warn on unsupported modifier mask */
     XKB_ERROR_UNSUPPORTED_MODIFIER_MASK = 60,
+    /** Expected an array entry, but the index is missing */
+    XKB_ERROR_EXPECTED_ARRAY_ENTRY = 77,
+    /** Illegal keycode alias with the name of a real key */
+    XKB_WARNING_ILLEGAL_KEYCODE_ALIAS = 101,
     /** Warn on unrecognized keysyms */
     XKB_WARNING_UNRECOGNIZED_KEYSYM = 107,
+    /** A virtual modifier is used before being declared */
+    XKB_ERROR_UNDECLARED_VIRTUAL_MODIFIER = 123,
+    /** The type of the statement is not allowed in the context */
+    XKB_ERROR_WRONG_STATEMENT_TYPE = 150,
+    /** Geometry sections are not supported */
+    XKB_WARNING_UNSUPPORTED_GEOMETRY_SECTION = 172,
     /** Warn if no key type can be inferred */
     XKB_WARNING_CANNOT_INFER_KEY_TYPE = 183,
+    /** The result of a key type “preserve” entry must be a subset of its input modifiers. */
+    XKB_WARNING_ILLEGAL_KEY_TYPE_PRESERVE_RESULT = 195,
+    /** Syntax error in the include statement */
+    XKB_ERROR_INVALID_INCLUDE_STATEMENT = 203,
+    /** A modmap entry is invalid */
+    XKB_ERROR_INVALID_MODMAP_ENTRY = 206,
     /** Warn when a group index is not supported */
     XKB_ERROR_UNSUPPORTED_GROUP_INDEX = 237,
+    /** The name of a key type level is defined multiple times. */
+    XKB_WARNING_CONFLICTING_KEY_TYPE_LEVEL_NAMES = 239,
+    /** Invalid statement setting default values */
+    XKB_ERROR_INVALID_SET_DEFAULT_STATEMENT = 254,
+    /** Conflicting “map” entries in type definition */
+    XKB_WARNING_CONFLICTING_KEY_TYPE_MAP_ENTRY = 266,
     /** Warn if using an undefined key type */
     XKB_WARNING_UNDEFINED_KEY_TYPE = 286,
     /** Warn if a group name was defined for group other than the first one */
     XKB_WARNING_NON_BASE_GROUP_NAME = 305,
     /** Warn when a shift level is not supported */
     XKB_ERROR_UNSUPPORTED_SHIFT_LEVEL = 312,
+    /** Could not find a file used in an include statement */
+    XKB_ERROR_INCLUDED_FILE_NOT_FOUND = 338,
+    /** Use of an operator that is unknown and thus unsupported */
+    XKB_ERROR_UNKNOWN_OPERATOR = 345,
+    /** An entry is duplicated and will be ignored */
+    XKB_WARNING_DUPLICATE_ENTRY = 378,
+    /** Conflicting definitions of a key type */
+    XKB_WARNING_CONFLICTING_KEY_TYPE_DEFINITIONS = 407,
+    /** A statement is in a wrong scope and should be moved */
+    XKB_ERROR_WRONG_SCOPE = 428,
+    /** Missing default section in included file */
+    XKB_WARNING_MISSING_DEFAULT_SECTION = 433,
     /** Warn if there are conflicting keysyms while merging keys */
     XKB_WARNING_CONFLICTING_KEY_SYMBOL = 461,
+    /** The operation is invalid in the context */
+    XKB_ERROR_INVALID_OPERATION = 478,
     /** Warn on numeric keysym (other than 0-9) */
     XKB_WARNING_NUMERIC_KEYSYM = 489,
     /** TODO: add description */
     XKB_WARNING_EXTRA_SYMBOLS_IGNORED = 516,
+    /** Conflicting definitions of a key name or alias */
+    XKB_WARNING_CONFLICTING_KEY_NAME = 523,
+    /** Cannot allocate memory */
+    XKB_ERROR_ALLOCATION_ERROR = 550,
     /** Warn when a field has not the expected type */
     XKB_ERROR_WRONG_FIELD_TYPE = 578,
+    /** Invalid _real_ modifier */
+    XKB_ERROR_INVALID_REAL_MODIFIER = 623,
     /** Warn on unknown escape sequence in string literal */
     XKB_WARNING_UNKNOWN_CHAR_ESCAPE_SEQUENCE = 645,
+    /** The target file of an include statement could not be processed */
+    XKB_ERROR_INVALID_INCLUDED_FILE = 661,
     /** Warn if a key defines multiple groups at once */
     XKB_WARNING_MULTIPLE_GROUPS_AT_ONCE = 700,
+    /** A legacy X11 symbol field is not supported */
+    XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD = 711,
     /** The syntax is invalid and the file cannot be parsed */
     XKB_ERROR_INVALID_SYNTAX = 769,
-    /** TODO: add description */
+    /** Reference to an undefined keycode */
     XKB_WARNING_UNDEFINED_KEYCODE = 770,
+    /** An expression has not the expected type */
+    XKB_ERROR_INVALID_EXPRESSION_TYPE = 784,
+    /** A value is invalid and will be ignored */
+    XKB_ERROR_INVALID_VALUE = 796,
     /** Warn if there are conflicting modmap definitions */
     XKB_WARNING_CONFLICTING_MODMAP = 800,
+    /** A field is unknown and will be ignored */
+    XKB_ERROR_UNKNOWN_FIELD = 812,
     /** Warn if there are conflicting actions while merging keys */
     XKB_WARNING_CONFLICTING_KEY_ACTION = 883,
     /** Warn if there are conflicting key types while merging groups */
-    XKB_WARNING_CONFLICTING_KEY_TYPE = 893,
+    XKB_WARNING_CONFLICTING_KEY_TYPE_MERGING_GROUPS = 893,
+    /** Conflicting symbols entry for a key */
+    XKB_ERROR_CONFLICTING_KEY_SYMBOLS_ENTRY = 901,
+    /** Missing group index in a group name entry */
+    XKB_WARNING_MISSING_SYMBOLS_GROUP_NAME_INDEX = 903,
     /** Warn if there are conflicting fields while merging keys */
     XKB_WARNING_CONFLICTING_KEY_FIELDS = 935,
+    /** An identifier is used but is not built-in */
+    XKB_ERROR_INVALID_IDENTIFIER = 949,
     /** Warn if using a symbol not defined in the keymap */
     XKB_WARNING_UNRESOLVED_KEYMAP_SYMBOL = 965,
-    _XKB_LOG_MESSAGE_MAX_CODE = 965
+    /** Some modifiers used in a key type “map” or “preserve” entry are not declared */
+    XKB_WARNING_UNDECLARED_MODIFIERS_IN_KEY_TYPE = 971,
+    _XKB_LOG_MESSAGE_MAX_CODE = 971
 };
 
 typedef uint32_t xkb_message_code_t;
diff --git a/src/messages-codes.h.jinja b/src/messages-codes.h.jinja
index 2195af4..49a876c 100644
--- a/src/messages-codes.h.jinja
+++ b/src/messages-codes.h.jinja
@@ -7,6 +7,14 @@
 #include <stdint.h>
 
 /**
+ * Special case when no message identifier is defined.
+ *
+ * @added 1.6.0
+ *
+ */
+#define XKB_LOG_MESSAGE_NO_ID 0
+
+/**
  * @name Codes of the log messages
  *
  * @added 1.6.0
diff --git a/src/xkbcomp/ast-build.c b/src/xkbcomp/ast-build.c
index 347eed8..4654ae4 100644
--- a/src/xkbcomp/ast-build.c
+++ b/src/xkbcomp/ast-build.c
@@ -525,7 +525,9 @@ IncludeCreate(struct xkb_context *ctx, char *str, enum merge_mode merge)
     return first;
 
 err:
-    log_err(ctx, "Illegal include statement \"%s\"; Ignored\n", stmt);
+    log_err_with_code(ctx,
+            XKB_ERROR_INVALID_INCLUDE_STATEMENT,
+            "Illegal include statement \"%s\"; Ignored\n", stmt);
     FreeInclude(first);
     free(stmt);
     return NULL;
diff --git a/src/xkbcomp/expr.c b/src/xkbcomp/expr.c
index 558fef3..6e3e451 100644
--- a/src/xkbcomp/expr.c
+++ b/src/xkbcomp/expr.c
@@ -63,7 +63,9 @@ ExprResolveLhs(struct xkb_context *ctx, const ExprDef *expr,
     default:
         break;
     }
-    log_wsgo(ctx, "Unexpected operator %d in ResolveLhs\n", expr->expr.op);
+    log_wsgo_with_code(ctx,
+        XKB_ERROR_INVALID_SYNTAX,
+        "Unexpected operator %d in ResolveLhs\n", expr->expr.op);
     return false;
 }
 
@@ -139,7 +141,8 @@ ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr,
     switch (expr->expr.op) {
     case EXPR_VALUE:
         if (expr->expr.value_type != EXPR_TYPE_BOOLEAN) {
-            log_err(ctx,
+            log_err_with_code(ctx,
+                    XKB_ERROR_WRONG_FIELD_TYPE,
                     "Found constant of type %s where boolean was expected\n",
                     expr_value_type_to_string(expr->expr.value_type));
             return false;
@@ -163,11 +166,15 @@ ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr,
                 return true;
             }
         }
-        log_err(ctx, "Identifier \"%s\" of type boolean is unknown\n", ident);
+        log_err_with_code(ctx,
+            XKB_ERROR_INVALID_IDENTIFIER,
+            "Identifier \"%s\" of type boolean is unknown\n", ident);
         return false;
 
     case EXPR_FIELD_REF:
-        log_err(ctx, "Default \"%s.%s\" of type boolean is unknown\n",
+        log_err_with_code(ctx,
+                XKB_ERROR_INVALID_EXPRESSION_TYPE,
+                "Default \"%s.%s\" of type boolean is unknown\n",
                 xkb_atom_text(ctx, expr->field_ref.element),
                 xkb_atom_text(ctx, expr->field_ref.field));
         return false;
@@ -188,12 +195,16 @@ ExprResolveBoolean(struct xkb_context *ctx, const ExprDef *expr,
     case EXPR_ACTION_DECL:
     case EXPR_ACTION_LIST:
     case EXPR_KEYSYM_LIST:
-        log_err(ctx, "%s of boolean values not permitted\n",
+        log_err_with_code(ctx,
+                XKB_ERROR_INVALID_OPERATION,
+                "%s of boolean values not permitted\n",
                 expr_op_type_to_string(expr->expr.op));
         break;
 
     default:
-        log_wsgo(ctx, "Unknown operator %d in ResolveBoolean\n",
+        log_wsgo_with_code(ctx,
+                 XKB_ERROR_UNKNOWN_OPERATOR,
+                 "Unknown operator %d in ResolveBoolean\n",
                  expr->expr.op);
         break;
     }
@@ -210,7 +221,8 @@ ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr,
     switch (expr->expr.op) {
     case EXPR_VALUE:
         if (expr->expr.value_type != EXPR_TYPE_INT) {
-            log_err(ctx,
+            log_err_with_code(ctx,
+                    XKB_ERROR_WRONG_FIELD_TYPE,
                     "Found constant of type %s where an int was expected\n",
                     expr_value_type_to_string(expr->expr.value_type));
             return false;
@@ -239,7 +251,9 @@ ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr,
             break;
         case EXPR_DIVIDE:
             if (rightRtrn == 0) {
-                log_err(ctx, "Cannot divide by zero: %d / %d\n",
+                log_err_with_code(ctx,
+                        XKB_ERROR_INVALID_OPERATION,
+                        "Cannot divide by zero: %d / %d\n",
                         leftRtrn, rightRtrn);
                 return false;
             }
@@ -263,8 +277,9 @@ ExprResolveKeyCode(struct xkb_context *ctx, const ExprDef *expr,
         return ExprResolveKeyCode(ctx, expr->unary.child, kc);
 
     default:
-        log_wsgo(ctx, "Unknown operator %d in ResolveKeyCode\n",
-                 expr->expr.op);
+        log_wsgo_with_code(ctx,
+            XKB_ERROR_INVALID_SYNTAX,
+            "Unknown operator %d in ResolveKeyCode\n", expr->expr.op);
         break;
     }
 
@@ -294,7 +309,8 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr,
     switch (expr->expr.op) {
     case EXPR_VALUE:
         if (expr->expr.value_type != EXPR_TYPE_INT) {
-            log_err(ctx,
+            log_err_with_code(ctx,
+                    XKB_ERROR_WRONG_FIELD_TYPE,
                     "Found constant of type %s where an int was expected\n",
                     expr_value_type_to_string(expr->expr.value_type));
             return false;
@@ -308,7 +324,9 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr,
             ok = lookup(ctx, lookupPriv, expr->ident.ident, EXPR_TYPE_INT, &u);
 
         if (!ok)
-            log_err(ctx, "Identifier \"%s\" of type int is unknown\n",
+            log_err_with_code(ctx,
+                    XKB_ERROR_INVALID_IDENTIFIER,
+                    "Identifier \"%s\" of type int is unknown\n",
                     xkb_atom_text(ctx, expr->ident.ident));
         else
             *val_rtrn = (int) u;
@@ -316,7 +334,9 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr,
         return ok;
 
     case EXPR_FIELD_REF:
-        log_err(ctx, "Default \"%s.%s\" of type int is unknown\n",
+        log_err_with_code(ctx,
+                XKB_ERROR_INVALID_EXPRESSION_TYPE,
+                "Default \"%s.%s\" of type int is unknown\n",
                 xkb_atom_text(ctx, expr->field_ref.element),
                 xkb_atom_text(ctx, expr->field_ref.field));
         return false;
@@ -343,13 +363,17 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr,
             break;
         case EXPR_DIVIDE:
             if (r == 0) {
-                log_err(ctx, "Cannot divide by zero: %d / %d\n", l, r);
+                log_err_with_code(ctx,
+                    XKB_ERROR_INVALID_OPERATION,
+                    "Cannot divide by zero: %d / %d\n", l, r);
                 return false;
             }
             *val_rtrn = l / r;
             break;
         default:
-            log_err(ctx, "%s of integers not permitted\n",
+            log_err_with_code(ctx,
+                    XKB_ERROR_INVALID_OPERATION,
+                    "%s of integers not permitted\n",
                     expr_op_type_to_string(expr->expr.op));
             return false;
         }
@@ -357,11 +381,15 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr,
         return true;
 
     case EXPR_ASSIGN:
-        log_wsgo(ctx, "Assignment operator not implemented yet\n");
+        log_wsgo_with_code(ctx,
+                 XKB_ERROR_INVALID_OPERATION,
+                 "Assignment operator not implemented yet\n");
         break;
 
     case EXPR_NOT:
-        log_err(ctx, "The ! operator cannot be applied to an integer\n");
+        log_err_with_code(ctx,
+                XKB_ERROR_INVALID_OPERATION,
+                "The ! operator cannot be applied to an integer\n");
         return false;
 
     case EXPR_INVERT:
@@ -379,7 +407,9 @@ ExprResolveIntegerLookup(struct xkb_context *ctx, const ExprDef *expr,
                                         lookupPriv);
 
     default:
-        log_wsgo(ctx, "Unknown operator %d in ResolveInteger\n",
+        log_wsgo_with_code(ctx,
+                 XKB_ERROR_UNKNOWN_OPERATOR,
+                 "Unknown operator %d in ResolveInteger\n",
                  expr->expr.op);
         break;
     }
@@ -454,7 +484,9 @@ ExprResolveString(struct xkb_context *ctx, const ExprDef *expr,
     switch (expr->expr.op) {
     case EXPR_VALUE:
         if (expr->expr.value_type != EXPR_TYPE_STRING) {
-            log_err(ctx, "Found constant of type %s, expected a string\n",
+            log_err_with_code(ctx,
+                    XKB_ERROR_WRONG_FIELD_TYPE,
+                    "Found constant of type %s, expected a string\n",
                     expr_value_type_to_string(expr->expr.value_type));
             return false;
         }
@@ -463,12 +495,16 @@ ExprResolveString(struct xkb_context *ctx, const ExprDef *expr,
         return true;
 
     case EXPR_IDENT:
-        log_err(ctx, "Identifier \"%s\" of type string not found\n",
+        log_err_with_code(ctx,
+                XKB_ERROR_INVALID_IDENTIFIER,
+                "Identifier \"%s\" of type string not found\n",
                 xkb_atom_text(ctx, expr->ident.ident));
         return false;
 
     case EXPR_FIELD_REF:
-        log_err(ctx, "Default \"%s.%s\" of type string not found\n",
+        log_err_with_code(ctx,
+                XKB_ERROR_INVALID_EXPRESSION_TYPE,
+                "Default \"%s.%s\" of type string not found\n",
                 xkb_atom_text(ctx, expr->field_ref.element),
                 xkb_atom_text(ctx, expr->field_ref.field));
         return false;
@@ -485,12 +521,16 @@ ExprResolveString(struct xkb_context *ctx, const ExprDef *expr,
     case EXPR_ACTION_DECL:
     case EXPR_ACTION_LIST:
     case EXPR_KEYSYM_LIST:
-        log_err(ctx, "%s of strings not permitted\n",
+        log_err_with_code(ctx,
+                XKB_ERROR_INVALID_SYNTAX,
+                "%s of strings not permitted\n",
                 expr_op_type_to_string(expr->expr.op));
         return false;
 
     default:
-        log_wsgo(ctx, "Unknown operator %d in ResolveString\n",
+        log_wsgo_with_code(ctx,
+                 XKB_ERROR_UNKNOWN_OPERATOR,
+                 "Unknown operator %d in ResolveString\n",
                  expr->expr.op);
         break;
     }
@@ -502,18 +542,22 @@ ExprResolveEnum(struct xkb_context *ctx, const ExprDef *expr,
                 unsigned int *val_rtrn, const LookupEntry *values)
 {
     if (expr->expr.op != EXPR_IDENT) {
-        log_err(ctx, "Found a %s where an enumerated value was expected\n",
+        log_err_with_code(ctx,
+                XKB_ERROR_WRONG_FIELD_TYPE,
+                "Found a %s where an enumerated value was expected\n",
                 expr_op_type_to_string(expr->expr.op));
         return false;
     }
 
     if (!SimpleLookup(ctx, values, expr->ident.ident, EXPR_TYPE_INT,
                       val_rtrn)) {
-        log_err(ctx, "Illegal identifier %s; expected one of:\n",
+        log_err_with_code(ctx,
+                XKB_ERROR_INVALID_IDENTIFIER,
+                "Illegal identifier %s; expected one of:\n",
                 xkb_atom_text(ctx, expr->ident.ident));
         while (values && values->name)
         {
-            log_err(ctx, "\t%s\n", values->name);
+            log_err_with_code(ctx, XKB_ERROR_INVALID_IDENTIFIER, "\t%s\n", values->name);
             values++;
         }
         return false;
@@ -536,7 +580,8 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr,
     switch (expr->expr.op) {
     case EXPR_VALUE:
         if (expr->expr.value_type != EXPR_TYPE_INT) {
-            log_err(ctx,
+            log_err_with_code(ctx,
+                    XKB_ERROR_WRONG_FIELD_TYPE,
                     "Found constant of type %s where a mask was expected\n",
                     expr_value_type_to_string(expr->expr.value_type));
             return false;
@@ -548,12 +593,16 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr,
         ok = lookup(ctx, lookupPriv, expr->ident.ident, EXPR_TYPE_INT,
                     val_rtrn);
         if (!ok)
-            log_err(ctx, "Identifier \"%s\" of type int is unknown\n",
+            log_err_with_code(ctx,
+                    XKB_ERROR_INVALID_IDENTIFIER,
+                    "Identifier \"%s\" of type int is unknown\n",
                     xkb_atom_text(ctx, expr->ident.ident));
         return ok;
 
     case EXPR_FIELD_REF:
-        log_err(ctx, "Default \"%s.%s\" of type int is unknown\n",
+        log_err_with_code(ctx,
+                XKB_ERROR_INVALID_EXPRESSION_TYPE,
+                "Default \"%s.%s\" of type int is unknown\n",
                 xkb_atom_text(ctx, expr->field_ref.element),
                 xkb_atom_text(ctx, expr->field_ref.field));
         return false;
@@ -564,7 +613,8 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr,
     case EXPR_ACTION_DECL:
         if (bogus == NULL)
             bogus = "function use";
-        log_err(ctx,
+        log_err_with_code(ctx,
+                XKB_ERROR_WRONG_FIELD_TYPE,
                 "Unexpected %s in mask expression; Expression Ignored\n",
                 bogus);
         return false;
@@ -588,7 +638,9 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr,
             break;
         case EXPR_MULTIPLY:
         case EXPR_DIVIDE:
-            log_err(ctx, "Cannot %s masks; Illegal operation ignored\n",
+            log_err_with_code(ctx,
+                    XKB_ERROR_INVALID_OPERATION,
+                    "Cannot %s masks; Illegal operation ignored\n",
                     (expr->expr.op == EXPR_DIVIDE ? "divide" : "multiply"));
             return false;
         default:
@@ -598,7 +650,9 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr,
         return true;
 
     case EXPR_ASSIGN:
-        log_wsgo(ctx, "Assignment operator not implemented yet\n");
+        log_wsgo_with_code(ctx,
+                 XKB_ERROR_INVALID_OPERATION,
+                 "Assignment operator not implemented yet\n");
         break;
 
     case EXPR_INVERT:
@@ -614,12 +668,16 @@ ExprResolveMaskLookup(struct xkb_context *ctx, const ExprDef *expr,
     case EXPR_NOT:
         left = expr->unary.child;
         if (!ExprResolveIntegerLookup(ctx, left, &v, lookup, lookupPriv))
-            log_err(ctx, "The %s operator cannot be used with a mask\n",
+            log_err_with_code(ctx,
+                    XKB_ERROR_INVALID_OPERATION,
+                    "The %s operator cannot be used with a mask\n",
                     (expr->expr.op == EXPR_NEGATE ? "-" : "!"));
         return false;
 
     default:
-        log_wsgo(ctx, "Unknown operator %d in ResolveMask\n",
+        log_wsgo_with_code(ctx,
+                 XKB_ERROR_UNKNOWN_OPERATOR,
+                 "Unknown operator %d in ResolveMask\n",
                  expr->expr.op);
         break;
     }
@@ -696,7 +754,8 @@ ExprResolveMod(struct xkb_context *ctx, const ExprDef *def,
     xkb_atom_t name;
 
     if (def->expr.op != EXPR_IDENT) {
-        log_err(ctx,
+        log_err_with_code(ctx,
+                XKB_ERROR_WRONG_FIELD_TYPE,
                 "Cannot resolve virtual modifier: "
                 "found %s where a virtual modifier name was expected\n",
                 expr_op_type_to_string(def->expr.op));
@@ -706,7 +765,8 @@ ExprResolveMod(struct xkb_context *ctx, const ExprDef *def,
     name = def->ident.ident;
     ndx = XkbModNameToIndex(mods, name, mod_type);
     if (ndx == XKB_MOD_INVALID) {
-        log_err(ctx,
+        log_err_with_code(ctx,
+                XKB_ERROR_UNDECLARED_VIRTUAL_MODIFIER,
                 "Cannot resolve virtual modifier: "
                 "\"%s\" was not previously declared\n",
                 xkb_atom_text(ctx, name));
diff --git a/src/xkbcomp/include.c b/src/xkbcomp/include.c
index d39be89..fc692fb 100644
--- a/src/xkbcomp/include.c
+++ b/src/xkbcomp/include.c
@@ -201,21 +201,31 @@ LogIncludePaths(struct xkb_context *ctx)
     unsigned int i;
 
     if (xkb_context_num_include_paths(ctx) > 0) {
-        log_err(ctx, "%d include paths searched:\n",
+        log_err_with_code(ctx,
+                XKB_ERROR_INCLUDED_FILE_NOT_FOUND,
+                "%d include paths searched:\n",
                 xkb_context_num_include_paths(ctx));
         for (i = 0; i < xkb_context_num_include_paths(ctx); i++)
-            log_err(ctx, "\t%s\n",
+            log_err_with_code(ctx,
+                    XKB_ERROR_INCLUDED_FILE_NOT_FOUND,
+                    "\t%s\n",
                     xkb_context_include_path_get(ctx, i));
     }
     else {
-        log_err(ctx, "There are no include paths to search\n");
+        log_err_with_code(ctx,
+                XKB_ERROR_INCLUDED_FILE_NOT_FOUND,
+                "There are no include paths to search\n");
     }
 
     if (xkb_context_num_failed_include_paths(ctx) > 0) {
-        log_err(ctx, "%d include paths could not be added:\n",
+        log_err_with_code(ctx,
+                XKB_ERROR_INCLUDED_FILE_NOT_FOUND,
+                "%d include paths could not be added:\n",
                 xkb_context_num_failed_include_paths(ctx));
         for (i = 0; i < xkb_context_num_failed_include_paths(ctx); i++)
-            log_err(ctx, "\t%s\n",
+            log_err_with_code(ctx,
+                    XKB_ERROR_INCLUDED_FILE_NOT_FOUND,
+                    "\t%s\n",
                     xkb_context_failed_include_path_get(ctx, i));
     }
 }
@@ -246,7 +256,9 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name,
         buf = asprintf_safe("%s/%s/%s", xkb_context_include_path_get(ctx, i),
                             typeDir, name);
         if (!buf) {
-            log_err(ctx, "Failed to alloc buffer for (%s/%s/%s)\n",
+            log_err_with_code(ctx,
+                    XKB_ERROR_ALLOCATION_ERROR,
+                    "Failed to alloc buffer for (%s/%s/%s)\n",
                     xkb_context_include_path_get(ctx, i), typeDir, name);
             continue;
         }
@@ -264,7 +276,9 @@ FindFileInXkbPath(struct xkb_context *ctx, const char *name,
 
     /* We only print warnings if we can't find the file on the first lookup */
     if (*offset == 0) {
-        log_err(ctx, "Couldn't find file \"%s/%s\" in include paths\n",
+        log_err_with_code(ctx,
+                XKB_ERROR_INCLUDED_FILE_NOT_FOUND,
+                "Couldn't find file \"%s/%s\" in include paths\n",
                 typeDir, name);
         LogIncludePaths(ctx);
     }
@@ -292,7 +306,8 @@ ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt,
 
         if (xkb_file) {
             if (xkb_file->file_type != file_type) {
-                log_err(ctx,
+                log_err_with_code(ctx,
+                        XKB_ERROR_INVALID_INCLUDED_FILE,
                         "Include file of wrong type (expected %s, got %s); "
                         "Include file \"%s\" ignored\n",
                         xkb_file_type_to_string(file_type),
@@ -310,10 +325,14 @@ ProcessIncludeFile(struct xkb_context *ctx, IncludeStmt *stmt,
 
     if (!xkb_file) {
         if (stmt->map)
-            log_err(ctx, "Couldn't process include statement for '%s(%s)'\n",
+            log_err_with_code(ctx,
+                    XKB_ERROR_INVALID_INCLUDED_FILE,
+                    "Couldn't process include statement for '%s(%s)'\n",
                     stmt->file, stmt->map);
         else
-            log_err(ctx, "Couldn't process include statement for '%s'\n",
+            log_err_with_code(ctx,
+                    XKB_ERROR_INVALID_INCLUDED_FILE,
+                    "Couldn't process include statement for '%s'\n",
                     stmt->file);
     }
 
diff --git a/src/xkbcomp/keycodes.c b/src/xkbcomp/keycodes.c
index 35c84b7..41ddb20 100644
--- a/src/xkbcomp/keycodes.c
+++ b/src/xkbcomp/keycodes.c
@@ -230,13 +230,15 @@ AddKeyName(KeyNamesInfo *info, xkb_keycode_t kc, xkb_atom_t name,
         if (merge == MERGE_OVERRIDE) {
             darray_item(info->key_names, old_kc) = XKB_ATOM_NONE;
             if (report)
-                log_warn(info->ctx,
+                log_warn_with_code(info->ctx,
+                         XKB_WARNING_CONFLICTING_KEY_NAME,
                          "Key name %s assigned to multiple keys; "
                          "Using %d, ignoring %d\n", kname, kc, old_kc);
         }
         else {
             if (report)
                 log_vrb(info->ctx, 3,
+                        XKB_WARNING_CONFLICTING_KEY_NAME,
                         "Key name %s assigned to multiple keys; "
                         "Using %d, ignoring %d\n", kname, old_kc, kc);
             return true;
@@ -397,6 +399,7 @@ HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge)
         if (old->alias == def->alias) {
             if (def->real == old->real) {
                 log_vrb(info->ctx, 1,
+                        XKB_WARNING_CONFLICTING_KEY_NAME,
                         "Alias of %s for %s declared more than once; "
                         "First definition ignored\n",
                         KeyNameText(info->ctx, def->alias),
@@ -408,7 +411,8 @@ HandleAliasDef(KeyNamesInfo *info, KeyAliasDef *def, enum merge_mode merge)
                 use = (merge == MERGE_AUGMENT ? old->real : def->real);
                 ignore = (merge == MERGE_AUGMENT ? def->real : old->real);
 
-                log_warn(info->ctx,
+                log_warn_with_code(info->ctx,
+                         XKB_WARNING_CONFLICTING_KEY_NAME,
                          "Multiple definitions for alias %s; "
                          "Using %s, ignoring %s\n",
                          KeyNameText(info->ctx, old->alias),
@@ -573,6 +577,7 @@ CopyKeyAliasesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info)
         /* Check that ->real is a key. */
         if (!XkbKeyByName(keymap, alias->real, false)) {
             log_vrb(info->ctx, 5,
+                    XKB_WARNING_UNDEFINED_KEYCODE,
                     "Attempt to alias %s to non-existent key %s; Ignored\n",
                     KeyNameText(info->ctx, alias->alias),
                     KeyNameText(info->ctx, alias->real));
@@ -583,6 +588,7 @@ CopyKeyAliasesToKeymap(struct xkb_keymap *keymap, KeyNamesInfo *info)
         /* Check that ->alias is not a key. */
         if (XkbKeyByName(keymap, alias->alias, false)) {
             log_vrb(info->ctx, 5,
+                    XKB_WARNING_ILLEGAL_KEYCODE_ALIAS,
                     "Attempt to create alias with the name of a real key; "
                     "Alias \"%s = %s\" ignored\n",
                     KeyNameText(info->ctx, alias->alias),
diff --git a/src/xkbcomp/keymap.c b/src/xkbcomp/keymap.c
index 0d14913..0878159 100644
--- a/src/xkbcomp/keymap.c
+++ b/src/xkbcomp/keymap.c
@@ -245,6 +245,7 @@ CompileKeymap(XkbFile *file, struct xkb_keymap *keymap, enum merge_mode merge)
             file->file_type > LAST_KEYMAP_FILE_TYPE) {
             if (file->file_type == FILE_TYPE_GEOMETRY) {
                 log_vrb(ctx, 1,
+                        XKB_WARNING_UNSUPPORTED_GEOMETRY_SECTION,
                         "Geometry sections are not supported; ignoring\n");
             } else {
                 log_err(ctx, "Cannot define %s in a keymap file\n",
diff --git a/src/xkbcomp/parser.y b/src/xkbcomp/parser.y
index e1226b1..0fd663a 100644
--- a/src/xkbcomp/parser.y
+++ b/src/xkbcomp/parser.y
@@ -856,6 +856,7 @@ parse(struct xkb_context *ctx, struct scanner *scanner, const char *map)
 
     if (first)
         log_vrb(ctx, 5,
+                XKB_WARNING_MISSING_DEFAULT_SECTION,
                 "No map in include statement, but \"%s\" contains several; "
                 "Using first defined map, \"%s\"\n",
                 scanner->file_name, first->name);
diff --git a/src/xkbcomp/symbols.c b/src/xkbcomp/symbols.c
index e438139..6d31c7c 100644
--- a/src/xkbcomp/symbols.c
+++ b/src/xkbcomp/symbols.c
@@ -62,9 +62,6 @@
 #include "keysym.h"
 
 
-// TODO: convert log_err to log_err_with_code
-// TODO: convert log_vrb to log_vrb_with_code
-
 enum key_repeat {
     KEY_REPEAT_UNDEFINED = 0,
     KEY_REPEAT_YES = 1,
@@ -246,7 +243,7 @@ MergeGroups(SymbolsInfo *info, GroupInfo *into, GroupInfo *from, bool clobber,
 
             if (report) {
                 log_warn_with_code(info->ctx,
-                         XKB_WARNING_CONFLICTING_KEY_TYPE,
+                         XKB_WARNING_CONFLICTING_KEY_TYPE_MERGING_GROUPS,
                          "Multiple definitions for group %d type of key %s; "
                          "Using %s, ignoring %s\n",
                          group + 1, KeyNameText(info->ctx, key_name),
@@ -592,7 +589,8 @@ HandleIncludeSymbols(SymbolsInfo *info, IncludeStmt *include)
         if (stmt->modifier) {
             next_incl.explicit_group = atoi(stmt->modifier) - 1;
             if (next_incl.explicit_group >= XKB_MAX_GROUPS) {
-                log_err(info->ctx,
+                log_err_with_code(info->ctx,
+                        XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
                         "Cannot set explicit group to %d - must be between 1..%d; "
                         "Ignoring group number\n",
                         next_incl.explicit_group + 1, XKB_MAX_GROUPS);
@@ -640,7 +638,8 @@ GetGroupIndex(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
         }
 
         if (i >= XKB_MAX_GROUPS) {
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_UNSUPPORTED_GROUP_INDEX,
                     "Too many groups of %s for key %s (max %u); "
                     "Ignoring %s defined for extra groups\n",
                     name, KeyInfoText(info, keyi), XKB_MAX_GROUPS, name);
@@ -686,7 +685,8 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
     }
 
     if (value->expr.op != EXPR_KEYSYM_LIST) {
-        log_err(info->ctx,
+        log_err_with_code(info->ctx,
+                XKB_ERROR_WRONG_FIELD_TYPE,
                 "Expected a list of symbols, found %s; "
                 "Ignoring symbols for group %u of %s\n",
                 expr_op_type_to_string(value->expr.op), ndx + 1,
@@ -695,7 +695,8 @@ AddSymbolsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
     }
 
     if (groupi->defined & GROUP_FIELD_SYMS) {
-        log_err(info->ctx,
+        log_err_with_code(info->ctx,
+                XKB_ERROR_CONFLICTING_KEY_SYMBOLS_ENTRY,
                 "Symbols for key %s, group %u already defined; "
                 "Ignoring duplicate definition\n",
                 KeyInfoText(info, keyi), ndx + 1);
@@ -784,7 +785,8 @@ AddActionsToKey(SymbolsInfo *info, KeyInfo *keyi, ExprDef *arrayNdx,
         union xkb_action *toAct = &darray_item(groupi->levels, i).action;
 
         if (!HandleActionDef(info->ctx, info->actions, &info->mods, act, toAct))
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_INVALID_VALUE,
                     "Illegal action definition for %s; "
                     "Action for group %u/level %u ignored\n",
                     KeyInfoText(info, keyi), ndx + 1, i + 1);
@@ -815,7 +817,8 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
         xkb_atom_t val;
 
         if (!ExprResolveString(info->ctx, value, &val)) {
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_WRONG_FIELD_TYPE,
                     "The type field of a key symbol map must be a string; "
                     "Ignoring illegal type definition\n");
             return false;
@@ -853,7 +856,8 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
 
         if (!ExprResolveModMask(info->ctx, value, MOD_VIRT, &info->mods,
                                 &mask)) {
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_UNSUPPORTED_MODIFIER_MASK,
                     "Expected a virtual modifier mask, found %s; "
                     "Ignoring virtual modifiers definition for key %s\n",
                     expr_op_type_to_string(value->expr.op),
@@ -868,6 +872,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
              istreq(field, "lock") ||
              istreq(field, "locks")) {
         log_vrb(info->ctx, 1,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Key behaviors not supported; "
                 "Ignoring locking specification for key %s\n",
                 KeyInfoText(info, keyi));
@@ -876,6 +881,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
              istreq(field, "permanentradiogroup") ||
              istreq(field, "allownone")) {
         log_vrb(info->ctx, 1,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Radio groups not supported; "
                 "Ignoring radio group specification for key %s\n",
                 KeyInfoText(info, keyi));
@@ -883,6 +889,7 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
     else if (istreq_prefix("overlay", field) ||
              istreq_prefix("permanentoverlay", field)) {
         log_vrb(info->ctx, 1,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Overlays not supported; "
                 "Ignoring overlay specification for key %s\n",
                 KeyInfoText(info, keyi));
@@ -893,7 +900,8 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
         unsigned int val;
 
         if (!ExprResolveEnum(info->ctx, value, &val, repeatEntries)) {
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_INVALID_VALUE,
                     "Illegal repeat setting for %s; "
                     "Non-boolean repeat setting ignored\n",
                     KeyInfoText(info, keyi));
@@ -908,7 +916,8 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
         bool set;
 
         if (!ExprResolveBoolean(info->ctx, value, &set)) {
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_INVALID_VALUE,
                     "Illegal groupsWrap setting for %s; "
                     "Non-boolean value ignored\n",
                     KeyInfoText(info, keyi));
@@ -923,7 +932,8 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
         bool set;
 
         if (!ExprResolveBoolean(info->ctx, value, &set)) {
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_INVALID_VALUE,
                     "Illegal groupsClamp setting for %s; "
                     "Non-boolean value ignored\n",
                     KeyInfoText(info, keyi));
@@ -950,7 +960,8 @@ SetSymbolsField(SymbolsInfo *info, KeyInfo *keyi, const char *field,
         keyi->defined |= KEY_FIELD_GROUPINFO;
     }
     else {
-        log_err(info->ctx,
+        log_err_with_code(info->ctx,
+                XKB_ERROR_UNKNOWN_FIELD,
                 "Unknown field %s in a symbol interpretation; "
                 "Definition ignored\n",
                 field);
@@ -968,6 +979,7 @@ SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value)
 
     if (!arrayNdx) {
         log_vrb(info->ctx, 1,
+                XKB_WARNING_MISSING_SYMBOLS_GROUP_NAME_INDEX,
                 "You must specify an index when specifying a group name; "
                 "Group name definition without array subscript ignored\n");
         return false;
@@ -981,7 +993,8 @@ SetGroupName(SymbolsInfo *info, ExprDef *arrayNdx, ExprDef *value)
     }
 
     if (!ExprResolveString(info->ctx, value, &name)) {
-        log_err(info->ctx,
+        log_err_with_code(info->ctx,
+                XKB_ERROR_WRONG_FIELD_TYPE,
                 "Group name must be a string; "
                 "Illegal name for group %d ignored\n", group);
         return false;
@@ -1031,24 +1044,28 @@ HandleGlobalVar(SymbolsInfo *info, VarDef *stmt)
     }
     else if (!elem && (istreq(field, "groupswrap") ||
                        istreq(field, "wrapgroups"))) {
-        log_err(info->ctx,
+        log_err_with_code(info->ctx,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Global \"groupswrap\" not supported; Ignored\n");
         ret = true;
     }
     else if (!elem && (istreq(field, "groupsclamp") ||
                        istreq(field, "clampgroups"))) {
-        log_err(info->ctx,
+        log_err_with_code(info->ctx,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Global \"groupsclamp\" not supported; Ignored\n");
         ret = true;
     }
     else if (!elem && (istreq(field, "groupsredirect") ||
                        istreq(field, "redirectgroups"))) {
-        log_err(info->ctx,
+        log_err_with_code(info->ctx,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Global \"groupsredirect\" not supported; Ignored\n");
         ret = true;
     }
     else if (!elem && istreq(field, "allownone")) {
-        log_err(info->ctx,
+        log_err_with_code(info->ctx,
+                XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD,
                 "Radio groups not supported; "
                 "Ignoring \"allownone\" specification\n");
         ret = true;
@@ -1070,7 +1087,8 @@ HandleSymbolsBody(SymbolsInfo *info, VarDef *def, KeyInfo *keyi)
 
     for (; def; def = (VarDef *) def->common.next) {
         if (def->name && def->name->expr.op == EXPR_FIELD_REF) {
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_WRONG_SCOPE,
                     "Cannot set a global default value from within a key statement; "
                     "Move statements to the global file scope\n");
             continue;
@@ -1180,7 +1198,8 @@ HandleModMapDef(SymbolsInfo *info, ModMapDef *def)
         // Handle normal entry
         ndx = XkbModNameToIndex(&info->mods, def->modifier, MOD_REAL);
         if (ndx == XKB_MOD_INVALID) {
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_INVALID_REAL_MODIFIER,
                     "Illegal modifier map definition; "
                     "Ignoring map for non-modifier \"%s\"\n",
                     xkb_atom_text(ctx, def->modifier));
@@ -1205,7 +1224,8 @@ HandleModMapDef(SymbolsInfo *info, ModMapDef *def)
             tmp.u.keySym = sym;
         }
         else {
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_INVALID_MODMAP_ENTRY,
                     "Modmap entries may contain only key names or keysyms; "
                     "Illegal definition for %s modifier ignored\n",
                     ModIndexText(info->ctx, &info->mods, tmp.modifier));
@@ -1243,7 +1263,8 @@ HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge)
             ok = HandleModMapDef(info, (ModMapDef *) stmt);
             break;
         default:
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_WRONG_STATEMENT_TYPE,
                     "Symbols files may not include other types; "
                     "Ignoring %s\n", stmt_type_to_string(stmt->type));
             ok = false;
@@ -1254,7 +1275,9 @@ HandleSymbolsFile(SymbolsInfo *info, XkbFile *file, enum merge_mode merge)
             info->errorCount++;
 
         if (info->errorCount > 10) {
-            log_err(info->ctx, "Abandoning symbols file \"%s\"\n",
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_INVALID_SYNTAX,
+                    "Abandoning symbols file \"%s\"\n",
                     file->name);
             break;
         }
@@ -1436,7 +1459,7 @@ CopySymbolsDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info,
      */
     key = XkbKeyByName(keymap, keyi->name, false);
     if (!key) {
-        log_vrb_with_code(info->ctx, 5,
+        log_vrb(info->ctx, 5,
                 XKB_WARNING_UNDEFINED_KEYCODE,
                 "Key %s not found in keycodes; Symbols ignored\n",
                 KeyInfoText(info, keyi));
@@ -1480,7 +1503,7 @@ CopySymbolsDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info,
         if (type->num_levels < darray_size(groupi->levels)) {
             struct xkb_level *leveli;
 
-            log_vrb_with_code(info->ctx, 1,
+            log_vrb(info->ctx, 1,
                     XKB_WARNING_EXTRA_SYMBOLS_IGNORED,
                     "Type \"%s\" has %d levels, but %s has %d levels; "
                     "Ignoring extra symbols\n",
@@ -1533,7 +1556,7 @@ CopyModMapDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info,
     if (!entry->haveSymbol) {
         key = XkbKeyByName(keymap, entry->u.keyName, true);
         if (!key) {
-            log_vrb_with_code(info->ctx, 5,
+            log_vrb(info->ctx, 5,
                     XKB_WARNING_UNDEFINED_KEYCODE,
                     "Key %s not found in keycodes; "
                     "Modifier map entry for %s not updated\n",
@@ -1545,7 +1568,7 @@ CopyModMapDefToKeymap(struct xkb_keymap *keymap, SymbolsInfo *info,
     else {
         key = FindKeyForSymbol(keymap, entry->u.keySym);
         if (!key) {
-            log_vrb_with_code(info->ctx, 5,
+            log_vrb(info->ctx, 5,
                     XKB_WARNING_UNRESOLVED_KEYMAP_SYMBOL,
                     "Key \"%s\" not found in symbol map; "
                     "Modifier map entry for %s not updated\n",
diff --git a/src/xkbcomp/types.c b/src/xkbcomp/types.c
index e8e82df..fe089ae 100644
--- a/src/xkbcomp/types.c
+++ b/src/xkbcomp/types.c
@@ -143,7 +143,8 @@ AddKeyType(KeyTypesInfo *info, KeyTypeInfo *new, bool same_file)
     if (old) {
         if (new->merge == MERGE_REPLACE || new->merge == MERGE_OVERRIDE) {
             if ((same_file && verbosity > 0) || verbosity > 9) {
-                log_warn(info->ctx,
+                log_warn_with_code(info->ctx,
+                         XKB_WARNING_CONFLICTING_KEY_TYPE_DEFINITIONS,
                          "Multiple definitions of the %s key type; "
                          "Earlier definition ignored\n",
                          xkb_atom_text(info->ctx, new->name));
@@ -158,6 +159,7 @@ AddKeyType(KeyTypesInfo *info, KeyTypeInfo *new, bool same_file)
 
         if (same_file)
             log_vrb(info->ctx, 4,
+                    XKB_WARNING_CONFLICTING_KEY_TYPE_DEFINITIONS,
                     "Multiple definitions of the %s key type; "
                     "Later definition ignored\n",
                     xkb_atom_text(info->ctx, new->name));
@@ -255,7 +257,8 @@ SetModifiers(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
                  "Illegal array subscript ignored\n");
 
     if (!ExprResolveModMask(info->ctx, value, MOD_BOTH, &info->mods, &mods)) {
-        log_err(info->ctx,
+        log_err_with_code(info->ctx,
+                XKB_ERROR_UNSUPPORTED_MODIFIER_MASK,
                 "Key type mask field must be a modifier mask; "
                 "Key type definition ignored\n");
         return false;
@@ -298,7 +301,8 @@ AddMapEntry(KeyTypesInfo *info, KeyTypeInfo *type,
     old = FindMatchingMapEntry(type, new->mods.mods);
     if (old) {
         if (report && old->level != new->level) {
-            log_warn(info->ctx,
+            log_warn_with_code(info->ctx,
+                     XKB_WARNING_CONFLICTING_KEY_TYPE_MAP_ENTRY,
                      "Multiple map entries for %s in %s; "
                      "Using %d, ignoring %d\n",
                      MapEntryTxt(info, new), TypeTxt(info, type),
@@ -307,6 +311,7 @@ AddMapEntry(KeyTypesInfo *info, KeyTypeInfo *type,
         }
         else {
             log_vrb(info->ctx, 10,
+                    XKB_WARNING_CONFLICTING_KEY_TYPE_MAP_ENTRY,
                     "Multiple occurrences of map[%s]= %d in %s; Ignored\n",
                     MapEntryTxt(info, new), new->level + 1,
                     TypeTxt(info, type));
@@ -345,7 +350,8 @@ SetMapEntry(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
 
     if (entry.mods.mods & (~type->mods)) {
         log_vrb(info->ctx, 1,
-                "Map entry for unused modifiers in %s; "
+                XKB_WARNING_UNDECLARED_MODIFIERS_IN_KEY_TYPE,
+                "Map entry for modifiers not used by type %s; "
                 "Using %s instead of %s\n",
                 TypeTxt(info, type),
                 ModMaskText(info->ctx, &info->mods,
@@ -388,6 +394,7 @@ AddPreserve(KeyTypesInfo *info, KeyTypeInfo *type,
         /* Map exists with same preserve; do nothing. */
         if (entry->preserve.mods == preserve_mods) {
             log_vrb(info->ctx, 10,
+                    XKB_WARNING_DUPLICATE_ENTRY,
                     "Identical definitions for preserve[%s] in %s; "
                     "Ignored\n",
                     ModMaskText(info->ctx, &info->mods, mods),
@@ -397,6 +404,7 @@ AddPreserve(KeyTypesInfo *info, KeyTypeInfo *type,
 
         /* Map exists with different preserve; latter wins. */
         log_vrb(info->ctx, 1,
+                XKB_WARNING_CONFLICTING_KEY_TYPE_PRESERVE_ENTRIES,
                 "Multiple definitions for preserve[%s] in %s; "
                 "Using %s, ignoring %s\n",
                 ModMaskText(info->ctx, &info->mods, mods),
@@ -441,14 +449,16 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
         after = ModMaskText(info->ctx, &info->mods, mods);
 
         log_vrb(info->ctx, 1,
-                "Preserve for modifiers not used by the %s type; "
+                XKB_WARNING_UNDECLARED_MODIFIERS_IN_KEY_TYPE,
+                "Preserve entry for modifiers not used by the %s type; "
                 "Index %s converted to %s\n",
                 TypeTxt(info, type), before, after);
     }
 
     if (!ExprResolveModMask(info->ctx, value, MOD_BOTH, &info->mods,
                             &preserve_mods)) {
-        log_err(info->ctx,
+        log_err_with_code(info->ctx,
+                XKB_ERROR_UNSUPPORTED_MODIFIER_MASK,
                 "Preserve value in a key type is not a modifier mask; "
                 "Ignoring preserve[%s] in type %s\n",
                 ModMaskText(info->ctx, &info->mods, mods),
@@ -464,6 +474,7 @@ SetPreserve(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
         after = ModMaskText(info->ctx, &info->mods, preserve_mods);
 
         log_vrb(info->ctx, 1,
+                XKB_WARNING_ILLEGAL_KEY_TYPE_PRESERVE_RESULT,
                 "Illegal value for preserve[%s] in type %s; "
                 "Converted %s to %s\n",
                 ModMaskText(info->ctx, &info->mods, mods),
@@ -488,6 +499,7 @@ AddLevelName(KeyTypesInfo *info, KeyTypeInfo *type,
     /* Same level, same name. */
     if (darray_item(type->level_names, level) == name) {
         log_vrb(info->ctx, 10,
+                XKB_WARNING_DUPLICATE_ENTRY,
                 "Duplicate names for level %d of key type %s; Ignored\n",
                 level + 1, TypeTxt(info, type));
         return true;
@@ -500,6 +512,7 @@ AddLevelName(KeyTypesInfo *info, KeyTypeInfo *type,
                             darray_item(type->level_names, level));
         new = xkb_atom_text(info->ctx, name);
         log_vrb(info->ctx, 1,
+                XKB_WARNING_CONFLICTING_KEY_TYPE_LEVEL_NAMES,
                 "Multiple names for level %d of key type %s; "
                 "Using %s, ignoring %s\n",
                 level + 1, TypeTxt(info, type),
@@ -531,7 +544,8 @@ SetLevelName(KeyTypesInfo *info, KeyTypeInfo *type, ExprDef *arrayNdx,
                                  type, "level name", "integer");
 
     if (!ExprResolveString(info->ctx, value, &level_name)) {
-        log_err(info->ctx,
+        log_err_with_code(info->ctx,
+                XKB_ERROR_WRONG_FIELD_TYPE,
                 "Non-string name for level %d in key type %s; "
                 "Ignoring illegal level name definition\n",
                 level + 1, xkb_atom_text(info->ctx, type->name));
@@ -566,7 +580,8 @@ SetKeyTypeField(KeyTypesInfo *info, KeyTypeInfo *type,
         type_field = TYPE_FIELD_LEVEL_NAME;
         ok = SetLevelName(info, type, arrayNdx, value);
     } else {
-        log_err(info->ctx,
+        log_err_with_code(info->ctx,
+                XKB_ERROR_UNKNOWN_FIELD,
                 "Unknown field %s in key type %s; Definition ignored\n",
                 field, TypeTxt(info, type));
     }
@@ -589,7 +604,8 @@ HandleKeyTypeBody(KeyTypesInfo *info, VarDef *def, KeyTypeInfo *type)
             continue;
 
         if (elem && istreq(elem, "type")) {
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_INVALID_SET_DEFAULT_STATEMENT,
                     "Support for changing the default type has been removed; "
                     "Statement ignored\n");
             continue;
@@ -644,7 +660,8 @@ HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge)
             ok = HandleKeyTypeDef(info, (KeyTypeDef *) stmt, merge);
             break;
         case STMT_VAR:
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_WRONG_STATEMENT_TYPE,
                     "Support for changing the default type has been removed; "
                     "Statement ignored\n");
             ok = true;
@@ -653,7 +670,8 @@ HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge)
             ok = HandleVModDef(info->ctx, &info->mods, (VModDef *) stmt, merge);
             break;
         default:
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_WRONG_STATEMENT_TYPE,
                     "Key type files may not include other declarations; "
                     "Ignoring %s\n", stmt_type_to_string(stmt->type));
             ok = false;
@@ -664,7 +682,8 @@ HandleKeyTypesFile(KeyTypesInfo *info, XkbFile *file, enum merge_mode merge)
             info->errorCount++;
 
         if (info->errorCount > 10) {
-            log_err(info->ctx,
+            log_err_with_code(info->ctx,
+                    XKB_ERROR_INVALID_SYNTAX,
                     "Abandoning keytypes file \"%s\"\n", file->name);
             break;
         }
diff --git a/src/xkbcomp/xkbcomp-priv.h b/src/xkbcomp/xkbcomp-priv.h
index 5a7765f..50c07b5 100644
--- a/src/xkbcomp/xkbcomp-priv.h
+++ b/src/xkbcomp/xkbcomp-priv.h
@@ -82,7 +82,8 @@ static inline bool
 ReportNotArray(struct xkb_context *ctx, const char *type, const char *field,
                const char *name)
 {
-    log_err(ctx,
+    log_err_with_code(ctx,
+            XKB_ERROR_WRONG_FIELD_TYPE,
             "The %s %s field is not an array; "
             "Ignoring illegal assignment in %s\n",
             type, field, name);
@@ -93,7 +94,8 @@ static inline bool
 ReportShouldBeArray(struct xkb_context *ctx, const char *type,
                     const char *field, const char *name)
 {
-    log_err(ctx,
+    log_err_with_code(ctx,
+            XKB_ERROR_EXPECTED_ARRAY_ENTRY,
             "Missing subscript for %s %s; "
             "Ignoring illegal assignment in %s\n",
             type, field, name);
diff --git a/test/log.c b/test/log.c
index 384fabc..14e4845 100644
--- a/test/log.c
+++ b/test/log.c
@@ -25,6 +25,7 @@
 
 #include "test.h"
 #include "context.h"
+#include "messages-codes.h"
 
 #ifdef __GNUC__
 #pragma GCC diagnostic ignored "-Wmissing-format-attribute"
@@ -89,14 +90,14 @@ main(void)
     log_info(ctx, "first info\n");
     log_dbg(ctx, "first debug: %s\n", "hello");
     log_err(ctx, "first error: %lu\n", 115415UL);
-    log_vrb(ctx, 5, "first verbose 5\n");
+    log_vrb(ctx, 5, XKB_LOG_MESSAGE_NO_ID, "first verbose 5\n");
 
     xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_DEBUG);
     log_warn(ctx, "second warning: %d\n", 87);
     log_dbg(ctx, "second debug: %s %s\n", "hello", "world");
     log_info(ctx, "second info\n");
     log_err(ctx, "second error: %lu\n", 115415UL);
-    log_vrb(ctx, 6, "second verbose 6\n");
+    log_vrb(ctx, 6, XKB_LOG_MESSAGE_NO_ID, "second verbose 6\n");
 
     xkb_context_set_log_verbosity(ctx, 0);
     xkb_context_set_log_level(ctx, XKB_LOG_LEVEL_CRITICAL);
@@ -104,14 +105,14 @@ main(void)
     log_dbg(ctx, "third debug: %s %s\n", "hello", "world");
     log_info(ctx, "third info\n");
     log_err(ctx, "third error: %lu\n", 115415UL);
-    log_vrb(ctx, 0, "third verbose 0\n");
+    log_vrb(ctx, 0, XKB_LOG_MESSAGE_NO_ID, "third verbose 0\n");
 
     printf("%s", log_string.item);
 
     assert(streq(log_string.item,
                  "warning: first warning: 87\n"
                  "error: first error: 115415\n"
-                 "warning: first verbose 5\n"
+                 "warning: [XKB-000] first verbose 5\n"
                  "warning: second warning: 87\n"
                  "debug: second debug: hello world\n"
                  "info: second info\n"
diff --git a/tools/messages.c b/tools/messages.c
index abda073..fc3b411 100644
--- a/tools/messages.c
+++ b/tools/messages.c
@@ -39,26 +39,57 @@
 
 static const struct xkb_message_entry xkb_messages[] = {
     {XKB_ERROR_MALFORMED_NUMBER_LITERAL, "Malformed number literal"},
+    {XKB_WARNING_CONFLICTING_KEY_TYPE_PRESERVE_ENTRIES, "Conflicting key type preserve entries"},
     {XKB_ERROR_UNSUPPORTED_MODIFIER_MASK, "Unsupported modifier mask"},
+    {XKB_ERROR_EXPECTED_ARRAY_ENTRY, "Expected array entry"},
+    {XKB_WARNING_ILLEGAL_KEYCODE_ALIAS, "Illegal keycode alias"},
     {XKB_WARNING_UNRECOGNIZED_KEYSYM, "Unrecognized keysym"},
+    {XKB_ERROR_UNDECLARED_VIRTUAL_MODIFIER, "Undeclared virtual modifier"},
+    {XKB_ERROR_WRONG_STATEMENT_TYPE, "Wrong statement type"},
+    {XKB_WARNING_UNSUPPORTED_GEOMETRY_SECTION, "Unsupported geometry section"},
     {XKB_WARNING_CANNOT_INFER_KEY_TYPE, "Cannot infer key type"},
+    {XKB_WARNING_ILLEGAL_KEY_TYPE_PRESERVE_RESULT, "Illegal key type preserve result"},
+    {XKB_ERROR_INVALID_INCLUDE_STATEMENT, "Invalid include statement"},
+    {XKB_ERROR_INVALID_MODMAP_ENTRY, "Invalid modmap entry"},
     {XKB_ERROR_UNSUPPORTED_GROUP_INDEX, "Unsupported group index"},
+    {XKB_WARNING_CONFLICTING_KEY_TYPE_LEVEL_NAMES, "Conflicting key type level names"},
+    {XKB_ERROR_INVALID_SET_DEFAULT_STATEMENT, "Invalid set default statement"},
+    {XKB_WARNING_CONFLICTING_KEY_TYPE_MAP_ENTRY, "Conflicting key type map entry"},
     {XKB_WARNING_UNDEFINED_KEY_TYPE, "Undefined key type"},
     {XKB_WARNING_NON_BASE_GROUP_NAME, "Non base group name"},
     {XKB_ERROR_UNSUPPORTED_SHIFT_LEVEL, "Unsupported shift level"},
+    {XKB_ERROR_INCLUDED_FILE_NOT_FOUND, "Included file not found"},
+    {XKB_ERROR_UNKNOWN_OPERATOR, "Unknown operator"},
+    {XKB_WARNING_DUPLICATE_ENTRY, "Duplicate entry"},
+    {XKB_WARNING_CONFLICTING_KEY_TYPE_DEFINITIONS, "Conflicting key type definitions"},
+    {XKB_ERROR_WRONG_SCOPE, "Wrong scope"},
+    {XKB_WARNING_MISSING_DEFAULT_SECTION, "Missing default section"},
     {XKB_WARNING_CONFLICTING_KEY_SYMBOL, "Conflicting key symbol"},
+    {XKB_ERROR_INVALID_OPERATION, "Invalid operation"},
     {XKB_WARNING_NUMERIC_KEYSYM, "Numeric keysym"},
     {XKB_WARNING_EXTRA_SYMBOLS_IGNORED, "Extra symbols ignored"},
+    {XKB_WARNING_CONFLICTING_KEY_NAME, "Conflicting key name"},
+    {XKB_ERROR_ALLOCATION_ERROR, "Allocation error"},
     {XKB_ERROR_WRONG_FIELD_TYPE, "Wrong field type"},
+    {XKB_ERROR_INVALID_REAL_MODIFIER, "Invalid real modifier"},
     {XKB_WARNING_UNKNOWN_CHAR_ESCAPE_SEQUENCE, "Unknown char escape sequence"},
+    {XKB_ERROR_INVALID_INCLUDED_FILE, "Invalid included file"},
     {XKB_WARNING_MULTIPLE_GROUPS_AT_ONCE, "Multiple groups at once"},
+    {XKB_WARNING_UNSUPPORTED_SYMBOLS_FIELD, "Unsupported symbols field"},
     {XKB_ERROR_INVALID_SYNTAX, "Invalid syntax"},
     {XKB_WARNING_UNDEFINED_KEYCODE, "Undefined keycode"},
+    {XKB_ERROR_INVALID_EXPRESSION_TYPE, "Invalid expression type"},
+    {XKB_ERROR_INVALID_VALUE, "Invalid value"},
     {XKB_WARNING_CONFLICTING_MODMAP, "Conflicting modmap"},
+    {XKB_ERROR_UNKNOWN_FIELD, "Unknown field"},
     {XKB_WARNING_CONFLICTING_KEY_ACTION, "Conflicting key action"},
-    {XKB_WARNING_CONFLICTING_KEY_TYPE, "Conflicting key type"},
+    {XKB_WARNING_CONFLICTING_KEY_TYPE_MERGING_GROUPS, "Conflicting key type merging groups"},
+    {XKB_ERROR_CONFLICTING_KEY_SYMBOLS_ENTRY, "Conflicting key symbols entry"},
+    {XKB_WARNING_MISSING_SYMBOLS_GROUP_NAME_INDEX, "Missing symbols group name index"},
     {XKB_WARNING_CONFLICTING_KEY_FIELDS, "Conflicting key fields"},
-    {XKB_WARNING_UNRESOLVED_KEYMAP_SYMBOL, "Unresolved keymap symbol"}
+    {XKB_ERROR_INVALID_IDENTIFIER, "Invalid identifier"},
+    {XKB_WARNING_UNRESOLVED_KEYMAP_SYMBOL, "Unresolved keymap symbol"},
+    {XKB_WARNING_UNDECLARED_MODIFIERS_IN_KEY_TYPE, "Undeclared modifiers in key type"}
 };
 
 int