Class: Caps::Tokenizer::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/caps/tokenizer/location.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(parser) ⇒ Location

Returns a new instance of Location.



8
9
10
11
# File 'lib/caps/tokenizer/location.rb', line 8

def initialize(parser)
  @parser = parser
  @start = parser.pos
end

Instance Attribute Details

#startObject (readonly)

Returns the value of attribute start.



6
7
8
# File 'lib/caps/tokenizer/location.rb', line 6

def start
  @start
end

Instance Method Details

#finishObject



17
18
19
20
21
22
# File 'lib/caps/tokenizer/location.rb', line 17

def finish
  {
    start: @start,
    end: @parser.pos
  }
end

#push_node(type, **opts) ⇒ Object



13
14
15
# File 'lib/caps/tokenizer/location.rb', line 13

def push_node(type, **opts)
  @parser.push_node(type, **opts.merge({ position: finish }))
end