File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -145,7 +145,7 @@ def lex_token
145145 end
146146 return [ type , token ]
147147 else
148- raise ParseError , "Unexpected token: #{ @scanner . peek ( 10 ) . chomp } ." # steep:ignore UnknownConstant
148+ raise ParseError , location . generate_error_message ( "Unexpected token" ) # steep:ignore UnknownConstant
149149 end
150150 end
151151
@@ -186,7 +186,7 @@ def lex_c_code
186186 code << @scanner . getch
187187 end
188188 end
189- raise ParseError , "Unexpected code: #{ code } ." # steep:ignore UnknownConstant
189+ raise ParseError , location . generate_error_message ( "Unexpected code: #{ code } " ) # steep:ignore UnknownConstant
190190 end
191191
192192 private
Original file line number Diff line number Diff line change 396396 it do
397397 path = fixture_path ( "common/unexpected_token.y" )
398398 text = File . read ( path )
399- grammar_file = Lrama ::Lexer ::GrammarFile . new ( path , text )
399+ grammar_file = Lrama ::Lexer ::GrammarFile . new ( "unexpected_token.y" , text )
400400 lexer = Lrama ::Lexer . new ( grammar_file )
401401
402- expect { lexer . next_token } . to raise_error ( ParseError , "Unexpected token: @invalid." )
402+ expect { lexer . next_token } . to raise_error ( ParseError , <<~MSG )
403+ unexpected_token.y:5:0: Unexpected token
404+ 5 | @invalid
405+ | ^
406+ MSG
403407 end
404408 end
405409
410414 lexer . status = :c_declaration
411415 lexer . end_symbol = "%}"
412416
413- expect { lexer . next_token } . to raise_error ( ParseError , "Unexpected code: @invalid." )
417+ expect { lexer . next_token } . to raise_error ( ParseError , <<~MSG )
418+ invalid.y:1:0: Unexpected code: @invalid
419+ 1 | @invalid
420+ | ^~~~~~~~
421+ MSG
414422 end
415423 end
416424
You can’t perform that action at this time.
0 commit comments