Tokenization

alpaca.internal.lexer.Tokenization
abstract transparent class Tokenization[Ctx <: LexerCtx](using betweenStages: BetweenStages[Ctx], errorHandling: ErrorHandling[Ctx], empty: Empty[Ctx]) extends Selectable

The result of compiling a lexer definition.

This abstract class represents a compiled lexer that can tokenize input. It is generated by the lexer macro and provides methods to access tokens and perform tokenization.

Type parameters

Ctx

the global context type

Attributes

Experimental
true
Source
Tokenization.scala
Graph
Supertypes
trait Selectable
class Object
trait Matchable
class Any

Members list

Type members

Types

type Fields <: AnyNamedTuple

Attributes

Source
Tokenization.scala
final type Lexeme = withFields[Lexeme[_, _], LexemeFields]

Attributes

Source
Tokenization.scala
type LexemeFields <: AnyNamedTuple

Attributes

Source
Tokenization.scala

Value members

Abstract methods

protected def compiled: Pattern

The compiled pattern that matches all defined tokens.

The compiled pattern that matches all defined tokens.

Attributes

Source
Tokenization.scala
def selectDynamic(fieldName: String): Token[_, Ctx, _]

Provides dynamic access to tokens by name.

Provides dynamic access to tokens by name.

This allows accessing tokens using dot notation, e.g., myLexer.PLUS.

Value parameters

fieldName

the token name

Attributes

Returns

the token definition

Source
Tokenization.scala
def tokens: List[Token[_, Ctx, _]]

List of all tokens defined in this lexer, including ignored tokens.

List of all tokens defined in this lexer, including ignored tokens.

Attributes

Source
Tokenization.scala

Concrete methods

final def tokenize(input: CharSequence): (ctx: Ctx, lexemes: List[Lexeme])

Tokenizes the input character sequence.

Tokenizes the input character sequence.

Processes the input from start to finish, matching tokens and building a list of lexems. Throws a RuntimeException if an unexpected character is encountered.

Value parameters

input

the input to tokenize

Attributes

Returns

a list of lexems representing the tokenized input

Source
Tokenization.scala