Class: Puppet::Parser::E4ParserAdapter
- Defined in:
- lib/puppet/parser/e4_parser_adapter.rb
Overview
and makes use of the new evaluator.
Instance Method Summary collapse
- #file=(file) ⇒ Object
-
#initialize ⇒ E4ParserAdapter
constructor
A new instance of E4ParserAdapter.
- #parse(string = nil) ⇒ Object
- #string=(string) ⇒ Object
Constructor Details
#initialize ⇒ E4ParserAdapter
Returns a new instance of E4ParserAdapter.
11 12 13 14 15 |
# File 'lib/puppet/parser/e4_parser_adapter.rb', line 11 def initialize @file = '' @string = '' @use = :unspecified end |
Instance Method Details
#file=(file) ⇒ Object
17 18 19 20 |
# File 'lib/puppet/parser/e4_parser_adapter.rb', line 17 def file=(file) @file = file @use = :file end |
#parse(string = nil) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/puppet/parser/e4_parser_adapter.rb', line 22 def parse(string = nil) self.string = string if string parser = Pops::Parser::EvaluatingParser.singleton model = if @use == :string # Parse with a source_file to set in created AST objects (it was either given, or it may be unknown # if caller did not set a file and the present a string. # parser.parse_string(@string, @file || "unknown-source-location") else parser.parse_file(@file) end # the parse_result may be # * empty / nil (no input) # * a Model::Program # * a Model::Expression # args = {} Pops::Model::AstTransformer.new(@file).merge_location(args, model) ast_code = if model.is_a? Pops::Model::Program AST::PopsBridge::Program.new(model, args) else args[:value] = model AST::PopsBridge::Expression.new(args) end # Create the "main" class for the content - this content will get merged with all other "main" content AST::Hostclass.new('', :code => ast_code) end |
#string=(string) ⇒ Object
55 56 57 58 |
# File 'lib/puppet/parser/e4_parser_adapter.rb', line 55 def string=(string) @string = string @use = :string end |