From 9ecbd6306d227189ba161954aafc3e7f782a87b9 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Sat, 11 Oct 2008 18:45:16 +0200 Subject: Fixed #1104 - Classes and nodes should set $name variables Signed-off-by: Brice Figureau --- lib/puppet/parser/ast/hostclass.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/puppet/parser') diff --git a/lib/puppet/parser/ast/hostclass.rb b/lib/puppet/parser/ast/hostclass.rb index 7f89f8151..4f5c4797c 100644 --- a/lib/puppet/parser/ast/hostclass.rb +++ b/lib/puppet/parser/ast/hostclass.rb @@ -56,7 +56,12 @@ class Puppet::Parser::AST::HostClass < Puppet::Parser::AST::Definition # Don't create a subscope for the top-level class, since it already # has its own scope. - scope = subscope(scope, resource) unless resource.title == :main + unless resource.title == :main + scope = subscope(scope, resource) + + scope.setvar("title", resource.title) + scope.setvar("name", resource.name) + end # Add the parent scope namespaces to our own. if pnames -- cgit From c7ccc4ba7c42d56595564491ae578a1604c628d1 Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Tue, 28 Oct 2008 14:12:36 +0100 Subject: Fix #1682 - ASTArray should flatten product of evaluation of its children If the ASTArray contains children that evaluate to arrays themselves, they aren't flattened. --- lib/puppet/parser/ast/astarray.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib/puppet/parser') diff --git a/lib/puppet/parser/ast/astarray.rb b/lib/puppet/parser/ast/astarray.rb index 8f09aa922..0fccbca75 100644 --- a/lib/puppet/parser/ast/astarray.rb +++ b/lib/puppet/parser/ast/astarray.rb @@ -30,10 +30,9 @@ class Puppet::Parser::AST items << child end } - rets = items.flatten.collect { |child| child.safeevaluate(scope) - } + }.flatten return rets.reject { |o| o.nil? } end -- cgit From 9f30306d2c768bad3327ecb7748669afb10cd4aa Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Tue, 28 Oct 2008 14:15:08 +0100 Subject: Fix #857 - Multiple class of the same name don't append code The following manifest wasn't working: class one { notice('class one') } class one { notice('second class one') } include one It all boiled down to class code not being arrays. Encapsulating code in ASTArray when needed is enough to append code, because of the property of ASTArray to evaluate all their members in turn. Signed-off-by: Brice Figureau --- lib/puppet/parser/parser_support.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib/puppet/parser') diff --git a/lib/puppet/parser/parser_support.rb b/lib/puppet/parser/parser_support.rb index 853d6aa86..1583973a7 100644 --- a/lib/puppet/parser/parser_support.rb +++ b/lib/puppet/parser/parser_support.rb @@ -291,10 +291,14 @@ class Puppet::Parser::Parser if tmp == "" tmp = "main" end - + Puppet.debug addcontext("Adding code to %s" % tmp) # Else, add our code to it. if other.code and code + # promote if neededcodes to ASTArray so that we can append code + # ASTArray knows how to evaluate its members. + other.code = ast AST::ASTArray, :children => [other.code] unless other.code.is_a?(AST::ASTArray) + code = ast AST::ASTArray, :children => [code] unless code.is_a?(AST::ASTArray) other.code.children += code.children else other.code ||= code -- cgit From 2d37f09aa093b10cb64b9b649f0066217c53d48f Mon Sep 17 00:00:00 2001 From: Brice Figureau Date: Tue, 28 Oct 2008 14:17:12 +0100 Subject: Fix #1402 - Allow multiline comments Signed-off-by: Brice Figureau --- lib/puppet/parser/lexer.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'lib/puppet/parser') diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb index 9226434da..dd6c29d9f 100644 --- a/lib/puppet/parser/lexer.rb +++ b/lib/puppet/parser/lexer.rb @@ -157,6 +157,11 @@ class Puppet::Parser::Lexer TOKENS.add_token :COMMENT, %r{#.*}, :skip => true + TOKENS.add_token :MLCOMMENT, %r{/\*(.*?)\*/}m do |lexer, value| + lexer.line += value.count("\n") + [nil,nil] + end + TOKENS.add_token :RETURN, "\n", :skip => true, :incr_line => true, :skip_text => true TOKENS.add_token :SQUOTE, "'" do |lexer, value| -- cgit