File tree 1 file changed +24
-10
lines changed
1 file changed +24
-10
lines changed Original file line number Diff line number Diff line change @@ -2756,16 +2756,29 @@ class parser
2756
2756
-> void
2757
2757
{
2758
2758
auto m = std::string{msg};
2759
- if (include_curr_token) {
2760
- m += std::string (" (at '" ) + curr ().to_string (true ) + " ')" ;
2761
- }
2762
- if (
2763
- err_pos == source_position{}
2764
- && peek (0 )
2765
- )
2766
- {
2767
- err_pos = peek (0 )->position ();
2759
+
2760
+ if (done ()) {
2761
+ int i = 0 ;
2762
+ while (!peek (i)) { --i; };
2763
+ m += std::string (" (after '" ) + peek (i)->to_string (true ) + " ')" ;
2764
+ if (
2765
+ err_pos == source_position{}
2766
+ ) {
2767
+ err_pos = peek (i)->position ();
2768
+ }
2769
+ } else {
2770
+ if (include_curr_token) {
2771
+ m += std::string (" (at '" ) + curr ().to_string (true ) + " ')" ;
2772
+ }
2773
+ if (
2774
+ err_pos == source_position{}
2775
+ && peek (0 )
2776
+ )
2777
+ {
2778
+ err_pos = peek (0 )->position ();
2779
+ }
2768
2780
}
2781
+
2769
2782
errors.emplace_back ( err_pos, m, false , fallback );
2770
2783
}
2771
2784
@@ -4777,7 +4790,8 @@ class parser
4777
4790
4778
4791
// If there's no [ [ then this isn't a contract
4779
4792
if (
4780
- curr ().type () != lexeme::LeftBracket
4793
+ done ()
4794
+ || curr ().type () != lexeme::LeftBracket
4781
4795
|| !peek (1 )
4782
4796
|| peek (1 )->type () != lexeme::LeftBracket
4783
4797
)
You can’t perform that action at this time.
0 commit comments