SourceMap

trait SourceMap[Token]

Type class used to keep track of a a token's position in a source file.

A source map knows how to compute the following, given the current position in the input:

  • where the token starts.
  • where the token ends.

In the case of characters, for example, the mapping is fairly straightforward. A character:

  • starts at the current position.
  • ends at the beginning of the following line if the character is a line break.
  • ends at the next column otherwise.

One might imagine more complex scenarios, however. Typically, when splitting tokenization and parsing, you'll end up working with tokens that know their position in the original source code.

Companion:
object
class Object
trait Matchable
class Any

Value members

Abstract methods

def endsAt(token: Token, current: Position): Position
def startsAt(token: Token, current: Position): Position