summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-20 14:02:32 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-20 14:02:32 +0000
commit89bcc681f076d46604bc706325155a676010ff0b (patch)
tree3a8b09e8f131615e3a9d592a4c0b229dc40034fe
parentf4bc341b0083c2b59894c7f3b4af1bbf2af27cd9 (diff)
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
-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 07c521b..f73c96b 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 ef1c622..92810c1 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 0ec91f8..c28b9a9 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