Lexical Analyzer v0.1.0
 
Loading...
Searching...
No Matches
lexer.h File Reference

Lexical analyzer components for token processing. More...

#include "lexer_validation.h"

Go to the source code of this file.

Classes

struct  tok_t
 Container for token data and metadata. More...
 
struct  tokset_t
 Container for multiple tokens. More...
 

Typedefs

typedef enum tokcat_e tokcat_e
 
typedef enum tok_e tok_e
 
typedef struct tok_t tok_t
 
typedef struct tokset_t tokset_t
 

Enumerations

enum  tokcat_e { PRE_PROC , SYMBOLS , LITERAL , NFKI_LITERAL }
 Token category enumeration for categorizing different token types in the pre-processing phase. More...
 
enum  tok_e {
  KEYWORD , OPERATOR , PUNCTUATION , NUMERIC_LITERAL ,
  FLOATING_POINT_LITERAL , CHARACTER_LITERAL , STRING_LITERAL , INVALID_IDENTIFIER ,
  IDENTIFIER , PRE_PROCESSOR_OPERATOR
}
 Token type enumeration for categorizing various types of tokens during lexical analysis. More...
 

Functions

const char * toktyp_rval (const tok_e type)
 Returns a string representation of a token type.
 
tok_e get_toktyp (const char *const value, const tokcat_e type)
 Determines the specific token type from a given token string and its category.
 
tok_ttok_ctor ()
 Allocates and returns a new token object.
 
tok_t ** tok_nctor (const size_t n)
 Allocates and returns an array of token objects.
 
tok_ttok_ptor (char *value, const tok_e type, const size_t line, const size_t col)
 Creates and initializes a token with given values.
 
void tok_dtor (tok_t *tok)
 Frees the memory associated with a token.
 
void printf_tok (const tok_t *const tok)
 Prints the contents of a token to the standard output.
 
bool fwrite_tok (FILE *fp, const tok_t *const tok)
 Writes the contents of a token to a file.
 
tokset_ttokset_ctor ()
 Allocates and returns a new token set object.
 
tokset_ttokset_ptor (const size_t toksz)
 Creates and initializes a token set with a specified number of tokens.
 
void tokset_dtor (tokset_t *set)
 Frees the memory associated with a token set.
 
size_t cnt_toktyp (const tokset_t *const set, const tok_e type)
 Counts the number of tokens of a specific type in a token set.
 
void printf_tokset (const tokset_t *const set)
 Prints the contents of a token set to the standard output.
 
bool fwrite_tokset (FILE *fp, const tokset_t *const set)
 Writes the contents of a token set to a file.
 

Detailed Description

Lexical analyzer components for token processing.