summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-08-03 23:49:53 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2007-08-03 23:49:53 +0000
commit97cd057177f18a0e6694aab0e440f86e0bf08d42 (patch)
tree31a9808aa723180eb43f4fc2c952c3824f89d5d7 /lib/puppet
parent72f2ac39e036d3fea88569d17f3e455670bba063 (diff)
downloadpuppet-97cd057177f18a0e6694aab0e440f86e0bf08d42.tar.gz
puppet-97cd057177f18a0e6694aab0e440f86e0bf08d42.tar.xz
puppet-97cd057177f18a0e6694aab0e440f86e0bf08d42.zip
Fixing #314 and #729; here's the changelog:
Refactored how the parser and interpreter relate, so parsing is now effectively an atomic process (thus fixing #314 and #729). This makes the interpreter less prone to error and less prone to show the error to the clients. Note that this means that if a configuration fails to parse, then the previous, parseable configuration will be used instead, so the client will not know that the configuration failed to parse. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@2742 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/parser/ast.rb2
-rw-r--r--lib/puppet/parser/ast/component.rb4
-rw-r--r--lib/puppet/parser/ast/node.rb2
-rw-r--r--lib/puppet/parser/grammar.ra233
-rw-r--r--lib/puppet/parser/interpreter.rb251
-rw-r--r--lib/puppet/parser/parser.rb237
-rw-r--r--lib/puppet/parser/resource/param.rb2
7 files changed, 60 insertions, 671 deletions
diff --git a/lib/puppet/parser/ast.rb b/lib/puppet/parser/ast.rb
index c6067d353..ce5e8263e 100644
--- a/lib/puppet/parser/ast.rb
+++ b/lib/puppet/parser/ast.rb
@@ -86,7 +86,7 @@ class Puppet::Parser::AST
error = Puppet::Error.new(detail.to_s)
# We can't use self.fail here because it always expects strings,
# not exceptions.
- raise adderrorcontext(error)
+ raise adderrorcontext(error, detail)
end
end
diff --git a/lib/puppet/parser/ast/component.rb b/lib/puppet/parser/ast/component.rb
index 43ca85e4a..65f310212 100644
--- a/lib/puppet/parser/ast/component.rb
+++ b/lib/puppet/parser/ast/component.rb
@@ -16,7 +16,7 @@ class Puppet::Parser::AST
@name = :definition
attr_accessor :classname, :arguments, :code, :scope, :keyword
- attr_accessor :exported, :namespace, :interp, :virtual
+ attr_accessor :exported, :namespace, :parser, :virtual
# These are retrieved when looking up the superclass
attr_accessor :name
@@ -140,7 +140,7 @@ class Puppet::Parser::AST
end
def find_parentclass
- @interp.findclass(namespace, parentclass)
+ @parser.findclass(namespace, parentclass)
end
# Set our parent class, with a little check to avoid some potential
diff --git a/lib/puppet/parser/ast/node.rb b/lib/puppet/parser/ast/node.rb
index e873cac46..b9052168a 100644
--- a/lib/puppet/parser/ast/node.rb
+++ b/lib/puppet/parser/ast/node.rb
@@ -56,7 +56,7 @@ class Puppet::Parser::AST
private
# Search for the object matching our parent class.
def find_parentclass
- @interp.nodesearch(parentclass)
+ @parser.findnode(parentclass)
end
end
end
diff --git a/lib/puppet/parser/grammar.ra b/lib/puppet/parser/grammar.ra
index e55bbf23e..c7216186a 100644
--- a/lib/puppet/parser/grammar.ra
+++ b/lib/puppet/parser/grammar.ra
@@ -498,13 +498,13 @@ import: IMPORT qtexts {
# Disable definition inheritance for now. 8/27/06, luke
#definition: DEFINE NAME argumentlist parent LBRACE statements RBRACE {
definition: DEFINE classname argumentlist LBRACE statements RBRACE {
- interp.newdefine classname(val[1]), :arguments => val[2], :code => val[4]
+ newdefine classname(val[1]), :arguments => val[2], :code => val[4]
@lexer.indefine = false
result = nil
#} | DEFINE NAME argumentlist parent LBRACE RBRACE {
} | DEFINE classname argumentlist LBRACE RBRACE {
- interp.newdefine classname(val[1]), :arguments => val[2]
+ newdefine classname(val[1]), :arguments => val[2]
@lexer.indefine = false
result = nil
}
@@ -513,20 +513,20 @@ definition: DEFINE classname argumentlist LBRACE statements RBRACE {
hostclass: CLASS classname classparent LBRACE statements RBRACE {
# Our class gets defined in the parent namespace, not our own.
@lexer.namepop
- interp.newclass classname(val[1]), :code => val[4], :parent => val[2]
+ newclass classname(val[1]), :code => val[4], :parent => val[2]
result = nil
} | CLASS classname classparent LBRACE RBRACE {
# Our class gets defined in the parent namespace, not our own.
@lexer.namepop
- interp.newclass classname(val[1]), :parent => val[2]
+ newclass classname(val[1]), :parent => val[2]
result = nil
}
nodedef: NODE hostnames nodeparent LBRACE statements RBRACE {
- interp.newnode val[1], :parent => val[2], :code => val[4]
+ newnode val[1], :parent => val[2], :code => val[4]
result = nil
} | NODE hostnames nodeparent LBRACE RBRACE {
- interp.newnode val[1], :parent => val[2]
+ newnode val[1], :parent => val[2]
result = nil
}
@@ -637,226 +637,9 @@ Puppet[:typecheck] = true
Puppet[:paramcheck] = true
---- inner ----
-require 'puppet/parser/functions'
-attr_reader :file, :interp
-attr_accessor :files
-
-# Add context to a message; useful for error messages and such.
-def addcontext(message, obj = nil)
- obj ||= @lexer
-
- message += " on line %s" % obj.line
- if file = obj.file
- message += " in file %s" % file
- end
-
- return message
-end
-
-# Create an AST array out of all of the args
-def aryfy(*args)
- if args[0].instance_of?(AST::ASTArray)
- result = args.shift
- args.each { |arg|
- result.push arg
- }
- else
- result = ast AST::ASTArray, :children => args
- end
-
- return result
-end
-
-# Create an AST object, and automatically add the file and line information if
-# available.
-def ast(klass, hash = nil)
- hash ||= {}
- unless hash.include?(:line)
- hash[:line] = @lexer.line
- end
-
- unless hash.include?(:file)
- if file = @lexer.file
- hash[:file] = file
- end
- end
-
- return klass.new(hash)
-end
-
-# Raise a Parse error.
-def error(message)
- if brace = @lexer.expected
- message += "; expected '%s'"
- end
- except = Puppet::ParseError.new(message)
- except.line = @lexer.line
- if @lexer.file
- except.file = @lexer.file
- end
-
- raise except
-end
-
-def file=(file)
- unless FileTest.exists?(file)
- unless file =~ /\.pp$/
- file = file + ".pp"
- end
- unless FileTest.exists?(file)
- raise Puppet::Error, "Could not find file %s" % file
- end
- end
- if @files.detect { |f| f.file == file }
- raise Puppet::AlreadyImportedError.new("Import loop detected")
- else
- @files << Puppet::Util::LoadedFile.new(file)
- @lexer.file = file
- end
-end
-
-# Import our files.
-def import(file)
- if Puppet[:ignoreimport]
- return AST::ASTArray.new(:children => [])
- end
- # use a path relative to the file doing the importing
- if @lexer.file
- dir = @lexer.file.sub(%r{[^/]+$},'').sub(/\/$/, '')
- else
- dir = "."
- end
- if dir == ""
- dir = "."
- end
- result = ast AST::ASTArray
-
- # We can't interpolate at this point since we don't have any
- # scopes set up. Warn the user if they use a variable reference
- pat = file
- if pat.index("$")
- Puppet.warning(
- "The import of #{pat} contains a variable reference;" +
- " variables are not interpolated for imports " +
- "in file #{@lexer.file} at line #{@lexer.line}"
- )
- end
- files = Puppet::Module::find_manifests(pat, dir)
- if files.size == 0
- raise Puppet::ImportError.new("No file(s) found for import " +
- "of '#{pat}'")
- end
-
- files.collect { |file|
- parser = Puppet::Parser::Parser.new(interp)
- parser.files = self.files
- Puppet.debug("importing '%s'" % file)
-
- unless file =~ /^#{File::SEPARATOR}/
- file = File.join(dir, file)
- end
- begin
- parser.file = file
- rescue Puppet::AlreadyImportedError
- # This file has already been imported to just move on
- next
- end
-
- # This will normally add code to the 'main' class.
- parser.parse
- }
-end
-
-def initialize(interpreter)
- @interp = interpreter
- initvars()
-end
-
-# Initialize or reset all of our variables.
-def initvars
- @lexer = Puppet::Parser::Lexer.new()
- @files = []
-end
-
-# The fully qualifed name, with the full namespace.
-def classname(name)
- [@lexer.namespace, name].join("::").sub(/^::/, '')
-end
-
-def on_error(token,value,stack)
- #on '%s' at '%s' in\n'%s'" % [token,value,stack]
- #error = "line %s: parse error after '%s'" %
- # [@lexer.line,@lexer.last]
- error = "Syntax error at '%s'" % [value]
-
- if brace = @lexer.expected
- error += "; expected '%s'" % brace
- end
-
- except = Puppet::ParseError.new(error)
- except.line = @lexer.line
- if @lexer.file
- except.file = @lexer.file
- end
-
- raise except
-end
-
-# how should I do error handling here?
-def parse(string = nil)
- if string
- self.string = string
- end
- begin
- main = yyparse(@lexer,:scan)
- rescue Racc::ParseError => except
- error = Puppet::ParseError.new(except)
- error.line = @lexer.line
- error.file = @lexer.file
- error.set_backtrace except.backtrace
- raise error
- rescue Puppet::ParseError => except
- except.line ||= @lexer.line
- except.file ||= @lexer.file
- raise except
- rescue Puppet::Error => except
- # and this is a framework error
- except.line ||= @lexer.line
- except.file ||= @lexer.file
- raise except
- rescue Puppet::DevError => except
- except.line ||= @lexer.line
- except.file ||= @lexer.file
- raise except
- rescue => except
- error = Puppet::DevError.new(except.message)
- error.line = @lexer.line
- error.file = @lexer.file
- error.set_backtrace except.backtrace
- raise error
- end
- if main
- # Store the results as the top-level class.
- interp.newclass("", :code => main)
- return main
- end
-ensure
- @lexer.clear
-end
-
-# See if any of the files have changed.
-def reparse?
- if file = @files.detect { |file| file.changed? }
- return file.stamp
- else
- return false
- end
-end
-
-def string=(string)
- @lexer.string = string
-end
+# It got too annoying having code in a file that needs to be compiled.
+require 'puppet/parser/parser_support'
# Make emacs happy
# Local Variables:
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb
index b4936dd23..9da1928b3 100644
--- a/lib/puppet/parser/interpreter.rb
+++ b/lib/puppet/parser/interpreter.rb
@@ -30,6 +30,7 @@ class Puppet::Parser::Interpreter
begin
options[:scope].function_include(classes.find_all { |c| options[:scope].findclass(c) })
rescue => detail
+ puts detail.backtrace
raise Puppet::ParseError, "Could not evaluate classes for %s: %s" % [name, detail]
end
end
@@ -59,6 +60,7 @@ class Puppet::Parser::Interpreter
class << self
attr_writer :ldap
end
+
# just shorten the constant path a bit, using what amounts to an alias
AST = Puppet::Parser::AST
@@ -105,10 +107,6 @@ class Puppet::Parser::Interpreter
end
end
- def clear
- initparsevars
- end
-
# Iteratively evaluate all of the objects. This finds all of the objects
# that represent definitions and evaluates the definitions appropriately.
# It also adds defaults and overrides as appropriate.
@@ -264,48 +262,13 @@ class Puppet::Parser::Interpreter
check_resource_collections(scope)
end
- # Find a class definition, relative to the current namespace.
+ # Create proxy methods, so the scopes can call the interpreter, since
+ # they don't have access to the parser.
def findclass(namespace, name)
- #find_or_load namespace, name, @classtable
- fqfind namespace, name, @classtable
+ @parser.findclass(namespace, name)
end
-
- # Find a component definition, relative to the current namespace.
def finddefine(namespace, name)
- #find_or_load namespace, name, @definetable
- fqfind namespace, name, @definetable
- end
-
- # The recursive method used to actually look these objects up.
- def fqfind(namespace, name, table)
- namespace = namespace.downcase
- name = name.downcase
- if name =~ /^::/ or namespace == ""
- classname = name.sub(/^::/, '')
- unless table[classname]
- self.load(classname)
- end
- return table[classname]
- end
- ary = namespace.split("::")
-
- while ary.length > 0
- newname = (ary + [name]).join("::").sub(/^::/, '')
- if obj = table[newname] or (self.load(newname) and obj = table[newname])
- return obj
- end
-
- # Delete the second to last object, which reduces our namespace by one.
- ary.pop
- end
-
- # If we've gotten to this point without finding it, see if the name
- # exists at the top namespace
- if obj = table[name] or (self.load(name) and obj = table[name])
- return obj
- end
-
- return nil
+ @parser.finddefine(namespace, name)
end
# create our interpreter
@@ -335,8 +298,6 @@ class Puppet::Parser::Interpreter
@setup = false
- initparsevars()
-
# Set it to either the value or nil. This is currently only used
# by the cfengine module.
@classes = hash[:Classes] || []
@@ -361,55 +322,11 @@ class Puppet::Parser::Interpreter
end
@files = []
- @loaded = []
# Create our parser object
parsefiles
end
- # Initialize or reset the variables related to parsing.
- def initparsevars
- @classtable = {}
- @namespace = "main"
-
- @nodetable = {}
-
- @definetable = {}
- end
-
- # Try to load a class, since we could not find it.
- def load(classname)
- return false if classname == ""
- filename = classname.gsub("::", File::SEPARATOR)
-
- loaded = false
- # First try to load the top-level module
- mod = filename.scan(/^[\w-]+/).shift
- unless @loaded.include?(mod)
- @loaded << mod
- begin
- @parser.import(mod)
- Puppet.info "Autoloaded module %s" % mod
- loaded = true
- rescue Puppet::ImportError => detail
- # We couldn't load the module
- end
- end
-
- unless filename == mod and ! @loaded.include?(mod)
- @loaded << mod
- # Then the individual file
- begin
- @parser.import(filename)
- Puppet.info "Autoloaded file %s from module %s" % [filename, mod]
- loaded = true
- rescue Puppet::ImportError => detail
- # We couldn't load the file
- end
- end
- return loaded
- end
-
# Find the ldap node, return the class list and parent node specially,
# and everything else in a parameter hash.
def ldapsearch(node)
@@ -505,115 +422,10 @@ class Puppet::Parser::Interpreter
end
end
- # Split an fq name into a namespace and name
- def namesplit(fullname)
- ary = fullname.split("::")
- n = ary.pop || ""
- ns = ary.join("::")
- return ns, n
- end
-
- # Create a new class, or merge with an existing class.
- def newclass(name, options = {})
- name = name.downcase
- if @definetable.include?(name)
- raise Puppet::ParseError, "Cannot redefine class %s as a definition" %
- name
- end
- code = options[:code]
- parent = options[:parent]
-
- # If the class is already defined, then add code to it.
- if other = @classtable[name]
- # Make sure the parents match
- if parent and other.parentclass and (parent != other.parentclass)
- @parser.error("Class %s is already defined at %s:%s; cannot redefine" % [name, other.file, other.line])
- end
-
- # This might be dangerous...
- if parent and ! other.parentclass
- other.parentclass = parent
- end
-
- # This might just be an empty, stub class.
- if code
- tmp = name
- if tmp == ""
- tmp = "main"
- end
-
- Puppet.debug @parser.addcontext("Adding code to %s" % tmp)
- # Else, add our code to it.
- if other.code and code
- other.code.children += code.children
- else
- other.code ||= code
- end
- end
- else
- # Define it anew.
- # Note we're doing something somewhat weird here -- we're setting
- # the class's namespace to its fully qualified name. This means
- # anything inside that class starts looking in that namespace first.
- args = {:namespace => name, :classname => name, :interp => self}
- args[:code] = code if code
- args[:parentclass] = parent if parent
- @classtable[name] = @parser.ast AST::HostClass, args
- end
-
- return @classtable[name]
- end
-
- # Create a new definition.
- def newdefine(name, options = {})
- name = name.downcase
- if @classtable.include?(name)
- raise Puppet::ParseError, "Cannot redefine class %s as a definition" %
- name
- end
- # Make sure our definition doesn't already exist
- if other = @definetable[name]
- @parser.error("%s is already defined at %s:%s; cannot redefine" % [name, other.file, other.line])
- end
-
- ns, whatever = namesplit(name)
- args = {
- :namespace => ns,
- :arguments => options[:arguments],
- :code => options[:code],
- :classname => name
- }
-
- [:code, :arguments].each do |param|
- args[param] = options[param] if options[param]
- end
-
- @definetable[name] = @parser.ast AST::Component, args
- end
-
- # Create a new node. Nodes are special, because they're stored in a global
- # table, not according to namespaces.
- def newnode(names, options = {})
- names = [names] unless names.instance_of?(Array)
- names.collect do |name|
- name = name.to_s.downcase
- if other = @nodetable[name]
- @parser.error("Node %s is already defined at %s:%s; cannot redefine" % [other.name, other.file, other.line])
- end
- name = name.to_s if name.is_a?(Symbol)
- args = {
- :name => name,
- }
- if options[:code]
- args[:code] = options[:code]
- end
- if options[:parent]
- args[:parentclass] = options[:parent]
- end
- @nodetable[name] = @parser.ast(AST::Node, args)
- @nodetable[name].classname = name
- @nodetable[name].interp = self
- @nodetable[name]
+ # Pass these methods through to the parser.
+ [:newclass, :newdefine, :newnode].each do |name|
+ define_method(name) do |*args|
+ @parser.send(name, *args)
end
end
@@ -662,7 +474,7 @@ class Puppet::Parser::Interpreter
# See if our node was defined in the code.
def nodesearch_code(name)
- @nodetable[name]
+ @parser.nodes[name]
end
# Look for external node definitions.
@@ -815,29 +627,40 @@ class Puppet::Parser::Interpreter
end
end
- # Reset our parse tables.
- clear()
-
- # Create a new parser, just to keep things fresh.
- @parser = Puppet::Parser::Parser.new(self)
+ # Create a new parser, just to keep things fresh. Don't replace our
+ # current parser until we know weverything works.
+ newparser = Puppet::Parser::Parser.new()
if @code
- @parser.string = @code
+ newparser.string = @code
else
- @parser.file = @file
- # Mark when we parsed, so we can check freshness
- @parsedate = File.stat(@file).ctime.to_i
+ newparser.file = @file
end
# Parsing stores all classes and defines and such in their
# various tables, so we don't worry about the return.
- if @local
- @parser.parse
- else
- benchmark(:info, "Parsed manifest") do
- @parser.parse
+ begin
+ if @local
+ newparser.parse
+ else
+ benchmark(:info, "Parsed manifest") do
+ newparser.parse
+ end
+ end
+ # We've gotten this far, so it's ok to swap the parsers.
+ oldparser = @parser
+ @parser = newparser
+ if oldparser
+ oldparser.clear
+ end
+
+ # Mark when we parsed, so we can check freshness
+ @parsedate = Time.now.to_i
+ rescue => detail
+ if Puppet[:trace]
+ puts detail.backtrace
end
+ Puppet.err "Could not parse; using old configuration: %s" % detail
end
- @parsedate = Time.now.to_i
end
# Store the configs into the database.
diff --git a/lib/puppet/parser/parser.rb b/lib/puppet/parser/parser.rb
index f0bbeb499..21a054223 100644
--- a/lib/puppet/parser/parser.rb
+++ b/lib/puppet/parser/parser.rb
@@ -29,227 +29,10 @@ module Puppet
class Parser < Racc::Parser
-module_eval <<'..end grammar.ra modeval..id72fb6a61b8', 'grammar.ra', 640
-require 'puppet/parser/functions'
+module_eval <<'..end grammar.ra modeval..idc5e5087e93', 'grammar.ra', 640
-attr_reader :file, :interp
-attr_accessor :files
-
-# Add context to a message; useful for error messages and such.
-def addcontext(message, obj = nil)
- obj ||= @lexer
-
- message += " on line %s" % obj.line
- if file = obj.file
- message += " in file %s" % file
- end
-
- return message
-end
-
-# Create an AST array out of all of the args
-def aryfy(*args)
- if args[0].instance_of?(AST::ASTArray)
- result = args.shift
- args.each { |arg|
- result.push arg
- }
- else
- result = ast AST::ASTArray, :children => args
- end
-
- return result
-end
-
-# Create an AST object, and automatically add the file and line information if
-# available.
-def ast(klass, hash = nil)
- hash ||= {}
- unless hash.include?(:line)
- hash[:line] = @lexer.line
- end
-
- unless hash.include?(:file)
- if file = @lexer.file
- hash[:file] = file
- end
- end
-
- return klass.new(hash)
-end
-
-# Raise a Parse error.
-def error(message)
- if brace = @lexer.expected
- message += "; expected '%s'"
- end
- except = Puppet::ParseError.new(message)
- except.line = @lexer.line
- if @lexer.file
- except.file = @lexer.file
- end
-
- raise except
-end
-
-def file=(file)
- unless FileTest.exists?(file)
- unless file =~ /\.pp$/
- file = file + ".pp"
- end
- unless FileTest.exists?(file)
- raise Puppet::Error, "Could not find file %s" % file
- end
- end
- if @files.detect { |f| f.file == file }
- raise Puppet::AlreadyImportedError.new("Import loop detected")
- else
- @files << Puppet::Util::LoadedFile.new(file)
- @lexer.file = file
- end
-end
-
-# Import our files.
-def import(file)
- if Puppet[:ignoreimport]
- return AST::ASTArray.new(:children => [])
- end
- # use a path relative to the file doing the importing
- if @lexer.file
- dir = @lexer.file.sub(%r{[^/]+$},'').sub(/\/$/, '')
- else
- dir = "."
- end
- if dir == ""
- dir = "."
- end
- result = ast AST::ASTArray
-
- # We can't interpolate at this point since we don't have any
- # scopes set up. Warn the user if they use a variable reference
- pat = file
- if pat.index("$")
- Puppet.warning(
- "The import of #{pat} contains a variable reference;" +
- " variables are not interpolated for imports " +
- "in file #{@lexer.file} at line #{@lexer.line}"
- )
- end
- files = Puppet::Module::find_manifests(pat, dir)
- if files.size == 0
- raise Puppet::ImportError.new("No file(s) found for import " +
- "of '#{pat}'")
- end
-
- files.collect { |file|
- parser = Puppet::Parser::Parser.new(interp)
- parser.files = self.files
- Puppet.debug("importing '%s'" % file)
-
- unless file =~ /^#{File::SEPARATOR}/
- file = File.join(dir, file)
- end
- begin
- parser.file = file
- rescue Puppet::AlreadyImportedError
- # This file has already been imported to just move on
- next
- end
-
- # This will normally add code to the 'main' class.
- parser.parse
- }
-end
-
-def initialize(interpreter)
- @interp = interpreter
- initvars()
-end
-
-# Initialize or reset all of our variables.
-def initvars
- @lexer = Puppet::Parser::Lexer.new()
- @files = []
-end
-
-# The fully qualifed name, with the full namespace.
-def classname(name)
- [@lexer.namespace, name].join("::").sub(/^::/, '')
-end
-
-def on_error(token,value,stack)
- #on '%s' at '%s' in\n'%s'" % [token,value,stack]
- #error = "line %s: parse error after '%s'" %
- # [@lexer.line,@lexer.last]
- error = "Syntax error at '%s'" % [value]
-
- if brace = @lexer.expected
- error += "; expected '%s'" % brace
- end
-
- except = Puppet::ParseError.new(error)
- except.line = @lexer.line
- if @lexer.file
- except.file = @lexer.file
- end
-
- raise except
-end
-
-# how should I do error handling here?
-def parse(string = nil)
- if string
- self.string = string
- end
- begin
- main = yyparse(@lexer,:scan)
- rescue Racc::ParseError => except
- error = Puppet::ParseError.new(except)
- error.line = @lexer.line
- error.file = @lexer.file
- error.set_backtrace except.backtrace
- raise error
- rescue Puppet::ParseError => except
- except.line ||= @lexer.line
- except.file ||= @lexer.file
- raise except
- rescue Puppet::Error => except
- # and this is a framework error
- except.line ||= @lexer.line
- except.file ||= @lexer.file
- raise except
- rescue Puppet::DevError => except
- except.line ||= @lexer.line
- except.file ||= @lexer.file
- raise except
- rescue => except
- error = Puppet::DevError.new(except.message)
- error.line = @lexer.line
- error.file = @lexer.file
- error.set_backtrace except.backtrace
- raise error
- end
- if main
- # Store the results as the top-level class.
- interp.newclass("", :code => main)
- return main
- end
-ensure
- @lexer.clear
-end
-
-# See if any of the files have changed.
-def reparse?
- if file = @files.detect { |file| file.changed? }
- return file.stamp
- else
- return false
- end
-end
-
-def string=(string)
- @lexer.string = string
-end
+# It got too annoying having code in a file that needs to be compiled.
+require 'puppet/parser/parser_support'
# Make emacs happy
# Local Variables:
@@ -258,7 +41,7 @@ end
# $Id$
-..end grammar.ra modeval..id72fb6a61b8
+..end grammar.ra modeval..idc5e5087e93
##### racc 1.4.5 generates ###
@@ -1741,7 +1524,7 @@ module_eval <<'.,.,', 'grammar.ra', 496
module_eval <<'.,.,', 'grammar.ra', 506
def _reduce_135( val, _values, result )
- interp.newdefine classname(val[1]), :arguments => val[2], :code => val[4]
+ newdefine classname(val[1]), :arguments => val[2], :code => val[4]
@lexer.indefine = false
result = nil
@@ -1752,7 +1535,7 @@ module_eval <<'.,.,', 'grammar.ra', 506
module_eval <<'.,.,', 'grammar.ra', 510
def _reduce_136( val, _values, result )
- interp.newdefine classname(val[1]), :arguments => val[2]
+ newdefine classname(val[1]), :arguments => val[2]
@lexer.indefine = false
result = nil
result
@@ -1763,7 +1546,7 @@ module_eval <<'.,.,', 'grammar.ra', 518
def _reduce_137( val, _values, result )
# Our class gets defined in the parent namespace, not our own.
@lexer.namepop
- interp.newclass classname(val[1]), :code => val[4], :parent => val[2]
+ newclass classname(val[1]), :code => val[4], :parent => val[2]
result = nil
result
end
@@ -1773,7 +1556,7 @@ module_eval <<'.,.,', 'grammar.ra', 523
def _reduce_138( val, _values, result )
# Our class gets defined in the parent namespace, not our own.
@lexer.namepop
- interp.newclass classname(val[1]), :parent => val[2]
+ newclass classname(val[1]), :parent => val[2]
result = nil
result
end
@@ -1781,7 +1564,7 @@ module_eval <<'.,.,', 'grammar.ra', 523
module_eval <<'.,.,', 'grammar.ra', 528
def _reduce_139( val, _values, result )
- interp.newnode val[1], :parent => val[2], :code => val[4]
+ newnode val[1], :parent => val[2], :code => val[4]
result = nil
result
end
@@ -1789,7 +1572,7 @@ module_eval <<'.,.,', 'grammar.ra', 528
module_eval <<'.,.,', 'grammar.ra', 531
def _reduce_140( val, _values, result )
- interp.newnode val[1], :parent => val[2]
+ newnode val[1], :parent => val[2]
result = nil
result
end
diff --git a/lib/puppet/parser/resource/param.rb b/lib/puppet/parser/resource/param.rb
index fc3d72c85..4332bee85 100644
--- a/lib/puppet/parser/resource/param.rb
+++ b/lib/puppet/parser/resource/param.rb
@@ -12,7 +12,7 @@ class Puppet::Parser::Resource::Param
end
def inspect
- "#<#{self.class} @name => #{self.name}, @value => #{self.value}, @source => #{self.source.type}>"
+ "#<#{self.class} @name => #{self.name}, @value => #{self.value}, @source => #{self.source.name}>"
end
def line_to_i