Class: Diml::Parser
- Inherits:
-
Object
- Object
- Diml::Parser
- Defined in:
- lib/diml/document/parser.rb
Overview
Parser is responsible for converted raw content into a DiML document tree
Instance Method Summary collapse
-
#initialize(raw_content) ⇒ Parser
constructor
A new instance of Parser.
-
#parse ⇒ Object
Parses the raw content for a DIML document into the internal representation.
Constructor Details
#initialize(raw_content) ⇒ Parser
Returns a new instance of Parser.
16 17 18 |
# File 'lib/diml/document/parser.rb', line 16 def initialize(raw_content) @raw_content = raw_content end |
Instance Method Details
#parse ⇒ Object
Parses the raw content for a DIML document into the internal representation.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/diml/document/parser.rb', line 22 def parse basic_tokens = @raw_content.split(";") # Create new Content Tree ctree = ContentTree.new ctree.content = Root.new("") ctree.root! tree = build_tree(ctree, basic_tokens) # Return the root not the last value t = tree t = t.parent until t.root? t end |