isocline
Character Classes.

Convenience functions for character classes, highlighting and completion. More...

Functions

long ic_prev_char (const char *s, long pos)
 Convenience: return the position of a previous code point in a UTF-8 string s from postion pos. More...
 
long ic_next_char (const char *s, long pos)
 Convenience: return the position of the next code point in a UTF-8 string s from postion pos. More...
 
bool ic_starts_with (const char *s, const char *prefix)
 Convenience: does a string s starts with a given prefix ? More...
 
bool ic_istarts_with (const char *s, const char *prefix)
 Convenience: does a string s starts with a given prefix ignoring (ascii) case? More...
 
bool ic_char_is_white (const char *s, long len)
 Convenience: character class for whitespace [ \t\r\n]. More...
 
bool ic_char_is_nonwhite (const char *s, long len)
 Convenience: character class for non-whitespace [^ \t\r\n]. More...
 
bool ic_char_is_separator (const char *s, long len)
 Convenience: character class for separators. More...
 
bool ic_char_is_nonseparator (const char *s, long len)
 Convenience: character class for non-separators. More...
 
bool ic_char_is_letter (const char *s, long len)
 Convenience: character class for letters ([A-Za-z] and any unicode > 0x80). More...
 
bool ic_char_is_digit (const char *s, long len)
 Convenience: character class for digits ([0-9]). More...
 
bool ic_char_is_hexdigit (const char *s, long len)
 Convenience: character class for hexadecimal digits ([A-Fa-f0-9]). More...
 
bool ic_char_is_idletter (const char *s, long len)
 Convenience: character class for identifier letters ([A-Za-z0-9_-] and any unicode > 0x80). More...
 
bool ic_char_is_filename_letter (const char *s, long len)
 Convenience: character class for filename letters (not in " \t\r\n`@$><=;|&\{\}\‍(\‍)\[\]]"). More...
 
long ic_is_token (const char *s, long pos, ic_is_char_class_fun_t *is_token_char)
 Convenience: If this is a token start, return the length. Otherwise return 0. More...
 
long ic_match_token (const char *s, long pos, ic_is_char_class_fun_t *is_token_char, const char *token)
 Convenience: Does this match the specified token? Ensures not to match prefixes or suffixes, and returns the length of the match (in bytes). More...
 
long ic_match_any_token (const char *s, long pos, ic_is_char_class_fun_t *is_token_char, const char **tokens)
 Convenience: Do any of the specified tokens match? Ensures not to match prefixes or suffixes, and returns the length of the match (in bytes). More...
 

Detailed Description

Convenience functions for character classes, highlighting and completion.

Function Documentation

◆ ic_char_is_digit()

bool ic_char_is_digit ( const char *  s,
long  len 
)

Convenience: character class for digits ([0-9]).

◆ ic_char_is_filename_letter()

bool ic_char_is_filename_letter ( const char *  s,
long  len 
)

Convenience: character class for filename letters (not in " \t\r\n`@$><=;|&\{\}\‍(\‍)\[\]]").

◆ ic_char_is_hexdigit()

bool ic_char_is_hexdigit ( const char *  s,
long  len 
)

Convenience: character class for hexadecimal digits ([A-Fa-f0-9]).

◆ ic_char_is_idletter()

bool ic_char_is_idletter ( const char *  s,
long  len 
)

Convenience: character class for identifier letters ([A-Za-z0-9_-] and any unicode > 0x80).

◆ ic_char_is_letter()

bool ic_char_is_letter ( const char *  s,
long  len 
)

Convenience: character class for letters ([A-Za-z] and any unicode > 0x80).

◆ ic_char_is_nonseparator()

bool ic_char_is_nonseparator ( const char *  s,
long  len 
)

Convenience: character class for non-separators.

◆ ic_char_is_nonwhite()

bool ic_char_is_nonwhite ( const char *  s,
long  len 
)

Convenience: character class for non-whitespace [^ \t\r\n].

◆ ic_char_is_separator()

bool ic_char_is_separator ( const char *  s,
long  len 
)

Convenience: character class for separators.

([ \t\r\n,.;:/\\(){}\[\]].) This is used for word boundaries in isocline.

◆ ic_char_is_white()

bool ic_char_is_white ( const char *  s,
long  len 
)

Convenience: character class for whitespace [ \t\r\n].

◆ ic_is_token()

long ic_is_token ( const char *  s,
long  pos,
ic_is_char_class_fun_t is_token_char 
)

Convenience: If this is a token start, return the length. Otherwise return 0.

◆ ic_istarts_with()

bool ic_istarts_with ( const char *  s,
const char *  prefix 
)

Convenience: does a string s starts with a given prefix ignoring (ascii) case?

◆ ic_match_any_token()

long ic_match_any_token ( const char *  s,
long  pos,
ic_is_char_class_fun_t is_token_char,
const char **  tokens 
)

Convenience: Do any of the specified tokens match? Ensures not to match prefixes or suffixes, and returns the length of the match (in bytes).

E.g. ic_match_any_token("function",0,&ic_char_is_letter,{"fun","func",NULL}) returns 0. while ic_match_any_token("func x",0,&ic_char_is_letter,{"fun","func",NULL}) returns 4.

◆ ic_match_token()

long ic_match_token ( const char *  s,
long  pos,
ic_is_char_class_fun_t is_token_char,
const char *  token 
)

Convenience: Does this match the specified token? Ensures not to match prefixes or suffixes, and returns the length of the match (in bytes).

E.g. ic_match_token("function",0,&ic_char_is_letter,"fun") returns 0. while ic_match_token("fun x",0,&ic_char_is_letter,"fun"}) returns 3.

◆ ic_next_char()

long ic_next_char ( const char *  s,
long  pos 
)

Convenience: return the position of the next code point in a UTF-8 string s from postion pos.

Returns -1 if pos < 0 or pos >= strlen(s) (or other errors).

◆ ic_prev_char()

long ic_prev_char ( const char *  s,
long  pos 
)

Convenience: return the position of a previous code point in a UTF-8 string s from postion pos.

Returns -1 if pos <= 0 or pos > strlen(s) (or other errors).

◆ ic_starts_with()

bool ic_starts_with ( const char *  s,
const char *  prefix 
)

Convenience: does a string s starts with a given prefix ?