Class: TermUtils::AP::Parser
- Inherits:
-
Object
- Object
- TermUtils::AP::Parser
- Defined in:
- lib/term_utils/ap/parser.rb
Overview
Represents the argument list parser.
Instance Method Summary collapse
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
-
#parse_arguments(syntax, arguments, opts = {}) ⇒ TermUtils::AP::Result
Parses a given list of arguments.
-
#parse_command(syntax, command, opts = {}) ⇒ TermUtils::AP::Result
Parses a given command.
Constructor Details
#initialize ⇒ Parser
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.
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.
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 |