[#12372] Release compatibility/train — Prashant Srinivasan <Prashant.Srinivasan@...>

Hello all,

28 messages 2007/10/03
[#12373] Re: Release compatibility/train — Yukihiro Matsumoto <matz@...> 2007/10/03

Hi,

[#12374] Re: Release compatibility/train — David Flanagan <david@...> 2007/10/03

Yukihiro Matsumoto wrote:

[#12376] Re: Release compatibility/train — Prashant Srinivasan <Prashant.Srinivasan@...> 2007/10/03

[#12377] Re: Release compatibility/train — Yukihiro Matsumoto <matz@...> 2007/10/03

Hi,

[#12382] Re: Release compatibility/train — Charles Oliver Nutter <charles.nutter@...> 2007/10/03

Yukihiro Matsumoto wrote:

[#12385] Re: Release compatibility/train — Yukihiro Matsumoto <matz@...> 2007/10/03

Hi,

[#12388] Re: Release compatibility/train — Charles Oliver Nutter <charles.nutter@...> 2007/10/03

Yukihiro Matsumoto wrote:

[#12389] Re: Release compatibility/train — Yukihiro Matsumoto <matz@...> 2007/10/03

Hi,

[#12406] Re: Release compatibility/train — "David A. Black" <dblack@...> 2007/10/03

Hi --

[#12383] Include Rake in Ruby 1.9 — "NAKAMURA, Hiroshi" <nakahiro@...>

-----BEGIN PGP SIGNED MESSAGE-----

20 messages 2007/10/03

[#12539] Ordered Hashes in 1.9? — Michael Neumann <mneumann@...>

Hi all,

17 messages 2007/10/08
[#12542] Re: Ordered Hashes in 1.9? — Yukihiro Matsumoto <matz@...> 2007/10/08

Hi,

[#12681] Unicode: Progress? — murphy <murphy@...>

Hello!

17 messages 2007/10/15

[#12693] retry: revised 1.9 http patch — Hugh Sasse <hgs@...>

I'm reposting this because I've had little response to this version

11 messages 2007/10/15

[#12697] Range.first is incompatible with Enumerable.first — David Flanagan <david@...>

The new Enumerable.first method is a generalization of Array.first to

11 messages 2007/10/16

[#12754] Improving 'syntax error, unexpected $end, expecting kEND'? — Hugh Sasse <hgs@...>

I've had a look at this, but can't see how to do it: When I get

17 messages 2007/10/18
[#12886] Re: Improving 'syntax error, unexpected $end, expecting kEND'? — David Flanagan <david@...> 2007/10/23

The patch below changes this message to:

[#12758] Encoding::primary_encoding — David Flanagan <david@...>

Hi,

25 messages 2007/10/18
[#12763] Re: Encoding::primary_encoding — Nobuyoshi Nakada <nobu@...> 2007/10/19

Hi,

[#12802] Re: Encoding::primary_encoding — Wolfgang N疆asi-Donner <ed.odanow@...> 2007/10/21

Nobuyoshi Nakada schrieb:

[#12803] Re: Encoding::primary_encoding — Nobuyoshi Nakada <nobu@...> 2007/10/21

Hi,

[#12804] Re: Encoding::primary_encoding — Wolfgang N疆asi-Donner <ed.odanow@...> 2007/10/21

Nobuyoshi Nakada schrieb:

[#12808] Re: Encoding::primary_encoding — Nobuyoshi Nakada <nobu@...> 2007/10/22

Hi,

[#12818] Re: Encoding::primary_encoding — Wolfgang N疆asi-Donner <ed.odanow@...> 2007/10/22

Nobuyoshi Nakada schrieb:

[#12820] Re: Encoding::primary_encoding — "Michal Suchanek" <hramrach@...> 2007/10/22

T24gMjIvMTAvMjAwNywgV29sZmdhbmcgTsOhZGFzaS1Eb25uZXIgPGVkLm9kYW5vd0B3b25hZG8u

[#12823] Re: Encoding::primary_encoding — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/10/22

Michal Suchanek schrieb:

[#12824] Re: Encoding::primary_encoding — Nobuyoshi Nakada <nobu@...> 2007/10/22

Hi,

[#12767] \u escapes in string literals: proof of concept implementation — David Flanagan <david@...>

Back at the end of August, Matz wrote (see

45 messages 2007/10/19
[#12769] Re: \u escapes in string literals: proof of concept implementation — "Nobuyoshi Nakada" <nobu@...> 2007/10/19

Hi,

[#12782] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/20

Nobuyoshi Nakada wrote:

[#12831] Re: \u escapes in string literals: proof of concept implementation — Yukihiro Matsumoto <matz@...> 2007/10/22

Hi,

[#12841] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/22

Yukihiro Matsumoto wrote:

[#12862] Re: \u escapes in string literals: proof of concept implementation — Martin Duerst <duerst@...> 2007/10/23

At 04:19 07/10/23, David Flanagan wrote:

[#12864] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/23

Martin Duerst wrote:

[#12870] Re: \u escapes in string literals: proof of concept implementation — Martin Duerst <duerst@...> 2007/10/23

At 13:10 07/10/23, David Flanagan wrote:

[#12872] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/23

Martin Duerst wrote:

[#12936] Re: \u escapes in string literals: proof of concept implementation — Yukihiro Matsumoto <matz@...> 2007/10/25

Hi,

[#12980] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/26

Yukihiro Matsumoto wrote:

[#13028] Re: \u escapes in string literals: proof of concept implementation — Nobuyoshi Nakada <nobu@...> 2007/10/29

Hi,

[#13032] Re: \u escapes in string literals: proof of concept implementation — David Flanagan <david@...> 2007/10/29

Nobuyoshi Nakada wrote:

[#13034] Re: \u escapes in string literals: proof of concept implementation — Nobuyoshi Nakada <nobu@...> 2007/10/29

Hi,

[#13082] Re: \u escapes in string literals: proof of concept implementation — Martin Duerst <duerst@...> 2007/10/30

At 16:46 07/10/29, Nobuyoshi Nakada wrote:

[#13231] Re: \u escapes in string literals: proof of concept implementation — Nobuyoshi Nakada <nobu@...> 2007/11/06

Hi,

[#13234] Re: \u escapes in string literals: proof of concept implementation — Martin Duerst <duerst@...> 2007/11/06

At 11:29 07/11/06, Nobuyoshi Nakada wrote:

[#12825] clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...>

Hi,

53 messages 2007/10/22
[#12830] Re: clarification of ruby libraries installation paths? — Ben Bleything <ben@...> 2007/10/22

On Mon, Oct 22, 2007, Lucas Nussbaum wrote:

[#12833] Re: clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...> 2007/10/22

On 23/10/07 at 00:13 +0900, Ben Bleything wrote:

[#12835] Re: clarification of ruby libraries installation paths? — "Austin Ziegler" <halostatue@...> 2007/10/22

On 10/22/07, Lucas Nussbaum <lucas@lucas-nussbaum.net> wrote:

[#12836] Re: clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...> 2007/10/22

On 23/10/07 at 01:55 +0900, Austin Ziegler wrote:

[#12888] Re: clarification of ruby libraries installation paths? — Gonzalo Garramu <ggarra@...> 2007/10/23

Lucas Nussbaum wrote:

[#12894] Re: clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...> 2007/10/24

On 24/10/07 at 05:14 +0900, Gonzalo Garramu wrote:

[#13057] Re: clarification of ruby libraries installation paths? — Gonzalo Garramu <ggarra@...> 2007/10/29

Lucas Nussbaum wrote:

[#13058] Re: clarification of ruby libraries installation paths? — Lucas Nussbaum <lucas@...> 2007/10/29

On 30/10/07 at 07:28 +0900, Gonzalo Garramu wrote:

[#12848] Re: clarification of ruby libraries installation paths? — Sam Roberts <sroberts@...> 2007/10/22

On Tue, Oct 23, 2007 at 01:55:29AM +0900, Austin Ziegler wrote:

[#12855] Re: clarification of ruby libraries installation paths? — "Austin Ziegler" <halostatue@...> 2007/10/23

On 10/22/07, Sam Roberts <sroberts@uniserve.com> wrote:

[#13016] Re: clarification of ruby libraries installation paths? — bob@... (Bob Proulx) 2007/10/28

Austin Ziegler wrote:

[#13029] Re: clarification of ruby libraries installation paths? — "Austin Ziegler" <halostatue@...> 2007/10/29

On 10/28/07, Bob Proulx <bob@proulx.com> wrote:

[#13054] Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — Lucas Nussbaum <lucas@...> 2007/10/29

Austin,

[#13055] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Luis Lavena" <luislavena@...> 2007/10/29

On 10/29/07, Lucas Nussbaum <lucas@lucas-nussbaum.net> wrote:

[#13064] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Austin Ziegler" <halostatue@...> 2007/10/30

On 10/29/07, Luis Lavena <luislavena@gmail.com> wrote:

[#13066] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Luis Lavena" <luislavena@...> 2007/10/30

On 10/30/07, Austin Ziegler <halostatue@gmail.com> wrote:

[#13094] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Rick Bradley" <rick@...> 2007/10/30

Do we think that maybe, just maybe, things went off the rails when the

[#13095] Re: Austin Ziegler's behaviour (Was: clarification of ruby libraries installation paths?) — "Luis Lavena" <luislavena@...> 2007/10/30

On 10/30/07, Rick Bradley <rick@rickbradley.com> wrote:

[#12900] Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Wolfgang Nádasi-Donner <ed.odanow@...>

Dear Ruby 1.9 architects, developers, and testers!

31 messages 2007/10/24
[#12905] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Yukihiro Matsumoto <matz@...> 2007/10/24

Hi,

[#12907] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/10/24

Yukihiro Matsumoto schrieb:

[#12909] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Yukihiro Matsumoto <matz@...> 2007/10/24

Hi,

[#12940] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/10/25
[#12942] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Wolfgang Nádasi-Donner <ed.odanow@...> 2007/10/25

I have a (hopefully) final question before testing all

[#12948] Re: Hopefully Complete List of Possible Encoding Specifications - Existing Ones — Nobuyoshi Nakada <nobu@...> 2007/10/26

Hi,

[#12951] Fluent programming in Ruby — David Flanagan <david@...>

From the ChangeLog:

16 messages 2007/10/26

[#12996] General hash keys for colon notation — murphy <murphy@...>

Dear language designer(s) and parser wizards,

16 messages 2007/10/28

[#13027] Implementation of "guessUTF" method - final questions — Wolfgang Nádasi-Donner <ed.odanow@...>

Dear Ruby designers, developers, and testers!

22 messages 2007/10/29

[#13069] new Enumerable.butfirst method — David Flanagan <david@...>

Matz,

17 messages 2007/10/30

Re: Improving 'syntax error, unexpected $end, expecting kEND'?

From: David Flanagan <david@...>
Date: 2007-10-26 18:23:16 UTC
List: ruby-core #12975
David Flanagan wrote:

> Another possibility is to hack yyerror to clean up the error messages 
> for us, possibly stripping the quotation marks (so that we could have 
> "\"rescue\" modifier" with only the keyword in quotes and removing any 
> hacky spaces or non-printing characters we stuck into the token strings 
> to fool bison.  I haven't done any real C string manipulation complete 
> with memory allocation and freeing in 10 years, however, so I'm a little 
> reluctant to attempt this myself...

Okay, despite my protests of not knowing how to do this, I figured it 
out.  The yyerror function already uses ALLOCA_N once to allocate a 
string on the stack, so I don't feel bad about using it again.

Now, before printing the error message it strips all double quotes out 
of it.  So we can get error messages like "unexpected 'rescue' modifier"
And I can get "end of file" in an error message without quotes. 
Furthermore, we can solve the issue of having to have unique strings for 
each token by just inserting additional escaped double-quotes characters 
where I was using spaces before.  They'll be stripped out.

Its kind of hacky, but it makes for nice error messages. Updated patch 
is attached.

	David

Attachments (1)

patch (6.48 KB, text/x-diff)
Index: parse.y
===================================================================
--- parse.y	(revision 13782)
+++ parse.y	(working copy)
@@ -592,64 +592,87 @@
 }
 
 /*%%%*/
+/* 
+ * Token names in double quotes are just for use in error messages. 
+ * The escaped double-quotes within the names are stripped out in yyerror.
+ * They are required so that two distinct tokens don't have the same name
+ */
 %token
 /*%
 %token <val>
 %*/
-	keyword_class
-	keyword_module
-	keyword_def
-	keyword_undef
-	keyword_begin
-	keyword_rescue
-	keyword_ensure
-	keyword_end
-	keyword_if
-	keyword_unless
-	keyword_then
-	keyword_elsif
-	keyword_else
-	keyword_case
-	keyword_when
-	keyword_while
-	keyword_until
-	keyword_for
-	keyword_break
-	keyword_next
-	keyword_redo
-	keyword_retry
-	keyword_in
-	keyword_do
-	keyword_do_cond
-	keyword_do_block
-	keyword_do_LAMBDA
-	keyword_return
-	keyword_yield
-	keyword_super
-	keyword_self
-	keyword_nil
-	keyword_true
-	keyword_false
-	keyword_and
-	keyword_or
-	keyword_not
-	modifier_if
-	modifier_unless
-	modifier_while
-	modifier_until
-	modifier_rescue
-	keyword_alias
-	keyword_defined
-	keyword_BEGIN
-	keyword_END
-	keyword__LINE__
-	keyword__FILE__
 
-%token <id>   tIDENTIFIER tFID tGVAR tIVAR tCONSTANT tCVAR tLABEL
-%token <node> tINTEGER tFLOAT tSTRING_CONTENT tCHAR
-%token <node> tNTH_REF tBACK_REF
-%token <num>  tREGEXP_END
+        end_of_file 0     "end of file"
+	keyword_class     "'class'"
+	keyword_module    "'module'"
+	keyword_def       "'def'"
+	keyword_undef     "'undef'"
+	keyword_begin     "'begin'"
+	keyword_rescue    "'rescue'"
+	keyword_ensure    "'ensure'"
+	keyword_end       "'end'"
+	keyword_if        "'if'"
+	keyword_unless    "'unless'"
+	keyword_then      "'then'"
+	keyword_elsif     "'elsif'"
+	keyword_else      "'else'"
+	keyword_case      "'case'"
+	keyword_when      "'when'"
+	keyword_while     "'while'"
+	keyword_until     "'until'"
+	keyword_for       "'for'"
+	keyword_break     "'break'"
+	keyword_next      "'next'"
+	keyword_redo      "'redo'"
+	keyword_retry     "'retry'"
+	keyword_in        "'in'"
+	keyword_do        "'do'"
+	keyword_do_cond   "'do'\""
+	keyword_do_block  "'do'\"\""
+	keyword_do_LAMBDA "'do'\"\"\""
+	keyword_return    "'return'"
+	keyword_yield     "'yield'"
+	keyword_super     "'super'"
+	keyword_self      "'self'"
+	keyword_nil       "'nil'"
+	keyword_true      "'true'"
+	keyword_false     "'false'"
+	keyword_and       "'and'"
+	keyword_or        "'or'"
+	keyword_not       "'not'"
+	modifier_if       "'if' modifer"
+	modifier_unless   "'unless' modifier"
+	modifier_while    "'while' modifer"
+        modifier_until    "'until' modifer"
+	modifier_rescue   "'rescue' modifier"
+	keyword_alias     "'alias'"
+	keyword_defined   "'defined?'"
+	keyword_BEGIN     "'BEGIN'"
+	keyword_END       "'END'"
+	keyword__LINE__   "'__LINE__'"
+	keyword__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"
+  tCHAR                   "character literal"
+  tNTH_REF                "$n"
+  tBACK_REF               "$&, &`, &\\, or $+"
+
+%token <num>
+  tREGEXP_END             "regexp end"
+
+
 %type <node> singleton strings string string1 xstring regexp
 %type <node> string_contents xstring_contents string_content
 %type <node> words qwords word_list qword_list word
@@ -674,36 +697,52 @@
 /*%
 %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 <id> tOP_ASGN	/* +=, -=  etc. */
-%token tASSOC		/* => */
-%token tLPAREN		/* ( */
-%token tLPAREN_ARG	/* ( */
-%token tRPAREN		/* ) */
-%token tLBRACK		/* [ */
-%token tLBRACE		/* { */
-%token tLBRACE_ARG	/* { */
-%token tSTAR		/* * */
-%token tAMPER		/* & */
-%token tLAMBDA		/* -> */
-%token tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tWORDS_BEG tQWORDS_BEG
-%token tSTRING_DBEG tSTRING_DVAR tSTRING_END tLAMBEG
+%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	"abbreviated assignment"  /* +=, -=  etc. */
+%token tASSOC		"'=>'"
+%token tLPAREN		"'('"
+%token tLPAREN_ARG	"'('\""
+%token tRPAREN		"')'"
+%token tLBRACK		"'['"
+%token tLBRACE		"'{'"
+%token tLBRACE_ARG	"'{'\""
+%token tSTAR		"'*'"
+%token tAMPER		"'&'"
+%token tLAMBDA		"'->'"
 
+%token
+  tSYMBEG               "beginning of symbol"
+  tSTRING_BEG           "beginning of string"
+  tXSTRING_BEG          "beginning of execution string"
+  tREGEXP_BEG           "beginning of regexp"
+  tWORDS_BEG            "'%w'"
+  tQWORDS_BEG           "'%W'"
+  tSTRING_DBEG          "string interpolation"
+  tSTRING_DVAR          "string interpolation\""
+  tSTRING_END           "end of string"
+  tLAMBEG               "beginning of lambda"
+ 
+
 /*
  *	precedence table
  */
@@ -4586,7 +4625,21 @@
     const char *p, *pe;
     char *buf;
     int len, i;
+    char *c;
 
+    /*
+     * Strip double quotes from the error message
+     * This is a hack to clean up error messages generated by bison
+     * See the token strings declared with %token
+     */
+    len = strlen(msg);
+    buf = ALLOCA_N(char, len);
+    for(i = 0, c = buf; i < len; i++) {
+	if (msg[i] != '"') *c++ = msg[i];
+    }
+    *c = '\0';  /* NUL-terminate */
+    msg = buf;
+
     compile_error(PARSER_ARG "%s", msg);
     p = lex_p;
     while (lex_pbeg <= p) {

In This Thread