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