class Crass::TokenScanner

Experimental RBS support (using type sampling data from the type_fusion project).

# sig/crass/token-scanner.rbs

class Crass::TokenScanner
  def consume: () -> Hash?
  def reset: () -> Integer
end

Like {Scanner}, but for tokens!

def collect

execution, and returns them.
Executes the given block, collects all tokens that are consumed during its
def collect
  start = @pos
  yield
  @tokens[start...@pos] || []
end

def consume

Experimental RBS support (using type sampling data from the type_fusion project).

def consume: () -> [["node", "Symbol"], ["pos", "Integer"], ["raw", "String"], ["value", "String"]]?

This signature was generated using 2 samples from 1 application.

`nil` if there is no next token.
Consumes the next token and returns it, advancing the pointer. Returns
def consume
  @current = @tokens[@pos]
  @pos += 1 if @current
  @current
end

def initialize(tokens)

def initialize(tokens)
  @tokens = tokens.to_a
  reset
end

def peek

token.
Returns the next token without consuming it, or `nil` if there is no next
def peek
  @tokens[@pos]
end

def reconsume

http://www.w3.org/TR/2013/WD-css-syntax-3-20130919/#reconsume-the-current-input-token

Reconsumes the current token, moving the pointer back one position.
def reconsume
  @pos -= 1 if @pos > 0
end

def reset

Experimental RBS support (using type sampling data from the type_fusion project).

def reset: () -> Integer

This signature was generated using 1 sample from 1 application.

Resets the pointer to the first token in the list.
def reset
  @current = nil
  @pos     = 0
end