5#include <portals/document_encoding.hpp>
6#include <portals/document_highlight_types.hpp>
19enum class HighlightSqlMode {
39 MYSQL_DIRECTIVE_VALUE,
40 MYSQL_DIRECTIVE_TRAIL,
50enum class HighlightMarkdownMode {
65enum class HighlightMySqlComment {
72enum class HighlightMySqlSet {
82enum class HighlightMySqlTarget {
105 HighlightMySqlComment
comment{HighlightMySqlComment::NONE};
106 HighlightMySqlSet
set{HighlightMySqlSet::OFF};
107 HighlightMySqlTarget
target{HighlightMySqlTarget::OTHER};
158 HighlightSqlMode
sqlMode{HighlightSqlMode::TEXT};
181class DocumentHighlighter;
188 friend class DocumentHighlighter;
223 bool endOfInput =
false) noexcept;
236 detail::HighlightState state_{};
Definition document_highlight.hpp:187
DocumentHighlightResult feed(std::span< const DecodedScalar > input, std::span< TokenRun > output, bool endOfInput=false) noexcept
DocumentHighlightCheckpoint checkpoint() const noexcept
DocumentHighlighter(DocumentHighlighterOptions options={}, std::uint64_t initialByteOffset=0) noexcept
std::uint64_t nextByteOffset() const noexcept
DocumentHighlighter(const DocumentHighlightCheckpoint &checkpoint) noexcept
Public Portals API.
Definition action.hpp:8
DocumentLanguage
Explicit lexical profiles; unknown names resolve to PLAIN.
Definition document_highlight_types.hpp:11
@ POSTGRESQL_LEXICAL
Bounded PostgreSQL source profile, not a semantic parser.
Definition document_highlight_types.hpp:13
DocumentMySqlMode
MySQL lexical string modes supported initially and by source SET SQL_MODE.
Definition document_highlight_types.hpp:92
Decoded Unicode scalar with its exact interval in the original byte stream.
Definition document_encoding.hpp:45
Committed progress; errors leave their triggering transition uncommitted.
Definition document_highlight_types.hpp:84
Fixed-capacity policy copied into checkpoints.
Definition document_highlight_types.hpp:98
One nonempty semantic interval in original source bytes.
Definition document_highlight_types.hpp:65
Fixed MySQL client/source state, with no runtime or variable environment.
Definition document_highlight.hpp:89
bool wordVariable
Current bounded word follows @ and must not introduce a statement or keyword role.
Definition document_highlight.hpp:125
DecodedScalar star
Potential executable-comment closing star.
Definition document_highlight.hpp:96
bool modeNoBackslash
Current mode literal includes NO_BACKSLASH_ESCAPES.
Definition document_highlight.hpp:121
std::uint8_t terminatorLength
Current client delimiter length, in ASCII characters.
Definition document_highlight.hpp:99
bool lineStart
Only source-line indentation has been admitted.
Definition document_highlight.hpp:112
std::array< char32_t, 64 > replacement
DELIMITER value under construction before newline/EOF.
Definition document_highlight.hpp:91
std::array< std::uint8_t, 64 > matchedWidths
Original-byte widths of a delayed delimiter prefix.
Definition document_highlight.hpp:92
DocumentMySqlMode pendingMode
Mode to commit at the complete client terminator.
Definition document_highlight.hpp:110
std::uint32_t version
Accumulated executable-comment version gate.
Definition document_highlight.hpp:97
DocumentMySqlMode savedMode
Known @OLD_SQL_MODE value, if savedValid.
Definition document_highlight.hpp:109
bool variablePrefix
The last admitted source punctuation was an immediate variable-name @ prefix.
Definition document_highlight.hpp:124
std::array< char, 32 > modeWord
One bounded SQL_MODE item, never the whole literal.
Definition document_highlight.hpp:94
TokenRun matched
Original byte interval of the delayed delimiter prefix.
Definition document_highlight.hpp:95
bool pendingModeValid
A supported mode update awaits the client terminator.
Definition document_highlight.hpp:118
HighlightMySqlTarget target
Current assignment target.
Definition document_highlight.hpp:107
bool savedValid
One proven saved-mode slot is available.
Definition document_highlight.hpp:117
std::array< std::uint8_t, 64 > fallback
KMP proper-prefix lengths for bounded delimiter matching.
Definition document_highlight.hpp:93
bool pendingSavedValid
A supported save awaits the client terminator.
Definition document_highlight.hpp:119
HighlightMySqlComment comment
Executable wrapper phase.
Definition document_highlight.hpp:105
bool modeLiteral
A supported SQL_MODE string is being observed.
Definition document_highlight.hpp:120
bool modeWordEnded
Trailing whitespace began within a mode-list item.
Definition document_highlight.hpp:122
HighlightMySqlSet set
Observed SET clause phase.
Definition document_highlight.hpp:106
std::array< char32_t, 64 > terminator
Current bounded client statement delimiter.
Definition document_highlight.hpp:90
bool starPending
A closing star is delayed across a chunk boundary.
Definition document_highlight.hpp:114
bool routine
Current CREATE defines a stored program; SET is not executed during definition.
Definition document_highlight.hpp:116
std::uint8_t versionDigits
Retained version digit count; bound6.
Definition document_highlight.hpp:102
DocumentMySqlMode currentMode
Active session lexical mode.
Definition document_highlight.hpp:108
bool directiveSpace
Required whitespace after the DELIMITER keyword was admitted.
Definition document_highlight.hpp:123
DocumentMySqlMode pendingSavedMode
Saved mode to commit at the complete client terminator.
Definition document_highlight.hpp:111
std::uint8_t replacementLength
New directive delimiter characters retained.
Definition document_highlight.hpp:100
std::uint16_t setDepth
Parenthesis depth within unrelated SET expressions; bound65535.
Definition document_highlight.hpp:98
bool createStatement
Current statement began with CREATE.
Definition document_highlight.hpp:115
std::uint8_t matchedLength
Current terminator prefix length.
Definition document_highlight.hpp:101
bool wordLineStart
Current bounded word began at a source-line start.
Definition document_highlight.hpp:113
std::uint8_t atCount
At-sign qualification count, saturated at two.
Definition document_highlight.hpp:104
std::uint8_t modeWordLength
Retained mode-list item length; bound32.
Definition document_highlight.hpp:103
Trivially owned bounded state; size never depends on input/token/line length.
Definition document_highlight.hpp:129
HighlightMySqlState mysql
Fixed MySQL client/dump state.
Definition document_highlight.hpp:166
bool fenced
A Markdown fence is open.
Definition document_highlight.hpp:163
std::array< char, 16 > infoWord
Bounded fence language candidate, lowercased.
Definition document_highlight.hpp:141
bool infoEnded
Fence language word has ended or overflowed.
Definition document_highlight.hpp:169
TokenRun markdownPending
Delayed Markdown delimiter or close-line interval.
Definition document_highlight.hpp:133
bool eofFinalized
No further input may be admitted.
Definition document_highlight.hpp:176
std::uint8_t inlineLength
Required inline closing backtick count.
Definition document_highlight.hpp:154
std::uint16_t commentDepth
Currently open nested block comments.
Definition document_highlight.hpp:148
std::array< char32_t, 64 > delimiter
SQL tag characters, excluding dollar signs.
Definition document_highlight.hpp:139
bool escapeString
True only for explicit PostgreSQL E strings.
Definition document_highlight.hpp:160
bool lineCandidate
Delimiter began at a supported source line start.
Definition document_highlight.hpp:162
TokenRun pending
Delayed token prefix or delimiter interval.
Definition document_highlight.hpp:132
char32_t runCharacter
Current Markdown delimiter character.
Definition document_highlight.hpp:150
std::uint8_t numberPhase
Zero for integer, one for fraction, two for exponent digits.
Definition document_highlight.hpp:147
HighlightMarkdownMode markdownMode
Markdown scanner phase.
Definition document_highlight.hpp:159
std::uint8_t fenceLength
Required closing fence length.
Definition document_highlight.hpp:153
bool infoStarted
Fence info language word has begun.
Definition document_highlight.hpp:168
char32_t fenceCharacter
Opening fence character.
Definition document_highlight.hpp:151
char32_t previous
Previous comment delimiter candidate character.
Definition document_highlight.hpp:149
std::uint8_t delivered
Staged runs already copied to caller storage.
Definition document_highlight.hpp:138
std::uint8_t queued
Number of staged runs.
Definition document_highlight.hpp:137
HighlightSqlMode sqlMode
SQL scanner phase.
Definition document_highlight.hpp:158
std::array< TokenRun, 8 > speculative
SQL runs delayed while testing a fence close.
Definition document_highlight.hpp:135
bool statementStart
The next SQL word can introduce a COPY statement.
Definition document_highlight.hpp:170
bool copyHeader
A statement-start COPY header is active.
Definition document_highlight.hpp:171
bool copyHeaderCr
A header CR was admitted; an immediately following LF is still header whitespace.
Definition document_highlight.hpp:175
std::array< char, 16 > word
ASCII keyword candidate, uppercased.
Definition document_highlight.hpp:140
std::uint8_t indent
Source-line leading spaces seen, saturated at four.
Definition document_highlight.hpp:155
std::uint64_t nextOffset
Next required original-byte offset.
Definition document_highlight.hpp:131
std::uint8_t runLength
Current Markdown delimiter run length.
Definition document_highlight.hpp:152
DocumentLanguage embeddedLanguage
Recognized SQL fence language.
Definition document_highlight.hpp:165
std::uint8_t speculativeCount
Number of tentative SQL runs.
Definition document_highlight.hpp:136
bool copyStdin
COPY FROM STDIN was recognized outside parentheses.
Definition document_highlight.hpp:173
std::uint8_t suffixLength
Number of delayed numeric suffix scalars.
Definition document_highlight.hpp:146
bool copyFrom
A top-level COPY FROM token has been seen.
Definition document_highlight.hpp:172
std::uint16_t parentheses
SQL nesting depth used to identify COPY header direction.
Definition document_highlight.hpp:157
bool escaped
Next E-string scalar is escaped.
Definition document_highlight.hpp:161
std::uint8_t wordLength
Retained ASCII keyword characters.
Definition document_highlight.hpp:143
std::array< TokenRun, 8 > queue
Constant-capacity classified output staging.
Definition document_highlight.hpp:134
bool copyAwaitLine
Header semicolon was seen; next newline begins literal data.
Definition document_highlight.hpp:174
std::array< DecodedScalar, 2 > suffix
Pending numeric dot or exponent/sign.
Definition document_highlight.hpp:142
bool sqlFence
Current fence delegates its body to the same SQL scanner.
Definition document_highlight.hpp:164
std::uint8_t delimiterLength
Retained SQL tag characters or Markdown delimiter length.
Definition document_highlight.hpp:144
bool capturing
SQL output is currently speculative fence-close output.
Definition document_highlight.hpp:167
std::uint8_t infoLength
Retained fence info word length; excess is unknown/plain.
Definition document_highlight.hpp:156
std::uint8_t dollarMatch
Matched closing dollar delimiter prefix length.
Definition document_highlight.hpp:145
DocumentHighlighterOptions options
Immutable policy for this scanner generation.
Definition document_highlight.hpp:130