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