Parse individual token kinds
()
| 155 | |
| 156 | /// Parse individual token kinds |
| 157 | fn 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 | |
| 178 | fn multi_char_operators<'a>() -> impl Parser<'a, ParserInput<'a>, TokenKind, ParserError<'a>> { |
| 179 | choice(( |
no test coverage detected