class Puppet::Parser::AST
The base class for the 3x “parse tree”, now only used by the top level constructs and the compiler. Handles things like file name, line #, and also does the initialization for all of the parameters of all of the child objects.
Constants
- AST
The base class for the 3x “parse tree”, now only used by the top level constructs and the compiler. Handles things like file name, line #, and also does the initialization for all of the parameters of all of the child objects.
Attributes
Private Class Methods
# File lib/puppet/parser/ast.rb 46 def initialize(file: nil, line: nil, pos: nil) 47 @file = file 48 @line = line 49 @pos = pos 50 end
Private Instance Methods
Evaluate the current object. Just a stub method, since the subclass should override this method.
# File lib/puppet/parser/ast.rb 19 def evaluate(scope) 20 end
# File lib/puppet/parser/ast.rb 13 def inspect 14 "( #{self.class} #{self} #{@children.inspect} )" 15 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.
# File lib/puppet/parser/ast.rb 26 def safeevaluate(scope) 27 # We duplicate code here, rather than using exceptwrap, because this 28 # is called so many times during parsing. 29 begin 30 return self.evaluate(scope) 31 rescue Puppet::Pops::Evaluator::PuppetStopIteration => detail 32 raise detail 33 # # Only deals with StopIteration from the break() function as a general 34 # # StopIteration is a general runtime problem 35 # raise Puppet::ParseError.new(detail.message, detail.file, detail.line, detail) 36 rescue Puppet::Error => detail 37 raise adderrorcontext(detail) 38 rescue => detail 39 error = Puppet::ParseError.new(detail.to_s, nil, nil, detail) 40 # We can't use self.fail here because it always expects strings, 41 # not exceptions. 42 raise adderrorcontext(error, detail) 43 end 44 end