On Sep 27, 2008, at 4:21 AM, Brice Figureau wrote:

>
> The expressions can be used in if 'test' and in the
> right side of assignements.
>
> The expressions can contain any number of sub-expressions
> combined by either arithmetic operators, comparison operators,
> or boolean operators.
>
> Random Usage Examples:
> $result = ((( $two + 2) / $one) + 4 * 5.45) - (6 << 7) + (0x800 + -9)
> or
> if ($a < 10) and ($a + 10 != 200) {
> ...
> }

Sweet.
> [...]
> -# Currently we only support a single value, but eventually one  
> assumes
> -# we'll support operators and such.
> -iftest:         rvalue
> +# Unlike yacc/bison, it seems racc
> +# gives tons of shift/reduce warnings
> +# with the following syntax:
> +#
> +# expression: ...
> +#            | expression arithop expressio { ... }
> +#
> +# arithop: PLUS | MINUS | DIVIDE | TIMES ...
> +#
> +# So I had to develop the expression by adding one rule
> +# per operator :-(

Not so sweet. :/  Yay racc.
>
> casestatement:  CASE rvalue LBRACE caseopts RBRACE {
>     options = val[3]
> diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb
> index 71210d9..5dd036e 100644
> --- a/lib/puppet/parser/lexer.rb
> +++ b/lib/puppet/parser/lexer.rb
> @@ -126,12 +126,22 @@ class Puppet::Parser::Lexer
>         '\\' => :BACKSLASH,
>         '=>' => :FARROW,
>         '+>' => :PARROW,
> +        '+' => :PLUS,
> +        '-' => :MINUS,
> +        '/' => :DIV,
> +        '*' => :TIMES,
> +        '<<' => :LSHIFT,
> +        '>>' => :RSHIFT,
>         %r{([a-z][-\w]*::)+[a-z][-\w]*} => :CLASSNAME,
>         %r{((::){0,1}[A-Z][-\w]*)+} => :CLASSREF
>     )
>
>     TOKENS.add_tokens "Whatever" => :DQTEXT, "Nomatter" => :SQTEXT,  
> "alsonomatter" => :BOOLEAN
>
> +    TOKENS.add_token :NUMBER, %r{\b(?:0[xX][0-9A-Fa-f]+|0?\d+(?:\.\d 
> +)?(?:[eE]-?\d+)?)\b} do |lexer, value|
> +        [TOKENS[:NAME], value]
> +    end
> +


Went all out, didn't you? :)

-- 
Real freedom lies in wildness, not in civilization.
     -- Charles Lindbergh
---------------------------------------------------------------------
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