On Wed, 2011-02-16 at 17:12 +0100, Thomas Bellman wrote:
> On 2011-02-12 17:36, Brice Figureau wrote:
> 
> It appears that I'm late to the party, but:
> 
> > The following manifest was producing a parse error:
> > $int = { 'eth0' => 'bla' }
> > $foo = $int['eth0'] ? {
> >   'bla' => 'foo',
> >    default => 'bleh'
> > }
> > 
> > because selectors didn't support hash access.
> 
> > diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra
> > index 7a316d4..3a386d8 100644
> > --- a/lib/puppet/parser/grammar.ra
> > +++ b/lib/puppet/parser/grammar.ra
> > @@ -642,6 +642,7 @@ selectlhand:  name
> >    | funcrvalue
> >    | boolean
> >    | undef
> > +  | hasharrayaccess
> >    | DEFAULT {
> >      result = ast AST::Default, :value => val[0][:value], :line => 
> > val[0][:line]
> >  }
> 
> Question: why does the grammar not allow a generic rvalue here instead
> of only allowing a few ways of specifying values?  This question applies
> to lots of other places in the grammar as well, like resource names or
> function paramaters (you can't use a function call for a resource name,
> and you can't specify a literal array as a function parameter, but have
> to assign them to a dummy variable first).

The reason is that racc produces tons of reduce/shift conflicts if you
use rvalue instead of a selectlhand. I'm not exactly sure why it does
this (as I think yacc wouldn't do that for the same grammar).
It might be possible that it doesn't like some kind of recursion.

> And even so, shouldn't the above patch add "hasharrayaccesses" (plural)?

I think you are right.
Daniel (or who is the current "merge-captain" right now): should I send
a new patch?

> I'm not a parser expert, and this is the first time I've even looked at
> grammar.ra, but as a user of Puppet I find those restrictions annoying...

One thing I'm sure when I started hacking on the Puppet grammar is that
I didn't want to transform the DSL in a full-blown generic language. 
So for instance it's not possible to use an expression in the context of
any rvalues.

-- 
Brice Figureau
Follow the latest Puppet Community evolutions on www.planetpuppet.org!

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to