Hi,

Here is a series of patch that modify Puppet parser to:
 * add various operators (arithmetic, boolean...)
 * add various number format knowledge to the lexer
 * add the grammar to parse "complex" expressions

Right now, the expressions can be use:
 * in if tests:
 
    Ex:
    if ($var < 10 + 0xff) and ($var2 == 10) {
 
 * in right value of assignements:

    Ex:
    $var = 10 + 200 * -9 / (3 + $number)

Please review and comment as usual :-)
The code has been pushed to my github repository:
http://github.com/masterzen/puppet/tree/feature%2Fexpression

Brice Figureau


Brice Figureau (5):
  Add boolean operators to AST
  Add comparison operators (< > == != <= >=) to AST
  Add not operator to AST
  Add arithmetic operators to AST
  Add parser for arbitrary expressions

 lib/puppet/parser/ast.rb                     |    5 +
 lib/puppet/parser/ast/arithmetic_operator.rb |   41 +
 lib/puppet/parser/ast/boolean_operator.rb    |   48 +
 lib/puppet/parser/ast/comparison_operator.rb |   37 +
 lib/puppet/parser/ast/minus.rb               |   23 +
 lib/puppet/parser/ast/not.rb                 |   19 +
 lib/puppet/parser/grammar.ra                 |   87 ++-
 lib/puppet/parser/lexer.rb                   |   14 +-
 lib/puppet/parser/parser.rb                  | 1564 +++++++++++++++-----------
 lib/puppet/parser/scope.rb                   |   23 +
 spec/unit/parser/ast/arithmetic_operator.rb  |   80 ++
 spec/unit/parser/ast/boolean_operator.rb     |   52 +
 spec/unit/parser/ast/comparison_operator.rb  |   52 +
 spec/unit/parser/ast/minus.rb                |   36 +
 spec/unit/parser/ast/not.rb                  |   30 +
 spec/unit/parser/lexer.rb                    |   36 +-
 spec/unit/parser/parser.rb                   |   48 +-
 spec/unit/parser/scope.rb                    |   50 +
 test/data/snippets/arithmetic_expression.pp  |    8 +
 test/data/snippets/ifexpression.rb           |    6 +
 20 files changed, 1610 insertions(+), 649 deletions(-)
 create mode 100644 lib/puppet/parser/ast/arithmetic_operator.rb
 create mode 100644 lib/puppet/parser/ast/boolean_operator.rb
 create mode 100644 lib/puppet/parser/ast/comparison_operator.rb
 create mode 100644 lib/puppet/parser/ast/minus.rb
 create mode 100644 lib/puppet/parser/ast/not.rb
 create mode 100644 spec/unit/parser/ast/arithmetic_operator.rb
 create mode 100755 spec/unit/parser/ast/boolean_operator.rb
 create mode 100755 spec/unit/parser/ast/comparison_operator.rb
 create mode 100644 spec/unit/parser/ast/minus.rb
 create mode 100755 spec/unit/parser/ast/not.rb
 create mode 100644 test/data/snippets/arithmetic_expression.pp
 create mode 100644 test/data/snippets/ifexpression.rb


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