BlockSource

class BlockSource(inputRef: InputString, val lines: Type[LineSource], val offset: Int, val nestLevel: Int) extends SourceFragment

A block source represents the source for a block level element where each individual line might have a different x-offset to the root source.

This type of source is essential to preserve position tracking in recursive block parsing. For block level markup the first passes have to identify the type of block and remove their markup decoration. The remaining inline markup is then passed to inline parsers, but the input to those parsers is no longer a consecutive substring of the root input, making it hard to provide exact positions in error messages.

This type of source cursor solves this issue by providing a view to parsers that looks like a consecutive string of inline markup without the stripped decoration, while maintaining the x- and y-offsets of each line in relation to the root source.

Such a source will be used in multi-pass parsers, where the root parser might strip some markup decoration from each line and then pass the result down to the next recursion. In such a case each line might have a different x-offset from the root input. The use of this instance ensures that the correct position can still be tracked.

Companion:
object
class Object
trait Matchable
class Any

Type members

Types

Value members

Concrete methods

def atEnd: Boolean
def capture(numChars: Int): String
def consume(numChars: Int): BlockSource
override def equals(obj: Any): Boolean
Definition Classes
Any
override def hashCode(): Int
Definition Classes
Any
def remaining: Int
override def toString: String
Definition Classes
Any

Inherited methods

def char: Char

The character at the current offset.

The character at the current offset.

Inherited from:
SourceCursor
def charAt(relativeOffset: Int): Char

The character at the specified offset, relative from the current offset.

The character at the specified offset, relative from the current offset.

Inherited from:
SourceCursor
def length: Int

The length of the input of this cursor.

The length of the input of this cursor.

Inherited from:
SourceCursor
def path: Option[Path]

The (virtual) path of the document this input originates from; may be empty in case of generated sources.

The (virtual) path of the document this input originates from; may be empty in case of generated sources.

Inherited from:
SourceCursor

Concrete fields

lazy val input: String
val lines: Type[LineSource]
val nestLevel: Int
val offset: Int
lazy val position: Position
lazy val root: RootSource