From 62ec5eb01874472e2df9d871ef329d5a76b9c853 Mon Sep 17 00:00:00 2001 From: nobu Date: Mon, 21 Jan 2019 10:24:56 +0000 Subject: [PATCH] parse.y: more token names git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66896 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- bootstraptest/test_literal_suffix.rb | 6 +++--- parse.y | 25 +++++++++++++++++++++---- test/ruby/test_parse.rb | 2 +- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/bootstraptest/test_literal_suffix.rb b/bootstraptest/test_literal_suffix.rb index 4316c9e040..c36fa7078f 100644 --- a/bootstraptest/test_literal_suffix.rb +++ b/bootstraptest/test_literal_suffix.rb @@ -46,9 +46,9 @@ assert_equal '1', '1rescue nil' assert_equal '10000000000000000001/10000000000000000000', '1.0000000000000000001r' -assert_equal 'syntax error, unexpected tIDENTIFIER, expecting end-of-input', +assert_equal 'syntax error, unexpected local variable or method, expecting end-of-input', %q{begin eval('1ir', nil, '', 0); rescue SyntaxError => e; e.message[/\A:(?:\d+:)? (.*)/, 1] end} -assert_equal 'syntax error, unexpected tIDENTIFIER, expecting end-of-input', +assert_equal 'syntax error, unexpected local variable or method, expecting end-of-input', %q{begin eval('1.2ir', nil, '', 0); rescue SyntaxError => e; e.message[/\A:(?:\d+:)? (.*)/, 1] end} -assert_equal 'syntax error, unexpected tIDENTIFIER, expecting end-of-input', +assert_equal 'syntax error, unexpected local variable or method, expecting end-of-input', %q{begin eval('1e1r', nil, '', 0); rescue SyntaxError => e; e.message[/\A:(?:\d+:)? (.*)/, 1] end} diff --git a/parse.y b/parse.y index 701497c733..b72a71f502 100644 --- a/parse.y +++ b/parse.y @@ -826,9 +826,21 @@ static void token_info_warn(struct parser_params *p, const char *token, token_in keyword__FILE__ "__FILE__" keyword__ENCODING__ "__ENCODING__" -%token tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL -%token tINTEGER tFLOAT tRATIONAL tIMAGINARY tSTRING_CONTENT tCHAR -%token tNTH_REF tBACK_REF +%token tIDENTIFIER "local variable or method" +%token tFID "method" +%token tGVAR "global variable" +%token tIVAR "instance variable" +%token tCONSTANT "constant" +%token tCVAR "class variable" +%token tLABEL +%token tINTEGER "integer literal" +%token tFLOAT "float literal" +%token tRATIONAL "rational literal" +%token tIMAGINARY "imaginary literal" +%token tCHAR "char literal" +%token tNTH_REF "numbered reference" +%token tBACK_REF "back reference" +%token tSTRING_CONTENT %token tREGEXP_END %type singleton strings string string1 xstring regexp @@ -902,7 +914,12 @@ static void token_info_warn(struct parser_params *p, const char *token, token_in %token tLAMBDA "->" %token tSYMBEG "symbol literal" %token tSTRING_BEG "string literal" -%token tXSTRING_BEG tREGEXP_BEG tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG +%token tXSTRING_BEG "backtick literal" +%token tREGEXP_BEG "regexp literal" +%token tWORDS_BEG "word list" +%token tQWORDS_BEG "verbatim word list" +%token tSYMBOLS_BEG "symbol list" +%token tQSYMBOLS_BEG "verbatim symbol list" %token tSTRING_DBEG tSTRING_DEND tSTRING_DVAR tSTRING_END tLAMBEG tLABEL_END /* diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index c7aeeecb61..1345dabc6e 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -1079,7 +1079,7 @@ x = __ENCODING__ end def test_truncated_source_line - e = assert_raise_with_message(SyntaxError, /unexpected tIDENTIFIER/) do + e = assert_raise_with_message(SyntaxError, /unexpected local variable or method/) do eval("'0123456789012345678901234567890123456789' abcdefghijklmnopqrstuvwxyz0123456789 0123456789012345678901234567890123456789") end line = e.message.lines[1]