diff options
| author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-11 22:32:51 +0000 |
|---|---|---|
| committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-04-11 22:32:51 +0000 |
| commit | 71793fb3d096b74977b73fffe16bbeb8f45c94b9 (patch) | |
| tree | b1d2ac064df3fbe004b216112fea8ab2a0856b15 | |
| parent | f522a7e4fe87de6214d1d8e5e6d587d1948117ab (diff) | |
| download | puppet-71793fb3d096b74977b73fffe16bbeb8f45c94b9.tar.gz puppet-71793fb3d096b74977b73fffe16bbeb8f45c94b9.tar.xz puppet-71793fb3d096b74977b73fffe16bbeb8f45c94b9.zip | |
Changing "set" to "tag"
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1106 980ebf18-57e1-0310-9a29-db15c13687c0
| -rw-r--r-- | lib/puppet/parser/ast.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/parser/ast/tag.rb | 26 | ||||
| -rw-r--r-- | lib/puppet/parser/grammar.ra | 8 | ||||
| -rw-r--r-- | lib/puppet/parser/lexer.rb | 2 | ||||
| -rw-r--r-- | lib/puppet/parser/parser.rb | 12 | ||||
| -rwxr-xr-x | test/language/ast.rb | 8 | ||||
| -rw-r--r-- | test/puppettest.rb | 6 |
7 files changed, 45 insertions, 19 deletions
diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb index ea494dc6d..d9bb1cb4e 100644 --- a/lib/puppet/parser/ast.rb +++ b/lib/puppet/parser/ast.rb @@ -146,6 +146,6 @@ require 'puppet/parser/ast/objectref' require 'puppet/parser/ast/selector' require 'puppet/parser/ast/typedefaults' require 'puppet/parser/ast/vardef' -require 'puppet/parser/ast/set' +require 'puppet/parser/ast/tag' # $Id$ diff --git a/lib/puppet/parser/ast/tag.rb b/lib/puppet/parser/ast/tag.rb new file mode 100644 index 000000000..ce59558f3 --- /dev/null +++ b/lib/puppet/parser/ast/tag.rb @@ -0,0 +1,26 @@ +class Puppet::Parser::AST + # The code associated with a class. This is different from components + # in that each class is a singleton -- only one will exist for a given + # node. + class Set < AST::Branch + @name = :class + attr_accessor :type + + def evaluate(hash) + scope = hash[:scope] + + types = @type.safeevaluate(:scope => scope) + + types = [types] unless types.is_a? Array + + types.each do |type| + # Now set our class. We don't have to worry about checking + # whether we've been evaluated because we're not evaluating + # any code. + scope.setclass(self.object_id, type) + end + end + end +end + +# $Id$ diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra index c59d36809..b872f3979 100644 --- a/lib/puppet/parser/grammar.ra +++ b/lib/puppet/parser/grammar.ra @@ -7,7 +7,7 @@ class Puppet::Parser::Parser token LBRACK DQTEXT SQTEXT RBRACK LBRACE RBRACE SYMBOL FARROW COMMA TRUE FALSE EQUALS token QMARK LPAREN RPAREN ISEQUAL GREATEREQUAL GREATERTHAN LESSTHAN LESSEQUAL NOTEQUAL token IF ELSE IMPORT DEFINE ELSIF VARIABLE CLASS INHERITS NODE BOOLEAN DOT COLON TYPE -token NAME SEMIC CASE DEFAULT INCLUDE SET +token NAME SEMIC CASE DEFAULT INCLUDE TAG # We have 2 shift/reduce conflicts expect 2 @@ -59,7 +59,7 @@ statement: object | casestatement | import | include - | set + | tag | definition | hostclass | nodedef @@ -91,10 +91,10 @@ include: INCLUDE classnames { ) } -set: SET classnames { +tag: TAG classnames { classnames = aryfy(val[1]) - result = AST::Set.new( + result = AST::Tag.new( :line => @lexer.line, :file => @lexer.file, :type => val[1] diff --git a/lib/puppet/parser/lexer.rb b/lib/puppet/parser/lexer.rb index f5d2bde78..d007bb45e 100644 --- a/lib/puppet/parser/lexer.rb +++ b/lib/puppet/parser/lexer.rb @@ -54,7 +54,7 @@ module Puppet "include" => :INCLUDE, "inherits" => :INHERITS, "node" => :NODE, - "set" => :SET, + "tag" => :TAG, "true" => :BOOLEAN } diff --git a/lib/puppet/parser/parser.rb b/lib/puppet/parser/parser.rb index fb0a08338..913c6ff19 100644 --- a/lib/puppet/parser/parser.rb +++ b/lib/puppet/parser/parser.rb @@ -29,7 +29,7 @@ module Puppet class Parser < Racc::Parser -module_eval <<'..end grammar.ra modeval..idaa75576a17', 'grammar.ra', 745 +module_eval <<'..end grammar.ra modeval..idb478f6db18', 'grammar.ra', 745 attr_reader :file attr_accessor :files @@ -150,7 +150,7 @@ end # $Id$ -..end grammar.ra modeval..idaa75576a17 +..end grammar.ra modeval..idb478f6db18 ##### racc 1.4.4 generates ### @@ -483,7 +483,7 @@ racc_token_table = { :CASE => 38, :DEFAULT => 39, :INCLUDE => 40, - :SET => 41 } + :TAG => 41 } racc_use_result_var = true @@ -547,7 +547,7 @@ Racc_token_to_s_table = [ 'CASE', 'DEFAULT', 'INCLUDE', -'SET', +'TAG', '$start', 'program', 'statements', @@ -557,7 +557,7 @@ Racc_token_to_s_table = [ 'casestatement', 'import', 'include', -'set', +'tag', 'definition', 'hostclass', 'nodedef', @@ -699,7 +699,7 @@ module_eval <<'.,.,', 'grammar.ra', 102 def _reduce_14( val, _values, result ) classnames = aryfy(val[1]) - result = AST::Set.new( + result = AST::Tag.new( :line => @lexer.line, :file => @lexer.file, :type => val[1] diff --git a/test/language/ast.rb b/test/language/ast.rb index 5ffb72091..d87cf033c 100755 --- a/test/language/ast.rb +++ b/test/language/ast.rb @@ -65,9 +65,9 @@ class TestAST < Test::Unit::TestCase assert_equal(classes.sort, scope.classlist.sort) end - # Test that 'setobject' collects all of an object's parameters and stores + # Test that 'tagobject' collects all of an object's parameters and stores # them in one TransObject, rather than many. This is probably a bad idea. - def test_setobject + def test_tagobject top = nil children = [ fileobj("/etc", "owner" => "root"), @@ -651,8 +651,8 @@ class TestAST < Test::Unit::TestCase children = [] # Create child class one children << varobj("variable", "aclass") - children << setobj(type, varref("variable")) - children << setobj(type) + children << tagobj(type, varref("variable")) + children << tagobj(type) classes << "aclass" diff --git a/test/puppettest.rb b/test/puppettest.rb index 470a3d4fe..323da53e6 100644 --- a/test/puppettest.rb +++ b/test/puppettest.rb @@ -738,7 +738,7 @@ module ParserTesting } end - def setobj(*names) + def tagobj(*names) args = {} newnames = names.collect do |name| if name.is_a? AST @@ -748,8 +748,8 @@ module ParserTesting end end args[:type] = astarray(*newnames) - assert_nothing_raised("Could not create class %s" % names.inspect) { - return AST::Set.new(args) + assert_nothing_raised("Could not create tag %s" % names.inspect) { + return AST::Tag.new(args) } end |
