File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1592,20 +1592,6 @@ def next_token
15921592 end
15931593 end
15941594
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
16071595 end
1608-
16091596 end
1610-
16111597end
Original file line number Diff line number Diff line change @@ -54,6 +54,31 @@ def lookahead
5454 def shift_token
5555 @token = nil
5656 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+
5782 end
5883 end
5984 end
You can’t perform that action at this time.
0 commit comments