Class: CSKit::Parsers::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/cskit/parsers/parser.rb

Instance Method Summary collapse

Constructor Details

#initialize(citation_text) ⇒ Parser

Returns a new instance of Parser.



8
9
10
11
12
# File 'lib/cskit/parsers/parser.rb', line 8

def initialize(citation_text)
  @citation_text = citation_text
  @token_stream = get_token_stream
  @current = token_stream.next
end

Instance Method Details

#entry_pointObject

Raises:

  • (NotImplementedError)


25
26
27
28
# File 'lib/cskit/parsers/parser.rb', line 25

def entry_point
  raise NotImplementedError,
    "`#{__method__} must be defined in derived classes"
end

#parseObject



14
15
16
17
18
19
20
21
22
23
# File 'lib/cskit/parsers/parser.rb', line 14

def parse
  result = entry_point

  unless eos?
    raise ParserError, "Expected end of input but more input is available "\
      "at position #{current.position}"
  end

  result
end