Class: SyntaxTree::ERB::Parser
- Inherits:
-
Object
- Object
- SyntaxTree::ERB::Parser
- Defined in:
- lib/syntax_tree/erb/parser.rb
Defined Under Namespace
Classes: MissingTokenError, ParseError
Instance Attribute Summary collapse
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#tokens ⇒ Object
readonly
Returns the value of attribute tokens.
Instance Method Summary collapse
- #debug_tokens ⇒ Object
-
#initialize(source) ⇒ Parser
constructor
A new instance of Parser.
- #parse ⇒ Object
Constructor Details
#initialize(source) ⇒ Parser
Returns a new instance of Parser.
20 21 22 23 24 |
# File 'lib/syntax_tree/erb/parser.rb', line 20 def initialize(source) @source = source @tokens = make_tokens @found_doctype = false end |
Instance Attribute Details
#source ⇒ Object (readonly)
Returns the value of attribute source.
18 19 20 |
# File 'lib/syntax_tree/erb/parser.rb', line 18 def source @source end |
#tokens ⇒ Object (readonly)
Returns the value of attribute tokens.
18 19 20 |
# File 'lib/syntax_tree/erb/parser.rb', line 18 def tokens @tokens end |
Instance Method Details
#debug_tokens ⇒ Object
35 36 37 38 39 |
# File 'lib/syntax_tree/erb/parser.rb', line 35 def debug_tokens @tokens.each do |key, value, index, line| puts("#{key} #{value.inspect} #{index} #{line}") end end |
#parse ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/syntax_tree/erb/parser.rb', line 26 def parse elements = many { parse_any_tag } location = elements.first.location.to(elements.last.location) if elements.any? Document.new(elements: elements, location: location) end |