# Syntax error messages in 1.8.3

**URL:** <https://www.ruby-forum.com/t/syntax-error-messages-in-1-8-3/53724>\
**Category:** Ruby\
**Created:** [February 14, 2006, 1:13am UTC](https://www.ruby-forum.com/t/syntax-error-messages-in-1-8-3/53724 "2006-02-14T01:13:31Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabriele\_renzi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19b73/32.png) [@gabriele\_renzi](https://www.ruby-forum.com/u/gabriele_renzi)\
**Post date:** [February 14, 2006, 1:13am UTC](https://www.ruby-forum.com/t/syntax-error-messages-in-1-8-3/53724/1 "2006-02-14T01:13:31Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![gabriele\_renzi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19b73/32.png) [@gabriele\_renzi](https://www.ruby-forum.com/u/gabriele_renzi)\
**Post date:** [February 14, 2006, 2:14am UTC](https://www.ruby-forum.com/t/syntax-error-messages-in-1-8-3/53724/2 "2006-02-14T02:14:32Z")

</div>

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](mailto: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.

```

---

<div class="post-metadata">

**Author:** ![gabriele\_renzi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19b73/32.png) [@gabriele\_renzi](https://www.ruby-forum.com/u/gabriele_renzi)\
**Post date:** [February 15, 2006, 9:01pm UTC](https://www.ruby-forum.com/t/syntax-error-messages-in-1-8-3/53724/3 "2006-02-15T21:01:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gabriele\_renzi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19b73/32.png) [@gabriele\_renzi](https://www.ruby-forum.com/u/gabriele_renzi)\
**Post date:** [February 16, 2006, 1:03am UTC](https://www.ruby-forum.com/t/syntax-error-messages-in-1-8-3/53724/4 "2006-02-16T01:03:53Z")

</div>

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](mailto: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.

```

---

<div class="post-metadata">

**Author:** ![gabriele\_renzi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19b73/32.png) [@gabriele\_renzi](https://www.ruby-forum.com/u/gabriele_renzi)\
**Post date:** [March 2, 2006, 12:44am UTC](https://www.ruby-forum.com/t/syntax-error-messages-in-1-8-3/53724/5 "2006-03-02T00:44:17Z")

</div>

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”’.

---

<div class="post-metadata">

**Author:** ![gabriele\_renzi](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/e19b73/32.png) [@gabriele\_renzi](https://www.ruby-forum.com/u/gabriele_renzi)\
**Post date:** [March 2, 2006, 12:28am UTC](https://www.ruby-forum.com/t/syntax-error-messages-in-1-8-3/53724/6 "2006-03-02T00:28:45Z")

</div>

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.
