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 @@ -3071,16 +3071,31 @@ class parser
3071
3071
-> void
3072
3072
{
3073
3073
auto m = std::string{msg};
3074
- if (include_curr_token) {
3075
- m += std::string (" (at '" ) + curr ().to_string (true ) + " ')" ;
3076
- }
3077
- if (
3078
- err_pos == source_position{}
3079
- && peek (0 )
3080
- )
3081
- {
3082
- err_pos = peek (0 )->position ();
3074
+
3075
+ if (done ()) {
3076
+ int i = 0 ;
3077
+ while (!peek (i) && pos + i > 0 ) { --i; };
3078
+ if (peek (i)) {
3079
+ m += std::string (" (after '" ) + peek (i)->to_string (true ) + " ')" ;
3080
+ if (
3081
+ err_pos == source_position{}
3082
+ ) {
3083
+ err_pos = peek (i)->position ();
3084
+ }
3085
+ }
3086
+ } else {
3087
+ if (include_curr_token) {
3088
+ m += std::string (" (at '" ) + curr ().to_string (true ) + " ')" ;
3089
+ }
3090
+ if (
3091
+ err_pos == source_position{}
3092
+ && peek (0 )
3093
+ )
3094
+ {
3095
+ err_pos = peek (0 )->position ();
3096
+ }
3083
3097
}
3098
+
3084
3099
errors.emplace_back ( err_pos, m, false , fallback );
3085
3100
}
3086
3101
@@ -5086,7 +5101,8 @@ class parser
5086
5101
5087
5102
// If there's no [ [ then this isn't a contract
5088
5103
if (
5089
- curr ().type () != lexeme::LeftBracket
5104
+ done ()
5105
+ || curr ().type () != lexeme::LeftBracket
5090
5106
|| !peek (1 )
5091
5107
|| peek (1 )->type () != lexeme::LeftBracket
5092
5108
)
You can’t perform that action at this time.
0 commit comments