# File lib/puppet/parser/parser_support.rb, line 143
143:     def import(file)
144:         if Puppet[:ignoreimport]
145:             return AST::ASTArray.new(:children => [])
146:         end
147:         # use a path relative to the file doing the importing
148:         if @lexer.file
149:             dir = @lexer.file.sub(%r{[^/]+$},'').sub(/\/$/, '')
150:         else
151:             dir = "."
152:         end
153:         if dir == ""
154:             dir = "."
155:         end
156:         result = ast AST::ASTArray
157: 
158:         # We can't interpolate at this point since we don't have any
159:         # scopes set up. Warn the user if they use a variable reference
160:         raise "Got no file" unless file
161:         pat = file
162:         if pat.index("$")
163:             Puppet.warning(
164:                "The import of #{pat} contains a variable reference;" +
165:                " variables are not interpolated for imports " +
166:                "in file #{@lexer.file} at line #{@lexer.line}"
167:             )
168:         end
169:         files = Puppet::Parser::Files.find_manifests(pat, :cwd => dir, :environment => @environment)
170:         if files.size == 0
171:             raise Puppet::ImportError.new("No file(s) found for import " +
172:                                           "of '#{pat}'")
173:         end
174: 
175:         files.collect { |file|
176:             parser = Puppet::Parser::Parser.new(:loaded_code => @loaded_code, :environment => @environment)
177:             parser.files = self.files
178:             Puppet.debug("importing '%s'" % file)
179: 
180:             unless file =~ /^#{File::SEPARATOR}/
181:                 file = File.join(dir, file)
182:             end
183:             begin
184:                 parser.file = file
185:             rescue Puppet::AlreadyImportedError
186:                 # This file has already been imported to just move on
187:                 next
188:             end
189: 
190:             # This will normally add code to the 'main' class.
191:             parser.parse
192:         }
193:     end