Forum: Ruby Syntax error messages in 1.8.3

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
gabriele renzi (Guest)
on 2006-02-14 02:13
(Received via mailing list)
Hi gurus and nubys,

I wonder if this is related to the 1.8.4 one-click installer (preview)
or a general change in ruby: I'm getting really weird error messages for
syntax errors, it seem that ruby spits out some non-formatted names from
the parser code whe it encounters a syntax error.

Some examples:

---
def
t.rb:1: parse error, unexpected $
---
p() p
t.rb:1: parse error, unexpected tIDENTIFIER, expecting $
---
p(/)
t.rb:1: unterminated string meets end of file
t.rb:1: parse error, unexpected tSTRING_END, expecting tSTRING_CONTENT
or tREGEXP_END or tSTRING_DBEG or tSTRING_DVAR
  p(/)
       ^
---
p(
t.rb:1: parse error, unexpected $, expecting ')'

Ok, the errors are obvious and I understand what messages mean.. but I
don't remember they were like this in the past.
Could someone confirm if (s)he's getting this and if it is ok?
Yukihiro M. (Guest)
on 2006-02-14 03:14
(Received via mailing list)
Hi,

In message "Re: Syntax error messages in 1.8.3"
    on Tue, 14 Feb 2006 09:13:25 +0900, gabriele renzi
<removed_email_address@domain.invalid> writes:

|def
|t.rb:1: parse error, unexpected $

|Ok, the errors are obvious and I understand what messages mean.. but I
|don't remember they were like this in the past.
|Could someone confirm if (s)he's getting this and if it is ok?

I'm getting this too.  And this is a feature of bison 2.x, I guess.

							matz.
gabriele renzi (Guest)
on 2006-02-15 22:01
(Received via mailing list)
Yukihiro M. ha scritto:
> |Could someone confirm if (s)he's getting this and if it is ok?
>
> I'm getting this too.  And this is a feature of bison 2.x, I guess.
>
> 							matz.

I see, but would it be possible to replace internal identifiers such as
  tSTRING_DVAR with something user-readable?

thanks
Yukihiro M. (Guest)
on 2006-02-16 02:03
(Received via mailing list)
Hi,

In message "Re: Syntax error messages in 1.8.3"
    on Thu, 16 Feb 2006 04:58:26 +0900, gabriele renzi
<removed_email_address@domain.invalid> writes:

|> I'm getting this too.  And this is a feature of bison 2.x, I guess.

|I see, but would it be possible to replace internal identifiers such as
|  tSTRING_DVAR with something user-readable?

I'm afraid not.  Bison doesn't give us a hook to replace it.  Correct
me if I'm wrong.

							matz.
gabriele renzi (Guest)
on 2006-03-02 01:28
(Received via mailing list)
Yukihiro M. ha scritto:
> I'm afraid not.  Bison doesn't give us a hook to replace it.  Correct
> me if I'm wrong.

mh.. I did some research/test, it seem you could just use something like

%token foo  "expressive name"

i.e. adding this:
%token tSTRING_DVAR "embedded code"
%token tSTRING_END   "end of String"
%token tSTRING_CONTENT "continuated String"
%token tREGEXP_END "end of Regexp"
%token tSTRING_DBEG "beginning of String"

to parse.y gives this result:

$miniruby
p(/)
^D
unterminated string meets end of file
syntax error, unexpected "end of String", expecting "continuated String"
or "end of Regexp" or "beginning of String" or "embedded code"

(I think there is a switch in bison 2.1 to avoid " )

It is not a whole hook that could allow even better messages but it may
be better than the current internals identifiers.

Hope this helps.
gabriele renzi (Guest)
on 2006-03-02 01:44
(Received via mailing list)
gabriele renzi ha scritto:


> (I think there is a switch in bison 2.1 to avoid " )

I was wrong, quoting the 2.1 announcement:

* When generating verbose diagnostics, Bison-generated parsers no longer
   quote the literal strings associated with tokens.  For example, for
   a syntax error associated with '%token NUM "number"' they might
   print 'syntax error, unexpected number' instead of 'syntax error,
   unexpected "number"'.
This topic is locked and can not be replied to.