|
| struct | frame |
| | One entry on the per-scan mode stack: the active mode and where it was entered (the entry position feeds the unterminated/diagnostic messages). More...
|
| |
| struct | grammar |
| | A parsed grammar: the rules in order, and each rule's name (index = the rule's kind). More...
|
| |
| class | grammar_error |
| | Thrown for a malformed .lex grammar: where (origin, 1-based line, and 1-based byte column in the line when the cause has one) and why. More...
|
| |
| struct | indent_state |
| | The open blocks of a scan (Indentation), one per scan as its mode stack is. More...
|
| |
| class | layout_error |
| | Thrown when a line's indentation matches no enclosing level. More...
|
| |
| struct | layout_roles |
| | The token kinds whose rules take part in the indentation (Layout Awareness Level B), as a lexer's lexer::layout_roles gives them, for layout. More...
|
| |
| class | lex_error |
| | Thrown when no rule matches at a position (a lexical error). More...
|
| |
| class | lexer |
| | A lexer built from an ordered list of rules. More...
|
| |
| struct | mode_action |
| | A mode transition, fired when its rule wins, acting on the scan's mode stack: enter a nested mode, leave the current one, or replace it. More...
|
| |
| struct | position |
| | A location in the source text. More...
|
| |
| struct | rule |
| | A token rule: a kind, the pattern that recognizes it, whether matches are discarded (whitespace, comments), and — for contextual lexing — the modes it is active in and an optional mode transition it fires when it wins. More...
|
| |
| struct | token |
| | One lexical token: a typed slice of the source. More...
|
| |
| class | token_iterator |
| | Forward (single-pass) iterator yielding one token at a time. More...
|
| |
| class | token_range |
| | A lazy range of tokens, returned by lexer::scan. More...
|
| |
| class | token_stream |
| | Text fed in pieces, lexed as it arrives, with exactly the tokens lexer::tokenize gives the whole text: the same munches, modes, positions and errors. More...
|
| |
|
| enum class | tab_policy : std::uint8_t { columns
, python
} |
| | How the overload of layout() that takes the source measures indentation. More...
|
| |
| enum class | eof_policy { omit
, append
} |
| | Whether tokenization appends a synthetic end-of-input token. More...
|
| |
| enum class | indent_role : std::uint8_t {
none
, entry
, key
, value
,
reset
} |
| | A rule's part in the indentation the lexer tracks, Layout Awareness Level B (see Indentation). The roles are those of a block language whose collections open at a column: YAML's sequence entries, mapping keys and values, and document markers. More...
|
| |
| enum class | extension : std::uint8_t { none
, block
, lines
} |
| | How a token extends over the lines below its own, bounded by the indentation the lexer tracks (see Indentation). More...
|
| |
| enum class | dfa_policy : std::uint8_t { automatic
, requested
} |
| | Which modes a lexer tries to accelerate with a real::dfa. More...
|
| |
| enum class | error_policy { raise
, token
} |
| | What a lexer does when it reaches a byte that no rule in the active mode can begin. More...
|
| |
| enum class | column_unit { bytes
, codepoints
, utf16
} |
| | The unit a token's position::column is counted in. More...
|
| |
|
| grammar | parse_grammar (std::string_view text, const std::string &origin="<string>") |
| | Parses a .lex grammar from text (see the file documentation for the format).
|
| |
| grammar | load_grammar (const std::string &path) |
| | Reads and parses the .lex grammar at path.
|
| |
| std::vector< token > | layout (std::span< const token > tokens, const std::vector< bool > &mode_significant={}, const layout_roles &roles={}) |
| | Rewrites tokens with NEWLINE / INDENT / DEDENT inserted.
|
| |
| std::vector< token > | layout (std::span< const token > tokens, std::string_view source, tab_policy tabs, const std::vector< bool > &mode_significant={}, const layout_roles &roles={}) |
| | Rewrites tokens with NEWLINE / INDENT / DEDENT inserted, measuring indentation in source under tabs.
|
| |
| void | apply_transition (const rule &r, position start, std::vector< frame > &stack) |
| | Applies rule r's mode transition (if any) to stack — the per-scan mode-stack mutation, kept pure so the lexer and the fuzz oracle share it verbatim.
|
| |
| bool | takes_part (const rule &r) noexcept |
| | Whether a token of r takes part in the indentation (a role or an extension).
|
| |
| std::ptrdiff_t | indent_reference (const rule &r, position start, const indent_state &state) noexcept |
| | The innermost open block once the token of r at start has updated state (apply_indent), state itself left as it is: the reference the token's extension reads, decided before the update is, as a stream waiting for more text must not have made it.
|
| |
| void | apply_indent (const rule &r, position start, indent_state &state) |
| | Updates state for the token of r at start (Indentation): the blocks deeper than its column close (every block for a reset), then an entry opens one at its column, a key is kept as the line's candidate if it is the first since the line began or since an entry or a value, and a value opens one at that candidate's column. Pure, so the lexer and the fuzz oracle share it.
|
| |
| std::ptrdiff_t | leading_spaces (std::string_view source, std::size_t at) noexcept |
| | The spaces that begin the text at at of source.
|
| |
| std::size_t | past_blanks (std::string_view source, std::size_t at) noexcept |
| | Where the spaces, tabs and carriage returns from at in source end (a loop: a search for a set of bytes tests each byte against each of them).
|
| |
| bool | blank_between (std::string_view source, std::size_t first, std::size_t last, std::string_view blanks) noexcept |
| | Whether source holds only bytes of blanks from first to last.
|
| |
| std::optional< std::size_t > | block_extent (std::string_view source, std::size_t end, std::string_view match, std::ptrdiff_t reference, bool final) |
| | Where an extension::block token matched up to end of source (match its match) ends, with reference the innermost open block (Indentation); none while the text past source may still change it (final false: a stream's buffer).
|
| |
| std::optional< std::size_t > | lines_extent (std::string_view source, std::size_t end, const real::regex &continuation, std::ptrdiff_t reference, bool final) |
| | Where an extension::lines token matched up to end of source ends, each continued line read by continuation (Indentation), with reference the innermost open block; none while the text past source may still change it (final false).
|
| |
|
| constexpr int | newline {std::numeric_limits<int>::min() + 1} |
| | Reserved kind: end of a logical line.
|
| |
| constexpr int | indent {std::numeric_limits<int>::min() + 2} |
| | Reserved kind: indentation increased (start of a deeper block).
|
| |
| constexpr int | dedent {std::numeric_limits<int>::min() + 3} |
| | Reserved kind: indentation decreased (end of a block).
|
| |
| constexpr std::size_t | max_mode_depth {65536} |
| | The deepest the mode stack may grow. A push beyond it is a lex_error under either error policy: each frame costs memory, and without a bound an input of openers alone (16 MiB of ( under the python grammar) grew the stack past a gigabyte. 65 536 frames is ~2 MiB, far beyond any nesting a real grammar reaches.
|
| |
| constexpr int | end_of_input {std::numeric_limits<int>::min()} |
| | Reserved token kind for the synthetic end-of-input token.
|
| |
| constexpr int | error {std::numeric_limits<int>::min() + 4} |
| | Reserved token kind for a lexical-error run under scilex::error_policy::token.
|
| |
The unit a token's position::column is counted in.
The default bytes is the historical behaviour, bit-for-bit. codepoints counts Unicode scalar values (each valid UTF-8 codepoint is one column), and utf16 counts UTF-16 code units (a BMP codepoint is 1, an astral codepoint 2) — the unit an LSP client expects. A malformed byte (an orphan continuation, an overlong or out-of-range sequence) counts as one unit in every mode, so the column stays defined on the error runs error_policy::token emits. The chosen unit is not carried on position (one field, not self-describing) — the lexer declares it via lexer::columns, a named trade-off rather than a silent default.
| Enumerator |
|---|
| bytes | One column per byte (the default; column == byte offset within the line + 1).
|
| codepoints | One column per Unicode scalar value (a valid UTF-8 codepoint).
|
| utf16 | One column per UTF-16 code unit (BMP = 1, astral = 2) — the LSP unit.
|
| void scilex::apply_transition |
( |
const rule & |
r, |
|
|
position |
start, |
|
|
std::vector< frame > & |
stack |
|
) |
| |
|
inline |
Applies rule r's mode transition (if any) to stack — the per-scan mode-stack mutation, kept pure so the lexer and the fuzz oracle share it verbatim.
Depends only on r's action (its pre-resolved mode_action::target_id), the token start start, and the stack; it mutates only stack. push enters the target (remembering start), pop leaves the current mode, set replaces it in place. The target id is resolved once at build time, so this hot per-token pivot does no name→id map lookup.
- Exceptions
-
| lex_error | On a pop while the stack is at its root (nothing to leave), or a push that would take it past max_mode_depth. |