[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Syntax error messages in 1.8.3

gabriele renzi

2/14/2006 12:10:00 AM

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?
5 Answers

Yukihiro Matsumoto

2/14/2006 1:14:00 AM

0

Hi,

In message "Re: Syntax error messages in 1.8.3"
on Tue, 14 Feb 2006 09:13:25 +0900, gabriele renzi <surrender_it@-remove-yahoo.it> 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

2/15/2006 7:53:00 PM

0

Yukihiro Matsumoto ha scritto:
> Hi,
>
> In message "Re: Syntax error messages in 1.8.3"
> on Tue, 14 Feb 2006 09:13:25 +0900, gabriele renzi <surrender_it@-remove-yahoo.it> 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.

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

thanks

Yukihiro Matsumoto

2/16/2006 12:03:00 AM

0

Hi,

In message "Re: Syntax error messages in 1.8.3"
on Thu, 16 Feb 2006 04:58:26 +0900, gabriele renzi <surrender_it@-remove-yahoo.it> 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

3/1/2006 11:23:00 PM

0

Yukihiro Matsumoto ha scritto:
> Hi,
>
> In message "Re: Syntax error messages in 1.8.3"
> on Thu, 16 Feb 2006 04:58:26 +0900, gabriele renzi <surrender_it@-remove-yahoo.it> 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.

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

3/1/2006 11:42:00 PM

0

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"'.