diff options
Diffstat (limited to 'lib/puppet/parser/ast.rb')
-rw-r--r-- | lib/puppet/parser/ast.rb | 128 |
1 files changed, 64 insertions, 64 deletions
diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb index dffc30a8a..2773a240e 100644 --- a/lib/puppet/parser/ast.rb +++ b/lib/puppet/parser/ast.rb @@ -8,85 +8,85 @@ require 'puppet/file_collection/lookup' # Handles things like file name, line #, and also does the initialization # for all of the parameters of all of the child objects. class Puppet::Parser::AST - # Do this so I don't have to type the full path in all of the subclasses - AST = Puppet::Parser::AST + # Do this so I don't have to type the full path in all of the subclasses + AST = Puppet::Parser::AST - include Puppet::FileCollection::Lookup + include Puppet::FileCollection::Lookup - include Puppet::Util::Errors - include Puppet::Util::MethodHelper - include Puppet::Util::Docs + include Puppet::Util::Errors + include Puppet::Util::MethodHelper + include Puppet::Util::Docs - attr_accessor :parent, :scope + attr_accessor :parent, :scope - # don't fetch lexer comment by default - def use_docs - self.class.use_docs - end + # don't fetch lexer comment by default + def use_docs + self.class.use_docs + end - # allow our subclass to specify they want documentation - class << self - attr_accessor :use_docs - def associates_doc - self.use_docs = true - end + # allow our subclass to specify they want documentation + class << self + attr_accessor :use_docs + def associates_doc + self.use_docs = true end + end - # Does this ast object set something? If so, it gets evaluated first. - def self.settor? - if defined?(@settor) - @settor - else - false - end + # Does this ast object set something? If so, it gets evaluated first. + def self.settor? + if defined?(@settor) + @settor + else + false end + end - # Evaluate the current object. Just a stub method, since the subclass - # should override this method. - # of the contained children and evaluates them in turn, returning a - # list of all of the collected values, rejecting nil values - def evaluate(*options) - raise Puppet::DevError, "Did not override #evaluate in #{self.class}" - end + # Evaluate the current object. Just a stub method, since the subclass + # should override this method. + # of the contained children and evaluates them in turn, returning a + # list of all of the collected values, rejecting nil values + def evaluate(*options) + raise Puppet::DevError, "Did not override #evaluate in #{self.class}" + end - # Throw a parse error. - def parsefail(message) - self.fail(Puppet::ParseError, message) - end + # Throw a parse error. + def parsefail(message) + self.fail(Puppet::ParseError, message) + end - # Wrap a statemp in a reusable way so we always throw a parse error. - def parsewrap - exceptwrap :type => Puppet::ParseError do - yield - end + # Wrap a statemp in a reusable way so we always throw a parse error. + def parsewrap + exceptwrap :type => Puppet::ParseError do + yield end + end - # The version of the evaluate method that should be called, because it - # correctly handles errors. It is critical to use this method because - # it can enable you to catch the error where it happens, rather than - # much higher up the stack. - def safeevaluate(*options) - # We duplicate code here, rather than using exceptwrap, because this - # is called so many times during parsing. - begin - return self.evaluate(*options) - rescue Puppet::Error => detail - raise adderrorcontext(detail) - rescue => detail - error = Puppet::Error.new(detail.to_s) - # We can't use self.fail here because it always expects strings, - # not exceptions. - raise adderrorcontext(error, detail) - end + # The version of the evaluate method that should be called, because it + # correctly handles errors. It is critical to use this method because + # it can enable you to catch the error where it happens, rather than + # much higher up the stack. + def safeevaluate(*options) + # We duplicate code here, rather than using exceptwrap, because this + # is called so many times during parsing. + begin + return self.evaluate(*options) + rescue Puppet::Error => detail + raise adderrorcontext(detail) + rescue => detail + error = Puppet::Error.new(detail.to_s) + # We can't use self.fail here because it always expects strings, + # not exceptions. + raise adderrorcontext(error, detail) end + end - # Initialize the object. Requires a hash as the argument, and - # takes each of the parameters of the hash and calls the settor - # method for them. This is probably pretty inefficient and should - # likely be changed at some point. - def initialize(args) - set_options(args) - end + # Initialize the object. Requires a hash as the argument, and + # takes each of the parameters of the hash and calls the settor + # method for them. This is probably pretty inefficient and should + # likely be changed at some point. + def initialize(args) + set_options(args) + end end # And include all of the AST subclasses. |