Class: TermUtils::AP::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/term_utils/ap/parser.rb

Overview

Represents the argument list parser.

Instance Method Summary collapse

Constructor Details

#initializeParser

Returns a new instance of Parser



22
23
# File 'lib/term_utils/ap/parser.rb', line 22

def initialize
end

Instance Method Details

#parse_arguments(syntax, arguments, opts = {}) ⇒ TermUtils::AP::Result

Parses a given list of arguments.

Parameters:

Options Hash (opts):

  • :program (Boolean)

    Whether the first argument is the program name.

Returns:

Raises:



43
44
45
46
47
48
49
50
51
52
# File 'lib/term_utils/ap/parser.rb', line 43

def parse_arguments(syntax, arguments, opts = {})
  syntax = syntax.dup
  syntax.finalize!
  arguments = arguments.dup
  res = TermUtils::AP::Result.new(syntax)
  catch :done do
    parse0(res.value, syntax, arguments, opts)
  end
  res
end

#parse_command(syntax, command, opts = {}) ⇒ TermUtils::AP::Result

Parses a given command.

Parameters:

Options Hash (opts):

  • :program (Boolean)

    Whether the first argument is the program name.

Returns:

Raises:



32
33
34
# File 'lib/term_utils/ap/parser.rb', line 32

def parse_command(syntax, command, opts = {})
  parse_arguments(syntax, command.split(" "), opts)
end