LineSource

laika.parse.LineSource
See theLineSource companion object
class LineSource extends SourceFragment

A line source represents all or part of a single line from the root input source.

Such a source will be used in multi-pass parsers, particularly block-level 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.

A LineSource is usually used as part of a BlockSource and less frequently on its own.

Attributes

Companion
object
Graph
Supertypes
trait SourceCursor
class Object
trait Matchable
class Any

Members list

Type members

Types

type Self = LineSource

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): LineSource

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

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

lazy val parent: SourceCursor
lazy val position: Position

The current position in the input string.

The current position in the input string.

Attributes

lazy val root: RootSource

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