diff --git a/4coder_API.html b/4coder_API.html index 9e2a1697..d21b5613 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -192,107 +192,109 @@ will be replaced into the buffer.
view_id
If this is not a null summary, this field is the id of the associated view. If this is a null summary then view_id is 0.
buffer_id
If this is not a null summary, then this is the id of the buffer this view currently sees.
lock_flags
If this is not a null summary, this field contains flags describing the protection status of the view.
cursor
If this is not a null summary, this describes the position of the cursor.
mark
If this is not a null summary, this describes the position of the mark.
preferred_x
If this is not a null summary, this is the x position that is maintained in vertical navigation.
line_height
If this is not a null summary, this specifies the height of a line rendered in the view.
unwrapped_lines
If this is not a null summary, this indicates that the view is set to render with unwrapped lines.
show_whitespace
If this is not a null summary, this indicates that the view is set to highlight white space.
file_region
If this is not a null summary, this describes the screen position in which this view's buffer is displayed.
scroll_vars
If this is not a null summary, this describes the scrolling position inside the view.
See Also
Access_Flag
Full_Cursor

§3.4.40: User_Input

struct User_Input {
User_Input_Type_ID type;
bool32 abort;
union {
Key_Event_Data key;
Mouse_State mouse;
};
Generic_Command command;
};
Description
User_Input describes a user input event which can be either a key press or mouse event.
Fields
type
This field specifies whether the event was a key press or mouse event.
abort
This field indicates that an abort event has occurred and the command needs to shut down.
key
This field describes a key press event.
mouse
This field describes a mouse input event.
command
If this event would trigger a command, this field specifies what the command would be.
See Also
User_Input_Type_ID
Generic_Command

§3.4.41: Query_Bar

struct Query_Bar {
String prompt;
String string;
};
Description
Query_Bar is a struct used to store information in the user's control that will be displayed as a drop down bar durring an interactive command.
Fields
prompt
This specifies the prompt portion of the drop down bar.
string
This specifies the main string portion of the drop down bar.

§3.4.42: Event_Message

struct Event_Message {
int32_t type;
};
Description
This feature is not implemented.
Fields
type
This feature is not implemented.

§3.4.43: Theme_Color

struct Theme_Color {
Style_Tag tag;
int_color color;
};
Description
Theme_Color stores a style tag/color pair, for the purpose of setting and getting colors in the theme .
Fields
tag
color
See Also
Style_Tag
int_color

-

§4 String Library

§4.1 String Intro

Coming Soon

§4.2 String Function List

§4.3 String Function Descriptions

§4.3.1: char_is_slash

fstr_bool char_is_slash(
char c
)
Description
This call returns non-zero if c is \ or /.

§4.3.2: char_to_upper

char char_to_upper(
char c
)
Description
If c is a lowercase letter this call returns the uppercase equivalent, otherwise it returns c.

§4.3.3: char_to_lower

char char_to_lower(
char c
)
Description
If c is an uppercase letter this call returns the lowercase equivalent, otherwise it returns c.

§4.3.4: char_is_whitespace

fstr_bool char_is_whitespace(
char c
)
Description
This call returns non-zero if c is whitespace.

§4.3.5: char_is_alpha_numeric

fstr_bool char_is_alpha_numeric(
char c
)
Description
This call returns non-zero if c is any alphanumeric character including underscore.

§4.3.6: char_is_alpha_numeric_true

fstr_bool char_is_alpha_numeric_true(
char c
)
Description
This call returns non-zero if c is any alphanumeric character no including underscore.

§4.3.7: char_is_alpha

fstr_bool char_is_alpha(
char c
)
Description
This call returns non-zero if c is any alphabetic character including underscore.

§4.3.8: char_is_alpha_true

fstr_bool char_is_alpha_true(
char c
)
Description
This call returns non-zero if c is any alphabetic character.

§4.3.9: char_is_hex

fstr_bool char_is_hex(
char c
)
Description
This call returns non-zero if c is any valid hexadecimal digit.

§4.3.10: char_is_numeric

fstr_bool char_is_numeric(
char c
)
Description
This call returns non-zero if c is any valid decimal digit.

§4.3.11: make_string_cap

String make_string_cap(
void *str,
int32_t size,
int32_t mem_size
)
Parameters
str
The str parameter provides the of memory with which the string shall operate.
size
The size parameter expresses the initial size of the string. -If the memory does not already contain a useful string this should be zero.
mem_size
The mem_size parameter expresses the full size of the memory provided by str.
Description
This call returns the String created from the parameters.

§4.3.12: make_string

String make_string(
void *str,
int32_t size
)
Parameters
str
The str parameter provides the of memory with which the string shall operate.
size
The size parameter expresses the initial size of the string. +

§4 String Library

§4.1 String Intro

Coming Soon

§4.2 String Function List

§4.3 String Function Descriptions

§4.3.1: char_is_slash

fstr_bool char_is_slash(
char c
)
Description
This call returns non-zero if c is \ or /.

§4.3.2: char_to_upper

char char_to_upper(
char c
)
Description
If c is a lowercase letter this call returns the uppercase equivalent, otherwise it returns c.

§4.3.3: char_to_lower

char char_to_lower(
char c
)
Description
If c is an uppercase letter this call returns the lowercase equivalent, otherwise it returns c.

§4.3.4: char_is_whitespace

fstr_bool char_is_whitespace(
char c
)
Description
This call returns non-zero if c is whitespace.

§4.3.5: char_is_alpha_numeric

fstr_bool char_is_alpha_numeric(
char c
)
Description
This call returns non-zero if c is any alphanumeric character including underscore.

§4.3.6: char_is_alpha_numeric_true

fstr_bool char_is_alpha_numeric_true(
char c
)
Description
This call returns non-zero if c is any alphanumeric character no including underscore.

§4.3.7: char_is_alpha

fstr_bool char_is_alpha(
char c
)
Description
This call returns non-zero if c is any alphabetic character including underscore.

§4.3.8: char_is_alpha_true

fstr_bool char_is_alpha_true(
char c
)
Description
This call returns non-zero if c is any alphabetic character.

§4.3.9: char_is_hex

fstr_bool char_is_hex(
char c
)
Description
This call returns non-zero if c is any valid hexadecimal digit.

§4.3.10: char_is_numeric

fstr_bool char_is_numeric(
char c
)
Description
This call returns non-zero if c is any valid decimal digit.

§4.3.11: make_string_cap

String make_string_cap(
void *str,
int32_t size,
int32_t mem_size
)
Parameters
str
The str parameter provides the of memory with which the string shall operate.
size
The size parameter expresses the initial size of the string. +If the memory does not already contain a useful string this should be zero.
mem_size
The mem_size parameter expresses the full size of the memory provided by str.
Description
This call returns the String created from the parameters.

§4.3.12: make_string

String make_string(
void *str,
int32_t size
)
Parameters
str
The str parameter provides the of memory with which the string shall operate.
size
The size parameter expresses the initial size of the string. If the memory does not already contain a useful string this should be zero. Since this version does not specify the size of the memory it is also assumed that this size is the maximum size of the memory.
Description
This call returns the String created from the parameters.

§4.3.13: make_lit_string

#define make_lit_string(s)
Description
This macro takes a literal string in quotes and uses it to create a String with the correct size and memory size. Strings created this way should usually not be mutated.

§4.3.14: make_fixed_width_string

#define make_fixed_width_string(s)
Description
This macro takes a local char array with a fixed width and uses it to create an empty String with the correct size and memory size to operate on the array.

§4.3.15: expand_str

#define expand_str(s)
Description
This macro is a helper for any calls that take a char*,integer pair to specify a string. This macro expands to both of those parameters from one String struct.

§4.3.16: str_size

int32_t str_size(
char *str
)
Description
This call returns the number of bytes before a null terminator starting at str.

§4.3.17: make_string_slowly

String make_string_slowly(
void *str
)
Description
This call makes a string by counting the number of bytes before a null terminator and -treating that as the size and memory size of the string.

§4.3.18: substr_tail

String substr_tail(
String str,
int32_t start
)
Description
This call creates a substring of str that starts with an offset from str's base. +treating that as the size and memory size of the string.

§4.3.18: substr_tail

String substr_tail(
String str,
int32_t start
)
Description
This call creates a substring of str that starts with an offset from str's base. The new string uses the same underlying memory so both strings will see changes. -Usually strings created this way should only go through immutable calls.

§4.3.19: substr

String substr(
String str,
int32_t start,
int32_t size
)
Description
This call creates a substring of str that starts with an offset from str's base, +Usually strings created this way should only go through immutable calls.

§4.3.19: substr

String substr(
String str,
int32_t start,
int32_t size
)
Description
This call creates a substring of str that starts with an offset from str's base, and has a fixed size. The new string uses the same underlying memory so both strings will see changes. Usually strings created this way should only go through immutable calls.

§4.3.20: skip_whitespace

String skip_whitespace(
String str
)
Description
This call creates a substring that starts with the first non-whitespace character of str. Like other substr calls, the new string uses the underlying memory and so should usually be considered immutable.
See Also

§4.3.21: chop_whitespace

String chop_whitespace(
String str
)
Description
This call creates a substring that ends with the last non-whitespace character of str. Like other substr calls, the new string uses the underlying memory and so should usually be considered immutable.
See Also

§4.3.22: skip_chop_whitespace

String skip_chop_whitespace(
String str
)
Description
This call is equivalent to calling skip_whitespace and chop_whitespace together.
See Also

§4.3.23: tailstr

String tailstr(
String str
)
Description
This call returns an empty String with underlying memory taken from -the portion of str's memory that is not used.

§4.3.24: match_cc

fstr_bool match_cc(
char *a,
char *b
)
Description
This call returns non-zero if a and b are equivalent.

§4.3.25: match_sc

fstr_bool match_sc(
String a,
char *b
)
Description
This call returns non-zero if a and b are equivalent.

§4.3.26: match_cs

fstr_bool match_cs(
char *a,
String b
)
Description
This call returns non-zero if a and b are equivalent.

§4.3.27: match_ss

fstr_bool match_ss(
String a,
String b
)
Description
This call returns non-zero if a and b are equivalent.

§4.3.28: match_part_ccl

fstr_bool match_part_ccl(
char *a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. -In other words this call returns non-zero if b is a prefix of a.

§4.3.29: match_part_scl

fstr_bool match_part_scl(
String a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. +the portion of str's memory that is not used.

§4.3.24: match_cc

fstr_bool match_cc(
char *a,
char *b
)
Description
This call returns non-zero if a and b are equivalent.

§4.3.25: match_sc

fstr_bool match_sc(
String a,
char *b
)
Description
This call returns non-zero if a and b are equivalent.

§4.3.26: match_cs

fstr_bool match_cs(
char *a,
String b
)
Description
This call returns non-zero if a and b are equivalent.

§4.3.27: match_ss

fstr_bool match_ss(
String a,
String b
)
Description
This call returns non-zero if a and b are equivalent.

§4.3.28: match_part_ccl

fstr_bool match_part_ccl(
char *a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. +In other words this call returns non-zero if b is a prefix of a.

§4.3.29: match_part_scl

fstr_bool match_part_scl(
String a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. In other words this call returns non-zero if b is a prefix of a.

§4.3.30: match_part_cc

fstr_bool match_part_cc(
char *a,
char *b
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. In other words this call returns non-zero if b is a prefix of a.

§4.3.31: match_part_sc

fstr_bool match_part_sc(
String a,
char *b
)
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. In other words this call returns non-zero if b is a prefix of a.

§4.3.32: match_part_cs

fstr_bool match_part_cs(
char *a,
String b
)
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. In other words this call returns non-zero if b is a prefix of a.

§4.3.33: match_part_ss

fstr_bool match_part_ss(
String a,
String b
)
Description
This call is similar to a match call, except that it is permitted for a to be longer than b. -In other words this call returns non-zero if b is a prefix of a.

§4.3.34: match_insensitive_cc

fstr_bool match_insensitive_cc(
char *a,
char *b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.

§4.3.35: match_insensitive_sc

fstr_bool match_insensitive_sc(
String a,
char *b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.

§4.3.36: match_insensitive_cs

fstr_bool match_insensitive_cs(
char *a,
String b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.

§4.3.37: match_insensitive_ss

fstr_bool match_insensitive_ss(
String a,
String b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.

§4.3.38: match_part_insensitive_ccl

fstr_bool match_part_insensitive_ccl(
char *a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also

§4.3.39: match_part_insensitive_scl

fstr_bool match_part_insensitive_scl(
String a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also

§4.3.40: match_part_insensitive_cc

fstr_bool match_part_insensitive_cc(
char *a,
char *b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also

§4.3.41: match_part_insensitive_sc

fstr_bool match_part_insensitive_sc(
String a,
char *b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also

§4.3.42: match_part_insensitive_cs

fstr_bool match_part_insensitive_cs(
char *a,
String b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also

§4.3.43: match_part_insensitive_ss

fstr_bool match_part_insensitive_ss(
String a,
String b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also

§4.3.44: compare_cc

int32_t compare_cc(
char *a,
char *b
)
Description
This call returns zero if a and b are equivalent, +In other words this call returns non-zero if b is a prefix of a.

§4.3.34: match_insensitive_cc

fstr_bool match_insensitive_cc(
char *a,
char *b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.

§4.3.35: match_insensitive_sc

fstr_bool match_insensitive_sc(
String a,
char *b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.

§4.3.36: match_insensitive_cs

fstr_bool match_insensitive_cs(
char *a,
String b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.

§4.3.37: match_insensitive_ss

fstr_bool match_insensitive_ss(
String a,
String b
)
Description
This call returns non-zero if a and b are equivalent under case insensitive comparison.

§4.3.38: match_part_insensitive_ccl

fstr_bool match_part_insensitive_ccl(
char *a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also

§4.3.39: match_part_insensitive_scl

fstr_bool match_part_insensitive_scl(
String a,
char *b,
int32_t *len
)
Parameters
len
If this call returns non-zero this parameter is used to output the length of b.
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also

§4.3.40: match_part_insensitive_cc

fstr_bool match_part_insensitive_cc(
char *a,
char *b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also

§4.3.41: match_part_insensitive_sc

fstr_bool match_part_insensitive_sc(
String a,
char *b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also

§4.3.42: match_part_insensitive_cs

fstr_bool match_part_insensitive_cs(
char *a,
String b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also

§4.3.43: match_part_insensitive_ss

fstr_bool match_part_insensitive_ss(
String a,
String b
)
Description
This call performs the same partial matching rule as match_part under case insensitive comparison.
See Also

§4.3.44: compare_cc

int32_t compare_cc(
char *a,
char *b
)
Description
This call returns zero if a and b are equivalent, it returns negative if a sorts before b alphabetically, -and positive if a sorts after b alphabetically.

§4.3.45: compare_sc

int32_t compare_sc(
String a,
char *b
)
Description
This call returns zero if a and b are equivalent, +and positive if a sorts after b alphabetically.

§4.3.45: compare_sc

int32_t compare_sc(
String a,
char *b
)
Description
This call returns zero if a and b are equivalent, it returns negative if a sorts before b alphabetically, and positive if a sorts after b alphabetically.

§4.3.46: compare_cs

int32_t compare_cs(
char *a,
String b
)
Description
This call returns zero if a and b are equivalent, it returns negative if a sorts before b alphabetically, and positive if a sorts after b alphabetically.

§4.3.47: compare_ss

int32_t compare_ss(
String a,
String b
)
Description
This call returns zero if a and b are equivalent, it returns negative if a sorts before b alphabetically, -and positive if a sorts after b alphabetically.

§4.3.48: find_c_char

int32_t find_c_char(
char *str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call returns the index of the first occurance of character, or the size of the string -if the character is not found.

§4.3.49: find_s_char

int32_t find_s_char(
String str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call returns the index of the first occurance of character, or the size of the string -if the character is not found.

§4.3.50: rfind_s_char

int32_t rfind_s_char(
String str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call looks for the largest index less than or equal to the start position where -the given character occurs. If the index is found it is returned otherwise -1 is returned.

§4.3.51: find_c_chars

int32_t find_c_chars(
char *str,
int32_t start,
char *characters
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
character
The characters parameter provides a null terminated array of characters for which to search.
Description
This call returns the index of the first occurance of a character in the characters array, +and positive if a sorts after b alphabetically.

§4.3.48: find_c_char

int32_t find_c_char(
char *str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call returns the index of the first occurance of character, or the size of the string +if the character is not found.

§4.3.49: find_s_char

int32_t find_s_char(
String str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call returns the index of the first occurance of character, or the size of the string +if the character is not found.

§4.3.50: rfind_s_char

int32_t rfind_s_char(
String str,
int32_t start,
char character
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The character parameter provides the character for which to search.
Description
This call looks for the largest index less than or equal to the start position where +the given character occurs. If the index is found it is returned otherwise -1 is returned.

§4.3.51: find_c_chars

int32_t find_c_chars(
char *str,
int32_t start,
char *characters
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
character
The characters parameter provides a null terminated array of characters for which to search.
Description
This call returns the index of the first occurance of a character in the characters array, or the size of the string if no such character is not found.

§4.3.52: find_s_chars

int32_t find_s_chars(
String str,
int32_t start,
char *characters
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
character
The characters parameter provides a null terminated array of characters for which to search.
Description
This call returns the index of the first occurance of a character in the characters array, -or the size of the string if no such character is not found.

§4.3.53: find_substr_c

int32_t find_substr_c(
char *str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the first occurance of the seek substring in str or the -size of str if no such substring in str is found.

§4.3.54: find_substr_s

int32_t find_substr_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the first occurance of the seek substring in str or the -size of str if no such substring in str is found.

§4.3.55: rfind_substr_s

int32_t rfind_substr_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the last occurance of the seek substring in str -or -1 if no such substring in str is found.

§4.3.56: find_substr_insensitive_c

int32_t find_substr_insensitive_c(
char *str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call acts as find_substr under case insensitive comparison.
See Also

§4.3.57: find_substr_insensitive_s

int32_t find_substr_insensitive_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call acts as find_substr under case insensitive comparison.
See Also

§4.3.58: has_substr_c

fstr_bool has_substr_c(
char *s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek.

§4.3.59: has_substr_s

fstr_bool has_substr_s(
String s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek.

§4.3.60: has_substr_insensitive_c

fstr_bool has_substr_insensitive_c(
char *s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek -under case insensitive comparison.

§4.3.61: has_substr_insensitive_s

fstr_bool has_substr_insensitive_s(
String s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek -under case insensitive comparison.

§4.3.62: copy_fast_unsafe_cc

int32_t copy_fast_unsafe_cc(
char *dest,
char *src
)
Description
This call performs a copy from the src buffer to the dest buffer. +or the size of the string if no such character is not found.

§4.3.53: find_substr_c

int32_t find_substr_c(
char *str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the first occurance of the seek substring in str or the +size of str if no such substring in str is found.

§4.3.54: find_substr_s

int32_t find_substr_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the first occurance of the seek substring in str or the +size of str if no such substring in str is found.

§4.3.55: rfind_substr_s

int32_t rfind_substr_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call returns the index of the last occurance of the seek substring in str +or -1 if no such substring in str is found.

§4.3.56: find_substr_insensitive_c

int32_t find_substr_insensitive_c(
char *str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a null terminated string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call acts as find_substr under case insensitive comparison.
See Also

§4.3.57: find_substr_insensitive_s

int32_t find_substr_insensitive_s(
String str,
int32_t start,
String seek
)
Parameters
str
The str parameter provides a string to search.
start
The start parameter provides the index of the first character in str to search.
seek
The seek parameter provides a string to find in str.
Description
This call acts as find_substr under case insensitive comparison.
See Also

§4.3.58: has_substr_c

fstr_bool has_substr_c(
char *s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek.

§4.3.59: has_substr_s

fstr_bool has_substr_s(
String s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek.

§4.3.60: has_substr_insensitive_c

fstr_bool has_substr_insensitive_c(
char *s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek +under case insensitive comparison.

§4.3.61: has_substr_insensitive_s

fstr_bool has_substr_insensitive_s(
String s,
String seek
)
Description
This call returns non-zero if the string s contains a substring equivalent to seek +under case insensitive comparison.

§4.3.62: copy_fast_unsafe_cc

int32_t copy_fast_unsafe_cc(
char *dest,
char *src
)
Description
This call performs a copy from the src buffer to the dest buffer. The copy does not stop until a null terminator is found in src. There is no safety against overrun so dest must be large enough to contain src. The null terminator is not written to dest. This call returns the number -of bytes coppied to dest.

§4.3.63: copy_fast_unsafe_cs

int32_t copy_fast_unsafe_cs(
char *dest,
String src
)
Description
This call performs a copy from the src string to the dest buffer. +of bytes coppied to dest.

§4.3.63: copy_fast_unsafe_cs

int32_t copy_fast_unsafe_cs(
char *dest,
String src
)
Description
This call performs a copy from the src string to the dest buffer. The copy does not stop until src.size characters are coppied. There is no safety against overrun so dest must be large enough to contain src. The null terminator is not written to dest. This call returns the number -of bytes coppied to dest.

§4.3.64: copy_checked_ss

fstr_bool copy_checked_ss(
String *dest,
String src
)
Description
This call performs a copy from the src string to the dest string. +of bytes coppied to dest.

§4.3.64: copy_checked_ss

fstr_bool copy_checked_ss(
String *dest,
String src
)
Description
This call performs a copy from the src string to the dest string. The memory_size of dest is checked before any coppying is done. -This call returns non-zero on a successful copy.

§4.3.65: copy_partial_sc

fstr_bool copy_partial_sc(
String *dest,
char *src
)
Description
This call performs a copy from the src buffer to the dest string. +This call returns non-zero on a successful copy.

§4.3.65: copy_partial_sc

fstr_bool copy_partial_sc(
String *dest,
char *src
)
Description
This call performs a copy from the src buffer to the dest string. The memory_size of dest is checked if the entire copy cannot be performed, as many bytes as possible are coppied to dest. This call returns non-zero -if the entire string is coppied to dest.

§4.3.66: copy_partial_ss

fstr_bool copy_partial_ss(
String *dest,
String src
)
Description
This call performs a copy from the src string to the dest string. +if the entire string is coppied to dest.

§4.3.66: copy_partial_ss

fstr_bool copy_partial_ss(
String *dest,
String src
)
Description
This call performs a copy from the src string to the dest string. The memory_size of dest is checked if the entire copy cannot be performed, as many bytes as possible are coppied to dest. This call returns non-zero -if the entire string is coppied to dest.

§4.3.67: copy_cc

int32_t copy_cc(
char *dest,
char *src
)
Description
This call performs a copy from src to dest equivalent to copy_fast_unsafe.
See Also

§4.3.68: copy_ss

void copy_ss(
String *dest,
String src
)
Description
This call performs a copy from src to dest equivalent to copy_checked.
See Also

§4.3.69: copy_sc

void copy_sc(
String *dest,
char *src
)
Description
This call performs a copy from src to dest equivalent to copy_partial.
See Also

§4.3.70: append_checked_ss

fstr_bool append_checked_ss(
String *dest,
String src
)
Description
This call checks if there is enough space in dest's underlying memory -to append src onto dest. If there is src is appended and the call returns non-zero.

§4.3.71: append_partial_sc

fstr_bool append_partial_sc(
String *dest,
char *src
)
Description
This call attemps to append as much of src into the space in dest's underlying memory -as possible. If the entire string is appended the call returns non-zero.

§4.3.72: append_partial_ss

fstr_bool append_partial_ss(
String *dest,
String src
)
Description
This call attemps to append as much of src into the space in dest's underlying memory -as possible. If the entire string is appended the call returns non-zero.

§4.3.73: append_s_char

fstr_bool append_s_char(
String *dest,
char c
)
Description
This call attemps to append c onto dest. If there is space left in dest's underlying -memory the character is appended and the call returns non-zero.

§4.3.74: append_ss

fstr_bool append_ss(
String *dest,
String src
)
Description
This call is equivalent to append_partial.
See Also

§4.3.75: append_sc

fstr_bool append_sc(
String *dest,
char *src
)
Description
This call is equivalent to append_partial.
See Also

§4.3.76: terminate_with_null

fstr_bool terminate_with_null(
String *str
)
Description
This call attemps to append a null terminator onto str without effecting the +if the entire string is coppied to dest.

§4.3.67: copy_cc

int32_t copy_cc(
char *dest,
char *src
)
Description
This call performs a copy from src to dest equivalent to copy_fast_unsafe.
See Also

§4.3.68: copy_ss

void copy_ss(
String *dest,
String src
)
Description
This call performs a copy from src to dest equivalent to copy_checked.
See Also

§4.3.69: copy_sc

void copy_sc(
String *dest,
char *src
)
Description
This call performs a copy from src to dest equivalent to copy_partial.
See Also

§4.3.70: append_checked_ss

fstr_bool append_checked_ss(
String *dest,
String src
)
Description
This call checks if there is enough space in dest's underlying memory +to append src onto dest. If there is src is appended and the call returns non-zero.

§4.3.71: append_partial_sc

fstr_bool append_partial_sc(
String *dest,
char *src
)
Description
This call attemps to append as much of src into the space in dest's underlying memory +as possible. If the entire string is appended the call returns non-zero.

§4.3.72: append_partial_ss

fstr_bool append_partial_ss(
String *dest,
String src
)
Description
This call attemps to append as much of src into the space in dest's underlying memory +as possible. If the entire string is appended the call returns non-zero.

§4.3.73: append_s_char

fstr_bool append_s_char(
String *dest,
char c
)
Description
This call attemps to append c onto dest. If there is space left in dest's underlying +memory the character is appended and the call returns non-zero.

§4.3.74: append_ss

fstr_bool append_ss(
String *dest,
String src
)
Description
This call is equivalent to append_partial.
See Also

§4.3.75: append_sc

fstr_bool append_sc(
String *dest,
char *src
)
Description
This call is equivalent to append_partial.
See Also

§4.3.76: terminate_with_null

fstr_bool terminate_with_null(
String *str
)
Description
This call attemps to append a null terminator onto str without effecting the size of str. This is usually called when the time comes to pass the the string to an API that requires a null terminator. This call returns non-zero if there was a spare byte in the strings underlying memory.

§4.3.77: append_padding

fstr_bool append_padding(
String *dest,
char c,
int32_t target_size
)
Description
This call pads out dest so that it has a size of target_size by appending the padding character c until the target size is achieved. This call returns -non-zero if dest does not run out of space in the underlying memory.

§4.3.78: replace_char

void replace_char(
String *str,
char replace,
char with
)
Parameters
str
The str parameter provides the string in which replacement shall be performed.
replace
The replace character specifies which character should be replaced.
with
The with character specifies what to write into the positions where replacement occurs.
Description
This call replaces all occurances of character in str with another character.

§4.3.79: to_lower_cc

void to_lower_cc(
char *src,
char *dst
)
Parameters
src
The source string to conver to lowercase. This string must be null terminated.
dst
The destination buffer to receive the converted string. This must be large +non-zero if dest does not run out of space in the underlying memory.

§4.3.78: replace_char

void replace_char(
String *str,
char replace,
char with
)
Parameters
str
The str parameter provides the string in which replacement shall be performed.
replace
The replace character specifies which character should be replaced.
with
The with character specifies what to write into the positions where replacement occurs.
Description
This call replaces all occurances of character in str with another character.

§4.3.79: to_lower_cc

void to_lower_cc(
char *src,
char *dst
)
Parameters
src
The source string to conver to lowercase. This string must be null terminated.
dst
The destination buffer to receive the converted string. This must be large enough to contain all of src and a null terminator.
Description
Rewrites the string in src into dst with all letters lowercased. src and dst should not overlap with the exception that src and dst may be exactly equal in order to convert the -string in place.

§4.3.80: to_lower_ss

void to_lower_ss(
String *dst,
String src
)
Parameters
dst
The destination buffer to receive the converted string. +string in place.

§4.3.80: to_lower_ss

void to_lower_ss(
String *dst,
String src
)
Parameters
dst
The destination buffer to receive the converted string. This must have a capacity of at least the size of src.
src
The source string to conver to lowercase.
Description
Rewrites the string in src into dst. src and dst should not overlap with the exception -that src and dst may be exactly equal in order to convert the string in place.

§4.3.81: to_lower_s

void to_lower_s(
String *str
)
Parameters
str
The string to be converted to all lowercase.
Description
This version of to_lower converts str to lowercase in place.

§4.3.82: to_upper_cc

void to_upper_cc(
char *src,
char *dst
)
Parameters
src
The source string to convert to uppercase. This string must be null terminated.
dst
The destination buffer to receive the converted string. +that src and dst may be exactly equal in order to convert the string in place.

§4.3.81: to_lower_s

void to_lower_s(
String *str
)
Parameters
str
The string to be converted to all lowercase.
Description
This version of to_lower converts str to lowercase in place.

§4.3.82: to_upper_cc

void to_upper_cc(
char *src,
char *dst
)
Parameters
src
The source string to convert to uppercase. This string must be null terminated.
dst
The destination buffer to receive the converted string. This must be large enough to contain all of src and a null terminator.
Description
Rewrites the string in src into dst. src and dst should not overlap with the exception -that src and dst may be exactly equal in order to convert the string in place.

§4.3.83: to_upper_ss

void to_upper_ss(
String *dst,
String src
)
Parameters
dst
The destination buffer to receive the converted string. +that src and dst may be exactly equal in order to convert the string in place.

§4.3.83: to_upper_ss

void to_upper_ss(
String *dst,
String src
)
Parameters
dst
The destination buffer to receive the converted string. This must have a capacity of at least the size of src.
src
The source string to convert to uppercase.
Description
Rewrites the string in src into dst. src and dst should not overlap with the exception -that src and dst may be exactly equal in order to convert the string in place.

§4.3.84: to_upper_s

void to_upper_s(
String *str
)
Parameters
str
The string to be converted to all uppercase.
Description
This version of to_upper converts str to uppercase in place.

§4.3.85: to_camel_cc

void to_camel_cc(
char *src,
char *dst
)
Parameters
src
The source string to convert to camel case.
dst
The destination buffer to receive the converted string. +that src and dst may be exactly equal in order to convert the string in place.

§4.3.84: to_upper_s

void to_upper_s(
String *str
)
Parameters
str
The string to be converted to all uppercase.
Description
This version of to_upper converts str to uppercase in place.

§4.3.85: to_camel_cc

void to_camel_cc(
char *src,
char *dst
)
Parameters
src
The source string to convert to camel case.
dst
The destination buffer to receive the converted string. This must be large enough to contain all of src and a null terminator.
Description
Rewrites the string in src into dst. src and dst should not overlap with the exception that src and dst may be exactly equal in order to -convert the string in place.

§4.3.86: int_to_str_size

int32_t int_to_str_size(
int32_t x
)
Description
This call returns the number of bytes required to represent x as a string.

§4.3.87: int_to_str

fstr_bool int_to_str(
String *dest,
int32_t x
)
Description
This call writes a string representation of x into dest. If there is enough +convert the string in place.

§4.3.86: int_to_str_size

int32_t int_to_str_size(
int32_t x
)
Description
This call returns the number of bytes required to represent x as a string.

§4.3.87: int_to_str

fstr_bool int_to_str(
String *dest,
int32_t x
)
Description
This call writes a string representation of x into dest. If there is enough space in dest this call returns non-zero.

§4.3.88: append_int_to_str

fstr_bool append_int_to_str(
String *dest,
int32_t x
)
Description
This call appends a string representation of x onto dest. If there is enough space in dest this call returns non-zero.

§4.3.89: u64_to_str_size

int32_t u64_to_str_size(
uint64_t x
)
Description
This call returns the number of bytes required to represent x as a string.

§4.3.90: u64_to_str

fstr_bool u64_to_str(
String *dest,
uint64_t x
)
Description
This call writes a string representation of x into dest. If there is enough space in dest this call returns non-zero.

§4.3.91: append_u64_to_str

fstr_bool append_u64_to_str(
String *dest,
uint64_t x
)
Description
This call appends a string representation of x onto dest. If there is enough space in dest this call returns non-zero.

§4.3.92: float_to_str_size

int32_t float_to_str_size(
float x
)
Description
This call returns the number of bytes required to represent x as a string.

§4.3.93: append_float_to_str

fstr_bool append_float_to_str(
String *dest,
float x
)
Description
This call writes a string representation of x into dest. If there is enough space in dest this call returns non-zero.

§4.3.94: float_to_str

fstr_bool float_to_str(
String *dest,
float x
)
Description
This call appends a string representation of x onto dest. If there is enough -space in dest this call returns non-zero.

§4.3.95: str_is_int_c

int32_t str_is_int_c(
char *str
)
Description
If str is a valid string representation of an integer, this call returns non-zero

§4.3.96: str_is_int_s

fstr_bool str_is_int_s(
String str
)
Description
If str is a valid string representation of an integer, this call returns non-zero.

§4.3.97: str_to_int_c

int32_t str_to_int_c(
char *str
)
Description
If str is a valid string representation of an integer, this call will return -the integer represented by the string. Otherwise this call returns zero.

§4.3.98: str_to_int_s

int32_t str_to_int_s(
String str
)
Description
If str represents a valid string representation of an integer, this call will return +space in dest this call returns non-zero.

§4.3.95: str_is_int_c

int32_t str_is_int_c(
char *str
)
Description
If str is a valid string representation of an integer, this call returns non-zero

§4.3.96: str_is_int_s

fstr_bool str_is_int_s(
String str
)
Description
If str is a valid string representation of an integer, this call returns non-zero.

§4.3.97: str_to_int_c

int32_t str_to_int_c(
char *str
)
Description
If str is a valid string representation of an integer, this call will return +the integer represented by the string. Otherwise this call returns zero.

§4.3.98: str_to_int_s

int32_t str_to_int_s(
String str
)
Description
If str represents a valid string representation of an integer, this call will return the integer represented by the string. Otherwise this call returns zero.

§4.3.99: hexchar_to_int

int32_t hexchar_to_int(
char c
)
Description
If c is a valid hexadecimal digit [0-9a-fA-F] this call returns the value of the integer value of the digit. Otherwise the return is some nonsense value.

§4.3.100: int_to_hexchar

char int_to_hexchar(
int32_t x
)
Description
If x is in the range [0,15] this call returns the equivalent lowercase hexadecimal digit. Otherwise the return is some nonsense value.

§4.3.101: hexstr_to_int

uint32_t hexstr_to_int(
String str
)
Description
This call interprets str has a hexadecimal representation of an integer and returns the represented integer value.

§4.3.102: color_to_hexstr

fstr_bool color_to_hexstr(
String *s,
uint32_t color
)
Description
This call fills s with the hexadecimal representation of the color. -If there is enough memory in s to represent the color this call returns non-zero.

§4.3.103: hexstr_to_color

fstr_bool hexstr_to_color(
String s,
uint32_t *out
)
Description
This call interprets s as a color and writes the 32-bit integer representation into out.

§4.3.104: reverse_seek_slash_pos

int32_t reverse_seek_slash_pos(
String str,
int32_t pos
)
Description
This call searches for a slash in str by starting pos bytes from the end and going backwards.

§4.3.105: reverse_seek_slash

int32_t reverse_seek_slash(
String str
)
Description
This call searches for a slash in str by starting at the end and going backwards.

§4.3.106: front_of_directory

String front_of_directory(
String dir
)
Description
This call returns a substring of dir containing only the file name or +If there is enough memory in s to represent the color this call returns non-zero.

§4.3.103: hexstr_to_color

fstr_bool hexstr_to_color(
String s,
uint32_t *out
)
Description
This call interprets s as a color and writes the 32-bit integer representation into out.

§4.3.104: reverse_seek_slash_pos

int32_t reverse_seek_slash_pos(
String str,
int32_t pos
)
Description
This call searches for a slash in str by starting pos bytes from the end and going backwards.

§4.3.105: reverse_seek_slash

int32_t reverse_seek_slash(
String str
)
Description
This call searches for a slash in str by starting at the end and going backwards.

§4.3.106: front_of_directory

String front_of_directory(
String dir
)
Description
This call returns a substring of dir containing only the file name or folder name furthest to the right in the directory.
See Also

§4.3.107: path_of_directory

String path_of_directory(
String dir
)
Description
This call returns a substring of dir containing the whole path except -for the final file or folder name.
See Also

§4.3.108: set_last_folder_sc

fstr_bool set_last_folder_sc(
String *dir,
char *folder_name,
char slash
)
Parameters
dir
The dir parameter is the directory string in which to set the last folder in the directory.
folder_name
The folder_name parameter is a null terminated string specifying the name to set +for the final file or folder name.
See Also

§4.3.108: set_last_folder_sc

fstr_bool set_last_folder_sc(
String *dir,
char *folder_name,
char slash
)
Parameters
dir
The dir parameter is the directory string in which to set the last folder in the directory.
folder_name
The folder_name parameter is a null terminated string specifying the name to set at the end of the directory.
slash
The slash parameter specifies what slash to use between names in the directory.
Description
This call deletes the last file name or folder name in the dir string and appends the new provided one. -If there is enough memory in dir this call returns non-zero.

§4.3.109: set_last_folder_ss

fstr_bool set_last_folder_ss(
String *dir,
String folder_name,
char slash
)
Parameters
dir
The dir parameter is the directory string in which to set the last folder in the directory.
folder_name
The folder_name parameter is a string specifying the name to set at the end of the directory.
slash
The slash parameter specifies what slash to use between names in the directory.
Description
This call deletes the last file name or folder name in the dir string and appends the new provided one. +If there is enough memory in dir this call returns non-zero.

§4.3.109: set_last_folder_ss

fstr_bool set_last_folder_ss(
String *dir,
String folder_name,
char slash
)
Parameters
dir
The dir parameter is the directory string in which to set the last folder in the directory.
folder_name
The folder_name parameter is a string specifying the name to set at the end of the directory.
slash
The slash parameter specifies what slash to use between names in the directory.
Description
This call deletes the last file name or folder name in the dir string and appends the new provided one. If there is enough memory in dir this call returns non-zero.

§4.3.110: file_extension

String file_extension(
String str
)
Description
This call returns a substring containing only the file extension of the provided filename.
See Also

§4.3.111: remove_extension

fstr_bool remove_extension(
String *str
)
Description
This call attemps to delete a file extension off the end of a filename. This call returns non-zero on success.

§4.3.112: remove_last_folder

fstr_bool remove_last_folder(
String *str
)
Description
This call attemps to delete a folder or filename off the end of a path string. -This call returns non-zero on success.

§4.3.113: string_set_match_table

fstr_bool string_set_match_table(
void *str_set,
int32_t item_size,
int32_t count,
String str,
int32_t *match_index
)
Parameters
str_set
The str_set parameter is an array of String structs specifying matchable strings.
count
The count parameter specifies the number of String structs in the str_set array.
str
The str parameter specifies the string to match against the str_set.
match_index
If this call succeeds match_index is filled with the index into str_set where the match occurred.
Description
This call tries to see if str matches any of the strings in str_set. If there is a match the call -succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.
See Also

§4.3.114: string_set_match

fstr_bool string_set_match(
String *str_set,
int32_t count,
String str,
int32_t *match_index
)
Parameters
str_set
The str_set parameter is an array of String structs specifying matchable strings.
count
The count parameter specifies the number of String structs in the str_set array.
str
The str parameter specifies the string to match against the str_set.
match_index
If this call succeeds match_index is filled with the index into str_set where the match occurred.
Description
This call tries to see if str matches any of the strings in str_set. If there is a match the call +This call returns non-zero on success.

§4.3.113: string_set_match_table

fstr_bool string_set_match_table(
void *str_set,
int32_t item_size,
int32_t count,
String str,
int32_t *match_index
)
Parameters
str_set
The str_set parameter may be an array of any type. +It should point at the String in the first element of the array.
count
The item_size parameter should describe the "stride" from one String to the next, in other +words it should be the size of one element of the array.
count
The count parameter specifies the number of elements in the str_set array.
str
The str parameter specifies the string to match against the str_set.
match_index
If this call succeeds match_index is filled with the index into str_set where the match occurred.
Description
This call tries to see if str matches any of the strings in str_set. If there is a match the call +succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.
See Also

§4.3.114: string_set_match

fstr_bool string_set_match(
String *str_set,
int32_t count,
String str,
int32_t *match_index
)
Parameters
str_set
The str_set parameter is an array of String structs specifying matchable strings.
count
The count parameter specifies the number of String structs in the str_set array.
str
The str parameter specifies the string to match against the str_set.
match_index
If this call succeeds match_index is filled with the index into str_set where the match occurred.
Description
This call tries to see if str matches any of the strings in str_set. If there is a match the call succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.
See Also

-

§5 Lexer Library

§5.1 Lexer Intro

Coming Soon

§5.2 Lexer Function List

§5.3 Lexer Types List

§5.4 String Function Descriptions

§5.4.1: sub_match_list

int32_t sub_match_list(
char *chunk,
int32_t size,
String_List list,
int32_t sub_size
)
No documentation generated for this function.

§5.4.2: cpp_get_token

Cpp_Get_Token_Result cpp_get_token(
Cpp_Token_Stack *token_stack,
int32_t pos
)
No documentation generated for this function.

§5.4.3: cpp_shift_token_starts

void cpp_shift_token_starts(
Cpp_Token_Stack *stack,
int32_t from_token_i,
int32_t shift_amount
)
No documentation generated for this function.

§5.4.4: cpp_pp_directive_to_state

Lex_PP_State cpp_pp_directive_to_state(
Cpp_Token_Type type
)
No documentation generated for this function.

§5.4.5: cpp_place_token_nonalloc

int32_t cpp_place_token_nonalloc(
Cpp_Token *out_tokens,
int32_t token_i,
Cpp_Token token
)
No documentation generated for this function.

§5.4.6: cpp_push_token_nonalloc

bool cpp_push_token_nonalloc(
Cpp_Token_Stack *out_tokens,
Cpp_Token token
)
No documentation generated for this function.

§5.4.7: lex_data_init

Lex_Data lex_data_init(
char *tb
)
No documentation generated for this function.

§5.4.8: cpp_lex_nonalloc

int32_t cpp_lex_nonalloc(
Lex_Data *S_ptr,
char *chunk,
int32_t size,
Cpp_Token_Stack *token_stack_out
)
No documentation generated for this function.

§5.4.9: cpp_lex_nonalloc

int32_t cpp_lex_nonalloc(
Lex_Data *S_ptr,
char *chunk,
int32_t size,
Cpp_Token_Stack *token_stack_out,
int32_t max_tokens
)
No documentation generated for this function.

§5.4.10: cpp_lex_size_nonalloc

int32_t cpp_lex_size_nonalloc(
Lex_Data *S_ptr,
char *chunk,
int32_t size,
int32_t full_size,
Cpp_Token_Stack *token_stack_out
)
No documentation generated for this function.

§5.4.11: cpp_lex_size_nonalloc

int32_t cpp_lex_size_nonalloc(
Lex_Data *S_ptr,
char *chunk,
int32_t size,
int32_t full_size,
Cpp_Token_Stack *token_stack_out,
int32_t max_tokens
)
No documentation generated for this function.

§5.4.12: cpp_relex_nonalloc_start

Cpp_Relex_State cpp_relex_nonalloc_start(
char *data,
int32_t size,
Cpp_Token_Stack *stack,
int32_t start,
int32_t end,
int32_t amount,
int32_t tolerance
)
No documentation generated for this function.

§5.4.13: cpp_token_get_pp_state

char cpp_token_get_pp_state(
uint16_t bitfield
)
No documentation generated for this function.

§5.4.14: cpp__get_token

Cpp_Token cpp__get_token(
Cpp_Token_Stack *stack,
Cpp_Token *tokens,
int32_t size,
int32_t index
)
No documentation generated for this function.

§5.4.15: cpp_relex_nonalloc_main

int32_t cpp_relex_nonalloc_main(
Cpp_Relex_State *state,
Cpp_Token_Stack *relex_stack,
int32_t *relex_end,
char *spare
)
No documentation generated for this function.

§5.4.16: cpp_make_token_stack

Cpp_Token_Stack cpp_make_token_stack(
int32_t starting_max
)
No documentation generated for this function.

§5.4.17: cpp_free_token_stack

void cpp_free_token_stack(
Cpp_Token_Stack token_stack
)
No documentation generated for this function.

§5.4.18: cpp_resize_token_stack

void cpp_resize_token_stack(
Cpp_Token_Stack *token_stack,
int32_t new_max
)
No documentation generated for this function.

§5.4.19: cpp_push_token

void cpp_push_token(
Cpp_Token_Stack *token_stack,
Cpp_Token token
)
No documentation generated for this function.

§5.4.20: cpp_lex_file

void cpp_lex_file(
char *data,
int32_t size,
Cpp_Token_Stack *token_stack_out
)
No documentation generated for this function.

§5.5 String Function Descriptions

§5.5.1: Cpp_Token_Type

enum Cpp_Token_Type;
Description
A Cpp_Token_Type classifies a token to make parsing easier. Some types are not +

§5 Lexer Library

§5.1 Lexer Intro

Coming Soon

§5.2 Lexer Function List

§5.3 Lexer Types List

§5.4 Lexer Function Descriptions

§5.4.1: cpp_get_token

Cpp_Get_Token_Result cpp_get_token(
Cpp_Token_Stack *token_stack,
int32_t pos
)
No documentation generated for this function.

§5.4.2: cpp_shift_token_starts

void cpp_shift_token_starts(
Cpp_Token_Stack *stack,
int32_t from_token_i,
int32_t shift_amount
)
No documentation generated for this function.

§5.4.3: cpp_pp_directive_to_state

Lex_PP_State cpp_pp_directive_to_state(
Cpp_Token_Type type
)
No documentation generated for this function.

§5.4.4: cpp_place_token_nonalloc

int32_t cpp_place_token_nonalloc(
Cpp_Token *out_tokens,
int32_t token_i,
Cpp_Token token
)
No documentation generated for this function.

§5.4.5: cpp_push_token_nonalloc

bool cpp_push_token_nonalloc(
Cpp_Token_Stack *out_tokens,
Cpp_Token token
)
No documentation generated for this function.

§5.4.6: lex_data_init

Lex_Data lex_data_init(
char *tb
)
No documentation generated for this function.

§5.4.7: cpp_lex_nonalloc

int32_t cpp_lex_nonalloc(
Lex_Data *S_ptr,
char *chunk,
int32_t size,
Cpp_Token_Stack *token_stack_out
)
No documentation generated for this function.

§5.4.8: cpp_lex_nonalloc

int32_t cpp_lex_nonalloc(
Lex_Data *S_ptr,
char *chunk,
int32_t size,
Cpp_Token_Stack *token_stack_out,
int32_t max_tokens
)
No documentation generated for this function.

§5.4.9: cpp_lex_size_nonalloc

int32_t cpp_lex_size_nonalloc(
Lex_Data *S_ptr,
char *chunk,
int32_t size,
int32_t full_size,
Cpp_Token_Stack *token_stack_out
)
No documentation generated for this function.

§5.4.10: cpp_lex_size_nonalloc

int32_t cpp_lex_size_nonalloc(
Lex_Data *S_ptr,
char *chunk,
int32_t size,
int32_t full_size,
Cpp_Token_Stack *token_stack_out,
int32_t max_tokens
)
No documentation generated for this function.

§5.4.11: cpp_relex_nonalloc_start

Cpp_Relex_State cpp_relex_nonalloc_start(
char *data,
int32_t size,
Cpp_Token_Stack *stack,
int32_t start,
int32_t end,
int32_t amount,
int32_t tolerance
)
No documentation generated for this function.

§5.4.12: cpp_token_get_pp_state

char cpp_token_get_pp_state(
uint16_t bitfield
)
No documentation generated for this function.

§5.4.13: cpp_index_stack

Cpp_Token cpp_index_stack(
Cpp_Token_Stack *stack,
int32_t file_size,
int32_t index
)
No documentation generated for this function.

§5.4.14: cpp_relex_nonalloc_main

int32_t cpp_relex_nonalloc_main(
Cpp_Relex_State *state,
Cpp_Token_Stack *relex_stack,
int32_t *relex_end,
char *spare
)
No documentation generated for this function.

§5.4.15: cpp_make_token_stack

Cpp_Token_Stack cpp_make_token_stack(
int32_t starting_max
)
No documentation generated for this function.

§5.4.16: cpp_free_token_stack

void cpp_free_token_stack(
Cpp_Token_Stack token_stack
)
No documentation generated for this function.

§5.4.17: cpp_resize_token_stack

void cpp_resize_token_stack(
Cpp_Token_Stack *token_stack,
int32_t new_max
)
No documentation generated for this function.

§5.4.18: cpp_push_token

void cpp_push_token(
Cpp_Token_Stack *token_stack,
Cpp_Token token
)
No documentation generated for this function.

§5.4.19: cpp_lex_file

void cpp_lex_file(
char *data,
int32_t size,
Cpp_Token_Stack *token_stack_out
)
No documentation generated for this function.

§5.5 Lexer Type Descriptions

§5.5.1: Cpp_Token_Type

enum Cpp_Token_Type;
Description
A Cpp_Token_Type classifies a token to make parsing easier. Some types are not actually output by the lexer, but exist because parsers will also make use of token types in their own output.
Values
CPP_TOKEN_JUNK
CPP_TOKEN_COMMENT
CPP_PP_INCLUDE
CPP_PP_DEFINE
CPP_PP_UNDEF
CPP_PP_IF
CPP_PP_IFDEF
CPP_PP_IFNDEF
CPP_PP_ELSE
CPP_PP_ELIF
CPP_PP_ENDIF
CPP_PP_ERROR
CPP_PP_IMPORT
CPP_PP_USING
CPP_PP_LINE
CPP_PP_PRAGMA
CPP_PP_STRINGIFY
CPP_PP_CONCAT
CPP_PP_UNKNOWN
CPP_TOKEN_KEY_TYPE
CPP_TOKEN_KEY_MODIFIER
CPP_TOKEN_KEY_QUALIFIER
CPP_TOKEN_KEY_OPERATOR
This type is not stored in token output from the lexer.
CPP_TOKEN_KEY_CONTROL_FLOW
CPP_TOKEN_KEY_CAST
CPP_TOKEN_KEY_TYPE_DECLARATION
CPP_TOKEN_KEY_ACCESS
CPP_TOKEN_KEY_LINKAGE
CPP_TOKEN_KEY_OTHER
CPP_TOKEN_IDENTIFIER
CPP_TOKEN_INTEGER_CONSTANT
CPP_TOKEN_CHARACTER_CONSTANT
CPP_TOKEN_FLOATING_CONSTANT
CPP_TOKEN_STRING_CONSTANT
CPP_TOKEN_BOOLEAN_CONSTANT
CPP_TOKEN_STATIC_ASSERT
CPP_TOKEN_BRACKET_OPEN
CPP_TOKEN_BRACKET_CLOSE
CPP_TOKEN_PARENTHESE_OPEN
CPP_TOKEN_PARENTHESE_CLOSE
CPP_TOKEN_BRACE_OPEN
CPP_TOKEN_BRACE_CLOSE
CPP_TOKEN_SEMICOLON
CPP_TOKEN_ELLIPSIS
CPP_TOKEN_STAR
This is an 'ambiguous' token type because it requires parsing to determine the full nature of the token.
CPP_TOKEN_AMPERSAND
This is an 'ambiguous' token type because it requires diff --git a/4cpp_lexer.h b/4cpp_lexer.h index 7ecd7a77..2d7cd6f6 100644 --- a/4cpp_lexer.h +++ b/4cpp_lexer.h @@ -18,171 +18,130 @@ // TODO(allen): revisit this keyword data declaration system struct String_And_Flag{ - char *str; + String str; uint32_t flags; }; -struct String_List{ - String_And_Flag *data; - int32_t count; +static String_And_Flag preprops[] = { + {make_lit_string("include"), CPP_PP_INCLUDE } , + {make_lit_string("INCLUDE"), CPP_PP_INCLUDE } , + {make_lit_string("ifndef" ), CPP_PP_IFNDEF } , + {make_lit_string("IFNDEF" ), CPP_PP_IFNDEF } , + {make_lit_string("define" ), CPP_PP_DEFINE } , + {make_lit_string("DEFINE" ), CPP_PP_DEFINE } , + {make_lit_string("import" ), CPP_PP_IMPORT } , + {make_lit_string("IMPORT" ), CPP_PP_IMPORT } , + {make_lit_string("pragma" ), CPP_PP_PRAGMA } , + {make_lit_string("PRAGMA" ), CPP_PP_PRAGMA } , + {make_lit_string("undef" ), CPP_PP_UNDEF } , + {make_lit_string("UNDEF" ), CPP_PP_UNDEF } , + {make_lit_string("endif" ), CPP_PP_ENDIF } , + {make_lit_string("ENDIF" ), CPP_PP_ENDIF } , + {make_lit_string("error" ), CPP_PP_ERROR } , + {make_lit_string("ERROR" ), CPP_PP_ERROR } , + {make_lit_string("ifdef" ), CPP_PP_IFDEF } , + {make_lit_string("IFDEF" ), CPP_PP_IFDEF } , + {make_lit_string("using" ), CPP_PP_USING } , + {make_lit_string("USING" ), CPP_PP_USING } , + {make_lit_string("else" ), CPP_PP_ELSE } , + {make_lit_string("ELSE" ), CPP_PP_ELSE } , + {make_lit_string("elif" ), CPP_PP_ELIF } , + {make_lit_string("ELIF" ), CPP_PP_ELIF } , + {make_lit_string("line" ), CPP_PP_LINE } , + {make_lit_string("LINE" ), CPP_PP_LINE } , + {make_lit_string("if" ), CPP_PP_IF } , + {make_lit_string("IF" ), CPP_PP_IF } , }; -#define lexer_string_list(x) {x, (sizeof(x)/sizeof(*(x)))} - -static String_And_Flag preprop_strings[] = { - {"include", CPP_PP_INCLUDE}, - {"INCLUDE", CPP_PP_INCLUDE}, - {"ifndef", CPP_PP_IFNDEF}, - {"IFNDEF", CPP_PP_IFNDEF}, - {"define", CPP_PP_DEFINE}, - {"DEFINE", CPP_PP_DEFINE}, - {"import", CPP_PP_IMPORT}, - {"IMPORT", CPP_PP_IMPORT}, - {"pragma", CPP_PP_PRAGMA}, - {"PRAGMA", CPP_PP_PRAGMA}, - {"undef", CPP_PP_UNDEF}, - {"UNDEF", CPP_PP_UNDEF}, - {"endif", CPP_PP_ENDIF}, - {"ENDIF", CPP_PP_ENDIF}, - {"error", CPP_PP_ERROR}, - {"ERROR", CPP_PP_ERROR}, - {"ifdef", CPP_PP_IFDEF}, - {"IFDEF", CPP_PP_IFDEF}, - {"using", CPP_PP_USING}, - {"USING", CPP_PP_USING}, - {"else", CPP_PP_ELSE}, - {"ELSE", CPP_PP_ELSE}, - {"elif", CPP_PP_ELIF}, - {"ELIF", CPP_PP_ELIF}, - {"line", CPP_PP_LINE}, - {"LINE", CPP_PP_LINE}, - {"if", CPP_PP_IF}, - {"IF", CPP_PP_IF}, +static String_And_Flag keywords[] = { + {make_lit_string("true") , CPP_TOKEN_BOOLEAN_CONSTANT}, + {make_lit_string("false") , CPP_TOKEN_BOOLEAN_CONSTANT}, + + {make_lit_string("and") , CPP_TOKEN_AND}, + {make_lit_string("and_eq") , CPP_TOKEN_ANDEQ}, + {make_lit_string("bitand") , CPP_TOKEN_BIT_AND}, + {make_lit_string("bitor") , CPP_TOKEN_BIT_OR}, + {make_lit_string("or") , CPP_TOKEN_OR}, + {make_lit_string("or_eq") , CPP_TOKEN_OREQ}, + {make_lit_string("sizeof") , CPP_TOKEN_SIZEOF}, + {make_lit_string("alignof") , CPP_TOKEN_ALIGNOF}, + {make_lit_string("decltype") , CPP_TOKEN_DECLTYPE}, + {make_lit_string("throw") , CPP_TOKEN_THROW}, + {make_lit_string("new") , CPP_TOKEN_NEW}, + {make_lit_string("delete") , CPP_TOKEN_DELETE}, + {make_lit_string("xor") , CPP_TOKEN_BIT_XOR}, + {make_lit_string("xor_eq") , CPP_TOKEN_XOREQ}, + {make_lit_string("not") , CPP_TOKEN_NOT}, + {make_lit_string("not_eq") , CPP_TOKEN_NOTEQ}, + {make_lit_string("typeid") , CPP_TOKEN_TYPEID}, + {make_lit_string("compl") , CPP_TOKEN_BIT_NOT}, + + {make_lit_string("void") , CPP_TOKEN_KEY_TYPE}, + {make_lit_string("bool") , CPP_TOKEN_KEY_TYPE}, + {make_lit_string("char") , CPP_TOKEN_KEY_TYPE}, + {make_lit_string("int") , CPP_TOKEN_KEY_TYPE}, + {make_lit_string("float") , CPP_TOKEN_KEY_TYPE}, + {make_lit_string("double") , CPP_TOKEN_KEY_TYPE}, + + {make_lit_string("long") , CPP_TOKEN_KEY_MODIFIER}, + {make_lit_string("short") , CPP_TOKEN_KEY_MODIFIER}, + {make_lit_string("unsigned") , CPP_TOKEN_KEY_MODIFIER}, + + {make_lit_string("const") , CPP_TOKEN_KEY_QUALIFIER}, + {make_lit_string("volatile") , CPP_TOKEN_KEY_QUALIFIER}, + + {make_lit_string("asm") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("break") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("case") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("catch") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("continue") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("default") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("do") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("else") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("for") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("goto") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("if") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("return") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("switch") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("try") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("while") , CPP_TOKEN_KEY_CONTROL_FLOW}, + {make_lit_string("static_assert") , CPP_TOKEN_KEY_CONTROL_FLOW}, + + {make_lit_string("const_cast") , CPP_TOKEN_KEY_CAST}, + {make_lit_string("dynamic_cast") , CPP_TOKEN_KEY_CAST}, + {make_lit_string("reinterpret_cast") , CPP_TOKEN_KEY_CAST}, + {make_lit_string("static_cast") , CPP_TOKEN_KEY_CAST}, + + {make_lit_string("class") , CPP_TOKEN_KEY_TYPE_DECLARATION}, + {make_lit_string("enum") , CPP_TOKEN_KEY_TYPE_DECLARATION}, + {make_lit_string("struct") , CPP_TOKEN_KEY_TYPE_DECLARATION}, + {make_lit_string("typedef") , CPP_TOKEN_KEY_TYPE_DECLARATION}, + {make_lit_string("union") , CPP_TOKEN_KEY_TYPE_DECLARATION}, + {make_lit_string("template") , CPP_TOKEN_KEY_TYPE_DECLARATION}, + {make_lit_string("typename") , CPP_TOKEN_KEY_TYPE_DECLARATION}, + + {make_lit_string("friend") , CPP_TOKEN_KEY_ACCESS}, + {make_lit_string("namespace") , CPP_TOKEN_KEY_ACCESS}, + {make_lit_string("private") , CPP_TOKEN_KEY_ACCESS}, + {make_lit_string("protected") , CPP_TOKEN_KEY_ACCESS}, + {make_lit_string("public") , CPP_TOKEN_KEY_ACCESS}, + {make_lit_string("using") , CPP_TOKEN_KEY_ACCESS}, + + {make_lit_string("extern") , CPP_TOKEN_KEY_LINKAGE}, + {make_lit_string("export") , CPP_TOKEN_KEY_LINKAGE}, + {make_lit_string("inline") , CPP_TOKEN_KEY_LINKAGE}, + {make_lit_string("static") , CPP_TOKEN_KEY_LINKAGE}, + {make_lit_string("virtual") , CPP_TOKEN_KEY_LINKAGE}, + + {make_lit_string("alignas") , CPP_TOKEN_KEY_OTHER}, + {make_lit_string("explicit") , CPP_TOKEN_KEY_OTHER}, + {make_lit_string("noexcept") , CPP_TOKEN_KEY_OTHER}, + {make_lit_string("nullptr") , CPP_TOKEN_KEY_OTHER}, + {make_lit_string("operator") , CPP_TOKEN_KEY_OTHER}, + {make_lit_string("register") , CPP_TOKEN_KEY_OTHER}, + {make_lit_string("this") , CPP_TOKEN_KEY_OTHER}, + {make_lit_string("thread_local") , CPP_TOKEN_KEY_OTHER}, }; -static String_List preprops = lexer_string_list(preprop_strings); - -static String_And_Flag keyword_strings[] = { - {"true", CPP_TOKEN_BOOLEAN_CONSTANT}, - {"false", CPP_TOKEN_BOOLEAN_CONSTANT}, - - {"and", CPP_TOKEN_AND}, - {"and_eq", CPP_TOKEN_ANDEQ}, - {"bitand", CPP_TOKEN_BIT_AND}, - {"bitor", CPP_TOKEN_BIT_OR}, - {"or", CPP_TOKEN_OR}, - {"or_eq", CPP_TOKEN_OREQ}, - {"sizeof", CPP_TOKEN_SIZEOF}, - {"alignof", CPP_TOKEN_ALIGNOF}, - {"decltype", CPP_TOKEN_DECLTYPE}, - {"throw", CPP_TOKEN_THROW}, - {"new", CPP_TOKEN_NEW}, - {"delete", CPP_TOKEN_DELETE}, - {"xor", CPP_TOKEN_BIT_XOR}, - {"xor_eq", CPP_TOKEN_XOREQ}, - {"not", CPP_TOKEN_NOT}, - {"not_eq", CPP_TOKEN_NOTEQ}, - {"typeid", CPP_TOKEN_TYPEID}, - {"compl", CPP_TOKEN_BIT_NOT}, - - {"void", CPP_TOKEN_KEY_TYPE}, - {"bool", CPP_TOKEN_KEY_TYPE}, - {"char", CPP_TOKEN_KEY_TYPE}, - {"int", CPP_TOKEN_KEY_TYPE}, - {"float", CPP_TOKEN_KEY_TYPE}, - {"double", CPP_TOKEN_KEY_TYPE}, - - {"long", CPP_TOKEN_KEY_MODIFIER}, - {"short", CPP_TOKEN_KEY_MODIFIER}, - {"unsigned", CPP_TOKEN_KEY_MODIFIER}, - - {"const", CPP_TOKEN_KEY_QUALIFIER}, - {"volatile", CPP_TOKEN_KEY_QUALIFIER}, - - {"asm", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"break", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"case", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"catch", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"continue", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"default", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"do", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"else", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"for", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"goto", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"if", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"return", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"switch", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"try", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"while", CPP_TOKEN_KEY_CONTROL_FLOW}, - {"static_assert", CPP_TOKEN_KEY_CONTROL_FLOW}, - - {"const_cast", CPP_TOKEN_KEY_CAST}, - {"dynamic_cast", CPP_TOKEN_KEY_CAST}, - {"reinterpret_cast", CPP_TOKEN_KEY_CAST}, - {"static_cast", CPP_TOKEN_KEY_CAST}, - - {"class", CPP_TOKEN_KEY_TYPE_DECLARATION}, - {"enum", CPP_TOKEN_KEY_TYPE_DECLARATION}, - {"struct", CPP_TOKEN_KEY_TYPE_DECLARATION}, - {"typedef", CPP_TOKEN_KEY_TYPE_DECLARATION}, - {"union", CPP_TOKEN_KEY_TYPE_DECLARATION}, - {"template", CPP_TOKEN_KEY_TYPE_DECLARATION}, - {"typename", CPP_TOKEN_KEY_TYPE_DECLARATION}, - - {"friend", CPP_TOKEN_KEY_ACCESS}, - {"namespace", CPP_TOKEN_KEY_ACCESS}, - {"private", CPP_TOKEN_KEY_ACCESS}, - {"protected", CPP_TOKEN_KEY_ACCESS}, - {"public", CPP_TOKEN_KEY_ACCESS}, - {"using", CPP_TOKEN_KEY_ACCESS}, - - {"extern", CPP_TOKEN_KEY_LINKAGE}, - {"export", CPP_TOKEN_KEY_LINKAGE}, - {"inline", CPP_TOKEN_KEY_LINKAGE}, - {"static", CPP_TOKEN_KEY_LINKAGE}, - {"virtual", CPP_TOKEN_KEY_LINKAGE}, - - {"alignas", CPP_TOKEN_KEY_OTHER}, - {"explicit", CPP_TOKEN_KEY_OTHER}, - {"noexcept", CPP_TOKEN_KEY_OTHER}, - {"nullptr", CPP_TOKEN_KEY_OTHER}, - {"operator", CPP_TOKEN_KEY_OTHER}, - {"register", CPP_TOKEN_KEY_OTHER}, - {"this", CPP_TOKEN_KEY_OTHER}, - {"thread_local", CPP_TOKEN_KEY_OTHER}, -}; -static String_List keywords = lexer_string_list(keyword_strings); - -FCPP_LINK int32_t -sub_match_list(char *chunk, int32_t size, String_List list, int32_t sub_size){ - int32_t result = 0; - String str_main = {0}; - char *str_check = 0; - int32_t i = 0, l = 0; - - result = -1; - str_main = make_string(chunk, size); - if (sub_size > 0){ - str_main = substr(str_main, 0, sub_size); - for (i = 0; i < list.count; ++i){ - str_check = list.data[i].str; - if (match_sc(str_main, str_check)){ - result = i; - break; - } - } - } - else{ - for (i = 0; i < list.count; ++i){ - str_check = list.data[i].str; - if (match_part_scl(str_main, str_check, &l)){ - result = i; - break; - } - } - } - - return(result); -} FCPP_LINK Cpp_Get_Token_Result @@ -525,10 +484,12 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, } } - int32_t sub_match = sub_match_list(S.tb, S.tb_pos, keywords, word_size); + int32_t sub_match = -1; + string_set_match_table(keywords, sizeof(*keywords), ArrayCount(keywords), + make_string(S.tb, S.tb_pos), &sub_match); if (sub_match != -1){ - String_And_Flag data = keywords.data[sub_match]; + String_And_Flag data = keywords[sub_match]; S.token.type = (Cpp_Token_Type)data.flags; S.token.flags = CPP_TFLAG_IS_KEYWORD; } @@ -560,7 +521,6 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, { --S.pos; - int32_t word_size = S.pos - S.token_start; int32_t pos = S.tb_pos-1; int32_t i = 1; for (;i < pos; ++i){ @@ -569,10 +529,12 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, } } - int32_t sub_match = sub_match_list(S.tb+i, pos-i, preprops, word_size); + int32_t sub_match = -1; + string_set_match_table(preprops, sizeof(*preprops), ArrayCount(preprops), + make_string(S.tb+i, pos-i), &sub_match); if (sub_match != -1){ - String_And_Flag data = preprops.data[sub_match]; + String_And_Flag data = preprops[sub_match]; S.token.type = (Cpp_Token_Type)data.flags; S.token.flags = CPP_TFLAG_PP_DIRECTIVE; S.pp_state = (unsigned char)cpp_pp_directive_to_state(S.token.type); @@ -1078,19 +1040,19 @@ cpp_token_get_pp_state(uint16_t bitfield){ // TODO(allen): Eliminate this once we actually store the EOF token // in the token stack. FCPP_LINK Cpp_Token -cpp__get_token(Cpp_Token_Stack *stack, Cpp_Token *tokens, int32_t size, int32_t index){ +cpp_index_stack(Cpp_Token_Stack *stack, int32_t file_size, int32_t index){ Cpp_Token result; if (index < stack->count){ - result = tokens[index]; + result = stack->tokens[index]; } else{ - result.start = size; + result.start = file_size; result.size = 0; result.type = CPP_TOKEN_EOF; result.flags = 0; result.state_flags = 0; } - return result; + return(result); } FCPP_LINK int32_t @@ -1108,7 +1070,7 @@ cpp_relex_nonalloc_main(Cpp_Relex_State *state, lex.pos = state->relex_start; int32_t relex_end_i = state->end_token_i; - Cpp_Token match_token = cpp__get_token(stack, tokens, state->size, relex_end_i); + Cpp_Token match_token = cpp_index_stack(stack, state->size, relex_end_i); Cpp_Token end_token = match_token; int32_t went_too_far = false; @@ -1135,7 +1097,7 @@ cpp_relex_nonalloc_main(Cpp_Relex_State *state, while (lex.pos > end_token.start && relex_end_i < stack->count){ ++relex_end_i; - end_token = cpp__get_token(stack, tokens, state->size, relex_end_i); + end_token = cpp_index_stack(stack, state->size, relex_end_i); } } break; diff --git a/4ed_metagen.cpp b/4ed_metagen.cpp index 55ea8701..416bfc28 100644 --- a/4ed_metagen.cpp +++ b/4ed_metagen.cpp @@ -426,6 +426,11 @@ typedef struct Meta_Keywords{ Item_Type type; } Meta_Keywords; +typedef struct Used_Links{ + String *strs; + int32_t count, max; +} Used_Links; + static Item_Node null_item_node = {0}; static String @@ -1551,9 +1556,7 @@ compile_meta_unit(Partition *part, char **files, int32_t file_count, ++unit.set.count; } else{ - // TODO(allen): Convert this to a duff's routine and return - // this result to the user so that they may do whatever it - // is they want to do. + // TODO(allen): Warning } } } @@ -1672,6 +1675,28 @@ compile_meta_unit(Partition *part, char **files, int32_t file_count, return(unit); } +static void +init_used_links(Partition *part, Used_Links *used, int32_t count){ + used->strs = push_array(part, String, count); + used->count = 0; + used->max = count; +} + +static int32_t +try_to_use(Used_Links *used, String str){ + int32_t result = 1; + int32_t index = 0; + + if (string_set_match(used->strs, used->count, str, &index)){ + result = 0; + } + else{ + used->strs[used->count++] = str; + } + + return(result); +} + static void print_struct_html(String *out, Item_Node *member){ String name = member->name; @@ -1701,7 +1726,9 @@ print_struct_html(String *out, Item_Node *member){ } static void -print_function_html(String *out, String ret, char *function_call_head, String name, Argument_Breakdown breakdown){ +print_function_html(String *out, Used_Links *used, String cpp_name, + String ret, char *function_call_head, String name, Argument_Breakdown breakdown){ + append_ss (out, ret); append_s_char (out, ' '); append_sc (out, function_call_head); @@ -1961,8 +1988,8 @@ print_item_in_list(String *out, String name, char *id_postfix){ } static void -print_item(String *out, Partition *part, Item_Node *item, - char *id_postfix, char *function_prefix, +print_item(String *out, Partition *part, Used_Links *used, + Item_Node *item, char *id_postfix, char *function_prefix, char *section, int32_t I){ Temp_Memory temp = begin_temp_memory(part); @@ -1977,6 +2004,17 @@ print_item(String *out, Partition *part, Item_Node *item, append_sc(out, id_postfix); append_sc(out, "' style='margin-bottom: 1cm;'>"); + int32_t has_cpp_name = 0; + if (item->cpp_name.str != 0){ + if (try_to_use(used, item->cpp_name)){ + append_sc(out, "
"); + has_cpp_name = 1; + } + } + append_sc (out, "

§"); append_sc (out, section); append_s_char (out, '.'); @@ -1992,7 +2030,8 @@ print_item(String *out, Partition *part, Item_Node *item, { // NOTE(allen): Code box Assert(function_prefix != 0); - print_function_html(out, item->ret, function_prefix, item->name, item->breakdown); + print_function_html(out, used, item->cpp_name, + item->ret, function_prefix, item->name, item->breakdown); // NOTE(allen): Close the code box append_sc(out, "

"); @@ -2139,6 +2178,10 @@ print_item(String *out, Partition *part, Item_Node *item, }break; } + if (has_cpp_name){ + append_sc(out, "
"); + } + // NOTE(allen): Close the item box append_sc(out, "

"); @@ -2573,6 +2616,9 @@ generate_custom_headers(){ if (begin_file_out(&context, API_DOC, &out)){ + Used_Links used_links = {0}; + init_used_links(part, &used_links, 4000); + append_sc(&out, "" "" @@ -2730,7 +2776,7 @@ generate_custom_headers(){ append_ss (&out, name); append_sc (&out, "
"); - print_function_html(&out, item->ret, "app->", name, item->breakdown); + print_function_html(&out, &used_links, item->cpp_name, item->ret, "app->", name, item->breakdown); append_sc(&out, "
"); print_function_docs(&out, part, name, item->doc_string); @@ -2745,7 +2791,7 @@ generate_custom_headers(){ int32_t I = 1; for (int32_t i = 0; i < unit.set.count; ++i, ++I){ - print_item(&out, part, unit.set.items + i, "_doc", 0, SECTION, I); + print_item(&out, part, &used_links, unit.set.items + i, "_doc", 0, SECTION, I); } #undef MAJOR_SECTION @@ -2781,7 +2827,7 @@ generate_custom_headers(){ append_sc(&out, "

§"SECTION" String Function Descriptions

"); for (int32_t i = 0; i < string_unit.set.count; ++i){ - print_item(&out, part, string_unit.set.items+i, "_doc", "", SECTION, i+1); + print_item(&out, part, &used_links, string_unit.set.items+i, "_doc", "", SECTION, i+1); } #undef MAJOR_SECTION @@ -2827,7 +2873,7 @@ generate_custom_headers(){ append_sc(&out, "

§"SECTION" Lexer Function Descriptions

"); for (int32_t i = 0; i < lexer_funcs_unit.set.count; ++i){ - print_item(&out, part, lexer_funcs_unit.set.items+i, "_doc", "", SECTION, i+1); + print_item(&out, part, &used_links, lexer_funcs_unit.set.items+i, "_doc", "", SECTION, i+1); } #undef SECTION @@ -2835,7 +2881,7 @@ generate_custom_headers(){ append_sc(&out, "

§"SECTION" Lexer Type Descriptions

"); for (int32_t i = 0; i < lexer_types_unit.set.count; ++i){ - print_item(&out, part, lexer_types_unit.set.items+i, "_doc", "", SECTION, i+1); + print_item(&out, part, &used_links, lexer_types_unit.set.items+i, "_doc", "", SECTION, i+1); } diff --git a/build.c b/build.c index 3d2ae4ef..4255b113 100644 --- a/build.c +++ b/build.c @@ -63,14 +63,15 @@ static char cmd[4096]; static int32_t error_state = 0; +static int32_t prev_error = 0; #define systemf(...) do{ \ int32_t n = snprintf(cmd, sizeof(cmd), __VA_ARGS__); \ assert(n < sizeof(cmd)); \ - if (system(cmd) != 0) error_state = 1; \ + prev_error = system(cmd); \ + if (prev_error != 0) error_state = 1; \ }while(0) - static void init_time_system(); static uint64_t get_time(); static int32_t get_current_directory(char *buffer, int32_t max); @@ -653,7 +654,7 @@ fsm_generator(char *cdir){ END_TIME_SECTION("build fsm generator"); } - { + if (prev_error == 0){ BEGIN_TIME_SECTION(); execute(cdir, META_DIR"/fsmgen"); END_TIME_SECTION("run fsm generator"); @@ -669,7 +670,7 @@ metagen(char *cdir){ END_TIME_SECTION("build metagen"); } - { + if (prev_error == 0){ BEGIN_TIME_SECTION(); execute(cdir, META_DIR"/metagen"); END_TIME_SECTION("run metagen"); @@ -715,9 +716,9 @@ standard_build(char *cdir, uint32_t flags){ metagen(cdir); - do_buildsuper(cdir); + //do_buildsuper(cdir); - build_main(cdir, flags); + //build_main(cdir, flags); } #define PACK_DIR "../distributions" diff --git a/internal_4coder_string.cpp b/internal_4coder_string.cpp index 12bbff9b..fd24b4b3 100644 --- a/internal_4coder_string.cpp +++ b/internal_4coder_string.cpp @@ -1744,8 +1744,11 @@ This call returns non-zero on success.) */{ CPP_NAME(string_set_match) FSTRING_LINK fstr_bool string_set_match_table(void *str_set, int32_t item_size, int32_t count, String str, int32_t *match_index)/* -DOC_PARAM(str_set, The str_set parameter is an array of String structs specifying matchable strings.) -DOC_PARAM(count, The count parameter specifies the number of String structs in the str_set array.) +DOC_PARAM(str_set, The str_set parameter may be an array of any type. +It should point at the String in the first element of the array.) +DOC_PARAM(count, The item_size parameter should describe the "stride" from one String to the next, in other +words it should be the size of one element of the array.) +DOC_PARAM(count, The count parameter specifies the number of elements in the str_set array.) DOC_PARAM(str, The str parameter specifies the string to match against the str_set.) DOC_PARAM(match_index, If this call succeeds match_index is filled with the index into str_set where the match occurred.) DOC(This call tries to see if str matches any of the strings in str_set. If there is a match the call