Class: Choosy::SuperParser

Inherits:
Object
  • Object
show all
Defined in:
lib/choosy/super_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(super_command) ⇒ SuperParser

Returns a new instance of SuperParser.



11
12
13
14
15
# File 'lib/choosy/super_parser.rb', line 11

def initialize(super_command)
  @super_command = super_command
  @verifier = Verifier.new
  generate_terminals
end

Instance Attribute Details

#terminalsObject (readonly)

Returns the value of attribute terminals.



9
10
11
# File 'lib/choosy/super_parser.rb', line 9

def terminals
  @terminals
end

#verifierObject (readonly)

Returns the value of attribute verifier.



9
10
11
# File 'lib/choosy/super_parser.rb', line 9

def verifier
  @verifier
end

Instance Method Details

#parse!(args) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/choosy/super_parser.rb', line 17

def parse!(args)
  result = parse_globals(args)
  unparsed = result.unparsed

  while unparsed.length > 0
    command_result = parse_command(unparsed, terminals)
    result.subresults << command_result
    
    unparsed = command_result.unparsed
  end

  result.subresults.each do |subresult|
    if subresult.command.name == Choosy::DSL::SuperCommandBuilder::HELP
      verifier.verify!(subresult)
    end
  end

  verifier.verify!(result)

  result.subresults.each do |subresult|
    subresult.options.merge!(result.options)
    verifier.verify!(subresult)
  end

  result
end