LexerCtx

halotukozak.alpaca.LexerCtx
See theLexerCtx companion object
trait LexerCtx extends Product, Selectable

The base of every lexer context: the state a lexer carries from one token to the next, read and assigned as ctx in rule bodies, and snapshotted into every lexeme and LexerError.

A context must be a case class whose fields all have default values, since the lexer macro builds the initial context from those defaults:

case class BrainLexContext(squareBrackets: Int = 0, line: Line = Line.Start) extends LexerCtx

A field whose type has a given Tracking, like Line or Column, is updated after every match.

Attributes

Companion
object
Source
lexer.scala
Graph
Supertypes
trait Selectable
trait Product
trait Equals
class Object
trait Matchable
class Any
Show all
Known subtypes
class Default
class Empty

Members list

Value members

Concrete methods

inline def applyDynamic(inline name: String)(inline args: Any*): Any

Not meant to be called: assigning a context field outside a lexer rule or handler is a compile error.

Not meant to be called: assigning a context field outside a lexer rule or handler is a compile error.

Attributes

Source
lexer.scala
final def peek(n: Int): String

A copy of at most the next n characters of the input still to be tokenized, fewer at its end.

A copy of at most the next n characters of the input still to be tokenized, fewer at its end.

Meant for a custom ErrorHandling instance to look at what failed to match any token rule, e.g. to pick a recovery strategy based on what comes next. Only the requested characters are read and copied, and the result is safe to keep after the callback returns.

Value parameters

n

the maximum number of characters to return

Attributes

Throws
IllegalArgumentException

if n is negative

Source
lexer.scala

Inherited methods

def productElementName(n: Int): String

The name of the n^th^ element of this product, 0-based. In the default implementation, an empty string.

The name of the n^th^ element of this product, 0-based. In the default implementation, an empty string.

Value parameters

n

the index of the element name to return

Attributes

Returns

the name of the specified element

Throws
IndexOutOfBoundsException

if the n is out of range(n < 0 || n >= productArity).

Inherited from:
Product
Source
Product.scala
def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
Source
Product.scala
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
Source
Product.scala
def productPrefix: String

A string used in the toString methods of derived classes. Implementations may override this method to prepend a string prefix to the result of toString methods.

A string used in the toString methods of derived classes. Implementations may override this method to prepend a string prefix to the result of toString methods.

Attributes

Returns

in the default implementation, the empty string

Inherited from:
Product
Source
Product.scala

Inherited and Abstract methods

def canEqual(that: Any): Boolean

Checks whether this instance can possibly equal that.

Checks whether this instance can possibly equal that.

A method that should be called from every well-designed equals method that is open to be overridden in a subclass. See Programming in Scala, Chapter 28 for discussion and design.

Value parameters

that

the value being probed for possible equality

Attributes

Returns

true if this instance can possibly equal that, otherwise false

Inherited from:
Equals
Source
Equals.scala
def productArity: Int

The size of this product.

The size of this product.

Attributes

Returns

for a product A(x,,1,,, ..., x,,k,,), returns k

Inherited from:
Product
Source
Product.scala
def productElement(n: Int): Any

The n^th^ element of this product, 0-based. In other words, for a product A(x,,1,,, ..., x,,k,,), returns x,,(n+1),, where `0 = productArity).

The n^th^ element of this product, 0-based. In other words, for a product A(x,,1,,, ..., x,,k,,), returns x,,(n+1),, where `0 = productArity).

Attributes

Returns

the element n elements after the first element

Inherited from:
Product
Source
Product.scala