LexicalScanner

class LexicalScanner(val moduleNameProducer: () -> String)

A LexicalScanner tracks all visible A_Lexers while compiling a module. It maintains an AtomicReferenceArray from Latin-1 codepoints (U+0000..U+00FF) to the A_Tuple of lexers whose filters passed for that codepoint. A separate ConcurrentHashMap tracks all remaining codepoints.

There is also a special instance that is reused for scanning module headers.

Author

Mark van Gulik

Constructors

Link copied to clipboard
fun LexicalScanner(moduleNameProducer: () -> String)

Functions

Link copied to clipboard
fun addLexer(lexer: A_Lexer)

Add an A_Lexer. Update not just the current lexing information for this loader, but also the specified atom's bundle's method and the current module.

Link copied to clipboard
fun freezeFromChanges()

Ensure new A_Lexers are not added after this point. This is a safety measure.

Link copied to clipboard
fun getLexersForCodePointThen(    lexingState: LexingState,     codePoint: Int,     continuation: (A_Tuple) -> Unit,     onFailure: (Map<A_Lexer, Throwable>) -> Unit)

Collect the lexers that should run when we encounter a character with the given (Int) code point, then pass this tuple of lexers to the supplied Kotlin function.

Properties

Link copied to clipboard
val allVisibleLexers: MutableList<A_Lexer>

The List of all lexers which are visible within the module being compiled.

Link copied to clipboard
var frozen: Boolean = false

When set, fail on attempts to change the lexical scanner. This is a safety measure.

Link copied to clipboard
val moduleNameProducer: () -> String

A function that produces the name of the module that this scanner is operating on behalf of, or "" for the scanner used for module headers.