Module: ShellOpts::Grammar

Defined in:
lib/shellopts/compiler.rb,
lib/shellopts/grammar/node.rb,
lib/shellopts/grammar/option.rb,
lib/shellopts/grammar/command.rb,
lib/shellopts/grammar/program.rb

Defined Under Namespace

Classes: Command, Compiler, Node, Option, Program

Class Method Summary collapse

Class Method Details

.compile(program_name, source) ⇒ Object

Compiles an option definition string and returns a Grammar::Program object. program_name is the name of the program and source is the option definition string



13
14
15
16
17
# File 'lib/shellopts/compiler.rb', line 13

def self.compile(program_name, source)
  program_name.is_a?(String) or raise Compiler::Error, "Expected String argument, got #{program_name.class}"
  source.is_a?(String) or raise Compiler::Error, "Expected String argument, got #{source.class}"
  Compiler.new(program_name, source).call
end