File tree Expand file tree Collapse file tree 2 files changed +25
-14
lines changed Expand file tree Collapse file tree 2 files changed +25
-14
lines changed Original file line number Diff line number Diff line change @@ -1592,20 +1592,6 @@ def next_token
1592
1592
end
1593
1593
end
1594
1594
1595
- def parse_error ( fmt , *args )
1596
- if IMAP . debug
1597
- $stderr. printf ( "@str: %s\n " , @str . dump )
1598
- $stderr. printf ( "@pos: %d\n " , @pos )
1599
- $stderr. printf ( "@lex_state: %s\n " , @lex_state )
1600
- if @token
1601
- $stderr. printf ( "@token.symbol: %s\n " , @token . symbol )
1602
- $stderr. printf ( "@token.value: %s\n " , @token . value . inspect )
1603
- end
1604
- end
1605
- raise ResponseParseError , format ( fmt , *args )
1606
- end
1607
1595
end
1608
-
1609
1596
end
1610
-
1611
1597
end
Original file line number Diff line number Diff line change @@ -54,6 +54,31 @@ def lookahead
54
54
def shift_token
55
55
@token = nil
56
56
end
57
+
58
+ def parse_error ( fmt , *args )
59
+ msg = format ( fmt , *args )
60
+ if IMAP . debug
61
+ local_path = File . dirname ( __dir__ )
62
+ tok = @token ? "%s: %p" % [ @token . symbol , @token . value ] : "nil"
63
+ warn "%s %s: %s" % [ self . class , __method__ , msg ]
64
+ warn " tokenized : %s" % [ @str [ ...@pos ] . dump ]
65
+ warn " remaining : %s" % [ @str [ @pos ..] . dump ]
66
+ warn " @lex_state: %s" % [ @lex_state ]
67
+ warn " @pos : %d" % [ @pos ]
68
+ warn " @token : %s" % [ tok ]
69
+ caller_locations ( 1 ..20 ) . each_with_index do |cloc , idx |
70
+ next unless cloc . path &.start_with? ( local_path )
71
+ warn " caller[%2d]: %-30s (%s:%d)" % [
72
+ idx ,
73
+ cloc . base_label ,
74
+ File . basename ( cloc . path , ".rb" ) ,
75
+ cloc . lineno
76
+ ]
77
+ end
78
+ end
79
+ raise ResponseParseError , msg
80
+ end
81
+
57
82
end
58
83
end
59
84
end
You can’t perform that action at this time.
0 commit comments