class TyranoDsl::Parser

Parse the DSL

Attributes

context[R]

@return [TyranoDsl::ParsingContext]

included_files_hierarchy[R]

@return [Array<String>]

word_location[RW]

@return [Array<String>]

Public Class Methods

new(parsing_context, initial_file_path) click to toggle source

@param [TyranoDsl::ParsingContext] parsing_context @param [String] initial_file_path

# File lib/tyrano_dsl/parser.rb, line 45
def initialize(parsing_context, initial_file_path)
  @context = parsing_context
  @logger = Logger.new(STDOUT)
  @included_files_hierarchy = [initial_file_path]
end
parse(initial_file_path) click to toggle source

Parse a file @param [String] initial_file_path @return [TyranoDsl::ParsingContext]

# File lib/tyrano_dsl/parser.rb, line 36
def self.parse(initial_file_path)
  parsing_context = TyranoDsl::ParsingContext.new
  parser = TyranoDsl::Parser.new(parsing_context, initial_file_path)
  parser.include_file(initial_file_path)
  parsing_context
end

Protected Instance Methods

add_parsed_word(word, parameters = {}) click to toggle source

Add a parsed word @param [String] word @param [Hash{String => Object}] parameters @return [void]

# File lib/tyrano_dsl/parser.rb, line 57
def add_parsed_word(word, parameters = {})
  context.words << TyranoDsl::ParsedWord.new(
      word,
      word_location,
      parameters
  )
end

Private Instance Methods

log() { || ... } click to toggle source
# File lib/tyrano_dsl/parser.rb, line 67
def log
  @logger.info(self.class) {yield}
end