Loading...
Searching...
No Matches
chemical.c
Go to the documentation of this file.
#include "arc/std/chemical.h"
#include "arc/std/parser/helpers.h"
#include "arc/std/bool.h"
#include "arc/std/hashtable.h"
#include "arc/std/parser.h"
#include <stddef.h>
#include <stdint.h>
#include <stdlib.h>
struct ARC_Chemical {
ARC_Parser *parser;
ARC_Hashtable *groups;
};
void ARC_Chemical_InitLexerRulesFn(ARC_Lexer *lexer){
}
uint32_t ARC_Chemical_GetStringIdFn(ARC_String *string){
if(ARC_String_EqualsCStringWithStrlen(string, "LAMBDA")){
return ARC_PARSER_TAG_LAMBDA;
}
return ~(uint32_t)0;
}
void ARC_ChemicalData_CreateFn(void **data, ARC_ParserTagToken *parsedData, void *userData){
*data = NULL;
if(data == NULL || userData == NULL){
//TODO: error here?
*data = NULL;
return;
}
}
void ARC_Chemical_Create(ARC_Chemical **chemical){
*chemical = (ARC_Chemical *)malloc(sizeof(ARC_Chemical));
/* ~ define the language as a string ~ */
char *languageCString =
"<language> -> <group> <language> | <variableLine> <language> | <whitespace> <language>\n"
"<group> -> <groupName> <whitespace> <variable> <whitespace> LEFT_CURLY_BRACE <whitespace> <variableLine> <whitespace> RIGHT_CURLY_BRACE\n"
"<variableLine> -> <type> <whitespace> <variable> <whitespace> EQUALS <whitespace> value <whitespace> SEMICOLON <whitespace>\n"
"<groupName> -> <variable>\n"
"<type> -> <variable>\n"
"<value> -> <variable> | <number> | <nestedValue>\n"
"<nestedValue> -> OPEN_CURLY_BRACE <whitespace> <valueArgs> <whitespace> CLOSE_CURLY_BRACE\n"
"<valueArgs> -> <value> | <value> COMMA <valueArgs>\n"
"<variable> -> ALPHA_UPPER_CHAR <variableName> | ALPHA_LOWER_CHAR <variableName> | UNDERSCORE <variableName>\n"
"<variableName> -> <charOrNum> <variableName> | LAMBDA\n"
"<charOrNum> -> ALPHA_UPPER_CHAR | ALPHA_LOWER_CHAR | UNDERSCORE | NUM\n"
"<number> -> NUMBER <number> | NUMBER LAMBDA\n"
"<whitespace> -> SPACE <whitespace> | TAB <whitespace> | NEWLINE <whitespace> | LAMBDA\n";
/* ~ define the language as a string ~ */
ARC_String *languageString;
ARC_String_CreateWithStrlen(&languageString, languageCString);
/* ~ init the userdata? ~ */
/* ~ create the language ~ */
//ARC_ParserData_CreateFn createCharFn = ARC_ChemicalData_CreateFn;
//ARC_ParserData_DestroyFn destroyCharFn = ARC_ChemicalData_DestroyFn;
//ARC_Parser_CreateFromString(parser, languageString, ARC_ParserCSV_InitLexerRulesFn, ARC_ParserCSV_GetStringIdFn, &createCharFn, &destroyCharFn, userdata);
//cleanup
ARC_String_Destroy(languageString);
}
void ARC_Chemical_Destroy(ARC_Chemical *chemical){
}
void ARC_Chemical_RegisterType(ARC_Chemical *chemical, ARC_String *typeName, ARC_ChemicalData_CopyToTypeFn *copyToTypeFn, ARC_ParserCSV_DestroyTypeFn destroyTypeFn){
}
void ARC_Chemical_SetGroup(ARC_Chemical *chemical, ARC_String *groupName){
}
void *ARC_Chemical_Get(ARC_Chemical *chemical, ARC_String *element){
return NULL;
}
void ARC_Chemical_LoadFromString(ARC_String *path){
}
void ARC_Chemical_LoadFromFile(ARC_String *path){
}
void ARC_Chemical_UnloadFromString(ARC_String *data){
}
void ARC_Chemical_UnloadFromFile(ARC_String *data){
}
bool.h
chemical.h
ARC_ParserCSV_DestroyTypeFn
void(* ARC_ParserCSV_DestroyTypeFn)(void *data)
TODO: write this.
Definition chemical.h:43
ARC_ChemicalData_CopyToTypeFn
void(* ARC_ChemicalData_CopyToTypeFn)(void **data, ARC_ParserTagToken *parsedData)
TODO: write this.
Definition chemical.h:38
hashtable.h
helpers.h
parser.h
ARC_PARSER_TAG_LAMBDA
#define ARC_PARSER_TAG_LAMBDA
basic tag for letting the parser know it is ok to end
Definition parser.h:150
ARC_Chemical_LoadFromFile
void ARC_Chemical_LoadFromFile(ARC_String *path)
TODO: write this.
Definition chemical.c:92
ARC_ChemicalData_CreateFn
void ARC_ChemicalData_CreateFn(void **data, ARC_ParserTagToken *parsedData, void *userData)
Definition chemical.c:27
ARC_Chemical_UnloadFromFile
void ARC_Chemical_UnloadFromFile(ARC_String *data)
TODO: write this.
Definition chemical.c:98
ARC_Chemical_LoadFromString
void ARC_Chemical_LoadFromString(ARC_String *path)
TODO: write this.
Definition chemical.c:89
ARC_Chemical_Create
void ARC_Chemical_Create(ARC_Chemical **chemical)
TODO: write this.
Definition chemical.c:36
ARC_Chemical_RegisterType
void ARC_Chemical_RegisterType(ARC_Chemical *chemical, ARC_String *typeName, ARC_ChemicalData_CopyToTypeFn *copyToTypeFn, ARC_ParserCSV_DestroyTypeFn destroyTypeFn)
TODO: write this.
Definition chemical.c:79
ARC_Chemical_SetGroup
void ARC_Chemical_SetGroup(ARC_Chemical *chemical, ARC_String *groupName)
sets current group in config
Definition chemical.c:82
ARC_Chemical_Destroy
void ARC_Chemical_Destroy(ARC_Chemical *chemical)
TODO: write this.
Definition chemical.c:76
ARC_Chemical_InitLexerRulesFn
void ARC_Chemical_InitLexerRulesFn(ARC_Lexer *lexer)
Definition chemical.c:16
ARC_Chemical_GetStringIdFn
uint32_t ARC_Chemical_GetStringIdFn(ARC_String *string)
Definition chemical.c:19
ARC_Chemical_UnloadFromString
void ARC_Chemical_UnloadFromString(ARC_String *data)
TODO: write this.
Definition chemical.c:95
ARC_Chemical_Get
void * ARC_Chemical_Get(ARC_Chemical *chemical, ARC_String *element)
get a value from a given keyname
Definition chemical.c:85
ARC_String_CreateWithStrlen
void ARC_String_CreateWithStrlen(ARC_String **string, char *data)
creates ARC_String type with strinlen
Definition string.c:32
ARC_String_EqualsCStringWithStrlen
ARC_Bool ARC_String_EqualsCStringWithStrlen(ARC_String *string, const char *cstring)
check if ARC_String and cstring match
Definition string.c:171
ARC_String_Destroy
void ARC_String_Destroy(ARC_String *string)
destroys ARC_String type
Definition string.c:52
ARC_Chemical
Definition chemical.c:10
ARC_Chemical::parser
ARC_Parser * parser
Definition chemical.c:11
ARC_Chemical::groups
ARC_Hashtable * groups
Definition chemical.c:13
ARC_Hashtable
Definition hashtable.c:7
ARC_Lexer
Definition lexer.c:10
ARC_ParserTagToken
a parser type used inside of the parser data create function
Definition parser.h:35
ARC_Parser
Definition parser.c:12
ARC_String
substring position within a string
Definition string.h:14