--------------040201060901050003090402
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Hi,
The attached patch adds literal strings for tokens in parse.y so that
parse error messages are more user-friendly. See [ruby-talk:179793] and
[ruby-talk:187099] for descriptions of the problem.
For example, instead of:
-e:1: syntax error, unexpected tIDENTIFIER, expecting $end
the output is:
-e:1: syntax error, unexpected identifier, expecting $end
or:
-e:1: syntax error, unexpected kEND
-e:1: syntax error, unexpected end
I created and tested the patch with the latest Ruby CVS. I hope the
formatting and indenting is ok and that I translated all tokens right.
Regards,
Robin Stocker
--------------040201060901050003090402
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
name arse.y.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename arse.y.patch"
Index: parse.y
RCS file: /src/ruby/parse.y,v
retrieving revision 1.434
diff -u -r1.434 parse.y
--- parse.y 26 Mar 2006 13:04:13 -0000 1.434
+++ parse.y 1 Apr 2006 16:50:21 -0000
@@ -475,59 +475,73 @@
/*%
%token <val>
%*/
- kCLASS
- kMODULE
- kDEF
- kUNDEF
- kBEGIN
- kRESCUE
- kENSURE
- kEND
- kIF
- kUNLESS
- kTHEN
- kELSIF
- kELSE
- kCASE
- kWHEN
- kWHILE
- kUNTIL
- kFOR
- kBREAK
- kNEXT
- kREDO
- kRETRY
- kIN
- kDO
- kDO_COND
- kDO_BLOCK
- kDO_LAMBDA
- kRETURN
- kYIELD
- kSUPER
- kSELF
- kNIL
- kTRUE
- kFALSE
- kAND
- kOR
- kNOT
- kIF_MOD
- kUNLESS_MOD
- kWHILE_MOD
- kUNTIL_MOD
- kRESCUE_MOD
- kALIAS
- kDEFINED
- klBEGIN
- klEND
- k__LINE__
- k__FILE__
+ kCLASS "class"
+ kMODULE "module"
+ kDEF "def"
+ kUNDEF "undef"
+ kBEGIN "begin"
+ kRESCUE "rescue"
+ kENSURE "ensure"
+ kEND "end"
+ kIF "if"
+ kUNLESS "unless"
+ kTHEN "then"
+ kELSIF "elsif"
+ kELSE "else"
+ kCASE "case"
+ kWHEN "when"
+ kWHILE "while"
+ kUNTIL "until"
+ kFOR "for"
+ kBREAK "break"
+ kNEXT "next"
+ kREDO "redo"
+ kRETRY "retry"
+ kIN "in"
+ kDO "do"
+ kDO_COND "do condition"
+ kDO_BLOCK "do block"
+ kDO_LAMBDA "do lambda"
+ kRETURN "return"
+ kYIELD "yield"
+ kSUPER "super"
+ kSELF "self"
+ kNIL "nil"
+ kTRUE "true"
+ kFALSE "false"
+ kAND "and"
+ kOR "or"
+ kNOT "not"
+ kIF_MOD "if modifier"
+ kUNLESS_MOD "unless modifier"
+ kWHILE_MOD "while modifier"
+ kUNTIL_MOD "until modifier"
+ kRESCUE_MOD "rescue modifier"
+ kALIAS "alias"
+ kDEFINED "defined"
+ klBEGIN "BEGIN"
+ klEND "END"
+ k__LINE__ "__LINE__"
+ k__FILE__ "__FILE__"
+
+%token <id>
+ tIDENTIFIER "identifier"
+ tFID
+ tGVAR "global variable"
+ tIVAR "instance variable"
+ tCONSTANT "constant"
+ tCVAR "class variable"
+ tLABEL "label"
+
+%token <node>
+ tINTEGER "integer"
+ tFLOAT "float"
+ tSTRING_CONTENT "string content"
-%token <id> tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL
-%token <node> tINTEGER tFLOAT tSTRING_CONTENT
%token <node> tNTH_REF tBACK_REF
-%token <num> tREGEXP_END
+
+%token <num>
+ tREGEXP_END "regexp end"
%type <node> singleton strings string string1 xstring regexp
%type <node> string_contents xstring_contents string_content
@@ -552,36 +566,51 @@
/*%
%type <val> program reswords then do dot_or_colon
%*/
-%token tUPLUS /* unary+ */
-%token tUMINUS /* unary- */
-%token tPOW /* ** */
-%token tCMP /* <