Class: ShellOpts::Ast::Parser

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

Overview

Parse a command line

Defined Under Namespace

Classes: Error

Instance Method Summary collapse

Constructor Details

#initialize(grammar, argv) ⇒ Parser

Returns a new instance of Parser.



23
24
25
26
# File 'lib/shellopts/parser.rb', line 23

def initialize(grammar, argv)
  @grammar, @argv = grammar, argv.dup
  @seen_options = {} # Used to keep track of repeated options
end

Instance Method Details

#callObject



28
29
30
31
32
33
# File 'lib/shellopts/parser.rb', line 28

def call
  program = Ast::Program.new(@grammar)
  parse_command(program)
  program.arguments = @argv
  program
end