Syntax error messages in 1.8.3

G

gabriele renzi

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?
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Syntax error messages in 1.8.3"

|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.
 
G

gabriele renzi

Yukihiro Matsumoto ha scritto:
Hi,

In message "Re: Syntax error messages in 1.8.3"

|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
 
Y

Yukihiro Matsumoto

Hi,

In message "Re: Syntax error messages in 1.8.3"

|> 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.
 
G

gabriele renzi

Yukihiro Matsumoto ha scritto:
Hi,

In message "Re: Syntax error messages in 1.8.3"

|> 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.
 
G

gabriele renzi

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,968
Messages
2,570,152
Members
46,697
Latest member
AugustNabo

Latest Threads

Top