On Feb 17, 2011, at 2:46 PM, Nick Lewis wrote:
> On Thu, Feb 17, 2011 at 2:11 PM, Luke Kanies <[email protected]> wrote:
> This looks more like a lexer problem than a parser problem to me.
>
> Negative numbers should be lexed the same as positive numbers, because
> otherwise you have to go in and specifically allow negative numbers
> everywhere.
>
> In the current solution, you have enabled negative numbers for functions, but
> not for parameter values:
>
> file { "/tmp/asdf": owner => -1 }
>
> That throws a parse exception.
>
> Note that there's an easy workaround:
>
> file { "/tmp/asdf": owner => "-1" }
>
> This works just fine with functions, too (given that Puppet's language only
> has strings, no numbers).
>
> It's true that this solution doesn't fix that problem. But it does fix the
> problem of not being able to call my_function(-$a), which has a more
> challenging workaround. A solution that would have solved both related
> problems would be more complex, and didn't feel appropriate for a fix
> targeting 2.6. In the future, there are a whole host of related lexer/parser
> issues I would like to address, including #5817, #5516, #5268, #3129.
Hmm. I think supporting that is actually a bug, and is one of the problems
with solving this at a syntactic level. Ruby doesn't support that syntax, and
my guess is nothing else reasonable does, either. If you want that, use quotes:
my_function("-$a")
I think our lexer should support negative numbers, but our parser absolutely
shouldn't care about them.
--
It is curious that physical courage should be so common in the world and
moral courage so rare. -- Mark Twain
---------------------------------------------------------------------
Luke Kanies -|- http://puppetlabs.com -|- +1(615)594-8199
--
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.