Class: Fmt::Parser
- Inherits:
-
Object
- Object
- Fmt::Parser
- Defined in:
- lib/fmt/parsers/parser.rb
Overview
Responsible for parsing various inputs and returning an AST (Abstract Syntax Tree)
Mechanics are similar to an ETL pipeline (Extract, Transform, Load), however, parsers only handle extracting and transforming.
Loading is handled by AST processors (Models)
Direct Known Subclasses
ArgumentsParser, EmbedParser, MacroParser, PipelineParser, TemplateParser
Constant Summary collapse
- Cache =
: Fmt::LRUCache – local in-memory cache
Fmt::LRUCache.new
Class Method Summary collapse
-
.esc(value) ⇒ Object
Escapes a string for use in a regular expression.
Instance Method Summary collapse
-
#parse ⇒ Object
Parses input passed to the constructor and returns an AST (Abstract Syntax Tree).
Class Method Details
.esc(value) ⇒ Object
Escapes a string for use in a regular expression
19 |
# File 'lib/fmt/parsers/parser.rb', line 19 def self.esc(value) = Regexp.escape(value.to_s) |
Instance Method Details
#parse ⇒ Object
Note:
Subclasses must implement the extract and transform methods
Parses input passed to the constructor and returns an AST (Abstract Syntax Tree)
-
Extract components
-
Transform to AST
29 30 31 |
# File 'lib/fmt/parsers/parser.rb', line 29 def parse extract.then { transform(**_1) } end |