Try to match a single-character token. Returns TOK_EOF if not matched. */
| 250 | |
| 251 | /* Try to match a single-character token. Returns TOK_EOF if not matched. */ |
| 252 | static cbm_token_type_t lex_single_char(char c) { |
| 253 | switch (c) { |
| 254 | case '(': |
| 255 | return TOK_LPAREN; |
| 256 | case ')': |
| 257 | return TOK_RPAREN; |
| 258 | case '[': |
| 259 | return TOK_LBRACKET; |
| 260 | case ']': |
| 261 | return TOK_RBRACKET; |
| 262 | case '-': |
| 263 | return TOK_DASH; |
| 264 | case '>': |
| 265 | return TOK_GT; |
| 266 | case '<': |
| 267 | return TOK_LT; |
| 268 | case ':': |
| 269 | return TOK_COLON; |
| 270 | case '.': |
| 271 | return TOK_DOT; |
| 272 | case '{': |
| 273 | return TOK_LBRACE; |
| 274 | case '}': |
| 275 | return TOK_RBRACE; |
| 276 | case '*': |
| 277 | return TOK_STAR; |
| 278 | case ',': |
| 279 | return TOK_COMMA; |
| 280 | case '=': |
| 281 | return TOK_EQ; |
| 282 | case '|': |
| 283 | return TOK_PIPE; |
| 284 | default: |
| 285 | return TOK_EOF; |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | /* Try to lex an identifier or keyword starting at position i. Returns true if matched. */ |
| 290 | static bool lex_try_ident(const char *input, int len, int *i, cbm_lex_result_t *out) { |