Reduct  v1.0.4-3-gdaf0d70
A functional and immutable language.
Loading...
Searching...
No Matches
Characters

Detailed Description

Lookup tables are used to reduce branching and improve performance when parsing and processing characters.

Data Structures

struct  reduct_char_info_t
 
struct  reduct_char_info
 Character information. More...
 

Macros

#define REDUCT_CHAR_FLAGS(_c)   (reductCharTable[(unsigned char)(_c)].flags)
 Get the character flags for a given character.
 
#define REDUCT_CHAR_TO_LOWER(_c)   (reductCharTable[(unsigned char)(_c)].lower)
 Get the lowercase equivalent of a character.
 
#define REDUCT_CHAR_TO_UPPER(_c)   (reductCharTable[(unsigned char)(_c)].upper)
 Get the uppercase equivalent of a character.
 
#define REDUCT_CHAR_IS_WHITESPACE(_c)   (REDUCT_CHAR_FLAGS(_c) & REDUCT_CHAR_WHITESPACE)
 Check if a character is whitespace.
 
#define REDUCT_CHAR_IS_LETTER(_c)   (REDUCT_CHAR_FLAGS(_c) & REDUCT_CHAR_LETTER)
 Check if a character is a letter.
 
#define REDUCT_CHAR_IS_DIGIT(_c)   (REDUCT_CHAR_FLAGS(_c) & REDUCT_CHAR_DIGIT)
 Check if a character is a decimal digit.
 
#define REDUCT_CHAR_IS_SYMBOL(_c)   (REDUCT_CHAR_FLAGS(_c) & REDUCT_CHAR_SYMBOL)
 Check if a character is a symbol.
 
#define REDUCT_CHAR_IS_HEX_DIGIT(_c)   (REDUCT_CHAR_FLAGS(_c) & REDUCT_CHAR_HEX_DIGIT)
 Check if a character is a hexidecimal digit.
 

Enumerations

enum  reduct_char_flags_t {
  REDUCT_CHAR_LETTER = (1 << 0) , REDUCT_CHAR_DIGIT = (1 << 1) , REDUCT_CHAR_SYMBOL = (1 << 2) , REDUCT_CHAR_WHITESPACE = (1 << 3) ,
  REDUCT_CHAR_HEX_DIGIT = (1 << 4)
}
 Character classification flags. More...
 

Variables

reduct_char_info_t reductCharTable [256]
 Global character lookup table.
 

Macro Definition Documentation

◆ REDUCT_CHAR_FLAGS

#define REDUCT_CHAR_FLAGS (   _c)    (reductCharTable[(unsigned char)(_c)].flags)

Get the character flags for a given character.

Parameters
_cThe character to get flags for.
Returns
The character flags.

Definition at line 54 of file char.h.

◆ REDUCT_CHAR_TO_LOWER

#define REDUCT_CHAR_TO_LOWER (   _c)    (reductCharTable[(unsigned char)(_c)].lower)

Get the lowercase equivalent of a character.

Parameters
_cThe character to get the lowercase equivalent of.
Returns
The lowercase equivalent of the character.

Definition at line 62 of file char.h.

◆ REDUCT_CHAR_TO_UPPER

#define REDUCT_CHAR_TO_UPPER (   _c)    (reductCharTable[(unsigned char)(_c)].upper)

Get the uppercase equivalent of a character.

Parameters
_cThe character to get the uppercase equivalent of.
Returns
The uppercase equivalent of the character.

Definition at line 70 of file char.h.

◆ REDUCT_CHAR_IS_WHITESPACE

#define REDUCT_CHAR_IS_WHITESPACE (   _c)    (REDUCT_CHAR_FLAGS(_c) & REDUCT_CHAR_WHITESPACE)

Check if a character is whitespace.

Parameters
_cThe character to check.
Returns
REDUCT_TRUE if the character is whitespace, REDUCT_FALSE otherwise.

Definition at line 78 of file char.h.

◆ REDUCT_CHAR_IS_LETTER

#define REDUCT_CHAR_IS_LETTER (   _c)    (REDUCT_CHAR_FLAGS(_c) & REDUCT_CHAR_LETTER)

Check if a character is a letter.

Parameters
_cThe character to check.
Returns
REDUCT_TRUE if the character is a letter, REDUCT_FALSE otherwise.

Definition at line 86 of file char.h.

◆ REDUCT_CHAR_IS_DIGIT

#define REDUCT_CHAR_IS_DIGIT (   _c)    (REDUCT_CHAR_FLAGS(_c) & REDUCT_CHAR_DIGIT)

Check if a character is a decimal digit.

Parameters
_cThe character to check.
Returns
REDUCT_TRUE if the character is a decimal digit, REDUCT_FALSE otherwise.

Definition at line 94 of file char.h.

◆ REDUCT_CHAR_IS_SYMBOL

#define REDUCT_CHAR_IS_SYMBOL (   _c)    (REDUCT_CHAR_FLAGS(_c) & REDUCT_CHAR_SYMBOL)

Check if a character is a symbol.

Parameters
_cThe character to check.
Returns
REDUCT_TRUE if the character is a symbol, REDUCT_FALSE otherwise.

Definition at line 102 of file char.h.

◆ REDUCT_CHAR_IS_HEX_DIGIT

#define REDUCT_CHAR_IS_HEX_DIGIT (   _c)    (REDUCT_CHAR_FLAGS(_c) & REDUCT_CHAR_HEX_DIGIT)

Check if a character is a hexidecimal digit.

Parameters
_cThe character to check.
Returns
REDUCT_TRUE if the character is a hexidecimal digit, REDUCT_FALSE otherwise.

Definition at line 110 of file char.h.

Enumeration Type Documentation

◆ reduct_char_flags_t

Character classification flags.

Follows the grammar defined in the README.

Enumerator
REDUCT_CHAR_LETTER 

Is a letter.

REDUCT_CHAR_DIGIT 

Is a decimal digit.

REDUCT_CHAR_SYMBOL 

Is a symbol.

REDUCT_CHAR_WHITESPACE 

Is whitespace.

REDUCT_CHAR_HEX_DIGIT 

Is a hexidecimal digit.

Definition at line 20 of file char.h.

Variable Documentation

◆ reductCharTable

reduct_char_info_t reductCharTable[256]
extern

Global character lookup table.

Definition at line 6 of file char_impl.h.