Archeus 0.0.0
A C library and game engine that focuses on documentation
Loading...
Searching...
No Matches
chemical.c File Reference
#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>

Go to the source code of this file.

Data Structures

struct  ARC_Chemical
 

Functions

void ARC_Chemical_InitLexerRulesFn (ARC_Lexer *lexer)
 
uint32_t ARC_Chemical_GetStringIdFn (ARC_String *string)
 
void ARC_ChemicalData_CreateFn (void **data, ARC_ParserTagToken *parsedData, void *userData)
 
void ARC_Chemical_Create (ARC_Chemical **chemical)
 TODO: write this.
 
void ARC_Chemical_Destroy (ARC_Chemical *chemical)
 TODO: write this.
 
void ARC_Chemical_RegisterType (ARC_Chemical *chemical, ARC_String *typeName, ARC_ChemicalData_CopyToTypeFn *copyToTypeFn, ARC_ParserCSV_DestroyTypeFn destroyTypeFn)
 TODO: write this.
 
void ARC_Chemical_SetGroup (ARC_Chemical *chemical, ARC_String *groupName)
 sets current group in config
 
void * ARC_Chemical_Get (ARC_Chemical *chemical, ARC_String *element)
 get a value from a given keyname
 
void ARC_Chemical_LoadFromString (ARC_String *path)
 TODO: write this.
 
void ARC_Chemical_LoadFromFile (ARC_String *path)
 TODO: write this.
 
void ARC_Chemical_UnloadFromString (ARC_String *data)
 TODO: write this.
 
void ARC_Chemical_UnloadFromFile (ARC_String *data)
 TODO: write this.
 

Function Documentation

◆ ARC_Chemical_Create()

void ARC_Chemical_Create ( ARC_Chemical ** chemical)

TODO: write this.

Definition at line 36 of file chemical.c.

36 {
37 *chemical = (ARC_Chemical *)malloc(sizeof(ARC_Chemical));
38
39 /* ~ define the language as a string ~ */
40 char *languageCString =
41 "<language> -> <group> <language> | <variableLine> <language> | <whitespace> <language>\n"
42
43 "<group> -> <groupName> <whitespace> <variable> <whitespace> LEFT_CURLY_BRACE <whitespace> <variableLine> <whitespace> RIGHT_CURLY_BRACE\n"
44
45 "<variableLine> -> <type> <whitespace> <variable> <whitespace> EQUALS <whitespace> value <whitespace> SEMICOLON <whitespace>\n"
46
47 "<groupName> -> <variable>\n"
48 "<type> -> <variable>\n"
49 "<value> -> <variable> | <number> | <nestedValue>\n"
50 "<nestedValue> -> OPEN_CURLY_BRACE <whitespace> <valueArgs> <whitespace> CLOSE_CURLY_BRACE\n"
51 "<valueArgs> -> <value> | <value> COMMA <valueArgs>\n"
52
53 "<variable> -> ALPHA_UPPER_CHAR <variableName> | ALPHA_LOWER_CHAR <variableName> | UNDERSCORE <variableName>\n"
54 "<variableName> -> <charOrNum> <variableName> | LAMBDA\n"
55 "<charOrNum> -> ALPHA_UPPER_CHAR | ALPHA_LOWER_CHAR | UNDERSCORE | NUM\n"
56
57 "<number> -> NUMBER <number> | NUMBER LAMBDA\n"
58
59 "<whitespace> -> SPACE <whitespace> | TAB <whitespace> | NEWLINE <whitespace> | LAMBDA\n";
60
61 /* ~ define the language as a string ~ */
62 ARC_String *languageString;
63 ARC_String_CreateWithStrlen(&languageString, languageCString);
64
65 /* ~ init the userdata? ~ */
66
67 /* ~ create the language ~ */
68 //ARC_ParserData_CreateFn createCharFn = ARC_ChemicalData_CreateFn;
69 //ARC_ParserData_DestroyFn destroyCharFn = ARC_ChemicalData_DestroyFn;
70 //ARC_Parser_CreateFromString(parser, languageString, ARC_ParserCSV_InitLexerRulesFn, ARC_ParserCSV_GetStringIdFn, &createCharFn, &destroyCharFn, userdata);
71
72 //cleanup
73 ARC_String_Destroy(languageString);
74}
void ARC_String_CreateWithStrlen(ARC_String **string, char *data)
creates ARC_String type with strinlen
Definition string.c:32
void ARC_String_Destroy(ARC_String *string)
destroys ARC_String type
Definition string.c:52
substring position within a string
Definition string.h:14

References ARC_String_CreateWithStrlen(), and ARC_String_Destroy().

Referenced by ARC_TEST().

◆ ARC_Chemical_Destroy()

void ARC_Chemical_Destroy ( ARC_Chemical * chemical)

TODO: write this.

Definition at line 76 of file chemical.c.

76 {
77}

Referenced by ARC_TEST().

◆ ARC_Chemical_Get()

void * ARC_Chemical_Get ( ARC_Chemical * chemical,
ARC_String * element )

get a value from a given keyname

Note
name may be prefaced with <group>:: to specify group
Parameters
[in]chemicalARC_Chemical to get value from
[in]elementname of a variable that has been read in
Returns
the stored element on success, or NULL on failure

Definition at line 85 of file chemical.c.

85 {
86 return NULL;
87}

◆ ARC_Chemical_GetStringIdFn()

uint32_t ARC_Chemical_GetStringIdFn ( ARC_String * string)

Definition at line 19 of file chemical.c.

19 {
20 if(ARC_String_EqualsCStringWithStrlen(string, "LAMBDA")){
22 }
23
24 return ~(uint32_t)0;
25}
#define ARC_PARSER_TAG_LAMBDA
basic tag for letting the parser know it is ok to end
Definition parser.h:150
ARC_Bool ARC_String_EqualsCStringWithStrlen(ARC_String *string, const char *cstring)
check if ARC_String and cstring match
Definition string.c:171

References ARC_PARSER_TAG_LAMBDA, and ARC_String_EqualsCStringWithStrlen().

◆ ARC_Chemical_InitLexerRulesFn()

void ARC_Chemical_InitLexerRulesFn ( ARC_Lexer * lexer)

Definition at line 16 of file chemical.c.

16 {
17}

◆ ARC_Chemical_LoadFromFile()

void ARC_Chemical_LoadFromFile ( ARC_String * path)

TODO: write this.

Definition at line 92 of file chemical.c.

92 {
93}

◆ ARC_Chemical_LoadFromString()

void ARC_Chemical_LoadFromString ( ARC_String * path)

TODO: write this.

Definition at line 89 of file chemical.c.

89 {
90}

◆ 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 at line 79 of file chemical.c.

79 {
80}

◆ ARC_Chemical_SetGroup()

void ARC_Chemical_SetGroup ( ARC_Chemical * chemical,
ARC_String * groupName )

sets current group in config

Note
ARC_Chemical_Get will use this set group
Parameters
[in]chemicalARC_Config we are setting current group in
[in]groupnamename of group that will be set

Definition at line 82 of file chemical.c.

82 {
83}

◆ ARC_Chemical_UnloadFromFile()

void ARC_Chemical_UnloadFromFile ( ARC_String * data)

TODO: write this.

Definition at line 98 of file chemical.c.

98 {
99}

◆ ARC_Chemical_UnloadFromString()

void ARC_Chemical_UnloadFromString ( ARC_String * data)

TODO: write this.

Definition at line 95 of file chemical.c.

95 {
96}

◆ ARC_ChemicalData_CreateFn()

void ARC_ChemicalData_CreateFn ( void ** data,
ARC_ParserTagToken * parsedData,
void * userData )

Definition at line 27 of file chemical.c.

27 {
28 *data = NULL;
29 if(data == NULL || userData == NULL){
30 //TODO: error here?
31 *data = NULL;
32 return;
33 }
34}