librdesc
Loading...
Searching...
No Matches
Classes | Functions
exblex.h File Reference

Basic lexer, used for testing. More...

#include "../../src/common.h"
#include <ctype.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for exblex.h:

Go to the source code of this file.

Classes

struct  exblex
 EXtremely Basic LEXer. More...
 

Functions

static void exblex_init (struct exblex *l, const char *buf, const char *tokens)
 Initializes the basic lexer with a null-terminated list of chars.
 
static char * exblex_current_seminfo (struct exblex *l)
 Retrieves the semantic information for the last token.
 
static uint16_t exblex_next (struct exblex *l)
 Fetches the next token.
 

Detailed Description

Basic lexer, used for testing.

Function Documentation

◆ exblex_current_seminfo()

static char * exblex_current_seminfo ( struct exblex l)
inlinestatic

Retrieves the semantic information for the last token.

Returns
Pointer to token text (for 'w' and 'd' tokens), or NULL for punctuation tokens.
Note
Caller takes ownership of returned pointer, and must free() after use.

◆ exblex_init()

static void exblex_init ( struct exblex l,
const char *  buf,
const char *  tokens 
)
inlinestatic

Initializes the basic lexer with a null-terminated list of chars.

Warning
Identifier 0 is reserved in exblex. First element of tokens (index 0) should be null-character, as it is reserved.
See also
struct exblex for details.

◆ exblex_next()

static uint16_t exblex_next ( struct exblex l)
inlinestatic

Fetches the next token.

Returns
Token ID:
  • 0 for EOF/end of input
  • Index into tokens[] array for the matched character or class
Note
For 'w' (word) and 'd' (digit) tokens, retrieve the matched text using exblex_current_seminfo.