class 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 47 def initialize(file: nil, line: nil, pos: nil) 48 @file = file 49 @line = line 50 @pos = pos 51 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 20 def evaluate(scope) 21 end
# File lib/puppet/parser/ast.rb 14 def inspect 15 "( #{self.class} #{self} #{@children.inspect} )" 16 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 27 def safeevaluate(scope) 28 # We duplicate code here, rather than using exceptwrap, because this 29 # is called so many times during parsing. 30 begin 31 return self.evaluate(scope) 32 rescue Puppet::Pops::Evaluator::PuppetStopIteration => detail 33 raise detail 34 # # Only deals with StopIteration from the break() function as a general 35 # # StopIteration is a general runtime problem 36 # raise Puppet::ParseError.new(detail.message, detail.file, detail.line, detail) 37 rescue Puppet::Error => detail 38 raise adderrorcontext(detail) 39 rescue => detail 40 error = Puppet::ParseError.new(detail.to_s, nil, nil, detail) 41 # We can't use self.fail here because it always expects strings, 42 # not exceptions. 43 raise adderrorcontext(error, detail) 44 end 45 end