Class: OllamaAgent::RuntimeCommandSystem::AST::Parser
- Inherits:
-
Object
- Object
- OllamaAgent::RuntimeCommandSystem::AST::Parser
- Defined in:
- lib/ollama_agent/runtime_command_system/ast.rb
Constant Summary collapse
- COMMAND_PATTERN =
%r{\A/([a-zA-Z][a-zA-Z0-9_-]*)(.*)\z}- TOKEN_PATTERN =
/[^\s"]+|"[^"]*"/
Class Method Summary collapse
Class Method Details
.parse(input, cursor_pos = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/ollama_agent/runtime_command_system/ast.rb', line 49 def parse(input, cursor_pos = nil) text = input.to_s return nil unless text.start_with?("/") cursor = cursor_pos || text.length match = text.match(COMMAND_PATTERN) return partial_command(text, cursor) unless match name = match[1] tail = match[2].to_s CommandNode.new( name: name, arguments: parse_arguments(tail, name.length + 1), raw: text, cursor_pos: cursor ) end |