Class: Puppet::Pops::Parser::EppParser
- Defined in:
- lib/puppet/pops/parser/epp_parser.rb
Overview
The EppParser is a specialized Puppet Parser that starts parsing in Epp Text mode
Constant Summary
Constants inherited from Parser
Parser::Factory, Parser::Racc_arg, Parser::Racc_debug_parser, Parser::Racc_token_to_s_table
Instance Attribute Summary
Attributes inherited from Parser
Instance Method Summary collapse
-
#_parse ⇒ Object
private
Performs the parsing and returns the resulting model.
-
#initvars ⇒ void
Initializes the epp parser support by creating a new instance of Lexer configured to start in Epp Lexing mode.
-
#parse_file(file) ⇒ Object
Parses a file expected to contain epp text/DSL logic.
Methods inherited from Parser
#_reduce_none, #add_definition, #add_mapping, #aryfy, #classname, #create_empty_program, #create_program, #error, #heredoc_loc, #initialize, #loc, #namepop, #namespace, #namestack, #on_error, #parse_string, #token_text, #transform_calls, #transform_resource_wo_title
Constructor Details
This class inherits a constructor from Puppet::Pops::Parser::Parser
Instance Method Details
#_parse ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Performs the parsing and returns the resulting model. The lexer holds state, and this is setup with Parser#parse_string, or #parse_file.
TODO: deal with options containing origin (i.e. parsing a string from externally known location). TODO: should return the model, not a Hostclass
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/puppet/pops/parser/epp_parser.rb', line 31 def _parse() begin @yydebug = false main = yyparse(@lexer,:scan_epp) # #Commented out now because this hides problems in the racc grammar while developing # # TODO include this when test coverage is good enough. # rescue Puppet::ParseError => except # except.line ||= @lexer.line # except.file ||= @lexer.file # except.pos ||= @lexer.pos # raise except # rescue => except # raise Puppet::ParseError.new(except.message, @lexer.file, @lexer.line, @lexer.pos, except) end return main ensure @lexer.clear @namestack = [] @definitions = [] end |
#initvars ⇒ void
This method returns an undefined value.
Initializes the epp parser support by creating a new instance of Lexer configured to start in Epp Lexing mode.
8 9 10 |
# File 'lib/puppet/pops/parser/epp_parser.rb', line 8 def initvars self.lexer = Puppet::Pops::Parser::Lexer2.new()# {:mode => :epp}) end |
#parse_file(file) ⇒ Object
Parses a file expected to contain epp text/DSL logic.
13 14 15 16 17 18 19 20 21 |
# File 'lib/puppet/pops/parser/epp_parser.rb', line 13 def parse_file(file) unless FileTest.exist?(file) unless file =~ /\.epp$/ file = file + ".epp" end end @lexer.file = file _parse() end |