Make more progress on package configuration, fill out C docs.

This commit is contained in:
Joshua Bemenderfer
2023-02-21 22:35:53 -05:00
parent fb90f825ed
commit 3b7077e761
19 changed files with 872 additions and 275 deletions

View File

@@ -14,17 +14,22 @@ typedef struct terrace_linedata_s {
unsigned int offsetTail;
} terrace_linedata_t;
terrace_linedata_t terrace_create_line_data(const char indent) {
/**
* Initialize a terrace_linedata struct with default values to pass to terrace_parse_line()
* @param {const char} indent The character to use for indenting lines. ONLY ONE CHARACTER IS CURRENTLY PERMITTED.
* @returns {terrace_linedata_t} A linedata struct with the specified indent character and all other values initialized to 0.
*/
terrace_linedata_t terrace_create_linedata(const char indent) {
terrace_linedata_t line_data = { .indent = indent, .level = 0, .offsetHead = 0, .offsetTail = 0 };
return line_data;
}
/**
* Core Terrace parser function, sets level, offsetHead, and offsetTail in a lineData struct based on the current line.
* Core Terrace parser function, sets level, offsetHead, and offsetTail in a terrace_linedata struct based on the current line.
* @param char* line A pointer to the line to parse as a C-style string. Shouldn't end with a newline.
* @param terrace_linedata_t* lineData A pointer to the terrace_linedata_t struct to store information about the current line in.
*/
void terrace_parse_line(const char *line, terrace_linedata_t *lineData) {
void terrace_parse_line(const char* line, terrace_linedata_t* lineData) {
// Empty lines are nullptr/0 as they have no characters. (The newline character should be stripped off.)
// Special case handling for these allows them to be parsed extra quickly.
if (!line) {