From bc7d5589455b582890d8e54a326e0ea24e1f7786 Mon Sep 17 00:00:00 2001 From: Allen Webster Date: Mon, 5 Sep 2016 11:44:19 -0400 Subject: [PATCH] lexer doc section setup --- 4coder_API.html | 209 +++++++++++---------- 4cpp_clear_config.h | 54 ------ 4cpp_lexer.h | 37 +--- 4cpp_lexer_fsms.h | 12 +- 4coder_lexer_types.h => 4cpp_lexer_types.h | 0 4cpp_preprocessor.cpp | 19 -- 4ed_metagen.cpp | 103 ++++++++-- build.c | 4 +- fsm_table_generator.cpp | 2 +- 9 files changed, 205 insertions(+), 235 deletions(-) delete mode 100644 4cpp_clear_config.h rename 4coder_lexer_types.h => 4cpp_lexer_types.h (100%) delete mode 100644 4cpp_preprocessor.cpp diff --git a/4coder_API.html b/4coder_API.html index e25f2cd5..9e2a1697 100644 --- a/4coder_API.html +++ b/4coder_API.html @@ -1,8 +1,8 @@ 4coder API Docs -

4coder API

Table of Contents

+

4coder API

Table of Contents

§1 Introduction

This is the documentation for alpha 4.0.11 The documentation is still under construction so some of the links are linking to sections that have not been written yet. What is here should be correct and I suspect useful even without some of the other sections.

If you have questions or discover errors please contact editor@4coder.net or to get help from community members you can post on the 4coder forums hosted on handmade.network at 4coder.handmade.network

§2 4coder Systems

Coming Soon
-

§3 Types and Functions

§3.1 Function List

§3.2 Type List

§3.3 Function Descriptions

§3.3.1: exec_command

bool32 app->exec_command(
Application_Links *app,
Command_ID command_id
)
Parameters
command_id
The command_id parameter specifies which internal command to execute.
Return
This call returns non-zero if command_id named a valid internal command.
Description
A call to exec_command executes an internal command. +

§3 Types and Functions

§3.1 Function List

§3.2 Type List

§3.3 Function Descriptions

§3.3.1: exec_command

bool32 app->exec_command(
Application_Links *app,
Command_ID command_id
)
Parameters
command_id
The command_id parameter specifies which internal command to execute.
Return
This call returns non-zero if command_id named a valid internal command.
Description
A call to exec_command executes an internal command. If command_id is invalid a warning is posted to *messages*.
See Also

§3.3.2: exec_system_command

bool32 app->exec_system_command(
Application_Links *app,
View_Summary *view,
Buffer_Identifier buffer,
char *path,
int32_t path_len,
char *command,
int32_t command_len,
Command_Line_Input_Flag flags
)
Parameters
view
If the view parameter is non-null it specifies a view to display the command's output buffer.
buffer
The buffer the command will output to is specified by the buffer parameter. See Buffer_Identifier for information on how this type specifies a buffer.
path
The path parameter specifies the path in which the command shall be executed. The string need not be null terminated.
path_len
The parameter path_len specifies the length of the path string.
command
The command parameter specifies the command that shall be executed. The string need not be null terminated.
command_len
The parameter command_len specifies the length of the command string.
flags
Flags for the behavior of the call are specified in the flags parameter.
Return
This call returns non-zero on success.
Description
A call to exec_system_command executes a command as if called from the command line, and sends the output to a buffer. The buffer identifier can either name a new buffer that does not exist, name a buffer that does @@ -191,7 +191,108 @@ will be replaced into the buffer.
lock_flags
If this is not a null summary, this field contains flags describing the protection status of the buffer.
size
If this is not a null summary, this field specifies the size of the text in the buffer.
line_count
If this is not a null summary, this field specifies the number of lines in the buffer.
file_name
If this is not a null summary, this field specifies the file name associated to this buffer.
file_name_len
This field specifies the length of the file_name string.
buffer_name
If this is not a null summary, this field specifies the name of the buffer.
buffer_name_len
This field specifies the length of the buffer_name string.
is_lexed
If this is not a null summary, this field indicates whether the buffer is set to lex tokens.
map_id
If this is not a null summary, this field specifies the id of the command map for this buffer.
unwrapped_lines
If this is not a null summary, this field indicates whether the buffer 'prefers' wrapped lines.
See Also

§3.4.39: View_Summary

struct View_Summary {
bool32 exists;
int32_t view_id;
int32_t buffer_id;
Access_Flag lock_flags;
Full_Cursor cursor;
Full_Cursor mark;
float preferred_x;
float line_height;
bool32 unwrapped_lines;
bool32 show_whitespace;
i32_Rect file_region;
GUI_Scroll_Vars scroll_vars;
};
Description
View_Summary acts as a handle to a view and describes the state of the view.
Fields
exists
This field indicates whether the View_Summary describes a view that is open in 4coder. When this field is false the summary is referred to as a "null summary".
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

§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

§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

§3.4.44: Cpp_Token_Type

enum Cpp_Token_Type;
Description
A Cpp_Token_Type classifies a token to make parsing easier. Some types are not +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

+

§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. +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, +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. +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, +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, +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, +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. +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. +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. +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. +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. +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 +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 +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. +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. +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. +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. +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 +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 +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 +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 +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 +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 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 @@ -200,104 +301,4 @@ types in their own output.
CPP_TOKEN_MINUS
This is an 'ambiguous' token type because it requires parsing to determine the full nature of the token.
CPP_TOKEN_INCREMENT
This is an 'ambiguous' token type because it requires parsing to determine the full nature of the token.
CPP_TOKEN_DECREMENT
This is an 'ambiguous' token type because it requires - parsing to determine the full nature of the token.
CPP_TOKEN_SCOPE
CPP_TOKEN_POSTINC
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_POSTDEC
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_FUNC_STYLE_CAST
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_CPP_STYLE_CAST
CPP_TOKEN_CALL
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_INDEX
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DOT
CPP_TOKEN_ARROW
CPP_TOKEN_PREINC
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_PREDEC
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_POSITIVE
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_NEGAITVE
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_NOT
CPP_TOKEN_BIT_NOT
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_CAST
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DEREF
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_TYPE_PTR
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_ADDRESS
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_TYPE_REF
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_SIZEOF
CPP_TOKEN_ALIGNOF
CPP_TOKEN_DECLTYPE
CPP_TOKEN_TYPEID
CPP_TOKEN_NEW
CPP_TOKEN_DELETE
CPP_TOKEN_NEW_ARRAY
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DELETE_ARRAY
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_PTRDOT
CPP_TOKEN_PTRARROW
CPP_TOKEN_MUL
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DIV
CPP_TOKEN_MOD
CPP_TOKEN_ADD
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_SUB
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_LSHIFT
CPP_TOKEN_RSHIFT
CPP_TOKEN_LESS
CPP_TOKEN_GRTR
CPP_TOKEN_GRTREQ
CPP_TOKEN_LESSEQ
CPP_TOKEN_EQEQ
CPP_TOKEN_NOTEQ
CPP_TOKEN_BIT_AND
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_BIT_XOR
CPP_TOKEN_BIT_OR
CPP_TOKEN_AND
CPP_TOKEN_OR
CPP_TOKEN_TERNARY_QMARK
CPP_TOKEN_COLON
CPP_TOKEN_THROW
CPP_TOKEN_EQ
CPP_TOKEN_ADDEQ
CPP_TOKEN_SUBEQ
CPP_TOKEN_MULEQ
CPP_TOKEN_DIVEQ
CPP_TOKEN_MODEQ
CPP_TOKEN_LSHIFTEQ
CPP_TOKEN_RSHIFTEQ
CPP_TOKEN_ANDEQ
CPP_TOKEN_OREQ
CPP_TOKEN_XOREQ
CPP_TOKEN_COMMA
CPP_TOKEN_DEFINED
CPP_TOKEN_INCLUDE_FILE
CPP_TOKEN_ERROR_MESSAGE
CPP_TOKEN_EOF
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_TYPE_COUNT

§3.4.45: Cpp_Token

struct Cpp_Token {
Cpp_Token_Type type;
int32_t start, size;
uint16_t state_flags;
uint16_t flags;
};
Fields
type
size
state_flags
flags

§3.4.46: Cpp_Token_Flag

enum Cpp_Token_Flag;
Values
CPP_TFLAG_IGNORE = 0x1
CPP_TFLAG_PP_DIRECTIVE = 0x2
CPP_TFLAG_PP_BODY = 0x4
CPP_TFLAG_BAD_ENDING = 0x8
CPP_TFLAG_MULTILINE = 0x10
CPP_TFLAG_PARAMETERIZED = 0x20
CPP_TFLAG_IS_OPERATOR = 0x40
CPP_TFLAG_IS_KEYWORD = 0x80

§3.4.47: Cpp_Preprocessor_State

enum Cpp_Preprocessor_State;
Values
CPP_LEX_PP_DEFAULT
CPP_LEX_PP_IDENTIFIER
CPP_LEX_PP_MACRO_IDENTIFIER
CPP_LEX_PP_INCLUDE
CPP_LEX_PP_BODY
CPP_LEX_PP_BODY_IF
CPP_LEX_PP_NUMBER
CPP_LEX_PP_ERROR
CPP_LEX_PP_JUNK
CPP_LEX_PP_COUNT

§3.4.48: Cpp_Token_Stack

struct Cpp_Token_Stack {
Cpp_Token * tokens;
int32_t count, max_count;
};
Fields
tokens
max_count

§3.4.49: Cpp_Get_Token_Result

struct Cpp_Get_Token_Result {
int32_t token_index;
int32_t in_whitespace;
};
Fields
token_index
in_whitespace

§3.4.50: Cpp_Relex_State

struct Cpp_Relex_State {
char * data;
int32_t size;
Cpp_Token_Stack * stack;
int32_t start, end, amount;
int32_t start_token_i;
int32_t end_token_i;
int32_t relex_start;
int32_t tolerance;
int32_t space_request;
};
Fields
data
size
stack
amount
start_token_i
end_token_i
relex_start
tolerance
space_request

-

§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. -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, -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. -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, -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, -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, -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. -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. -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. -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. -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. -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 -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 -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. -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. -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. -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. -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 -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 -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 -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 -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 -succeeds and returns non-zero. The matching rule is equivalent to the matching rule for match.
See Also

\ No newline at end of file + parsing to determine the full nature of the token.
CPP_TOKEN_SCOPE
CPP_TOKEN_POSTINC
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_POSTDEC
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_FUNC_STYLE_CAST
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_CPP_STYLE_CAST
CPP_TOKEN_CALL
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_INDEX
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DOT
CPP_TOKEN_ARROW
CPP_TOKEN_PREINC
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_PREDEC
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_POSITIVE
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_NEGAITVE
This token is for parser use, it is not output by the lexer.
CPP_TOKEN_NOT
CPP_TOKEN_BIT_NOT
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_CAST
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DEREF
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_TYPE_PTR
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_ADDRESS
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_TYPE_REF
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_SIZEOF
CPP_TOKEN_ALIGNOF
CPP_TOKEN_DECLTYPE
CPP_TOKEN_TYPEID
CPP_TOKEN_NEW
CPP_TOKEN_DELETE
CPP_TOKEN_NEW_ARRAY
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DELETE_ARRAY
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_PTRDOT
CPP_TOKEN_PTRARROW
CPP_TOKEN_MUL
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_DIV
CPP_TOKEN_MOD
CPP_TOKEN_ADD
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_SUB
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_LSHIFT
CPP_TOKEN_RSHIFT
CPP_TOKEN_LESS
CPP_TOKEN_GRTR
CPP_TOKEN_GRTREQ
CPP_TOKEN_LESSEQ
CPP_TOKEN_EQEQ
CPP_TOKEN_NOTEQ
CPP_TOKEN_BIT_AND
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_BIT_XOR
CPP_TOKEN_BIT_OR
CPP_TOKEN_AND
CPP_TOKEN_OR
CPP_TOKEN_TERNARY_QMARK
CPP_TOKEN_COLON
CPP_TOKEN_THROW
CPP_TOKEN_EQ
CPP_TOKEN_ADDEQ
CPP_TOKEN_SUBEQ
CPP_TOKEN_MULEQ
CPP_TOKEN_DIVEQ
CPP_TOKEN_MODEQ
CPP_TOKEN_LSHIFTEQ
CPP_TOKEN_RSHIFTEQ
CPP_TOKEN_ANDEQ
CPP_TOKEN_OREQ
CPP_TOKEN_XOREQ
CPP_TOKEN_COMMA
CPP_TOKEN_DEFINED
CPP_TOKEN_INCLUDE_FILE
CPP_TOKEN_ERROR_MESSAGE
CPP_TOKEN_EOF
This type is for parser use, it is not output by the lexer.
CPP_TOKEN_TYPE_COUNT

§5.5.2: Cpp_Token

struct Cpp_Token {
Cpp_Token_Type type;
int32_t start, size;
uint16_t state_flags;
uint16_t flags;
};
Fields
type
size
state_flags
flags

§5.5.3: Cpp_Token_Flag

enum Cpp_Token_Flag;
Values
CPP_TFLAG_IGNORE = 0x1
CPP_TFLAG_PP_DIRECTIVE = 0x2
CPP_TFLAG_PP_BODY = 0x4
CPP_TFLAG_BAD_ENDING = 0x8
CPP_TFLAG_MULTILINE = 0x10
CPP_TFLAG_PARAMETERIZED = 0x20
CPP_TFLAG_IS_OPERATOR = 0x40
CPP_TFLAG_IS_KEYWORD = 0x80

§5.5.4: Cpp_Preprocessor_State

enum Cpp_Preprocessor_State;
Values
CPP_LEX_PP_DEFAULT
CPP_LEX_PP_IDENTIFIER
CPP_LEX_PP_MACRO_IDENTIFIER
CPP_LEX_PP_INCLUDE
CPP_LEX_PP_BODY
CPP_LEX_PP_BODY_IF
CPP_LEX_PP_NUMBER
CPP_LEX_PP_ERROR
CPP_LEX_PP_JUNK
CPP_LEX_PP_COUNT

§5.5.5: Cpp_Token_Stack

struct Cpp_Token_Stack {
Cpp_Token * tokens;
int32_t count, max_count;
};
Fields
tokens
max_count

§5.5.6: Cpp_Get_Token_Result

struct Cpp_Get_Token_Result {
int32_t token_index;
int32_t in_whitespace;
};
Fields
token_index
in_whitespace

§5.5.7: Cpp_Relex_State

struct Cpp_Relex_State {
char * data;
int32_t size;
Cpp_Token_Stack * stack;
int32_t start, end, amount;
int32_t start_token_i;
int32_t end_token_i;
int32_t relex_start;
int32_t tolerance;
int32_t space_request;
};
Fields
data
size
stack
amount
start_token_i
end_token_i
relex_start
tolerance
space_request

\ No newline at end of file diff --git a/4cpp_clear_config.h b/4cpp_clear_config.h deleted file mode 100644 index 248652eb..00000000 --- a/4cpp_clear_config.h +++ /dev/null @@ -1,54 +0,0 @@ -/* "4cpp" Open C++ Parser v0.1: Clear Config - no warranty implied; use at your own risk - -NOTES ON USE: - This file is used to clear options. The main use for this is for cases when you want - it include different portions of the library with different settings. So that the compiler - does not complain about redifintion, and so that you do not have to undef everything yourself - this is provided to undef everything at once. -*/ - -#ifdef FCPP_NO_CRT -#undef FCPP_NO_CRT -#endif - -#ifdef FCPP_NO_MALLOC -#undef FCPP_NO_MALLOC -#endif - -#ifdef FCPP_NO_ASSERT -#undef FCPP_NO_ASSERT -#endif - -#ifdef FCPP_NO_STRING -#undef FCPP_NO_STRING -#endif - -#ifdef FCPP_GET_MEMORY -#undef FCPP_GET_MEMORY -#endif - -#ifdef FCPP_FREE_MEMORY -#undef FCPP_FREE_MEMORY -#endif - -#ifdef FCPP_ASSERT -#undef FCPP_ASSERT -#endif - -#ifdef FCPP_MEM_COPY -#undef FCPP_MEM_COPY -#endif - -#ifdef FCPP_MEM_MOVE -#undef FCPP_MEM_MOVE -#endif - -#ifdef FCPP_LINK -#undef FCPP_LINK -#endif - -#ifdef FCPP_EXTERN -#undef FCPP_EXTERN -#endif - diff --git a/4cpp_lexer.h b/4cpp_lexer.h index 0f29a128..7ecd7a77 100644 --- a/4cpp_lexer.h +++ b/4cpp_lexer.h @@ -12,7 +12,7 @@ # define FCPP_LINK static #endif -#include "4coder_lexer_types.h" +#include "4cpp_lexer_types.h" #include "4cpp_lexer_fsms.h" #include "4cpp_lexer_tables.c" @@ -297,48 +297,15 @@ cpp_pp_directive_to_state(Cpp_Token_Type type){ return(result); } -#if 0 -FCPP_LINK Cpp_Token_Merge -cpp_attempt_token_merge(Cpp_Token prev_token, Cpp_Token next_token){ - Cpp_Token_Merge result = {(Cpp_Token_Type)0}; - if (next_token.type == CPP_TOKEN_COMMENT && prev_token.type == CPP_TOKEN_COMMENT && - next_token.flags == prev_token.flags && next_token.state_flags == prev_token.state_flags){ - result.did_merge = 1; - prev_token.size = next_token.start + next_token.size - prev_token.start; - result.new_token = prev_token; - } - else if (next_token.type == CPP_TOKEN_JUNK && prev_token.type == CPP_TOKEN_JUNK && - next_token.flags == prev_token.flags && next_token.state_flags == prev_token.state_flags){ - result.did_merge = 1; - prev_token.size = next_token.start + next_token.size - prev_token.start; - result.new_token = prev_token; - } - return(result); -} -#endif - FCPP_LINK int32_t cpp_place_token_nonalloc(Cpp_Token *out_tokens, int32_t token_i, Cpp_Token token){ - //Cpp_Token_Merge merge = {(Cpp_Token_Type)0}; Cpp_Token prev_token = {(Cpp_Token_Type)0}; if (token_i > 0){ prev_token = out_tokens[token_i - 1]; -#if 0 - merge = cpp_attempt_token_merge(prev_token, token); - if (merge.did_merge){ - out_tokens[token_i - 1] = merge.new_token; - } -#endif } -#if 0 - if (!merge.did_merge){ - out_tokens[token_i++] = token; - } -#else out_tokens[token_i++] = token; -#endif return(token_i); } @@ -449,7 +416,7 @@ cpp_lex_nonalloc(Lex_Data *S_ptr, S.token_start = S.pos; S.tb_pos = 0; - S.fsm = zero_lex_fsm(); + S.fsm = null_lex_fsm; for(;;){ { unsigned short *eq_classes = get_eq_classes[S.pp_state]; diff --git a/4cpp_lexer_fsms.h b/4cpp_lexer_fsms.h index dec4bf5c..9448d972 100644 --- a/4cpp_lexer_fsms.h +++ b/4cpp_lexer_fsms.h @@ -84,19 +84,11 @@ enum Lex_PP_State{ struct Lex_FSM{ uint8_t state; - union{ - uint8_t int_state; - uint8_t directive_state; - uint8_t sub_machine; - }; + uint8_t int_state; uint8_t emit_token; uint8_t multi_line; }; -inline Lex_FSM -zero_lex_fsm(){ - Lex_FSM fsm = {0}; - return(fsm); -} +static Lex_FSM null_lex_fsm = {0}; #endif diff --git a/4coder_lexer_types.h b/4cpp_lexer_types.h similarity index 100% rename from 4coder_lexer_types.h rename to 4cpp_lexer_types.h diff --git a/4cpp_preprocessor.cpp b/4cpp_preprocessor.cpp deleted file mode 100644 index ce825892..00000000 --- a/4cpp_preprocessor.cpp +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Mr. 4th Dimention - Allen Webster - * - * 30.11.2015 - * - * CPP preprocessor - * - */ - -// TOP - -#define byte unsigned char - - - -#undef byte - -// BOTTOM - diff --git a/4ed_metagen.cpp b/4ed_metagen.cpp index 8cb0a5fa..55ea8701 100644 --- a/4ed_metagen.cpp +++ b/4ed_metagen.cpp @@ -2193,10 +2193,40 @@ generate_custom_headers(){ string_keys, ArrayCount(string_keys)); + // NOTE(allen): Parse the lexer library + static char *lexer_types_files[] = { + "4cpp_lexer_types.h", + }; + + static Meta_Keywords lexer_types_keys[] = { + {make_lit_string("typedef") , Item_Typedef } , + {make_lit_string("struct") , Item_Struct } , + {make_lit_string("union") , Item_Union } , + {make_lit_string("ENUM") , Item_Enum } , + }; + + Meta_Unit lexer_types_unit = + compile_meta_unit(part, lexer_types_files, ArrayCount(lexer_types_files), + lexer_types_keys, ArrayCount(lexer_types_keys)); + + static char *lexer_funcs_files[] = { + "4cpp_lexer.h", + }; + + static Meta_Keywords lexer_funcs_keys[] = { + {make_lit_string("FCPP_LINK") , Item_Function } , + }; + + Meta_Unit lexer_funcs_unit = + compile_meta_unit(part, lexer_funcs_files, ArrayCount(lexer_funcs_files), + lexer_funcs_keys, ArrayCount(lexer_funcs_keys)); + + + // NOTE(allen): Parse the customization API files static char *functions_files[] = { "4ed_api_implementation.cpp", - "win32_api_impl.cpp" + "win32_api_impl.cpp", }; static Meta_Keywords functions_keys[] = { @@ -2225,11 +2255,9 @@ generate_custom_headers(){ partition_align(part, 4); } - // NOTE(allen): Parse the customization API types static char *type_files[] = { "4coder_types.h", - "4coder_lexer_types.h", }; static Meta_Keywords type_keys[] = { @@ -2242,7 +2270,6 @@ generate_custom_headers(){ Meta_Unit unit = compile_meta_unit(part, type_files, ArrayCount(type_files), type_keys, ArrayCount(type_keys)); - // NOTE(allen): Output String out = str_alloc(part, 10 << 20); Out_Context context = {0}; @@ -2599,8 +2626,7 @@ generate_custom_headers(){ "" "
" - "

4coder API

" - ); + "

4coder API

"); struct Section{ char *id_string; @@ -2611,11 +2637,11 @@ generate_custom_headers(){ {"introduction", "Introduction"}, {"4coder_systems", "4coder Systems"}, {"types_and_functions", "Types and Functions"}, - {"string_library", "String Library"} + {"string_library", "String Library"}, + {"lexer_library", "Lexer Library"} }; - append_sc(&out, - "

Table of Contents

""
    "); + append_sc(&out, "

    Table of Contents

    ""
      "); int32_t section_count = ArrayCount(sections); for (int32_t i = 0; i < section_count; ++i){ @@ -2745,7 +2771,7 @@ generate_custom_headers(){ append_sc(&out, "
        "); for (int32_t i = 0; i < string_unit.set.count; ++i){ - print_item_in_list(&out, string_unit.set.items[i].name, "_str_doc"); + print_item_in_list(&out, string_unit.set.items[i].name, "_doc"); } append_sc(&out, "
      "); @@ -2755,9 +2781,64 @@ 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, "_str_doc", "", SECTION, i+1); + print_item(&out, part, string_unit.set.items+i, "_doc", "", SECTION, i+1); } +#undef MAJOR_SECTION +#define MAJOR_SECTION "5" + + append_sc(&out, "\n

      §"MAJOR_SECTION" "); + append_sc(&out, sections[4].display_string); + append_sc(&out, "

      "); + +#undef SECTION +#define SECTION MAJOR_SECTION".1" + + append_sc(&out, "

      §"SECTION" Lexer Intro

      "); + + append_sc(&out, "
      Coming Soon
      "); + +#undef SECTION +#define SECTION MAJOR_SECTION".2" + + append_sc(&out, "

      §"SECTION" Lexer Function List

      "); + + append_sc(&out, "
        "); + for (int32_t i = 0; i < lexer_funcs_unit.set.count; ++i){ + print_item_in_list(&out, lexer_funcs_unit.set.items[i].name, "_doc"); + } + append_sc(&out, "
      "); + +#undef SECTION +#define SECTION MAJOR_SECTION".3" + + append_sc(&out, "

      §"SECTION" Lexer Types List

      "); + + append_sc(&out, "
        "); + for (int32_t i = 0; i < lexer_types_unit.set.count; ++i){ + print_item_in_list(&out, lexer_types_unit.set.items[i].name, "_doc"); + } + append_sc(&out, "
      "); + +#undef SECTION +#define SECTION MAJOR_SECTION".4" + + 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); + } + +#undef SECTION +#define SECTION MAJOR_SECTION".5" + + 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); + } + + append_sc(&out, "
      "); end_file_out(context); } diff --git a/build.c b/build.c index 2441a342..3d2ae4ef 100644 --- a/build.c +++ b/build.c @@ -445,7 +445,7 @@ init_build_line(Build_Line *line){ "..\\foreign\\freetype.lib" #define CL_ICON \ -"..\\foreign\\freetype.lib" +"..\\res\\icon.res" static void build_cl(uint32_t flags, @@ -808,6 +808,8 @@ package(char *cdir){ copy_all ("4coder_*.h", PACK_SUPER_DIR); copy_all ("4coder_*.cpp", PACK_SUPER_DIR); + copy_all ("4cpp_*.h", PACK_SUPER_DIR); + copy_all ("4cpp_*.c", PACK_SUPER_DIR); copy_file(0, "buildsuper"BAT, PACK_SUPER_DIR, 0); get_4coder_dist_name(&str, 0, "API", "html"); diff --git a/fsm_table_generator.cpp b/fsm_table_generator.cpp index c6c6519e..c682d033 100644 --- a/fsm_table_generator.cpp +++ b/fsm_table_generator.cpp @@ -14,7 +14,7 @@ #define Assert(n) do{ if (!(n)) { *(int*)0 = 0xA11E; } }while(0) #define ArrayCount(a) (sizeof(a)/sizeof(*a)) -#include "4coder_lexer_types.h" +#include "4cpp_lexer_types.h" #include "4cpp_lexer_fsms.h" #include "4ed_mem_ansi.c"