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 @@ -2853,16 +2853,31 @@ class parser
2853
2853
-> void
2854
2854
{
2855
2855
auto m = std::string{msg};
2856
- if (include_curr_token) {
2857
- m += std::string (" (at '" ) + curr ().to_string (true ) + " ')" ;
2858
- }
2859
- if (
2860
- err_pos == source_position{}
2861
- && peek (0 )
2862
- )
2863
- {
2864
- err_pos = peek (0 )->position ();
2856
+
2857
+ if (done ()) {
2858
+ int i = 0 ;
2859
+ while (!peek (i) && pos + i > 0 ) { --i; };
2860
+ if (peek (i)) {
2861
+ m += std::string (" (after '" ) + peek (i)->to_string (true ) + " ')" ;
2862
+ if (
2863
+ err_pos == source_position{}
2864
+ ) {
2865
+ err_pos = peek (i)->position ();
2866
+ }
2867
+ }
2868
+ } else {
2869
+ if (include_curr_token) {
2870
+ m += std::string (" (at '" ) + curr ().to_string (true ) + " ')" ;
2871
+ }
2872
+ if (
2873
+ err_pos == source_position{}
2874
+ && peek (0 )
2875
+ )
2876
+ {
2877
+ err_pos = peek (0 )->position ();
2878
+ }
2865
2879
}
2880
+
2866
2881
errors.emplace_back ( err_pos, m, false , fallback );
2867
2882
}
2868
2883
@@ -4879,7 +4894,8 @@ class parser
4879
4894
4880
4895
// If there's no [ [ then this isn't a contract
4881
4896
if (
4882
- curr ().type () != lexeme::LeftBracket
4897
+ done ()
4898
+ || curr ().type () != lexeme::LeftBracket
4883
4899
|| !peek (1 )
4884
4900
|| peek (1 )->type () != lexeme::LeftBracket
4885
4901
)
You can’t perform that action at this time.
0 commit comments