@@ -120,6 +120,7 @@ impl Parser {
120
120
kind : ParserErrorKind :: InvalidDefinition ( self . current_token . kind . clone ( ) ) ,
121
121
hint : Some ( "Definition must be one of: `function`, `event`, `constant`, `error`, `macro`, `fn`, or `test`." . to_string ( ) ) ,
122
122
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
123
+ cursor : self . cursor ,
123
124
} ) ;
124
125
}
125
126
} ;
@@ -133,6 +134,7 @@ impl Parser {
133
134
TokenKind :: Include
134
135
) ) ,
135
136
spans : AstSpan ( self . spans . clone ( ) ) ,
137
+ cursor : self . cursor ,
136
138
} ) ;
137
139
}
138
140
}
@@ -158,6 +160,7 @@ impl Parser {
158
160
kind : ParserErrorKind :: InvalidName ( tok. clone ( ) ) ,
159
161
hint : Some ( format ! ( "Expected import string. Got: \" {tok}\" " ) ) ,
160
162
spans : AstSpan ( new_spans) ,
163
+ cursor : self . cursor ,
161
164
} ) ;
162
165
}
163
166
} ;
@@ -177,6 +180,7 @@ impl Parser {
177
180
kind : ParserErrorKind :: UnexpectedType ( self . current_token . kind . clone ( ) ) ,
178
181
hint : Some ( format ! ( "Expected: \" {kind}\" " ) ) ,
179
182
spans : AstSpan ( self . spans . clone ( ) ) ,
183
+ cursor : self . cursor ,
180
184
} )
181
185
}
182
186
}
@@ -198,6 +202,7 @@ impl Parser {
198
202
kind : ParserErrorKind :: DuplicateMacro ( m. name . to_owned ( ) ) ,
199
203
hint : Some ( "MACRO names should be unique" . to_string ( ) ) ,
200
204
spans : AstSpan ( vec ! [ m. span[ 2 ] . clone( ) ] ) ,
205
+ cursor : self . cursor ,
201
206
} )
202
207
} else {
203
208
Ok ( ( ) )
@@ -257,6 +262,7 @@ impl Parser {
257
262
kind : ParserErrorKind :: InvalidName ( tok. clone ( ) ) ,
258
263
hint : Some ( format ! ( "Expected function name, found: \" {tok}\" " ) ) ,
259
264
spans : AstSpan ( self . spans . clone ( ) ) ,
265
+ cursor : self . cursor ,
260
266
} ) ;
261
267
}
262
268
} ;
@@ -276,6 +282,7 @@ impl Parser {
276
282
"Expected one of: `view`, `pure`, `payable`, `nonpayable`." . to_string ( ) ,
277
283
) ,
278
284
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
285
+ cursor : self . cursor ,
279
286
} )
280
287
}
281
288
} ;
@@ -319,6 +326,7 @@ impl Parser {
319
326
kind : ParserErrorKind :: InvalidName ( tok. clone ( ) ) ,
320
327
hint : Some ( format ! ( "Expected event name, found: \" {tok}\" " ) ) ,
321
328
spans : AstSpan ( self . spans . clone ( ) ) ,
329
+ cursor : self . cursor ,
322
330
} ) ;
323
331
}
324
332
} ;
@@ -350,6 +358,7 @@ impl Parser {
350
358
kind : ParserErrorKind :: UnexpectedType ( tok) ,
351
359
hint : Some ( "Expected constant name." . to_string ( ) ) ,
352
360
spans : AstSpan ( self . spans . clone ( ) ) ,
361
+ cursor : self . cursor ,
353
362
} ) ;
354
363
}
355
364
} ;
@@ -375,6 +384,7 @@ impl Parser {
375
384
. to_string ( ) ,
376
385
) ,
377
386
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
387
+ cursor : self . cursor ,
378
388
} ) ;
379
389
}
380
390
} ;
@@ -403,6 +413,7 @@ impl Parser {
403
413
kind : ParserErrorKind :: UnexpectedType ( tok) ,
404
414
hint : Some ( "Expected error name." . to_string ( ) ) ,
405
415
spans : AstSpan ( self . spans . clone ( ) ) ,
416
+ cursor : self . cursor ,
406
417
} ) ;
407
418
}
408
419
} ;
@@ -450,6 +461,7 @@ impl Parser {
450
461
) ,
451
462
hint : Some ( format ! ( "Expected string for decorator flag: {s}" ) ) ,
452
463
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
464
+ cursor : self . cursor ,
453
465
} ) ;
454
466
}
455
467
}
@@ -466,6 +478,7 @@ impl Parser {
466
478
) ,
467
479
hint : Some ( format ! ( "Expected literal for decorator flag: {s}" ) ) ,
468
480
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
481
+ cursor : self . cursor ,
469
482
} ) ;
470
483
}
471
484
}
@@ -475,6 +488,7 @@ impl Parser {
475
488
kind : ParserErrorKind :: InvalidDecoratorFlag ( s. clone ( ) ) ,
476
489
hint : Some ( format ! ( "Unknown decorator flag: {s}" ) ) ,
477
490
spans : AstSpan ( self . spans . clone ( ) ) ,
491
+ cursor : self . cursor ,
478
492
} ) ;
479
493
}
480
494
}
@@ -493,6 +507,7 @@ impl Parser {
493
507
) ) ,
494
508
hint : Some ( String :: from ( "Unknown decorator flag" ) ) ,
495
509
spans : AstSpan ( self . spans . clone ( ) ) ,
510
+ cursor : self . cursor ,
496
511
} ) ;
497
512
}
498
513
}
@@ -597,6 +612,7 @@ impl Parser {
597
612
"Literal {hex_literal:?} contains too many bytes for opcode \" {o:?}\" "
598
613
) ) ,
599
614
spans : AstSpan ( curr_spans) ,
615
+ cursor : self . cursor ,
600
616
} ) ;
601
617
}
602
618
@@ -614,6 +630,7 @@ impl Parser {
614
630
o, self . current_token. kind
615
631
) ) ,
616
632
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
633
+ cursor : self . cursor ,
617
634
} )
618
635
}
619
636
}
@@ -704,6 +721,7 @@ impl Parser {
704
721
kind : ParserErrorKind :: InvalidTokenInMacroBody ( kind) ,
705
722
hint : None ,
706
723
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
724
+ cursor : self . cursor ,
707
725
} ) ;
708
726
}
709
727
} ;
@@ -817,6 +835,7 @@ impl Parser {
817
835
kind : ParserErrorKind :: InvalidTokenInLabelDefinition ( kind) ,
818
836
hint : None ,
819
837
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
838
+ cursor : self . cursor ,
820
839
} ) ;
821
840
}
822
841
} ;
@@ -948,6 +967,7 @@ impl Parser {
948
967
"Argument names cannot be EVM types: {arg_str}"
949
968
) ) ,
950
969
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
970
+ cursor : self . cursor ,
951
971
} ) ;
952
972
}
953
973
}
@@ -958,6 +978,7 @@ impl Parser {
958
978
) ,
959
979
hint : Some ( format ! ( "Argument names cannot be EVM types: {ty}" ) ) ,
960
980
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
981
+ cursor : self . cursor ,
961
982
} )
962
983
}
963
984
_ => { /* continue, valid string */ }
@@ -981,6 +1002,7 @@ impl Parser {
981
1002
kind : ParserErrorKind :: InvalidArgs ( self . current_token . kind . clone ( ) ) ,
982
1003
hint : None ,
983
1004
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
1005
+ cursor : self . cursor ,
984
1006
} ) ;
985
1007
}
986
1008
@@ -1004,6 +1026,7 @@ impl Parser {
1004
1026
kind : ParserErrorKind :: InvalidSingleArg ( self . current_token . kind . clone ( ) ) ,
1005
1027
hint : Some ( "Expected number representing stack item count." . to_string ( ) ) ,
1006
1028
spans : AstSpan ( single_arg_span) ,
1029
+ cursor : self . cursor ,
1007
1030
} )
1008
1031
}
1009
1032
} ;
@@ -1059,6 +1082,7 @@ impl Parser {
1059
1082
. to_string ( ) ,
1060
1083
) ,
1061
1084
spans : AstSpan ( new_spans) ,
1085
+ cursor : self . cursor ,
1062
1086
} ) ;
1063
1087
}
1064
1088
}
@@ -1147,7 +1171,8 @@ impl Parser {
1147
1171
) ,
1148
1172
hint : Some ( "Expected valid hex bytecode." . to_string ( ) ) ,
1149
1173
spans : AstSpan ( new_spans) ,
1150
- } ) ;
1174
+ cursor : self . cursor ,
1175
+ } )
1151
1176
}
1152
1177
} else {
1153
1178
StatementType :: LabelCall ( ident_str. to_string ( ) )
@@ -1162,7 +1187,8 @@ impl Parser {
1162
1187
kind : ParserErrorKind :: InvalidTableBodyToken ( kind. clone ( ) ) ,
1163
1188
hint : Some ( "Expected an identifier string." . to_string ( ) ) ,
1164
1189
spans : AstSpan ( new_spans) ,
1165
- } ) ;
1190
+ cursor : self . cursor ,
1191
+ } )
1166
1192
}
1167
1193
} ;
1168
1194
}
@@ -1189,6 +1215,7 @@ impl Parser {
1189
1215
kind : ParserErrorKind :: InvalidConstant ( kind) ,
1190
1216
hint : None ,
1191
1217
spans : AstSpan ( new_spans) ,
1218
+ cursor : self . cursor ,
1192
1219
} )
1193
1220
}
1194
1221
}
@@ -1221,6 +1248,7 @@ impl Parser {
1221
1248
kind : ParserErrorKind :: InvalidArgCallIdent ( kind) ,
1222
1249
hint : None ,
1223
1250
spans : AstSpan ( new_spans) ,
1251
+ cursor : self . cursor ,
1224
1252
} )
1225
1253
}
1226
1254
}
@@ -1250,6 +1278,7 @@ impl Parser {
1250
1278
kind : ParserErrorKind :: InvalidArgs ( kind) ,
1251
1279
hint : None ,
1252
1280
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
1281
+ cursor : self . cursor ,
1253
1282
} ) ,
1254
1283
}
1255
1284
}
@@ -1267,7 +1296,8 @@ impl Parser {
1267
1296
kind : ParserErrorKind :: InvalidUint256 ( size) ,
1268
1297
hint : None ,
1269
1298
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
1270
- } ) ;
1299
+ cursor : self . cursor ,
1300
+ } )
1271
1301
}
1272
1302
Ok ( self . match_kind ( self . current_token . kind . clone ( ) ) ?)
1273
1303
}
@@ -1277,7 +1307,8 @@ impl Parser {
1277
1307
kind : ParserErrorKind :: InvalidBytes ( size) ,
1278
1308
hint : None ,
1279
1309
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
1280
- } ) ;
1310
+ cursor : self . cursor ,
1311
+ } )
1281
1312
}
1282
1313
Ok ( self . match_kind ( self . current_token . kind . clone ( ) ) ?)
1283
1314
}
@@ -1291,7 +1322,8 @@ impl Parser {
1291
1322
kind : ParserErrorKind :: InvalidInt ( size) ,
1292
1323
hint : None ,
1293
1324
spans : AstSpan ( vec ! [ self . current_token. span. clone( ) ] ) ,
1294
- } ) ;
1325
+ cursor : self . cursor ,
1326
+ } )
1295
1327
}
1296
1328
let curr_token_kind = self . current_token . kind . clone ( ) ;
1297
1329
self . consume ( ) ;
0 commit comments