Class: HParser::Inline::Parser

Inherits:
Object
  • Object
show all
Includes:
Util
Defined in:
lib/hparser/inline/parser.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parsers = Parser.default_parser) ⇒ Parser

Returns a new instance of Parser.



12
13
14
# File 'lib/hparser/inline/parser.rb', line 12

def initialize(parsers=Parser.default_parser)
  @document =  Many1.new(Or.new(*parsers))
end

Class Method Details

.default_parserObject



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/hparser/inline/parser.rb', line 22

def self.default_parser
  parser = []
  ObjectSpace.each_object(Class){|klass|
    if klass.include?(HParser::Inline::Collectable) then
      parser.push klass
    end
  }
  parser.sort{|a,b|
    a <=> b or -(b <=> a).to_i
  }
end

Instance Method Details

#parse(str, context = nil) ⇒ Object



16
17
18
19
20
# File 'lib/hparser/inline/parser.rb', line 16

def parse str, context=nil
  scanner = StringScanner.new str
  e = @document.parse(scanner, context) || [ HParser::Inline::Text.new("") ]
  join_text e
end