Token type definitions and classification utilities. More...
Typedefs | |
typedef enum tokcat_e | tokcat_e |
typedef enum tok_e | tok_e |
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. | |
Token type definitions and classification utilities.
This group contains all enums and functions related to:
enum tok_e |
Token type enumeration for categorizing various types of tokens during lexical analysis.
This enumeration defines the different types of tokens that can be encountered during the tokenization phase of source code parsing. Each token type corresponds to a specific element or construct in the source code, such as keywords, operators, punctuation, literals, and identifiers.
enum tokcat_e |
Token category enumeration for categorizing different token types in the pre-processing phase.
This enumeration represents the different categories of tokens that are encountered during the lexical analysis or tokenization process. The token categories include preprocessor directives, symbols, literals, and numerical literals (including floating-point numbers, keywords, and identifiers).
Determines the specific token type from a given token string and its category.
This function maps a token string and its broader token category (from tokcat_e
) to a specific token type (from tok_e
). It internally uses helper functions to check the nature of the token based on its string value.
Depending on the token category, it checks the token string against known operators, punctuation, literals, keywords, and identifiers.
value | The token string to be classified. |
type | The general category of the token, given as a tokcat_e value. |
tok_e
. Returns INVALID_IDENTIFIER
if no match is found. const char * toktyp_rval | ( | const tok_e | type | ) |
Returns a string representation of a token type.
This function takes a token type from the tok_e
enumeration and returns its corresponding human-readable string name. It's primarily used for debugging, logging, or displaying token types in a user-friendly format.
type | The token type (of enum tok_e ) whose string representation is to be retrieved. |