apoCHARMM 1.0.0
High-performance molecular dynamics simulations on GPUs
 
Loading...
Searching...
No Matches
SelectionTokenizer Class Reference

Converts atom-selection expression bytes into owned parser tokens. More...

#include <SelectionTokenizer.h>

Static Public Member Functions

static std::vector< SelectionTokentokenize (const std::string_view selectionString)
 Tokenizes one atom-selection expression.
 

Detailed Description

Converts atom-selection expression bytes into owned parser tokens.

The tokenizer is stateless and operates synchronously on the calling host thread. It skips whitespace, recognizes parentheses and range separators, classifies supported dotted operators and bare keywords without regard to ASCII letter case, and appends exactly one SelectionTokenType::End token. Every nonterminal token owns a copy of its source spelling.

The tokenizer performs no PSF access, CUDA operation, transfer, stream work, or synchronization. It provides no internal locking, but independent calls share no mutable state.

See also
atom_selection

Member Function Documentation

◆ tokenize()

static std::vector< SelectionToken > SelectionTokenizer::tokenize ( const std::string_view  selectionString)
static

Tokenizes one atom-selection expression.

Source positions are zero-based byte offsets. The current implementation stores them in int, so expressions longer than INT_MAX bytes cannot preserve positions reliably.

Parameters
[in]selectionStringBorrowed expression view. The referenced bytes need not be null-terminated and are not retained. Embedded control bytes, including \0, are rejected unless classified as whitespace by the C locale.
Returns
A newly owned token vector in source order followed by one terminal token whose position is selectionString.size() after narrowing to int.
Exceptions
ApoCharmmErrorWith ApoCharmmErrorCode::InvalidArgument for an unterminated or unknown dotted operator, or for an unexpected source byte.
std::bad_allocIf token, text, or diagnostic allocation fails.
std::length_errorIf a token vector, token string, or diagnostic exceeds an implementation-defined limit.
Postcondition
The input bytes are unchanged and no reference to them is retained.
Warning
The implementation does not reject source lengths greater than INT_MAX before narrowing token positions.