On Sep 20, 2008, at 1:39 PM, Brice Figureau wrote:

>
> Hi,
>
> The more I think about that patch, the more I think I should expand it
> to a more generic expression parser/evaluator by adding arithmetic
> operators and such, so that we could write these stupid things:
>
> class superfeaturethatneedsplentyofram {
>   $min_ram = 2048 * 1024 * 1024
>   if ($ram / (1024*1024) < $min_ram) {
>     notice("not enough ram on node ${fqdn}")
>   }
> }
>
> I already started coding this in fact and I'm wondering if that's
> something that:
>  * is needed (I never myself got the need)
>  * would be welcome
>
> Anyway, that's an interesting exercise (mainly due to the lack or racc
> documentation or examples). Right now I'm struggling with shift/reduce
> conflicts I don't really know how to solve (anyone familiar with LALR
> parsers lurking here, please I welcome any help :-)).

Note that Puppet's language doesn't have numbers -- they're all  
treated as strings (only 'true' and 'false', when unquoted, are  
anything but strings) -- so you'll have to do a touch of magic to make  
math work.

Generally, I'm not opposed to this but I don't think it's all that  
important, either.  I expect others will stauchly disagree with me,  
though, and would love this functionality.

The lack of racc documentation is quite fun -- I can only ever find my  
own threads and code when looking for it. I can't imagine I'm the only  
person to ever use it, but I might be the only one to ever publish  
anything using it.

In terms of shift/reduce conflicts, they are the bane of LALR parser  
generators.  I'm willing to do what I can to help, but they're pretty  
unfun.  What's your code look like right now?

BTW, one thing that might be useful is to create a stand-alone parser  
that just does the arithmetic, and when you're happy with it, import  
it into Puppet.  Then again, that might be 10x harder. :)

-- 
I can win an argument on any topic, against any opponent. People know
this, and steer clear of me at parties. Often, as a sign of their
great respect, they don't even invite me. -- Dave Barry
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


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