Class: Foxtail::Bundle::Parser
- Inherits:
-
Object
- Object
- Foxtail::Bundle::Parser
- Defined in:
- lib/foxtail/bundle/parser.rb,
lib/foxtail/bundle/parser/ast.rb
Overview
Lightweight runtime parser for FTL resources. Equivalent to fluent-bundle’s FluentResource parser.
This parser is optimized for runtime performance and produces Bundle::Parser::AST structures directly. Unlike Syntax::Parser, it:
-
Does not track source positions
-
Does not preserve comments
-
Uses error recovery to skip invalid entries
-
Produces ‘String | Array` patterns directly
For validation and tooling, use Syntax::Parser instead.
Defined Under Namespace
Modules: AST Classes: ParseError
Instance Method Summary collapse
-
#parse(source) ⇒ Array<AST::Message, AST::Term>
Parse FTL source into an array of messages and terms.
Instance Method Details
#parse(source) ⇒ Array<AST::Message, AST::Term>
Parse FTL source into an array of messages and terms
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/foxtail/bundle/parser.rb', line 100 def parse(source) @source = source @cursor = 0 @body = [] # Iterate over message/term starts source.scan(RE_MESSAGE_START) do |match| id = match[0] @cursor = Regexp.last_match.end(0) begin @body << (id) rescue ParseError # Skip to next entry on error next end end @body end |