Issue #21608 has been updated by Henrik Lindberg.

Chris Wilson wrote:
> OK, at least the error message is better than the original one, which we 
> found very funny in the office.
> 
Oh, the pleasure we get from the WATs :-)

> But I still think that, at least in theory, during parsing there should be 
> two options after the "]": either a ":" or a "=>". Anything else would be a 
> parser error. (Assuming that the lexer has separated the input into tokens 
> and thrown away any white space, then the parser doesn't need to account for 
> that possibility). If the parser was able to present a list of the valid 
> options, that would have helped a lot.
> 
As far as I know, Racc (the parser generator used) does not present the options 
that would have made it a non-syntax error.
So, yeah, in theory.

> I still find the value "syntax error" pretty useless. Surely there is more 
> than one class of syntax error? How on earth is one supposed to resolve it, 
> apart from commenting things out until it stops breaking?
>
You are right, a syntax error is the last resort. That happens when the grammar 
runs out of options. In the future parser the grammar has been substantially 
relaxed (it allows as much as possible as "understandable" and uses a 
validation step to flag sentences that are not valid in the puppet language). 
As you will find when using the future parser it does a much better job in 
general of reporting errors. It is however not possible to completely get rid 
of emitting syntax error (ultimately it requires intelligence and intuition, 
and frankly, a parser is quite dumb).
  
> Why does the parser even consider the possibility of a function call? I 
> assume that parentheses around the expression are absolutely requires, and 
> there are no parentheses here. It was an option between "f" and "{", but 
> after seeing "{" it's no longer an option.

The puppet language (like ruby) allows function calls to be made without the 
parentheses. In Puppet this is allowed when one argument is given to the 
function, and the expression is a "top level" construct (i.e. appears as a 
statement rather than part of a expression). Thus the following two expressions 
are equivalent:
<pre>
f 1
f(1)
</pre>

But you have to have the parentheses in cases like this:
<pre>
10 + f(1)
</pre>


Some things that may be perceived as statements in the language are actually 
functions; e.g. `include` and `require`.

It would be a good thing to get rid of this by making include and require 
keywords and separate statements and then require parentheses around the 
argument list at all times.
That would increase the opportunity to provide better error messages as the 
number of possible options in the parser are then greatly reduced. 
However, that is a quite major change that makes introduction of new statement 
like functions impossible without language change. 

Again, I like to point out that Geppetto uses a different parser technology and 
you may find that it is easier to find and figure out what is wrong given that 
it is able to give more information in many cases.


----------------------------------------
Bug #21608: Syntax error at '}'; expected '}'
https://projects.puppetlabs.com/issues/21608#change-97782

* Author: Chris Wilson
* Status: Closed
* Priority: Normal
* Assignee: Henrik Lindberg
* Category: language
* Target version: 
* Affected Puppet version: 2.6.18
* Keywords: parser errors
* Branch: 
----------------------------------------
>From the following code:

<pre>
  # 
http://stackoverflow.com/questions/6399922/are-there-iterators-and-loops-in-puppet
  define f {
    file { "/root/.ssh/${title}":
      ensure => present,
      source => 'puppet:///files/ssh_keys/${title}',
      owner   => 'root', group => 'root', mode => '0400',
    }
  }
  f { ["id_beep_down", "id_beep_down.pub", "id_beep_up", "id_beep_up.pub",] }
</pre>

I think it's missing a colon after the last ], but that's not what the error 
message says.

<pre>
[puppet server]$ rpm -q puppet
puppet-2.6.18-3.el6.noarch
</pre>


-- 
You have received this notification because you have either subscribed to it, 
or are involved in it.
To change your notification preferences, please click here: 
http://projects.puppetlabs.com/my/account

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Bugs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-bugs.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to