Module parser

Module parser 

Source
Expand description

Statement parser for cqlsh-rs.

Handles multi-line input buffering, semicolon-terminated statement detection, comment stripping, string literal handling, and routing between CQL statements and built-in shell commands.

Key design decisions (from SP4 and SP16 upstream fixes):

  • Context-aware tokenization: NO regex preprocessing for comments (PR #150)
  • Truly incremental parsing: O(n) total work via scan_offset tracking (PR #151)

StructsΒ§

StatementParser
Incremental statement parser.

EnumsΒ§

InputKind
Classification of a parsed input line.
LexState πŸ”’
Lexer context states for tracking position within CQL input.
ParseResult
The result of feeding a line to the parser.

ConstantsΒ§

SHELL_COMMANDS πŸ”’
Built-in shell commands that don’t require a semicolon terminator.

FunctionsΒ§

classify_input
Classify a complete input as a shell command, CQL statement, or empty.
decode_char_at πŸ”’
Decode the char at byte offset i in s, returning the char and its UTF-8 byte length.
ends_with_apply_batch πŸ”’
Return true if text ends with the APPLY BATCH token pair.
is_shell_command
Check if the first line of input looks like a shell command.
parse_batch
Parse a complete input string (e.g., from -e or -f batch mode) into individual statements.
starts_with_begin_batch πŸ”’
Return true if text is the opening of a CQL BATCH block.
strip_comments πŸ”’
Strip comments from a CQL fragment (used on extracted statements).