diff --git a/doc/doxygen/doxygen-awesome-css/header.html b/doc/doxygen/doxygen-awesome-css/header.html index f0d2b33..87e4e0b 100644 --- a/doc/doxygen/doxygen-awesome-css/header.html +++ b/doc/doxygen/doxygen-awesome-css/header.html @@ -21,7 +21,7 @@ $search $mathjax $extrastylesheet - + diff --git a/doc/pages/standard/array.md b/doc/pages/standard/array.md index 9e95a0f..0f3536c 100644 --- a/doc/pages/standard/array.md +++ b/doc/pages/standard/array.md @@ -9,9 +9,7 @@ The API Reference for ::ARC_Array can be found here: arc/std/array.h # Example ```c -#include -#include -#include +#include //initing the array (as it is a basic type there is no ARC_Array_Create or ARC_Array_Destroy) ARC_Array exampleArray; diff --git a/doc/pages/standard/bool.md b/doc/pages/standard/bool.md index 1db0df2..ddb3633 100644 --- a/doc/pages/standard/bool.md +++ b/doc/pages/standard/bool.md @@ -9,7 +9,7 @@ The API Reference for ::ARC_Bool can be found here: arc/std/bool.h # Basic Example ```c -#include +#include ARC_Bool example = ARC_True; @@ -30,7 +30,7 @@ if(example == ARC_True){ #define ARC_True 1 #define ARC_False 0 -#include +#include ARC_Bool example = ARC_False; diff --git a/doc/pages/standard/errno.md b/doc/pages/standard/errno.md index 5346c61..ce270d4 100644 --- a/doc/pages/standard/errno.md +++ b/doc/pages/standard/errno.md @@ -13,7 +13,7 @@ When throwing errors, ::arc_errno should usually be set to an ARC_ERRNO_ define # Basic Example ```c -#include +#include void ARC_Example_ThrowNullError(){ uint32_t *exampleNumber = NULL; @@ -35,8 +35,7 @@ Sometimes the error will have data that could be helpful when debugging, so ther # Example With Variables ```c -#include -#include +#include void ARC_Example_ThrowPathError(ARC_String *path){ ARC_String *data; diff --git a/doc/pages/standard/lexer.md b/doc/pages/standard/lexer.md index 8fc6d13..0743fe6 100644 --- a/doc/pages/standard/lexer.md +++ b/doc/pages/standard/lexer.md @@ -1 +1,64 @@ \page standard-lexer ARC_Lexer + +# Basic Overview + +The ::ARC_Lexer type takes rules for what a token in, then takes a string and splits it up into tokens based on the rules. + +The API Reference for ::ARC_Lexer can be found here: arc/std/lexer.h + +Note: @ref standard-config "ARC_Config" uses a lot of functions from the lexer + +# Basic Example + +```c +#include + +const uint32_t TOKEN_NULL = 0; +const uint32_t TOKEN_NUMBER = 1; +const uint32_t TOKEN_ALPHA_LOWER_CHAR = 2; +const uint32_t TOKEN_ALPHA_UPPER_CHAR = 3; +const uint32_t TOKEN_HYPHEN = 4; + +//private function to initialize the lexer rules for the language +void ARC_Example_InitLexerRulesFn(ARC_Lexer *lexer){ + //null + ARC_Lexer_RegisterTokenRule(lexer, ARC_LexerTokenRule_CreateAndReturnMatchCharRule(TOKEN_NULL, 0)); + + //number + ARC_Lexer_RegisterTokenRule(lexer, ARC_LexerTokenRule_CreateAndReturnMatchCharOrBetween(TOKEN_NUMBER, '0', '9')); + + //alphabetic characters + ARC_Lexer_RegisterTokenRule(lexer, ARC_LexerTokenRule_CreateAndReturnMatchCharOrBetween(TOKEN_ALPHA_LOWER_CHAR, 'a', 'z')); + ARC_Lexer_RegisterTokenRule(lexer, ARC_LexerTokenRule_CreateAndReturnMatchCharOrBetween(TOKEN_ALPHA_UPPER_CHAR, 'A', 'Z')); + + //hyphen + ARC_Lexer_RegisterTokenRule(lexer, ARC_LexerTokenRule_CreateAndReturnMatchCharRule(TOKEN_HYPHEN, '-')); +} + +int main(){ + ARC_Lexer *lexer; + ARC_Lexer_Create(&lexer); + + //add the rules to the lexer + ARC_Example_InitLexerRulesFn(lexer); + + //create the example string to lex + ARC_String *exampleString; + ARC_String_CreateWithStrlen(&exampleString, "T-1000"); + + //this function handles cleanup for the string + ARC_Lexer_LexString(lexer, &exampleString); + + //loop through all the tokens printing the lexed contents + for(uint32_t index = 0; index < ARC_Lexer_GetTokenSize(lexer); index++){ + ARC_LexerToken *token = ARC_Lexer_GetToken(lexer, index); + + printf("%u) Token Rule: %u\n", index, token->rule); + } + + //cleanup + ARC_Lexer_Destroy(lexer); + + return 0; +} +``` diff --git a/doc/pages/standard/vector.md b/doc/pages/standard/vector.md index 6e2c3d1..9949b1c 100644 --- a/doc/pages/standard/vector.md +++ b/doc/pages/standard/vector.md @@ -9,9 +9,7 @@ The API Reference for ::ARC_Vector can be found here: arc/std/vector.h # Basic Example: ```c -#include -#include -#include +#include //creating an array with no callbacks (the simplest example of the array) ARC_Vector *vector; @@ -51,9 +49,7 @@ A handy feature of this implmentation fo a vector is the ability to add a compar # Comparison Callback Example ```c -#include -#include -#include +#include //the comparison callback to check if two integer pointers hold the same value ARC_Bool ARC_Example_VectorCompareDataFn(void *dataA, void *dataB){ @@ -115,10 +111,7 @@ As the vector takes a pointer, usually that pointer is allocated right before be # Destruction Callback Example ```c -#include -#include -#include -#include +#include //the destruction callback to free the allocated int32_t values void ARC_Example_VectorDestroyDataFn(void *data){ diff --git a/doc/style.md b/doc/style.md index c592e4e..28243cd 100644 --- a/doc/style.md +++ b/doc/style.md @@ -1,3 +1,5 @@ +@page style-guide Style Guide + # Introduction This document outlines the style for any C code that is to be stored within this repository. This document will most likely be changed over time as the style becomes more set. diff --git a/include/arc/std/config.h b/include/arc/std/config.h index 251007a..0c3e651 100644 --- a/include/arc/std/config.h +++ b/include/arc/std/config.h @@ -5,8 +5,8 @@ extern "C" { #endif -#include #include "arc/std/parser.h" +#include /** * @brief the config type for archeus, loads in a .chemical file which syntax is specified in the documentation diff --git a/include/arc/std/hashtable.h b/include/arc/std/hashtable.h index 965762e..2161f28 100644 --- a/include/arc/std/hashtable.h +++ b/include/arc/std/hashtable.h @@ -7,7 +7,6 @@ extern "C" { #include "arc/std/bool.h" #include -#include /** * @brief a hashing function ptr diff --git a/include/arc/std/io.h b/include/arc/std/io.h index 9a79e5d..28cafbe 100644 --- a/include/arc/std/io.h +++ b/include/arc/std/io.h @@ -5,8 +5,8 @@ extern "C" { #endif -#include #include "arc/std/string.h" +#include /** * @brief get string and size from file @@ -39,4 +39,4 @@ void ARC_IO_WriteStrToFile(ARC_String *path, ARC_String *data); } #endif -#endif //ARC_STD_IO_H_ \ No newline at end of file +#endif //ARC_STD_IO_H_ diff --git a/include/arc/std/lexer.h b/include/arc/std/lexer.h index fa17bf1..cdf57b5 100644 --- a/include/arc/std/lexer.h +++ b/include/arc/std/lexer.h @@ -4,6 +4,7 @@ #ifdef __cplusplus extern "C" { #endif + #include "arc/std/string.h" #include @@ -220,7 +221,7 @@ ARC_LexerTokenRule ARC_LexerTokenRule_CreateAndReturnMatchCharOrBetween(uint32_t * @brief creates a ARC_LexerTokenRule with a given id and string * * @note this is intended as a helper funtion - * #note string will not be freed (it will be copied and the copy will be freed) + * @note string will not be freed (it will be copied and the copy will be freed) * * @param[in] id a tokens id (basically the token value) * @param[in] character the string to match against, will be copied @@ -233,7 +234,7 @@ ARC_LexerTokenRule ARC_LexerTokenRule_CreateAndReturnMatchStringRule(uint32_t id * @brief creates a ARC_LexerTokenRule with a given id and string * * @note this is intended as a helper funtion - * #note string will not be freed (it will be copied and the copy will be freed) + * @note string will not be freed (it will be copied and the copy will be freed) * * @param[in] id a tokens id (basically the token value) * @param[in] character the string to match against, will be copied diff --git a/include/arc/std/string.h b/include/arc/std/string.h index 56d36eb..73ee50f 100644 --- a/include/arc/std/string.h +++ b/include/arc/std/string.h @@ -5,8 +5,8 @@ extern "C" { #endif -#include #include "bool.h" +#include /** * @brief substring position within a string diff --git a/src/std/config.c b/src/std/config.c index cbe3eb8..c32bafb 100644 --- a/src/std/config.c +++ b/src/std/config.c @@ -1,4 +1,5 @@ #include "arc/std/config.h" + #include "arc/std/array.h" #include "arc/std/bool.h" #include "arc/std/errno.h" diff --git a/src/std/hashtable.c b/src/std/hashtable.c index 8ccb06d..a8a3835 100644 --- a/src/std/hashtable.c +++ b/src/std/hashtable.c @@ -1,4 +1,5 @@ #include "arc/std/hashtable.h" + #include "arc/std/errno.h" #include #include diff --git a/src/std/lexer.c b/src/std/lexer.c index d5f6df1..94b9425 100644 --- a/src/std/lexer.c +++ b/src/std/lexer.c @@ -2,9 +2,9 @@ #include "arc/std/bool.h" #include "arc/std/errno.h" +#include "arc/std/io.h" #include "arc/std/string.h" #include "arc/std/vector.h" -#include "arc/std/io.h" #include struct ARC_Lexer { diff --git a/src/std/parser.c b/src/std/parser.c index b52518b..b98fa1f 100644 --- a/src/std/parser.c +++ b/src/std/parser.c @@ -1,10 +1,11 @@ -#include "arc/std/parser/parserlang.h" #include "arc/std/parser.h" + #include "arc/std/bool.h" #include "arc/std/errno.h" #include "arc/std/io.h" #include "arc/std/lexer.h" #include "arc/std/vector.h" +#include "arc/std/parser/parserlang.h" #include #include #include diff --git a/tests/std/lexer.c b/tests/std/lexer.c index 42daf2a..0e74db7 100644 --- a/tests/std/lexer.c +++ b/tests/std/lexer.c @@ -51,7 +51,7 @@ #define ARC_LEXER_TOKEN_PERCENT_CHAR '%' #define ARC_LEXER_TOKEN_PERCENT_TAG "PERCENT" -void ARC_Lexer_InitBasicTokenRules(ARC_Lexer *lexer){ +void ARC_Test_InitBasicLexerTokenRules(ARC_Lexer *lexer){ //null ARC_Lexer_RegisterTokenRule(lexer, ARC_LexerTokenRule_CreateAndReturnMatchCharRule(ARC_LEXER_TOKEN_NULL, 0)); @@ -91,7 +91,7 @@ ARC_TEST(Lexer_Char_Match){ ARC_Lexer *lexer; ARC_Lexer_Create(&lexer); - ARC_Lexer_InitBasicTokenRules(lexer); + ARC_Test_InitBasicLexerTokenRules(lexer); ARC_String *simple; ARC_String_CreateWithStrlen(&simple, "::{}!/.");