Class: TreeParser
- Inherits:
-
ServiceBase
- Object
- ServiceBase
- TreeParser
- Defined in:
- lib/rosetta/services/tree_parser.rb
Overview
Parse tokens into AST structure.
Constant Summary collapse
- BLOCK_TOKEN_TYPES =
{ QUOTE: BlockQuote, BASIC_LIST_ITEM: BasicList, NUMBERED_LIST_ITEM: NumberedList }.freeze
Instance Method Summary collapse
-
#call ⇒ Object
TODO: Investigate if this can be done without declaring and mutating the array.
-
#initialize(tokens) ⇒ TreeParser
constructor
A new instance of TreeParser.
Methods inherited from ServiceBase
Constructor Details
#initialize(tokens) ⇒ TreeParser
Returns a new instance of TreeParser.
30 31 32 33 |
# File 'lib/rosetta/services/tree_parser.rb', line 30 def initialize(tokens) @tokens = tokens @counter = 0 end |
Instance Method Details
#call ⇒ Object
TODO: Investigate if this can be done without declaring and mutating the array.
36 37 38 39 40 41 |
# File 'lib/rosetta/services/tree_parser.rb', line 36 def call parsed_tree = [] parsed_tree << consume_next_block until end_of_file? parsed_tree.compact end |