+1.  I reviewed parts of this in person with Paul, and then briefly
got confused when I went to +1 it since he had posted a slightly
different version of this patch under ticket #4633.  #4633 was
rejected in favor of this solution which doesn't flatten arrays.

On Fri, Aug 27, 2010 at 10:40 AM, Paul Berry <[email protected]> wrote:
> Changed the grammar so that the following "plural" constructs always
> parse as an ASTArray:
>
> - funcvalues
> - rvalues
> - resourceinstances
> - anyparams
> - params
> - caseopts
> - casevalues
>
> And the following "singluar" construct never parses as an ASTArray:
>
> - statement
>
> The previous behavior was for these constructs to parse as a scalar
> when they represented a single item and an ASTArray when they
> contained zero or multiple items.  ("Statement" could sometimes
> represent a single item because a single resource declaration could
> represent multiple resources).  This complicated other grammar rules
> and caused ambiguous handling of nested arrays.
>
> Also made these changes to the AST class hierarchy:
>
> - ResourceInstance no longer derives from ASTArray.  This relationship
>  was not meaningful because a ResourceInstance is a (title,
>  parameters) pair, not an array, and it produced complications when
>  we wanted to represent an array of ResourceInstance objects.
>
> - Resource no longer derives from ResourceReference.  No significant
>  functionality was being inherited and the relationship doesn't make
>  sense in an AST context.
>
> - ResourceOverride no longer derives from Resource.  No significant
>  functionality was being inherited and the relationship doesn't make
>  sense in an AST context.
>
> - Resource can now represent a compound resource instance such as
>  "notify { foo: ; bar: }".  This saves the parser from having to
>  use represent a statement as an array of objects.
>
> - ASTArray's evaluate method never flattens out arrays of arrays.
>
> Signed-off-by: Paul Berry <[email protected]>
> ---
>  lib/puppet/parser/ast.rb                   |    1 +
>  lib/puppet/parser/ast/astarray.rb          |   34 +--
>  lib/puppet/parser/ast/caseopt.rb           |   36 +--
>  lib/puppet/parser/ast/resource.rb          |   93 +++----
>  lib/puppet/parser/ast/resource_instance.rb |    9 +
>  lib/puppet/parser/ast/resource_override.rb |    5 +-
>  lib/puppet/parser/grammar.ra               |  131 ++------
>  lib/puppet/parser/parser.rb                |  454 
> +++++++++++++---------------
>  lib/puppet/parser/parser_support.rb        |   15 +-
>  spec/unit/parser/ast/astarray_spec.rb      |   49 +--
>  spec/unit/parser/ast/resource_spec.rb      |   23 +-
>  spec/unit/parser/parser_spec.rb            |    5 +-
>  test/language/parser.rb                    |    6 +-
>  test/lib/puppettest/parsertesting.rb       |   13 +-
>  14 files changed, 359 insertions(+), 515 deletions(-)
>  create mode 100644 lib/puppet/parser/ast/resource_instance.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