parse.y: token name

* parse.y: more descriptive token names in syntax error messages.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36738 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-08-20 14:02:32 +00:00
parent f4bc341b00
commit 89bcc681f0
3 changed files with 38 additions and 28 deletions

View File

@ -1,3 +1,7 @@
Mon Aug 20 23:02:27 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y: more descriptive token names in syntax error messages.
Mon Aug 20 20:36:30 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> Mon Aug 20 20:36:30 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm_insnhelper.c (vm_call_method): follow iclasses as klass in cfp * vm_insnhelper.c (vm_call_method): follow iclasses as klass in cfp

View File

@ -529,7 +529,7 @@ def assert_syntax_error expected, code, message = ''
end end
assert_syntax_error "unterminated string meets end of file", '().."', '[ruby-dev:29732]' assert_syntax_error "unterminated string meets end of file", '().."', '[ruby-dev:29732]'
assert_equal %q{[]}, %q{$&;[]}, '[ruby-dev:31068]' assert_equal %q{[]}, %q{$&;[]}, '[ruby-dev:31068]'
assert_syntax_error "syntax error, unexpected tSTAR, expecting '}'", %q{{*0}}, '[ruby-dev:31072]' assert_syntax_error "syntax error, unexpected *, expecting '}'", %q{{*0}}, '[ruby-dev:31072]'
assert_syntax_error "`@0' is not allowed as an instance variable name", %q{@0..0}, '[ruby-dev:31095]' assert_syntax_error "`@0' is not allowed as an instance variable name", %q{@0..0}, '[ruby-dev:31095]'
assert_syntax_error "identifier $00 is not valid to get", %q{$00..0}, '[ruby-dev:31100]' assert_syntax_error "identifier $00 is not valid to get", %q{$00..0}, '[ruby-dev:31100]'
assert_syntax_error "identifier $00 is not valid to set", %q{0..$00=1} assert_syntax_error "identifier $00 is not valid to set", %q{0..$00=1}

60
parse.y
View File

@ -741,34 +741,40 @@ static void token_info_pop(struct parser_params*, const char *token);
/*% /*%
%type <val> program reswords then do dot_or_colon %type <val> program reswords then do dot_or_colon
%*/ %*/
%token tUPLUS /* unary+ */ %token END_OF_INPUT 0 "end-of-input"
%token tUMINUS /* unary- */ %token tUPLUS "unary+"
%token tPOW /* ** */ %token tUMINUS "unary-"
%token tCMP /* <=> */ %token tPOW "**"
%token tEQ /* == */ %token tCMP "<=>"
%token tEQQ /* === */ %token tEQ "=="
%token tNEQ /* != */ %token tEQQ "==="
%token tGEQ /* >= */ %token tNEQ "!="
%token tLEQ /* <= */ %token tGEQ ">="
%token tANDOP tOROP /* && and || */ %token tLEQ "<="
%token tMATCH tNMATCH /* =~ and !~ */ %token tANDOP "&&"
%token tDOT2 tDOT3 /* .. and ... */ %token tOROP "||"
%token tAREF tASET /* [] and []= */ %token tMATCH "=~"
%token tLSHFT tRSHFT /* << and >> */ %token tNMATCH "!~"
%token tCOLON2 /* :: */ %token tDOT2 ".."
%token tCOLON3 /* :: at EXPR_BEG */ %token tDOT3 "..."
%token tAREF "[]"
%token tASET "[]="
%token tLSHFT "<<"
%token tRSHFT ">>"
%token tCOLON2 "::"
%token tCOLON3 ":: at EXPR_BEG"
%token <id> tOP_ASGN /* +=, -= etc. */ %token <id> tOP_ASGN /* +=, -= etc. */
%token tASSOC /* => */ %token tASSOC "=>"
%token tLPAREN /* ( */ %token tLPAREN "("
%token tLPAREN_ARG /* ( */ %token tLPAREN_ARG "( arg"
%token tRPAREN /* ) */ %token tRPAREN ")"
%token tLBRACK /* [ */ %token tLBRACK "["
%token tLBRACE /* { */ %token tLBRACE "{"
%token tLBRACE_ARG /* { */ %token tLBRACE_ARG "{ arg"
%token tSTAR /* * */ %token tSTAR "*"
%token tDSTAR /* ** */ %token tDSTAR "**arg"
%token tAMPER /* & */ %token tAMPER "&"
%token tLAMBDA /* -> */ %token tLAMBDA "->"
%token tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG %token tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tWORDS_BEG tQWORDS_BEG tSYMBOLS_BEG tQSYMBOLS_BEG
%token tSTRING_DBEG tSTRING_DEND tSTRING_DVAR tSTRING_END tLAMBEG %token tSTRING_DBEG tSTRING_DEND tSTRING_DVAR tSTRING_END tLAMBEG