working on debuging chemical language string

This commit is contained in:
herbglitch 2025-03-07 14:44:04 -07:00
parent bb3601b8f2
commit 18fc05d3d4
4 changed files with 34 additions and 23 deletions

View file

@ -318,6 +318,7 @@ uint32_t ARC_Chemical_GetStringIdFn(ARC_String *string){
}
void ARC_ChemicalData_CreateFn(void **data, ARC_ParserTagToken *parsedData, void *userData){
printf("HERE??\n");
*data = NULL;
if(parsedData == NULL || userData == NULL){
//TODO: error here?
@ -363,30 +364,30 @@ void ARC_Chemical_Create(ARC_Chemical **chemical){
/* ~ define the language as a string ~ */
char *languageCString =
"<language> -> <variableLine> <language> | <whitespace> <language> | LAMBDA\n"
"<language> -> <variableLine> <language> | <whitespace> <language> | LAMBDA\n"
"<variableLines> -> <variableLine> NEWLINE <variableLines> | <variableLine>\n"
"<variableLine> -> <allowSpace> <type> <whitespace> <variable> <whitespace> EQUAL <whitespace> <value> <whitespace> SEMICOLON <allowSpace>\n"
"<allowSpace> -> SPACE <allowSpace> | TAB <allowSpace> | LAMBDA\n"
"<variableLine> -> <allowSpace> <type> <whitespace> <variable> <whitespace> EQUAL <whitespace> <value> <whitespace> SEMICOLON <allowSpace>\n"
"<allowSpace> -> SPACE <allowSpace> | TAB <allowSpace> | LAMBDA\n"
"<groupName> -> <variable>\n"
"<type> -> <variable>\n"
"<value> -> <nestedValue> | <variable> | <number> | <string>\n"
"<nestedValue> -> OPEN_CURLY_BRACE <whitespace> <valueArgs> <whitespace> CLOSE_CURLY_BRACE\n"
"<valueArgs> -> <value> COMMA <valueArgs> | <value>\n"
"<groupName> -> <variable>\n"
"<type> -> <variable>\n"
"<value> -> <variable> | <number>\n"
//"<value> -> <variable> | <number> | <string> | <nestedValue>\n"
//"<nestedValue> -> OPEN_CURLY_BRACE <whitespace> <valueArgs> <whitespace> CLOSE_CURLY_BRACE\n"
//"<valueArgs> -> <value> COMMA <valueArgs> | <value>\n"
"<variable> -> ALPHA_UPPER_CHAR <variableName> | ALPHA_LOWER_CHAR <variableName> | UNDERSCORE <variableName>\n"
"<variableName> -> <variableChar> <variableName> | LAMBDA\n"
"<variableChar> -> ALPHA_UPPER_CHAR | ALPHA_LOWER_CHAR | UNDERSCORE | NUMBER\n"
"<variable> -> ALPHA_UPPER_CHAR <variableName> | ALPHA_LOWER_CHAR <variableName> | UNDERSCORE <variableName>\n"
"<variableName> -> <variableChar> <variableName> | LAMBDA\n"
"<variableChar> -> ALPHA_UPPER_CHAR | ALPHA_LOWER_CHAR | UNDERSCORE | NUMBER\n"
"<string> -> QUOTE <stringChars> QUOTE\n"
"<stringChars> -> <stringChar> <stringChars> | <escapeChar> <stringChars> | LAMBDA\n"
"<stringChar> -> TAB | SPACE | BANG | HASH | DOLLAR | PERCENT | AMPERSAND | SINGLE_QUOTE | OPEN_PAREN | CLOSE_PAREN | ASTERISK | PLUS | COMMA | MINUS | PERIOD | SLASH | NUMBER | COLON | SEMICOLON | LESS_THAN | GREATER_THAN | EQUAL | QUESTION_MARK | AT | ALPHA_UPPER_CHAR | OPEN_BRACKET | CLOSE_BRACKET | CARET | UNDERSCORE | GRAVE | ALPHA_LOWER_CHAR | OPEN_CURLY_BRACE | VERTICAL_LINE | CLOSE_CURLY_BRACE | TILDE\n"
"<escapeChar> -> BACKSLASH BACKSLASH | BACKSLASH QUOTE | BACKSLASH ALPHA_UPPER_CHAR | BACKSLASH ALPHA_LOWER_CHAR\n"
//"<string> -> QUOTE <stringChars> QUOTE\n"
//"<stringChars> -> <stringChar> <stringChars> | <escapeChar> <stringChars> | LAMBDA\n"
//"<stringChar> -> TAB | SPACE | BANG | HASH | DOLLAR | PERCENT | AMPERSAND | SINGLE_QUOTE | OPEN_PAREN | CLOSE_PAREN | ASTERISK | PLUS | COMMA | MINUS | PERIOD | SLASH | NUMBER | COLON | SEMICOLON | LESS_THAN | GREATER_THAN | EQUAL | QUESTION_MARK | AT | ALPHA_UPPER_CHAR | OPEN_BRACKET | CLOSE_BRACKET | CARET | UNDERSCORE | GRAVE | ALPHA_LOWER_CHAR | OPEN_CURLY_BRACE | VERTICAL_LINE | CLOSE_CURLY_BRACE | TILDE\n"
//"<escapeChar> -> BACKSLASH BACKSLASH | BACKSLASH QUOTE | BACKSLASH ALPHA_UPPER_CHAR | BACKSLASH ALPHA_LOWER_CHAR\n"
"<number> -> NUMBER <number> | NUMBER\n"
"<number> -> NUMBER <number> | NUMBER\n"
"<whitespace> -> SPACE <whitespace> | TAB <whitespace> | SPACE | TAB\n";
"<whitespace> -> SPACE <whitespace> | TAB <whitespace> | NEWLINE <whitespace> | LAMBDA\n";
/* ~ define the language as a string ~ */
ARC_String *languageString;
@ -411,8 +412,14 @@ void ARC_Chemical_Create(ARC_Chemical **chemical){
//add the default/empty group into the groups
ARC_Hashtable_DestroyKeyValueFn groupDataDestroyKeyValueFn = ARC_Chemical_GroupDataHashtableDestroyKeyValueFn;
//copy empty group cstring (to be freed by hashtable on cleanup, passing directly would cause a segfault)
char *emptyCStr = (char *)malloc(sizeof(char) * (strlen(ARC_CHEMICAL_DEFAULT_GROUP) + 1));
strcpy(emptyCStr, ARC_CHEMICAL_DEFAULT_GROUP);
//set the current group as empty, then add that into the groups hashtable
ARC_Hashtable_Create(&((*chemical)->currentGroup), NULL, &keyCompareFn, &groupDataDestroyKeyValueFn);
ARC_Hashtable_Add((*chemical)->groups, (void *)ARC_CHEMICAL_DEFAULT_GROUP, (*chemical)->currentGroup);
ARC_Hashtable_Add((*chemical)->groups, (void *)emptyCStr, (*chemical)->currentGroup);
//cleanup
ARC_String_Destroy(languageString);