scarf-python 0.2.2

Python bindings for the Scarf SystemVerilog tools
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
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
// =======================================================================
// token.rs
// =======================================================================
//! A wrapper around [`scarf_parser::Token`]

use crate::Span;
use pyo3::prelude::*;
use scarf_parser::{self, PreprocessorCache};

/// A wrapper around [`scarf_parser::Token`]
#[pyclass(eq, from_py_object, module = "scarf_python", str)]
#[derive(Clone, PartialEq, Eq)]
pub enum Token {
    Error(),
    // 1364-1995
    Always(),
    And(),
    Assign(),
    Begin(),
    Buf(),
    Bufif0(),
    Bufif1(),
    Case(),
    Casex(),
    Casez(),
    Cmos(),
    Deassign(),
    Default(),
    Defparam(),
    Disable(),
    Edge(),
    Else(),
    End(),
    Endcase(),
    Endfunction(),
    Endmodule(),
    Endprimitive(),
    Endspecify(),
    Endtable(),
    Endtask(),
    Event(),
    For(),
    Force(),
    Forever(),
    Fork(),
    Function(),
    Highz0(),
    Highz1(),
    If(),
    Ifnone(),
    Initial(),
    Inout(),
    Input(),
    Integer(),
    Join(),
    Large(),
    Macromodule(),
    Medium(),
    Module(),
    Nand(),
    Negedge(),
    Nmos(),
    Nor(),
    Not(),
    Notif0(),
    Notif1(),
    Or(),
    Output(),
    Parameter(),
    Pmos(),
    Posedge(),
    Primitive(),
    Pull0(),
    Pull1(),
    Pulldown(),
    Pullup(),
    Rcmos(),
    Real(),
    Realtime(),
    Reg(),
    Release(),
    Repeat(),
    Rnmos(),
    Rpmos(),
    Rtran(),
    Rtranif0(),
    Rtranif1(),
    Scalared(),
    Small(),
    Specify(),
    Specparam(),
    Strong0(),
    Strong1(),
    Supply0(),
    Supply1(),
    Table(),
    Task(),
    Time(),
    Tran(),
    Tranif0(),
    Tranif1(),
    Tri(),
    Tri0(),
    Tri1(),
    Triand(),
    Trior(),
    Trireg(),
    Vectored(),
    Wait(),
    Wand(),
    Weak0(),
    Weak1(),
    While(),
    Wire(),
    Wor(),
    Xnor(),
    Xor(),
    // 1364-2001
    Automatic(),
    Cell(),
    Config(),
    Design(),
    Endconfig(),
    Endgenerate(),
    Generate(),
    Genvar(),
    Incdir(),
    Include(),
    Instance(),
    Liblist(),
    Library(),
    Localparam(),
    Noshowcancelled(),
    PulsestyleOndetect(),
    PulsestyleOnevent(),
    Showcancelled(),
    Signed(),
    Unsigned(),
    Use(),
    // 1364-2005
    Uwire(),
    // 1800-2005
    Alias(),
    AlwaysComb(),
    AlwaysFf(),
    AlwaysLatch(),
    Assert(),
    Assume(),
    Before(),
    Bind(),
    Bins(),
    Binsof(),
    Bit(),
    Break(),
    Byte(),
    Chandle(),
    Class(),
    Clocking(),
    Const(),
    Constraint(),
    Context(),
    Continue(),
    Cover(),
    Covergroup(),
    Coverpoint(),
    Cross(),
    Dist(),
    Do(),
    Endclass(),
    Endclocking(),
    Endgroup(),
    Endinterface(),
    Endpackage(),
    Endprogram(),
    Endproperty(),
    Endsequence(),
    Enum(),
    Expect(),
    Export(),
    Extends(),
    Extern(),
    Final(),
    FirstMatch(),
    Foreach(),
    Forkjoin(),
    Iff(),
    IgnoreBins(),
    IllegalBins(),
    Import(),
    Inside(),
    Int(),
    Interface(),
    Intersect(),
    JoinAny(),
    JoinNone(),
    Local(),
    Logic(),
    Longint(),
    Matches(),
    Modport(),
    New(),
    Null(),
    Package(),
    Packed(),
    Priority(),
    Program(),
    Property(),
    Protected(),
    Pure(),
    Rand(),
    Randc(),
    Randcase(),
    Randsequence(),
    Ref(),
    Return(),
    Sequence(),
    Shortint(),
    Shortreal(),
    Solve(),
    Static(),
    String(),
    Struct(),
    Super(),
    Tagged(),
    This(),
    Throughout(),
    Timeprecision(),
    Timeunit(),
    Type(),
    Typedef(),
    Union(),
    Unique(),
    Var(),
    Virtual(),
    Void(),
    WaitOrder(),
    Wildcard(),
    With(),
    Within(),
    // 1800-2009
    AcceptOn(),
    Checker(),
    Endchecker(),
    Eventually(),
    Global(),
    Implies(),
    Let(),
    Nexttime(),
    RejectOn(),
    Restrict(),
    SAlways(),
    SEventually(),
    SNexttime(),
    SUntil(),
    SUntilWith(),
    Strong(),
    SyncAcceptOn(),
    SyncRejectOn(),
    Unique0(),
    Until(),
    UntilWith(),
    Untyped(),
    Weak(),
    // 1800-2012
    Implements(),
    Interconnect(),
    Nettype(),
    Soft(),
    // Directives
    DirUnderscoreFile(),
    DirUnderscoreLine(),
    DirBeginKeywords(),
    DirCelldefine(),
    DirDefaultNettype(),
    DirDefine(),
    DirElse(),
    DirElsif(),
    DirEndKeywords(),
    DirEndcelldefine(),
    DirEndif(),
    DirIfdef(),
    DirIfndef(),
    DirInclude(),
    DirLine(),
    DirNounconnectedDrive(),
    DirPragma(),
    DirResetall(),
    DirTimescale(),
    DirUnconnectedDrive(),
    DirUndef(),
    DirUndefineall(),
    // Operators
    Plus(),
    Minus(),
    Exclamation(),
    Quest(),
    Tilde(),
    Amp(),
    TildeAmp(),
    Pipe(),
    TildePipe(),
    Caret(),
    TildeCaret(),
    CaretTilde(),
    Star(),
    Slash(),
    Percent(),
    EqEq(),
    ExclEq(),
    PlusEq(),
    MinusEq(),
    StarEq(),
    SlashEq(),
    PercentEq(),
    AmpEq(),
    PipeEq(),
    CaretEq(),
    EqEqEq(),
    ExclEqEq(),
    EqEqQuest(),
    ExclEqQuest(),
    AmpAmp(),
    AmpAmpAmp(),
    PipePipe(),
    StarStar(),
    Lt(),
    LtEq(),
    Gt(),
    GtEq(),
    GtGt(),
    LtLt(),
    GtGtEq(),
    LtLtEq(),
    GtGtGt(),
    LtLtLt(),
    GtGtGtEq(),
    LtLtLtEq(),
    MinusGt(),
    MinusGtGt(),
    LtMinusGt(),
    PlusPlus(),
    MinusMinus(),
    PlusColon(),
    MinusColon(),
    PlusSlashMinus(),
    PlusPercentMinus(),
    // Symbols
    Paren(),
    EParen(),
    Bracket(),
    EBracket(),
    Brace(),
    EBrace(),
    Colon(),
    SColon(),
    Apost(),
    Comma(),
    Period(),
    Pound(),
    Dollar(),
    At(),
    AtAt(),
    Eq(),
    ColonColon(),
    ColonEq(),
    ColonSlash(),
    PoundPound(),
    PoundMinusPound(),
    PoundEqPound(),
    EqGt(),
    StarGt(),
    PipeMinusGt(),
    PipeEqGt(),
    Bslash(),
    // Other Language Grammar
    Std(),
    PathpulseDollar(),
    Option(),
    TypeOption(),
    Randomize(),
    Sample(),
    OneStep(),
    DollarSetup(),
    DollarHold(),
    DollarSetuphold(),
    DollarRecovery(),
    DollarRemoval(),
    DollarRecrem(),
    DollarSkew(),
    DollarTimeskew(),
    DollarFullskew(),
    DollarPeriod(),
    DollarWidth(),
    DollarNochange(),
    DollarRoot(),
    DollarUnit(),
    DollarFatal(),
    DollarError(),
    DollarWarning(),
    DollarInfo(),
    // Comments
    OnelineComment { text: String },
    BlockComment { text: String },
    // Numbers
    UnsignedNumber { text: String },
    FixedPointNumber { text: String },
    BinaryNumber { text: String },
    OctalNumber { text: String },
    DecimalNumber { text: String },
    HexNumber { text: String },
    ScientificNumber { text: String },
    UnbasedUnsizedLiteral { text: String },
    // Literals
    SystemTfIdentifier { text: String },
    SimpleIdentifier { text: String },
    EscapedIdentifier { text: String },
    PreprocessorIdentifier { text: String },
    TextMacro { text: String },
    StringLiteral { text: String },
    PreprocessorStringLiteral { text: String },
    TripleQuoteStringLiteral { text: String },
    PreprocessorTripleQuoteStringLiteral { text: String },
    Newline(),
}

impl std::fmt::Display for Token {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        let rust_token: scarf_parser::Token<'_> = self.into();
        rust_token.fmt(f)
    }
}

impl<'a> From<scarf_parser::Token<'a>> for Token {
    fn from(value: scarf_parser::Token<'a>) -> Self {
        match value {
            scarf_parser::Token::Error => Token::Error(),
            scarf_parser::Token::Always => Token::Always(),
            scarf_parser::Token::And => Token::And(),
            scarf_parser::Token::Assign => Token::Assign(),
            scarf_parser::Token::Begin => Token::Begin(),
            scarf_parser::Token::Buf => Token::Buf(),
            scarf_parser::Token::Bufif0 => Token::Bufif0(),
            scarf_parser::Token::Bufif1 => Token::Bufif1(),
            scarf_parser::Token::Case => Token::Case(),
            scarf_parser::Token::Casex => Token::Casex(),
            scarf_parser::Token::Casez => Token::Casez(),
            scarf_parser::Token::Cmos => Token::Cmos(),
            scarf_parser::Token::Deassign => Token::Deassign(),
            scarf_parser::Token::Default => Token::Default(),
            scarf_parser::Token::Defparam => Token::Defparam(),
            scarf_parser::Token::Disable => Token::Disable(),
            scarf_parser::Token::Edge => Token::Edge(),
            scarf_parser::Token::Else => Token::Else(),
            scarf_parser::Token::End => Token::End(),
            scarf_parser::Token::Endcase => Token::Endcase(),
            scarf_parser::Token::Endfunction => Token::Endfunction(),
            scarf_parser::Token::Endmodule => Token::Endmodule(),
            scarf_parser::Token::Endprimitive => Token::Endprimitive(),
            scarf_parser::Token::Endspecify => Token::Endspecify(),
            scarf_parser::Token::Endtable => Token::Endtable(),
            scarf_parser::Token::Endtask => Token::Endtask(),
            scarf_parser::Token::Event => Token::Event(),
            scarf_parser::Token::For => Token::For(),
            scarf_parser::Token::Force => Token::Force(),
            scarf_parser::Token::Forever => Token::Forever(),
            scarf_parser::Token::Fork => Token::Fork(),
            scarf_parser::Token::Function => Token::Function(),
            scarf_parser::Token::Highz0 => Token::Highz0(),
            scarf_parser::Token::Highz1 => Token::Highz1(),
            scarf_parser::Token::If => Token::If(),
            scarf_parser::Token::Ifnone => Token::Ifnone(),
            scarf_parser::Token::Initial => Token::Initial(),
            scarf_parser::Token::Inout => Token::Inout(),
            scarf_parser::Token::Input => Token::Input(),
            scarf_parser::Token::Integer => Token::Integer(),
            scarf_parser::Token::Join => Token::Join(),
            scarf_parser::Token::Large => Token::Large(),
            scarf_parser::Token::Macromodule => Token::Macromodule(),
            scarf_parser::Token::Medium => Token::Medium(),
            scarf_parser::Token::Module => Token::Module(),
            scarf_parser::Token::Nand => Token::Nand(),
            scarf_parser::Token::Negedge => Token::Negedge(),
            scarf_parser::Token::Nmos => Token::Nmos(),
            scarf_parser::Token::Nor => Token::Nor(),
            scarf_parser::Token::Not => Token::Not(),
            scarf_parser::Token::Notif0 => Token::Notif0(),
            scarf_parser::Token::Notif1 => Token::Notif1(),
            scarf_parser::Token::Or => Token::Or(),
            scarf_parser::Token::Output => Token::Output(),
            scarf_parser::Token::Parameter => Token::Parameter(),
            scarf_parser::Token::Pmos => Token::Pmos(),
            scarf_parser::Token::Posedge => Token::Posedge(),
            scarf_parser::Token::Primitive => Token::Primitive(),
            scarf_parser::Token::Pull0 => Token::Pull0(),
            scarf_parser::Token::Pull1 => Token::Pull1(),
            scarf_parser::Token::Pulldown => Token::Pulldown(),
            scarf_parser::Token::Pullup => Token::Pullup(),
            scarf_parser::Token::Rcmos => Token::Rcmos(),
            scarf_parser::Token::Real => Token::Real(),
            scarf_parser::Token::Realtime => Token::Realtime(),
            scarf_parser::Token::Reg => Token::Reg(),
            scarf_parser::Token::Release => Token::Release(),
            scarf_parser::Token::Repeat => Token::Repeat(),
            scarf_parser::Token::Rnmos => Token::Rnmos(),
            scarf_parser::Token::Rpmos => Token::Rpmos(),
            scarf_parser::Token::Rtran => Token::Rtran(),
            scarf_parser::Token::Rtranif0 => Token::Rtranif0(),
            scarf_parser::Token::Rtranif1 => Token::Rtranif1(),
            scarf_parser::Token::Scalared => Token::Scalared(),
            scarf_parser::Token::Small => Token::Small(),
            scarf_parser::Token::Specify => Token::Specify(),
            scarf_parser::Token::Specparam => Token::Specparam(),
            scarf_parser::Token::Strong0 => Token::Strong0(),
            scarf_parser::Token::Strong1 => Token::Strong1(),
            scarf_parser::Token::Supply0 => Token::Supply0(),
            scarf_parser::Token::Supply1 => Token::Supply1(),
            scarf_parser::Token::Table => Token::Table(),
            scarf_parser::Token::Task => Token::Task(),
            scarf_parser::Token::Time => Token::Time(),
            scarf_parser::Token::Tran => Token::Tran(),
            scarf_parser::Token::Tranif0 => Token::Tranif0(),
            scarf_parser::Token::Tranif1 => Token::Tranif1(),
            scarf_parser::Token::Tri => Token::Tri(),
            scarf_parser::Token::Tri0 => Token::Tri0(),
            scarf_parser::Token::Tri1 => Token::Tri1(),
            scarf_parser::Token::Triand => Token::Triand(),
            scarf_parser::Token::Trior => Token::Trior(),
            scarf_parser::Token::Trireg => Token::Trireg(),
            scarf_parser::Token::Vectored => Token::Vectored(),
            scarf_parser::Token::Wait => Token::Wait(),
            scarf_parser::Token::Wand => Token::Wand(),
            scarf_parser::Token::Weak0 => Token::Weak0(),
            scarf_parser::Token::Weak1 => Token::Weak1(),
            scarf_parser::Token::While => Token::While(),
            scarf_parser::Token::Wire => Token::Wire(),
            scarf_parser::Token::Wor => Token::Wor(),
            scarf_parser::Token::Xnor => Token::Xnor(),
            scarf_parser::Token::Xor => Token::Xor(),
            scarf_parser::Token::Automatic => Token::Automatic(),
            scarf_parser::Token::Cell => Token::Cell(),
            scarf_parser::Token::Config => Token::Config(),
            scarf_parser::Token::Design => Token::Design(),
            scarf_parser::Token::Endconfig => Token::Endconfig(),
            scarf_parser::Token::Endgenerate => Token::Endgenerate(),
            scarf_parser::Token::Generate => Token::Generate(),
            scarf_parser::Token::Genvar => Token::Genvar(),
            scarf_parser::Token::Incdir => Token::Incdir(),
            scarf_parser::Token::Include => Token::Include(),
            scarf_parser::Token::Instance => Token::Instance(),
            scarf_parser::Token::Liblist => Token::Liblist(),
            scarf_parser::Token::Library => Token::Library(),
            scarf_parser::Token::Localparam => Token::Localparam(),
            scarf_parser::Token::Noshowcancelled => Token::Noshowcancelled(),
            scarf_parser::Token::PulsestyleOndetect => {
                Token::PulsestyleOndetect()
            }
            scarf_parser::Token::PulsestyleOnevent => {
                Token::PulsestyleOnevent()
            }
            scarf_parser::Token::Showcancelled => Token::Showcancelled(),
            scarf_parser::Token::Signed => Token::Signed(),
            scarf_parser::Token::Unsigned => Token::Unsigned(),
            scarf_parser::Token::Use => Token::Use(),
            scarf_parser::Token::Uwire => Token::Uwire(),
            scarf_parser::Token::Alias => Token::Alias(),
            scarf_parser::Token::AlwaysComb => Token::AlwaysComb(),
            scarf_parser::Token::AlwaysFf => Token::AlwaysFf(),
            scarf_parser::Token::AlwaysLatch => Token::AlwaysLatch(),
            scarf_parser::Token::Assert => Token::Assert(),
            scarf_parser::Token::Assume => Token::Assume(),
            scarf_parser::Token::Before => Token::Before(),
            scarf_parser::Token::Bind => Token::Bind(),
            scarf_parser::Token::Bins => Token::Bins(),
            scarf_parser::Token::Binsof => Token::Binsof(),
            scarf_parser::Token::Bit => Token::Bit(),
            scarf_parser::Token::Break => Token::Break(),
            scarf_parser::Token::Byte => Token::Byte(),
            scarf_parser::Token::Chandle => Token::Chandle(),
            scarf_parser::Token::Class => Token::Class(),
            scarf_parser::Token::Clocking => Token::Clocking(),
            scarf_parser::Token::Const => Token::Const(),
            scarf_parser::Token::Constraint => Token::Constraint(),
            scarf_parser::Token::Context => Token::Context(),
            scarf_parser::Token::Continue => Token::Continue(),
            scarf_parser::Token::Cover => Token::Cover(),
            scarf_parser::Token::Covergroup => Token::Covergroup(),
            scarf_parser::Token::Coverpoint => Token::Coverpoint(),
            scarf_parser::Token::Cross => Token::Cross(),
            scarf_parser::Token::Dist => Token::Dist(),
            scarf_parser::Token::Do => Token::Do(),
            scarf_parser::Token::Endclass => Token::Endclass(),
            scarf_parser::Token::Endclocking => Token::Endclocking(),
            scarf_parser::Token::Endgroup => Token::Endgroup(),
            scarf_parser::Token::Endinterface => Token::Endinterface(),
            scarf_parser::Token::Endpackage => Token::Endpackage(),
            scarf_parser::Token::Endprogram => Token::Endprogram(),
            scarf_parser::Token::Endproperty => Token::Endproperty(),
            scarf_parser::Token::Endsequence => Token::Endsequence(),
            scarf_parser::Token::Enum => Token::Enum(),
            scarf_parser::Token::Expect => Token::Expect(),
            scarf_parser::Token::Export => Token::Export(),
            scarf_parser::Token::Extends => Token::Extends(),
            scarf_parser::Token::Extern => Token::Extern(),
            scarf_parser::Token::Final => Token::Final(),
            scarf_parser::Token::FirstMatch => Token::FirstMatch(),
            scarf_parser::Token::Foreach => Token::Foreach(),
            scarf_parser::Token::Forkjoin => Token::Forkjoin(),
            scarf_parser::Token::Iff => Token::Iff(),
            scarf_parser::Token::IgnoreBins => Token::IgnoreBins(),
            scarf_parser::Token::IllegalBins => Token::IllegalBins(),
            scarf_parser::Token::Import => Token::Import(),
            scarf_parser::Token::Inside => Token::Inside(),
            scarf_parser::Token::Int => Token::Int(),
            scarf_parser::Token::Interface => Token::Interface(),
            scarf_parser::Token::Intersect => Token::Intersect(),
            scarf_parser::Token::JoinAny => Token::JoinAny(),
            scarf_parser::Token::JoinNone => Token::JoinNone(),
            scarf_parser::Token::Local => Token::Local(),
            scarf_parser::Token::Logic => Token::Logic(),
            scarf_parser::Token::Longint => Token::Longint(),
            scarf_parser::Token::Matches => Token::Matches(),
            scarf_parser::Token::Modport => Token::Modport(),
            scarf_parser::Token::New => Token::New(),
            scarf_parser::Token::Null => Token::Null(),
            scarf_parser::Token::Package => Token::Package(),
            scarf_parser::Token::Packed => Token::Packed(),
            scarf_parser::Token::Priority => Token::Priority(),
            scarf_parser::Token::Program => Token::Program(),
            scarf_parser::Token::Property => Token::Property(),
            scarf_parser::Token::Protected => Token::Protected(),
            scarf_parser::Token::Pure => Token::Pure(),
            scarf_parser::Token::Rand => Token::Rand(),
            scarf_parser::Token::Randc => Token::Randc(),
            scarf_parser::Token::Randcase => Token::Randcase(),
            scarf_parser::Token::Randsequence => Token::Randsequence(),
            scarf_parser::Token::Ref => Token::Ref(),
            scarf_parser::Token::Return => Token::Return(),
            scarf_parser::Token::Sequence => Token::Sequence(),
            scarf_parser::Token::Shortint => Token::Shortint(),
            scarf_parser::Token::Shortreal => Token::Shortreal(),
            scarf_parser::Token::Solve => Token::Solve(),
            scarf_parser::Token::Static => Token::Static(),
            scarf_parser::Token::String => Token::String(),
            scarf_parser::Token::Struct => Token::Struct(),
            scarf_parser::Token::Super => Token::Super(),
            scarf_parser::Token::Tagged => Token::Tagged(),
            scarf_parser::Token::This => Token::This(),
            scarf_parser::Token::Throughout => Token::Throughout(),
            scarf_parser::Token::Timeprecision => Token::Timeprecision(),
            scarf_parser::Token::Timeunit => Token::Timeunit(),
            scarf_parser::Token::Type => Token::Type(),
            scarf_parser::Token::Typedef => Token::Typedef(),
            scarf_parser::Token::Union => Token::Union(),
            scarf_parser::Token::Unique => Token::Unique(),
            scarf_parser::Token::Var => Token::Var(),
            scarf_parser::Token::Virtual => Token::Virtual(),
            scarf_parser::Token::Void => Token::Void(),
            scarf_parser::Token::WaitOrder => Token::WaitOrder(),
            scarf_parser::Token::Wildcard => Token::Wildcard(),
            scarf_parser::Token::With => Token::With(),
            scarf_parser::Token::Within => Token::Within(),
            scarf_parser::Token::AcceptOn => Token::AcceptOn(),
            scarf_parser::Token::Checker => Token::Checker(),
            scarf_parser::Token::Endchecker => Token::Endchecker(),
            scarf_parser::Token::Eventually => Token::Eventually(),
            scarf_parser::Token::Global => Token::Global(),
            scarf_parser::Token::Implies => Token::Implies(),
            scarf_parser::Token::Let => Token::Let(),
            scarf_parser::Token::Nexttime => Token::Nexttime(),
            scarf_parser::Token::RejectOn => Token::RejectOn(),
            scarf_parser::Token::Restrict => Token::Restrict(),
            scarf_parser::Token::SAlways => Token::SAlways(),
            scarf_parser::Token::SEventually => Token::SEventually(),
            scarf_parser::Token::SNexttime => Token::SNexttime(),
            scarf_parser::Token::SUntil => Token::SUntil(),
            scarf_parser::Token::SUntilWith => Token::SUntilWith(),
            scarf_parser::Token::Strong => Token::Strong(),
            scarf_parser::Token::SyncAcceptOn => Token::SyncAcceptOn(),
            scarf_parser::Token::SyncRejectOn => Token::SyncRejectOn(),
            scarf_parser::Token::Unique0 => Token::Unique0(),
            scarf_parser::Token::Until => Token::Until(),
            scarf_parser::Token::UntilWith => Token::UntilWith(),
            scarf_parser::Token::Untyped => Token::Untyped(),
            scarf_parser::Token::Weak => Token::Weak(),
            scarf_parser::Token::Implements => Token::Implements(),
            scarf_parser::Token::Interconnect => Token::Interconnect(),
            scarf_parser::Token::Nettype => Token::Nettype(),
            scarf_parser::Token::Soft => Token::Soft(),
            scarf_parser::Token::DirUnderscoreFile => {
                Token::DirUnderscoreFile()
            }
            scarf_parser::Token::DirUnderscoreLine => {
                Token::DirUnderscoreLine()
            }
            scarf_parser::Token::DirBeginKeywords => Token::DirBeginKeywords(),
            scarf_parser::Token::DirCelldefine => Token::DirCelldefine(),
            scarf_parser::Token::DirDefaultNettype => {
                Token::DirDefaultNettype()
            }
            scarf_parser::Token::DirDefine => Token::DirDefine(),
            scarf_parser::Token::DirElse => Token::DirElse(),
            scarf_parser::Token::DirElsif => Token::DirElsif(),
            scarf_parser::Token::DirEndKeywords => Token::DirEndKeywords(),
            scarf_parser::Token::DirEndcelldefine => Token::DirEndcelldefine(),
            scarf_parser::Token::DirEndif => Token::DirEndif(),
            scarf_parser::Token::DirIfdef => Token::DirIfdef(),
            scarf_parser::Token::DirIfndef => Token::DirIfndef(),
            scarf_parser::Token::DirInclude => Token::DirInclude(),
            scarf_parser::Token::DirLine => Token::DirLine(),
            scarf_parser::Token::DirNounconnectedDrive => {
                Token::DirNounconnectedDrive()
            }
            scarf_parser::Token::DirPragma => Token::DirPragma(),
            scarf_parser::Token::DirResetall => Token::DirResetall(),
            scarf_parser::Token::DirTimescale => Token::DirTimescale(),
            scarf_parser::Token::DirUnconnectedDrive => {
                Token::DirUnconnectedDrive()
            }
            scarf_parser::Token::DirUndef => Token::DirUndef(),
            scarf_parser::Token::DirUndefineall => Token::DirUndefineall(),
            scarf_parser::Token::Plus => Token::Plus(),
            scarf_parser::Token::Minus => Token::Minus(),
            scarf_parser::Token::Exclamation => Token::Exclamation(),
            scarf_parser::Token::Quest => Token::Quest(),
            scarf_parser::Token::Tilde => Token::Tilde(),
            scarf_parser::Token::Amp => Token::Amp(),
            scarf_parser::Token::TildeAmp => Token::TildeAmp(),
            scarf_parser::Token::Pipe => Token::Pipe(),
            scarf_parser::Token::TildePipe => Token::TildePipe(),
            scarf_parser::Token::Caret => Token::Caret(),
            scarf_parser::Token::TildeCaret => Token::TildeCaret(),
            scarf_parser::Token::CaretTilde => Token::CaretTilde(),
            scarf_parser::Token::Star => Token::Star(),
            scarf_parser::Token::Slash => Token::Slash(),
            scarf_parser::Token::Percent => Token::Percent(),
            scarf_parser::Token::EqEq => Token::EqEq(),
            scarf_parser::Token::ExclEq => Token::ExclEq(),
            scarf_parser::Token::PlusEq => Token::PlusEq(),
            scarf_parser::Token::MinusEq => Token::MinusEq(),
            scarf_parser::Token::StarEq => Token::StarEq(),
            scarf_parser::Token::SlashEq => Token::SlashEq(),
            scarf_parser::Token::PercentEq => Token::PercentEq(),
            scarf_parser::Token::AmpEq => Token::AmpEq(),
            scarf_parser::Token::PipeEq => Token::PipeEq(),
            scarf_parser::Token::CaretEq => Token::CaretEq(),
            scarf_parser::Token::EqEqEq => Token::EqEqEq(),
            scarf_parser::Token::ExclEqEq => Token::ExclEqEq(),
            scarf_parser::Token::EqEqQuest => Token::EqEqQuest(),
            scarf_parser::Token::ExclEqQuest => Token::ExclEqQuest(),
            scarf_parser::Token::AmpAmp => Token::AmpAmp(),
            scarf_parser::Token::AmpAmpAmp => Token::AmpAmpAmp(),
            scarf_parser::Token::PipePipe => Token::PipePipe(),
            scarf_parser::Token::StarStar => Token::StarStar(),
            scarf_parser::Token::Lt => Token::Lt(),
            scarf_parser::Token::LtEq => Token::LtEq(),
            scarf_parser::Token::Gt => Token::Gt(),
            scarf_parser::Token::GtEq => Token::GtEq(),
            scarf_parser::Token::GtGt => Token::GtGt(),
            scarf_parser::Token::LtLt => Token::LtLt(),
            scarf_parser::Token::GtGtEq => Token::GtGtEq(),
            scarf_parser::Token::LtLtEq => Token::LtLtEq(),
            scarf_parser::Token::GtGtGt => Token::GtGtGt(),
            scarf_parser::Token::LtLtLt => Token::LtLtLt(),
            scarf_parser::Token::GtGtGtEq => Token::GtGtGtEq(),
            scarf_parser::Token::LtLtLtEq => Token::LtLtLtEq(),
            scarf_parser::Token::MinusGt => Token::MinusGt(),
            scarf_parser::Token::MinusGtGt => Token::MinusGtGt(),
            scarf_parser::Token::LtMinusGt => Token::LtMinusGt(),
            scarf_parser::Token::PlusPlus => Token::PlusPlus(),
            scarf_parser::Token::MinusMinus => Token::MinusMinus(),
            scarf_parser::Token::PlusColon => Token::PlusColon(),
            scarf_parser::Token::MinusColon => Token::MinusColon(),
            scarf_parser::Token::PlusSlashMinus => Token::PlusSlashMinus(),
            scarf_parser::Token::PlusPercentMinus => Token::PlusPercentMinus(),
            scarf_parser::Token::Paren => Token::Paren(),
            scarf_parser::Token::EParen => Token::EParen(),
            scarf_parser::Token::Bracket => Token::Bracket(),
            scarf_parser::Token::EBracket => Token::EBracket(),
            scarf_parser::Token::Brace => Token::Brace(),
            scarf_parser::Token::EBrace => Token::EBrace(),
            scarf_parser::Token::Colon => Token::Colon(),
            scarf_parser::Token::SColon => Token::SColon(),
            scarf_parser::Token::Apost => Token::Apost(),
            scarf_parser::Token::Comma => Token::Comma(),
            scarf_parser::Token::Period => Token::Period(),
            scarf_parser::Token::Pound => Token::Pound(),
            scarf_parser::Token::Dollar => Token::Dollar(),
            scarf_parser::Token::At => Token::At(),
            scarf_parser::Token::AtAt => Token::AtAt(),
            scarf_parser::Token::Eq => Token::Eq(),
            scarf_parser::Token::ColonColon => Token::ColonColon(),
            scarf_parser::Token::ColonEq => Token::ColonEq(),
            scarf_parser::Token::ColonSlash => Token::ColonSlash(),
            scarf_parser::Token::PoundPound => Token::PoundPound(),
            scarf_parser::Token::PoundMinusPound => Token::PoundMinusPound(),
            scarf_parser::Token::PoundEqPound => Token::PoundEqPound(),
            scarf_parser::Token::EqGt => Token::EqGt(),
            scarf_parser::Token::StarGt => Token::StarGt(),
            scarf_parser::Token::PipeMinusGt => Token::PipeMinusGt(),
            scarf_parser::Token::PipeEqGt => Token::PipeEqGt(),
            scarf_parser::Token::Bslash => Token::Bslash(),
            scarf_parser::Token::Std => Token::Std(),
            scarf_parser::Token::PathpulseDollar => Token::PathpulseDollar(),
            scarf_parser::Token::Option => Token::Option(),
            scarf_parser::Token::TypeOption => Token::TypeOption(),
            scarf_parser::Token::Randomize => Token::Randomize(),
            scarf_parser::Token::Sample => Token::Sample(),
            scarf_parser::Token::OneStep => Token::OneStep(),
            scarf_parser::Token::DollarSetup => Token::DollarSetup(),
            scarf_parser::Token::DollarHold => Token::DollarHold(),
            scarf_parser::Token::DollarSetuphold => Token::DollarSetuphold(),
            scarf_parser::Token::DollarRecovery => Token::DollarRecovery(),
            scarf_parser::Token::DollarRemoval => Token::DollarRemoval(),
            scarf_parser::Token::DollarRecrem => Token::DollarRecrem(),
            scarf_parser::Token::DollarSkew => Token::DollarSkew(),
            scarf_parser::Token::DollarTimeskew => Token::DollarTimeskew(),
            scarf_parser::Token::DollarFullskew => Token::DollarFullskew(),
            scarf_parser::Token::DollarPeriod => Token::DollarPeriod(),
            scarf_parser::Token::DollarWidth => Token::DollarWidth(),
            scarf_parser::Token::DollarNochange => Token::DollarNochange(),
            scarf_parser::Token::DollarRoot => Token::DollarRoot(),
            scarf_parser::Token::DollarUnit => Token::DollarUnit(),
            scarf_parser::Token::DollarFatal => Token::DollarFatal(),
            scarf_parser::Token::DollarError => Token::DollarError(),
            scarf_parser::Token::DollarWarning => Token::DollarWarning(),
            scarf_parser::Token::DollarInfo => Token::DollarInfo(),
            scarf_parser::Token::OnelineComment(str) => Token::OnelineComment {
                text: str.to_string(),
            },
            scarf_parser::Token::BlockComment(str) => Token::BlockComment {
                text: str.to_string(),
            },
            scarf_parser::Token::UnsignedNumber(str) => Token::UnsignedNumber {
                text: str.to_string(),
            },
            scarf_parser::Token::FixedPointNumber(str) => {
                Token::FixedPointNumber {
                    text: str.to_string(),
                }
            }
            scarf_parser::Token::BinaryNumber(str) => Token::BinaryNumber {
                text: str.to_string(),
            },
            scarf_parser::Token::OctalNumber(str) => Token::OctalNumber {
                text: str.to_string(),
            },
            scarf_parser::Token::DecimalNumber(str) => Token::DecimalNumber {
                text: str.to_string(),
            },
            scarf_parser::Token::HexNumber(str) => Token::HexNumber {
                text: str.to_string(),
            },
            scarf_parser::Token::ScientificNumber(str) => {
                Token::ScientificNumber {
                    text: str.to_string(),
                }
            }
            scarf_parser::Token::UnbasedUnsizedLiteral(str) => {
                Token::UnbasedUnsizedLiteral {
                    text: str.to_string(),
                }
            }
            scarf_parser::Token::SystemTfIdentifier(str) => {
                Token::SystemTfIdentifier {
                    text: str.to_string(),
                }
            }
            scarf_parser::Token::SimpleIdentifier(str) => {
                Token::SimpleIdentifier {
                    text: str.to_string(),
                }
            }
            scarf_parser::Token::EscapedIdentifier(str) => {
                Token::EscapedIdentifier {
                    text: str.to_string(),
                }
            }
            scarf_parser::Token::PreprocessorIdentifier(str) => {
                Token::PreprocessorIdentifier {
                    text: str.to_string(),
                }
            }
            scarf_parser::Token::TextMacro(str) => Token::TextMacro {
                text: str.to_string(),
            },
            scarf_parser::Token::StringLiteral(str) => Token::StringLiteral {
                text: str.to_string(),
            },
            scarf_parser::Token::PreprocessorStringLiteral(str) => {
                Token::PreprocessorStringLiteral {
                    text: str.to_string(),
                }
            }
            scarf_parser::Token::TripleQuoteStringLiteral(str) => {
                Token::TripleQuoteStringLiteral {
                    text: str.to_string(),
                }
            }
            scarf_parser::Token::PreprocessorTripleQuoteStringLiteral(str) => {
                Token::PreprocessorTripleQuoteStringLiteral {
                    text: str.to_string(),
                }
            }
            scarf_parser::Token::Newline => Token::Newline(),
        }
    }
}

impl<'a> From<&'a Token> for scarf_parser::Token<'a> {
    fn from(value: &'a Token) -> Self {
        match value {
            Token::Error() => scarf_parser::Token::Error,
            Token::Always() => scarf_parser::Token::Always,
            Token::And() => scarf_parser::Token::And,
            Token::Assign() => scarf_parser::Token::Assign,
            Token::Begin() => scarf_parser::Token::Begin,
            Token::Buf() => scarf_parser::Token::Buf,
            Token::Bufif0() => scarf_parser::Token::Bufif0,
            Token::Bufif1() => scarf_parser::Token::Bufif1,
            Token::Case() => scarf_parser::Token::Case,
            Token::Casex() => scarf_parser::Token::Casex,
            Token::Casez() => scarf_parser::Token::Casez,
            Token::Cmos() => scarf_parser::Token::Cmos,
            Token::Deassign() => scarf_parser::Token::Deassign,
            Token::Default() => scarf_parser::Token::Default,
            Token::Defparam() => scarf_parser::Token::Defparam,
            Token::Disable() => scarf_parser::Token::Disable,
            Token::Edge() => scarf_parser::Token::Edge,
            Token::Else() => scarf_parser::Token::Else,
            Token::End() => scarf_parser::Token::End,
            Token::Endcase() => scarf_parser::Token::Endcase,
            Token::Endfunction() => scarf_parser::Token::Endfunction,
            Token::Endmodule() => scarf_parser::Token::Endmodule,
            Token::Endprimitive() => scarf_parser::Token::Endprimitive,
            Token::Endspecify() => scarf_parser::Token::Endspecify,
            Token::Endtable() => scarf_parser::Token::Endtable,
            Token::Endtask() => scarf_parser::Token::Endtask,
            Token::Event() => scarf_parser::Token::Event,
            Token::For() => scarf_parser::Token::For,
            Token::Force() => scarf_parser::Token::Force,
            Token::Forever() => scarf_parser::Token::Forever,
            Token::Fork() => scarf_parser::Token::Fork,
            Token::Function() => scarf_parser::Token::Function,
            Token::Highz0() => scarf_parser::Token::Highz0,
            Token::Highz1() => scarf_parser::Token::Highz1,
            Token::If() => scarf_parser::Token::If,
            Token::Ifnone() => scarf_parser::Token::Ifnone,
            Token::Initial() => scarf_parser::Token::Initial,
            Token::Inout() => scarf_parser::Token::Inout,
            Token::Input() => scarf_parser::Token::Input,
            Token::Integer() => scarf_parser::Token::Integer,
            Token::Join() => scarf_parser::Token::Join,
            Token::Large() => scarf_parser::Token::Large,
            Token::Macromodule() => scarf_parser::Token::Macromodule,
            Token::Medium() => scarf_parser::Token::Medium,
            Token::Module() => scarf_parser::Token::Module,
            Token::Nand() => scarf_parser::Token::Nand,
            Token::Negedge() => scarf_parser::Token::Negedge,
            Token::Nmos() => scarf_parser::Token::Nmos,
            Token::Nor() => scarf_parser::Token::Nor,
            Token::Not() => scarf_parser::Token::Not,
            Token::Notif0() => scarf_parser::Token::Notif0,
            Token::Notif1() => scarf_parser::Token::Notif1,
            Token::Or() => scarf_parser::Token::Or,
            Token::Output() => scarf_parser::Token::Output,
            Token::Parameter() => scarf_parser::Token::Parameter,
            Token::Pmos() => scarf_parser::Token::Pmos,
            Token::Posedge() => scarf_parser::Token::Posedge,
            Token::Primitive() => scarf_parser::Token::Primitive,
            Token::Pull0() => scarf_parser::Token::Pull0,
            Token::Pull1() => scarf_parser::Token::Pull1,
            Token::Pulldown() => scarf_parser::Token::Pulldown,
            Token::Pullup() => scarf_parser::Token::Pullup,
            Token::Rcmos() => scarf_parser::Token::Rcmos,
            Token::Real() => scarf_parser::Token::Real,
            Token::Realtime() => scarf_parser::Token::Realtime,
            Token::Reg() => scarf_parser::Token::Reg,
            Token::Release() => scarf_parser::Token::Release,
            Token::Repeat() => scarf_parser::Token::Repeat,
            Token::Rnmos() => scarf_parser::Token::Rnmos,
            Token::Rpmos() => scarf_parser::Token::Rpmos,
            Token::Rtran() => scarf_parser::Token::Rtran,
            Token::Rtranif0() => scarf_parser::Token::Rtranif0,
            Token::Rtranif1() => scarf_parser::Token::Rtranif1,
            Token::Scalared() => scarf_parser::Token::Scalared,
            Token::Small() => scarf_parser::Token::Small,
            Token::Specify() => scarf_parser::Token::Specify,
            Token::Specparam() => scarf_parser::Token::Specparam,
            Token::Strong0() => scarf_parser::Token::Strong0,
            Token::Strong1() => scarf_parser::Token::Strong1,
            Token::Supply0() => scarf_parser::Token::Supply0,
            Token::Supply1() => scarf_parser::Token::Supply1,
            Token::Table() => scarf_parser::Token::Table,
            Token::Task() => scarf_parser::Token::Task,
            Token::Time() => scarf_parser::Token::Time,
            Token::Tran() => scarf_parser::Token::Tran,
            Token::Tranif0() => scarf_parser::Token::Tranif0,
            Token::Tranif1() => scarf_parser::Token::Tranif1,
            Token::Tri() => scarf_parser::Token::Tri,
            Token::Tri0() => scarf_parser::Token::Tri0,
            Token::Tri1() => scarf_parser::Token::Tri1,
            Token::Triand() => scarf_parser::Token::Triand,
            Token::Trior() => scarf_parser::Token::Trior,
            Token::Trireg() => scarf_parser::Token::Trireg,
            Token::Vectored() => scarf_parser::Token::Vectored,
            Token::Wait() => scarf_parser::Token::Wait,
            Token::Wand() => scarf_parser::Token::Wand,
            Token::Weak0() => scarf_parser::Token::Weak0,
            Token::Weak1() => scarf_parser::Token::Weak1,
            Token::While() => scarf_parser::Token::While,
            Token::Wire() => scarf_parser::Token::Wire,
            Token::Wor() => scarf_parser::Token::Wor,
            Token::Xnor() => scarf_parser::Token::Xnor,
            Token::Xor() => scarf_parser::Token::Xor,
            Token::Automatic() => scarf_parser::Token::Automatic,
            Token::Cell() => scarf_parser::Token::Cell,
            Token::Config() => scarf_parser::Token::Config,
            Token::Design() => scarf_parser::Token::Design,
            Token::Endconfig() => scarf_parser::Token::Endconfig,
            Token::Endgenerate() => scarf_parser::Token::Endgenerate,
            Token::Generate() => scarf_parser::Token::Generate,
            Token::Genvar() => scarf_parser::Token::Genvar,
            Token::Incdir() => scarf_parser::Token::Incdir,
            Token::Include() => scarf_parser::Token::Include,
            Token::Instance() => scarf_parser::Token::Instance,
            Token::Liblist() => scarf_parser::Token::Liblist,
            Token::Library() => scarf_parser::Token::Library,
            Token::Localparam() => scarf_parser::Token::Localparam,
            Token::Noshowcancelled() => scarf_parser::Token::Noshowcancelled,
            Token::PulsestyleOndetect() => {
                scarf_parser::Token::PulsestyleOndetect
            }
            Token::PulsestyleOnevent() => {
                scarf_parser::Token::PulsestyleOnevent
            }
            Token::Showcancelled() => scarf_parser::Token::Showcancelled,
            Token::Signed() => scarf_parser::Token::Signed,
            Token::Unsigned() => scarf_parser::Token::Unsigned,
            Token::Use() => scarf_parser::Token::Use,
            Token::Uwire() => scarf_parser::Token::Uwire,
            Token::Alias() => scarf_parser::Token::Alias,
            Token::AlwaysComb() => scarf_parser::Token::AlwaysComb,
            Token::AlwaysFf() => scarf_parser::Token::AlwaysFf,
            Token::AlwaysLatch() => scarf_parser::Token::AlwaysLatch,
            Token::Assert() => scarf_parser::Token::Assert,
            Token::Assume() => scarf_parser::Token::Assume,
            Token::Before() => scarf_parser::Token::Before,
            Token::Bind() => scarf_parser::Token::Bind,
            Token::Bins() => scarf_parser::Token::Bins,
            Token::Binsof() => scarf_parser::Token::Binsof,
            Token::Bit() => scarf_parser::Token::Bit,
            Token::Break() => scarf_parser::Token::Break,
            Token::Byte() => scarf_parser::Token::Byte,
            Token::Chandle() => scarf_parser::Token::Chandle,
            Token::Class() => scarf_parser::Token::Class,
            Token::Clocking() => scarf_parser::Token::Clocking,
            Token::Const() => scarf_parser::Token::Const,
            Token::Constraint() => scarf_parser::Token::Constraint,
            Token::Context() => scarf_parser::Token::Context,
            Token::Continue() => scarf_parser::Token::Continue,
            Token::Cover() => scarf_parser::Token::Cover,
            Token::Covergroup() => scarf_parser::Token::Covergroup,
            Token::Coverpoint() => scarf_parser::Token::Coverpoint,
            Token::Cross() => scarf_parser::Token::Cross,
            Token::Dist() => scarf_parser::Token::Dist,
            Token::Do() => scarf_parser::Token::Do,
            Token::Endclass() => scarf_parser::Token::Endclass,
            Token::Endclocking() => scarf_parser::Token::Endclocking,
            Token::Endgroup() => scarf_parser::Token::Endgroup,
            Token::Endinterface() => scarf_parser::Token::Endinterface,
            Token::Endpackage() => scarf_parser::Token::Endpackage,
            Token::Endprogram() => scarf_parser::Token::Endprogram,
            Token::Endproperty() => scarf_parser::Token::Endproperty,
            Token::Endsequence() => scarf_parser::Token::Endsequence,
            Token::Enum() => scarf_parser::Token::Enum,
            Token::Expect() => scarf_parser::Token::Expect,
            Token::Export() => scarf_parser::Token::Export,
            Token::Extends() => scarf_parser::Token::Extends,
            Token::Extern() => scarf_parser::Token::Extern,
            Token::Final() => scarf_parser::Token::Final,
            Token::FirstMatch() => scarf_parser::Token::FirstMatch,
            Token::Foreach() => scarf_parser::Token::Foreach,
            Token::Forkjoin() => scarf_parser::Token::Forkjoin,
            Token::Iff() => scarf_parser::Token::Iff,
            Token::IgnoreBins() => scarf_parser::Token::IgnoreBins,
            Token::IllegalBins() => scarf_parser::Token::IllegalBins,
            Token::Import() => scarf_parser::Token::Import,
            Token::Inside() => scarf_parser::Token::Inside,
            Token::Int() => scarf_parser::Token::Int,
            Token::Interface() => scarf_parser::Token::Interface,
            Token::Intersect() => scarf_parser::Token::Intersect,
            Token::JoinAny() => scarf_parser::Token::JoinAny,
            Token::JoinNone() => scarf_parser::Token::JoinNone,
            Token::Local() => scarf_parser::Token::Local,
            Token::Logic() => scarf_parser::Token::Logic,
            Token::Longint() => scarf_parser::Token::Longint,
            Token::Matches() => scarf_parser::Token::Matches,
            Token::Modport() => scarf_parser::Token::Modport,
            Token::New() => scarf_parser::Token::New,
            Token::Null() => scarf_parser::Token::Null,
            Token::Package() => scarf_parser::Token::Package,
            Token::Packed() => scarf_parser::Token::Packed,
            Token::Priority() => scarf_parser::Token::Priority,
            Token::Program() => scarf_parser::Token::Program,
            Token::Property() => scarf_parser::Token::Property,
            Token::Protected() => scarf_parser::Token::Protected,
            Token::Pure() => scarf_parser::Token::Pure,
            Token::Rand() => scarf_parser::Token::Rand,
            Token::Randc() => scarf_parser::Token::Randc,
            Token::Randcase() => scarf_parser::Token::Randcase,
            Token::Randsequence() => scarf_parser::Token::Randsequence,
            Token::Ref() => scarf_parser::Token::Ref,
            Token::Return() => scarf_parser::Token::Return,
            Token::Sequence() => scarf_parser::Token::Sequence,
            Token::Shortint() => scarf_parser::Token::Shortint,
            Token::Shortreal() => scarf_parser::Token::Shortreal,
            Token::Solve() => scarf_parser::Token::Solve,
            Token::Static() => scarf_parser::Token::Static,
            Token::String() => scarf_parser::Token::String,
            Token::Struct() => scarf_parser::Token::Struct,
            Token::Super() => scarf_parser::Token::Super,
            Token::Tagged() => scarf_parser::Token::Tagged,
            Token::This() => scarf_parser::Token::This,
            Token::Throughout() => scarf_parser::Token::Throughout,
            Token::Timeprecision() => scarf_parser::Token::Timeprecision,
            Token::Timeunit() => scarf_parser::Token::Timeunit,
            Token::Type() => scarf_parser::Token::Type,
            Token::Typedef() => scarf_parser::Token::Typedef,
            Token::Union() => scarf_parser::Token::Union,
            Token::Unique() => scarf_parser::Token::Unique,
            Token::Var() => scarf_parser::Token::Var,
            Token::Virtual() => scarf_parser::Token::Virtual,
            Token::Void() => scarf_parser::Token::Void,
            Token::WaitOrder() => scarf_parser::Token::WaitOrder,
            Token::Wildcard() => scarf_parser::Token::Wildcard,
            Token::With() => scarf_parser::Token::With,
            Token::Within() => scarf_parser::Token::Within,
            Token::AcceptOn() => scarf_parser::Token::AcceptOn,
            Token::Checker() => scarf_parser::Token::Checker,
            Token::Endchecker() => scarf_parser::Token::Endchecker,
            Token::Eventually() => scarf_parser::Token::Eventually,
            Token::Global() => scarf_parser::Token::Global,
            Token::Implies() => scarf_parser::Token::Implies,
            Token::Let() => scarf_parser::Token::Let,
            Token::Nexttime() => scarf_parser::Token::Nexttime,
            Token::RejectOn() => scarf_parser::Token::RejectOn,
            Token::Restrict() => scarf_parser::Token::Restrict,
            Token::SAlways() => scarf_parser::Token::SAlways,
            Token::SEventually() => scarf_parser::Token::SEventually,
            Token::SNexttime() => scarf_parser::Token::SNexttime,
            Token::SUntil() => scarf_parser::Token::SUntil,
            Token::SUntilWith() => scarf_parser::Token::SUntilWith,
            Token::Strong() => scarf_parser::Token::Strong,
            Token::SyncAcceptOn() => scarf_parser::Token::SyncAcceptOn,
            Token::SyncRejectOn() => scarf_parser::Token::SyncRejectOn,
            Token::Unique0() => scarf_parser::Token::Unique0,
            Token::Until() => scarf_parser::Token::Until,
            Token::UntilWith() => scarf_parser::Token::UntilWith,
            Token::Untyped() => scarf_parser::Token::Untyped,
            Token::Weak() => scarf_parser::Token::Weak,
            Token::Implements() => scarf_parser::Token::Implements,
            Token::Interconnect() => scarf_parser::Token::Interconnect,
            Token::Nettype() => scarf_parser::Token::Nettype,
            Token::Soft() => scarf_parser::Token::Soft,
            Token::DirUnderscoreFile() => {
                scarf_parser::Token::DirUnderscoreFile
            }
            Token::DirUnderscoreLine() => {
                scarf_parser::Token::DirUnderscoreLine
            }
            Token::DirBeginKeywords() => scarf_parser::Token::DirBeginKeywords,
            Token::DirCelldefine() => scarf_parser::Token::DirCelldefine,
            Token::DirDefaultNettype() => {
                scarf_parser::Token::DirDefaultNettype
            }
            Token::DirDefine() => scarf_parser::Token::DirDefine,
            Token::DirElse() => scarf_parser::Token::DirElse,
            Token::DirElsif() => scarf_parser::Token::DirElsif,
            Token::DirEndKeywords() => scarf_parser::Token::DirEndKeywords,
            Token::DirEndcelldefine() => scarf_parser::Token::DirEndcelldefine,
            Token::DirEndif() => scarf_parser::Token::DirEndif,
            Token::DirIfdef() => scarf_parser::Token::DirIfdef,
            Token::DirIfndef() => scarf_parser::Token::DirIfndef,
            Token::DirInclude() => scarf_parser::Token::DirInclude,
            Token::DirLine() => scarf_parser::Token::DirLine,
            Token::DirNounconnectedDrive() => {
                scarf_parser::Token::DirNounconnectedDrive
            }
            Token::DirPragma() => scarf_parser::Token::DirPragma,
            Token::DirResetall() => scarf_parser::Token::DirResetall,
            Token::DirTimescale() => scarf_parser::Token::DirTimescale,
            Token::DirUnconnectedDrive() => {
                scarf_parser::Token::DirUnconnectedDrive
            }
            Token::DirUndef() => scarf_parser::Token::DirUndef,
            Token::DirUndefineall() => scarf_parser::Token::DirUndefineall,
            Token::Plus() => scarf_parser::Token::Plus,
            Token::Minus() => scarf_parser::Token::Minus,
            Token::Exclamation() => scarf_parser::Token::Exclamation,
            Token::Quest() => scarf_parser::Token::Quest,
            Token::Tilde() => scarf_parser::Token::Tilde,
            Token::Amp() => scarf_parser::Token::Amp,
            Token::TildeAmp() => scarf_parser::Token::TildeAmp,
            Token::Pipe() => scarf_parser::Token::Pipe,
            Token::TildePipe() => scarf_parser::Token::TildePipe,
            Token::Caret() => scarf_parser::Token::Caret,
            Token::TildeCaret() => scarf_parser::Token::TildeCaret,
            Token::CaretTilde() => scarf_parser::Token::CaretTilde,
            Token::Star() => scarf_parser::Token::Star,
            Token::Slash() => scarf_parser::Token::Slash,
            Token::Percent() => scarf_parser::Token::Percent,
            Token::EqEq() => scarf_parser::Token::EqEq,
            Token::ExclEq() => scarf_parser::Token::ExclEq,
            Token::PlusEq() => scarf_parser::Token::PlusEq,
            Token::MinusEq() => scarf_parser::Token::MinusEq,
            Token::StarEq() => scarf_parser::Token::StarEq,
            Token::SlashEq() => scarf_parser::Token::SlashEq,
            Token::PercentEq() => scarf_parser::Token::PercentEq,
            Token::AmpEq() => scarf_parser::Token::AmpEq,
            Token::PipeEq() => scarf_parser::Token::PipeEq,
            Token::CaretEq() => scarf_parser::Token::CaretEq,
            Token::EqEqEq() => scarf_parser::Token::EqEqEq,
            Token::ExclEqEq() => scarf_parser::Token::ExclEqEq,
            Token::EqEqQuest() => scarf_parser::Token::EqEqQuest,
            Token::ExclEqQuest() => scarf_parser::Token::ExclEqQuest,
            Token::AmpAmp() => scarf_parser::Token::AmpAmp,
            Token::AmpAmpAmp() => scarf_parser::Token::AmpAmpAmp,
            Token::PipePipe() => scarf_parser::Token::PipePipe,
            Token::StarStar() => scarf_parser::Token::StarStar,
            Token::Lt() => scarf_parser::Token::Lt,
            Token::LtEq() => scarf_parser::Token::LtEq,
            Token::Gt() => scarf_parser::Token::Gt,
            Token::GtEq() => scarf_parser::Token::GtEq,
            Token::GtGt() => scarf_parser::Token::GtGt,
            Token::LtLt() => scarf_parser::Token::LtLt,
            Token::GtGtEq() => scarf_parser::Token::GtGtEq,
            Token::LtLtEq() => scarf_parser::Token::LtLtEq,
            Token::GtGtGt() => scarf_parser::Token::GtGtGt,
            Token::LtLtLt() => scarf_parser::Token::LtLtLt,
            Token::GtGtGtEq() => scarf_parser::Token::GtGtGtEq,
            Token::LtLtLtEq() => scarf_parser::Token::LtLtLtEq,
            Token::MinusGt() => scarf_parser::Token::MinusGt,
            Token::MinusGtGt() => scarf_parser::Token::MinusGtGt,
            Token::LtMinusGt() => scarf_parser::Token::LtMinusGt,
            Token::PlusPlus() => scarf_parser::Token::PlusPlus,
            Token::MinusMinus() => scarf_parser::Token::MinusMinus,
            Token::PlusColon() => scarf_parser::Token::PlusColon,
            Token::MinusColon() => scarf_parser::Token::MinusColon,
            Token::PlusSlashMinus() => scarf_parser::Token::PlusSlashMinus,
            Token::PlusPercentMinus() => scarf_parser::Token::PlusPercentMinus,
            Token::Paren() => scarf_parser::Token::Paren,
            Token::EParen() => scarf_parser::Token::EParen,
            Token::Bracket() => scarf_parser::Token::Bracket,
            Token::EBracket() => scarf_parser::Token::EBracket,
            Token::Brace() => scarf_parser::Token::Brace,
            Token::EBrace() => scarf_parser::Token::EBrace,
            Token::Colon() => scarf_parser::Token::Colon,
            Token::SColon() => scarf_parser::Token::SColon,
            Token::Apost() => scarf_parser::Token::Apost,
            Token::Comma() => scarf_parser::Token::Comma,
            Token::Period() => scarf_parser::Token::Period,
            Token::Pound() => scarf_parser::Token::Pound,
            Token::Dollar() => scarf_parser::Token::Dollar,
            Token::At() => scarf_parser::Token::At,
            Token::AtAt() => scarf_parser::Token::AtAt,
            Token::Eq() => scarf_parser::Token::Eq,
            Token::ColonColon() => scarf_parser::Token::ColonColon,
            Token::ColonEq() => scarf_parser::Token::ColonEq,
            Token::ColonSlash() => scarf_parser::Token::ColonSlash,
            Token::PoundPound() => scarf_parser::Token::PoundPound,
            Token::PoundMinusPound() => scarf_parser::Token::PoundMinusPound,
            Token::PoundEqPound() => scarf_parser::Token::PoundEqPound,
            Token::EqGt() => scarf_parser::Token::EqGt,
            Token::StarGt() => scarf_parser::Token::StarGt,
            Token::PipeMinusGt() => scarf_parser::Token::PipeMinusGt,
            Token::PipeEqGt() => scarf_parser::Token::PipeEqGt,
            Token::Bslash() => scarf_parser::Token::Bslash,
            Token::Std() => scarf_parser::Token::Std,
            Token::PathpulseDollar() => scarf_parser::Token::PathpulseDollar,
            Token::Option() => scarf_parser::Token::Option,
            Token::TypeOption() => scarf_parser::Token::TypeOption,
            Token::Randomize() => scarf_parser::Token::Randomize,
            Token::Sample() => scarf_parser::Token::Sample,
            Token::OneStep() => scarf_parser::Token::OneStep,
            Token::DollarSetup() => scarf_parser::Token::DollarSetup,
            Token::DollarHold() => scarf_parser::Token::DollarHold,
            Token::DollarSetuphold() => scarf_parser::Token::DollarSetuphold,
            Token::DollarRecovery() => scarf_parser::Token::DollarRecovery,
            Token::DollarRemoval() => scarf_parser::Token::DollarRemoval,
            Token::DollarRecrem() => scarf_parser::Token::DollarRecrem,
            Token::DollarSkew() => scarf_parser::Token::DollarSkew,
            Token::DollarTimeskew() => scarf_parser::Token::DollarTimeskew,
            Token::DollarFullskew() => scarf_parser::Token::DollarFullskew,
            Token::DollarPeriod() => scarf_parser::Token::DollarPeriod,
            Token::DollarWidth() => scarf_parser::Token::DollarWidth,
            Token::DollarNochange() => scarf_parser::Token::DollarNochange,
            Token::DollarRoot() => scarf_parser::Token::DollarRoot,
            Token::DollarUnit() => scarf_parser::Token::DollarUnit,
            Token::DollarFatal() => scarf_parser::Token::DollarFatal,
            Token::DollarError() => scarf_parser::Token::DollarError,
            Token::DollarWarning() => scarf_parser::Token::DollarWarning,
            Token::DollarInfo() => scarf_parser::Token::DollarInfo,
            Token::OnelineComment { text } => {
                scarf_parser::Token::OnelineComment(&text)
            }
            Token::BlockComment { text } => {
                scarf_parser::Token::BlockComment(&text)
            }
            Token::UnsignedNumber { text } => {
                scarf_parser::Token::UnsignedNumber(&text)
            }
            Token::FixedPointNumber { text } => {
                scarf_parser::Token::FixedPointNumber(&text)
            }
            Token::BinaryNumber { text } => {
                scarf_parser::Token::BinaryNumber(&text)
            }
            Token::OctalNumber { text } => {
                scarf_parser::Token::OctalNumber(&text)
            }
            Token::DecimalNumber { text } => {
                scarf_parser::Token::DecimalNumber(&text)
            }
            Token::HexNumber { text } => scarf_parser::Token::HexNumber(&text),
            Token::ScientificNumber { text } => {
                scarf_parser::Token::ScientificNumber(&text)
            }
            Token::UnbasedUnsizedLiteral { text } => {
                scarf_parser::Token::UnbasedUnsizedLiteral(&text)
            }
            Token::SystemTfIdentifier { text } => {
                scarf_parser::Token::SystemTfIdentifier(&text)
            }
            Token::SimpleIdentifier { text } => {
                scarf_parser::Token::SimpleIdentifier(&text)
            }
            Token::EscapedIdentifier { text } => {
                scarf_parser::Token::EscapedIdentifier(&text)
            }
            Token::PreprocessorIdentifier { text } => {
                scarf_parser::Token::PreprocessorIdentifier(&text)
            }
            Token::TextMacro { text } => scarf_parser::Token::TextMacro(&text),
            Token::StringLiteral { text } => {
                scarf_parser::Token::StringLiteral(&text)
            }
            Token::PreprocessorStringLiteral { text } => {
                scarf_parser::Token::PreprocessorStringLiteral(&text)
            }
            Token::TripleQuoteStringLiteral { text } => {
                scarf_parser::Token::TripleQuoteStringLiteral(&text)
            }
            Token::PreprocessorTripleQuoteStringLiteral { text } => {
                scarf_parser::Token::PreprocessorTripleQuoteStringLiteral(&text)
            }
            Token::Newline() => scarf_parser::Token::Newline,
        }
    }
}

/// A source file [`Token`] with an associated [`Span`]
#[pyclass(eq, from_py_object, module = "scarf_python", str)]
#[derive(Clone, PartialEq, Eq)]
pub struct SpannedToken {
    #[pyo3(get, set)]
    pub token: Token,
    #[pyo3(get, set)]
    pub span: Span,
}

impl<'a> From<scarf_parser::SpannedToken<'a>> for SpannedToken {
    fn from(value: scarf_parser::SpannedToken<'a>) -> Self {
        Self {
            token: value.0.into(),
            span: value.1.into(),
        }
    }
}

impl std::fmt::Display for SpannedToken {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        self.token.fmt(f)
    }
}

impl<'a> SpannedToken {
    /// Turn a [`SpannedToken`] into a [`scarf_parser::SpannedToken`]
    pub fn to_rust(
        &'a self,
        cache: &'a PreprocessorCache<'a>,
    ) -> scarf_parser::SpannedToken<'a> {
        scarf_parser::SpannedToken(
            (&self.token).into(),
            (&self.span).to_span(cache),
        )
    }
}