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.



5
6
7
8
9
# File 'lib/choosy/super_parser.rb', line 5

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.



3
4
5
# File 'lib/choosy/super_parser.rb', line 3

def terminals
  @terminals
end

#verifierObject (readonly)

Returns the value of attribute verifier.



3
4
5
# File 'lib/choosy/super_parser.rb', line 3

def verifier
  @verifier
end

Instance Method Details

#parse!(args) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/choosy/super_parser.rb', line 11

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