Hi, James wanted to merge this patch for 0.25 (although I'm myself not sure it is a good idea), so I'm posting a new version fixing all bugs I could find and takig into account the various comments I received.
Note to reviewers: 0002 and 0003 weren't touched, but all other patches were re-written or modified, so they are worth re-reading. Notes for this version: * scope ephemeral vars are now in their own symbol table * lexer returns a Regexp when it lexes a puppet regex * AST::Leaf nodes now supports a evaluate_match method which at the same time self-safeevaluate and "match" (either by equality for regular ast nodes or in the regexp sense for AST::Regex). This methods allows unification and simplification of AST if, case and selector code. * I added several spec tests for selector/case. * I changed loaded_code namespace finding tests which were using nodes (which IMHO doesn't support namespacing) to use hostclass instead (as there is no namespace support for the new node name using HostName instead of a String). * I don't know exactly how the first version of Regex nodes could have worked, but I discovered that the node classname is really important. When we evaluate the node to a resource the node classname (ie our regex converted to string) becomes the resource title. Of course using a regex source here broke everything (ie invalid tags, impossible to find the resource afterwards in the compiler...). So to fix this issue, in 0009 I introduced AST::Node#get_classname which if the node is a regex node returns the currently connected node name which is valid and mimics what would have happened if the node was a string nodename. But this has a drawback which IMHO isn't solvable easily: namely it isn't possible to inherits from a regex node (but IMHO it has no sense doing this). Thanks, Please review! Brice Brice Figureau (9): Implement ephemeral scope variables Allow variable $0 to $9 to be interpolated, if ephemeral Add regex, match and not match token to the lexer Add regexes and regex match operators to the parser Add AST::Regex, an AST leaf node representing a regex Fix #2033 - Allow regexp in if expression Enhance selector and case statements to match with regexp Make sure node are referenced by their names Implement node matching with regexes lib/puppet/parser/ast.rb | 1 + lib/puppet/parser/ast/caseopt.rb | 10 + lib/puppet/parser/ast/casestatement.rb | 11 +- lib/puppet/parser/ast/definition.rb | 6 +- lib/puppet/parser/ast/ifstatement.rb | 17 +- lib/puppet/parser/ast/leaf.rb | 83 ++- lib/puppet/parser/ast/match_operator.rb | 31 + lib/puppet/parser/ast/node.rb | 14 +- lib/puppet/parser/ast/selector.rb | 12 +- lib/puppet/parser/ast/vardef.rb | 2 +- lib/puppet/parser/grammar.ra | 24 +- lib/puppet/parser/lexer.rb | 7 + lib/puppet/parser/loaded_code.rb | 17 +- lib/puppet/parser/parser.rb | 1770 +++++++++++++++-------------- lib/puppet/parser/parser_support.rb | 4 +- lib/puppet/parser/scope.rb | 70 +- spec/unit/parser/ast/casestatement.rb | 143 +++ spec/unit/parser/ast/definition.rb | 18 + spec/unit/parser/ast/ifstatement.rb | 75 ++ spec/unit/parser/ast/leaf.rb | 194 ++++- spec/unit/parser/ast/match_operator.rb | 50 + spec/unit/parser/ast/node.rb | 20 + spec/unit/parser/ast/selector.rb | 156 +++ spec/unit/parser/ast/vardef.rb | 4 +- spec/unit/parser/lexer.rb | 14 + spec/unit/parser/loaded_code.rb | 114 ++- spec/unit/parser/parser.rb | 90 ++- spec/unit/parser/scope.rb | 98 ++- test/data/snippets/casestatement.pp | 7 + test/data/snippets/ifexpression.pp | 12 + test/data/snippets/ifexpression.rb | 6 - test/data/snippets/selectorvalues.pp | 7 + test/language/ast.rb | 5 +- test/language/snippets.rb | 7 +- test/lib/puppettest/parsertesting.rb | 5 + test/lib/puppettest/support/collection.rb | 2 +- 36 files changed, 2163 insertions(+), 943 deletions(-) create mode 100644 lib/puppet/parser/ast/match_operator.rb create mode 100755 spec/unit/parser/ast/casestatement.rb create mode 100755 spec/unit/parser/ast/ifstatement.rb create mode 100755 spec/unit/parser/ast/match_operator.rb create mode 100755 spec/unit/parser/ast/selector.rb create mode 100644 test/data/snippets/ifexpression.pp delete 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 -~----------~----~----~----~------~----~------~--~---
