MCPcopy Create free account
hub / github.com/PRQL/prql / token

Function token

prqlc/prqlc-parser/src/lexer/mod.rs:157–176  ·  view source on GitHub ↗

Parse individual token kinds

()

Source from the content-addressed store, hash-verified

155
156/// Parse individual token kinds
157fn token<'a>() -> impl Parser<'a, ParserInput<'a>, TokenKind, ParserError<'a>> {
158 // Main token parser for all tokens
159 // Strategic .boxed() calls reduce compile times for complex parsers with minimal runtime cost
160 choice((
161 line_wrap().boxed(), // Line continuation with backslash (complex recursive)
162 newline().to(TokenKind::NewLine), // Newline characters
163 multi_char_operators(), // Multi-character operators (==, !=, etc.)
164 interpolation().boxed(), // String interpolation (complex nested parsing)
165 param(), // Parameters ($name)
166 // Date literals must come before @ handling for annotations
167 date_token().boxed(), // Date literals (complex with multiple branches)
168 // Special handling for @ annotations - must come after date_token
169 just('@').to(TokenKind::Annotate), // @ annotation marker
170 one_of("></%=+-*[]().,:|!{}").map(TokenKind::Control), // Single-character controls
171 literal().map(TokenKind::Literal).boxed(), // Literals (complex with many branches)
172 keyword(), // Keywords (let, func, etc.)
173 ident_part().map(TokenKind::Ident), // Identifiers
174 comment(), // Comments (# and #!)
175 ))
176}
177
178fn multi_char_operators<'a>() -> impl Parser<'a, ParserInput<'a>, TokenKind, ParserError<'a>> {
179 choice((

Callers 1

lex_tokenFunction · 0.85

Calls 12

newlineFunction · 0.85
multi_char_operatorsFunction · 0.85
paramFunction · 0.85
date_tokenFunction · 0.85
literalFunction · 0.85
toMethod · 0.80
mapMethod · 0.80
line_wrapFunction · 0.70
interpolationFunction · 0.70
keywordFunction · 0.70
ident_partFunction · 0.70
commentFunction · 0.70

Tested by

no test coverage detected