summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--bootstraptest/test_syntax.rb2
-rw-r--r--parse.y60
3 files changed, 38 insertions, 28 deletions
diff --git a/ChangeLog b/ChangeLog
index 07c521b7b5..f73c96b0f1 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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>
* vm_insnhelper.c (vm_call_method): follow iclasses as klass in cfp
diff --git a/bootstraptest/test_syntax.rb b/bootstraptest/test_syntax.rb
index ef1c622ace..92810c1665 100644
--- a/bootstraptest/test_syntax.rb
+++ b/bootstraptest/test_syntax.rb
@@ -529,7 +529,7 @@ def assert_syntax_error expected, code, message = ''
end
assert_syntax_error "unterminated string meets end of file", '().."', '[ruby-dev:29732]'
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 "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}
diff --git a/parse.y b/parse.y
index 0ec91f8c38..c28b9a91a6 100644
--- a/parse.y
+++ b/parse.y
@@ -741,34 +741,40 @@ static void token_info_pop(struct parser_params*, const char *token);
/*%
%type <val> program reswords then do dot_or_colon
%*/
-%token tUPLUS /* unary+ */
-%token tUMINUS /* unary- */
-%token tPOW /* ** */
-%token tCMP /* <=> */
-%token tEQ /* == */
-%token tEQQ /* === */
-%token tNEQ /* != */
-%token tGEQ /* >= */
-%token tLEQ /* <= */
-%token tANDOP tOROP /* && and || */
-%token tMATCH tNMATCH /* =~ and !~ */
-%token tDOT2 tDOT3 /* .. and ... */
-%token tAREF tASET /* [] and []= */
-%token tLSHFT tRSHFT /* << and >> */
-%token tCOLON2 /* :: */
-%token tCOLON3 /* :: at EXPR_BEG */
+%token END_OF_INPUT 0 "end-of-input"
+%token tUPLUS "unary+"
+%token tUMINUS "unary-"
+%token tPOW "**"
+%token tCMP "<=>"
+%token tEQ "=="
+%token tEQQ "==="
+%token tNEQ "!="
+%token tGEQ ">="
+%token tLEQ "<="
+%token tANDOP "&&"
+%token tOROP "||"
+%token tMATCH "=~"
+%token tNMATCH "!~"
+%token tDOT2 ".."
+%token tDOT3 "..."
+%token tAREF "[]"
+%token tASET "[]="
+%token tLSHFT "<<"
+%token tRSHFT ">>"
+%token tCOLON2 "::"
+%token tCOLON3 ":: at EXPR_BEG"
%token <id> tOP_ASGN /* +=, -= etc. */
-%token tASSOC /* => */
-%token tLPAREN /* ( */
-%token tLPAREN_ARG /* ( */
-%token tRPAREN /* ) */
-%token tLBRACK /* [ */
-%token tLBRACE /* { */
-%token tLBRACE_ARG /* { */
-%token tSTAR /* * */
-%token tDSTAR /* ** */
-%token tAMPER /* & */
-%token tLAMBDA /* -> */
+%token tASSOC "=>"
+%token tLPAREN "("
+%token tLPAREN_ARG "( arg"
+%token tRPAREN ")"
+%token tLBRACK "["
+%token tLBRACE "{"
+%token tLBRACE_ARG "{ arg"
+%token tSTAR "*"
+%token tDSTAR "**arg"
+%token tAMPER "&"
+%token tLAMBDA "->"
%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