Class: RubyLLM::Toolbox::Toml::Parser
- Inherits:
-
Object
- Object
- RubyLLM::Toolbox::Toml::Parser
- Defined in:
- lib/ruby_llm/toolbox/toml.rb
Overview
Recursive-descent parser over a character cursor.
Constant Summary collapse
- DATETIME =
/\A(\d{4}-\d{2}-\d{2}([Tt ]\d{2}:\d{2}:\d{2}(\.\d+)?([Zz]|[+-]\d{2}:\d{2})?)?|\d{2}:\d{2}:\d{2}(\.\d+)?)/
Instance Method Summary collapse
-
#initialize(source) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(source) ⇒ Parser
Returns a new instance of Parser.
26 27 28 29 30 31 |
# File 'lib/ruby_llm/toolbox/toml.rb', line 26 def initialize(source) @s = source.to_s @i = 0 @len = @s.length @root = {} end |
Instance Method Details
#parse ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/ruby_llm/toolbox/toml.rb', line 33 def parse @current = @root loop do skip_blank break if eof? if peek == "[" parse_table_header else key = parse_key skip_inline_ws expect("=") value = parse_value assign(@current, key, value) expect_line_end end end @root end |