RootSource

laika.parse.RootSource
class RootSource(inputRef: InputString, val offset: Int, val nestLevel: Int) extends SourceCursor

A root source represents the full input string of a parsing operation.

In a single-pass parser like those for HOCON or CSS, only RootCursor instances will be used for the entire parsing operation.

In a multi-pass parser like those for text markup, a RootCursor is only used for the first pass, whereas the subsequent passes on parts of the input are performed with the other SourceCursor implementations.

For this reason this type of cursor is only meant to be used for creating a root cursor for the input holding the whole document (e.g. the entire markup document or the full template).

For creating a cursor for a fragment of the input, either BlockSource or LineSource must be used to preserve position tracking in relation to the root input.

Attributes

Graph
Supertypes
trait SourceCursor
class Object
trait Matchable
class Any

Members list

Type members

Types

type Self = RootSource

Value members

Concrete methods

def atEnd: Boolean

Indicates whether this contexts offset is behind the last character of the input string

Indicates whether this contexts offset is behind the last character of the input string

Attributes

def capture(numChars: Int): String

Captures a string containing the specified number of characters from the current offset. If the number of remaining characters is less than the specified number, all remaining characters will be returned.

Captures a string containing the specified number of characters from the current offset. If the number of remaining characters is less than the specified number, all remaining characters will be returned.

Attributes

def consume(numChars: Int): RootSource

Consumes the specified number of characters, returning a new SourceCursor with the new offset.

Consumes the specified number of characters, returning a new SourceCursor with the new offset.

Attributes

override def equals(obj: Any): Boolean

Compares the receiver object (this) with the argument object (that) for equivalence.

Compares the receiver object (this) with the argument object (that) for equivalence.

Any implementation of this method should be an equivalence relation:

  • It is reflexive: for any instance x of type Any, x.equals(x) should return true.
  • It is symmetric: for any instances x and y of type Any, x.equals(y) should return true if and only if y.equals(x) returns true.
  • It is transitive: for any instances x, y, and z of type Any if x.equals(y) returns true and y.equals(z) returns true, then x.equals(z) should return true.

If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode to ensure that objects which are "equal" (o1.equals(o2) returns true) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)).

Value parameters

that

the object to compare against this object for equality.

Attributes

Returns

true if the receiver object is equivalent to the argument; false otherwise.

Definition Classes
Any
override def hashCode(): Int

Calculate a hash code value for the object.

Calculate a hash code value for the object.

The default hashing algorithm is platform dependent.

Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)) yet not be equal (o1.equals(o2) returns false). A degenerate implementation could always return 0. However, it is required that if two objects are equal (o1.equals(o2) returns true) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals method.

Attributes

Returns

the hash code value for this object.

Definition Classes
Any

Create a new instance of this cursor with the nestLevel incremented.

Create a new instance of this cursor with the nestLevel incremented.

Attributes

def remaining: Int

Indicates the number of characters remaining in the input string after the current offset.

Indicates the number of characters remaining in the input string after the current offset.

Attributes

Returns a new SourceCursor with the input string being reversed, but pointing to the same character as this context.

Returns a new SourceCursor with the input string being reversed, but pointing to the same character as this context.

This is a low-level optimization for parsers that look for strings like email addresses where the first character is not significant, so that parsing backwards from any @ encountered in the input provided better performance.

Attributes

override def toString: String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Any

Inherited methods

def char: Char

The character at the current offset.

The character at the current offset.

Attributes

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.

Attributes

Inherited from:
SourceCursor
def length: Int

The length of the input of this cursor.

The length of the input of this cursor.

Attributes

Inherited from:
SourceCursor

Concrete fields

val input: String

The full input string, containing the string portions before and after the current offset.

The full input string, containing the string portions before and after the current offset.

Attributes

val nestLevel: Int

The nest level of this cursor in case of recursive parsing.

The nest level of this cursor in case of recursive parsing.

Attributes

val offset: Int

The offset of this cursor from the start of the source.

The offset of this cursor from the start of the source.

Attributes

override val 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.

Attributes

lazy val position: Position

The current position in the input string.

The current position in the input string.

Attributes

The source for the root input, positioned to match the offset of this (potentially nested) source.

The source for the root input, positioned to match the offset of this (potentially nested) source.

Attributes