2024-12-23 00:16:32 -07:00
# include "arc/std/chemical.h"
2024-12-22 23:31:37 -07:00
# include "arc/std/parser/helpers.h"
# include "arc/std/bool.h"
2024-12-23 00:16:32 -07:00
# include "arc/std/hashtable.h"
2024-12-22 23:31:37 -07:00
# include "arc/std/parser.h"
# include <stddef.h>
# include <stdint.h>
# include <stdlib.h>
2024-12-23 00:16:32 -07:00
struct ARC_Chemical {
ARC_Parser * parser ;
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
ARC_Hashtable * groups ;
} ;
2024-12-22 23:31:37 -07:00
2025-01-29 17:31:18 -07:00
//the grouping is based on the ascii table, but the ids are sequential to make finding tokens quicker (look at the lexer continious for more explanation)
static const uint32_t ARC_CHEMICAL_TAB = 0x01 ;
static const uint32_t ARC_CHEMICAL_NEWLINE = 0x02 ;
static const uint32_t ARC_CHEMICAL_SPACE = 0x03 ;
static const uint32_t ARC_CHEMICAL_BANG = 0x04 ;
static const uint32_t ARC_CHEMICAL_QUOTE = 0x05 ;
static const uint32_t ARC_CHEMICAL_HASH = 0x06 ;
static const uint32_t ARC_CHEMICAL_DOLLAR = 0x07 ;
static const uint32_t ARC_CHEMICAL_PERCENT = 0x08 ;
static const uint32_t ARC_CHEMICAL_AMPERSAND = 0x09 ;
static const uint32_t ARC_CHEMICAL_SINGLE_QUOTE = 0x0A ;
static const uint32_t ARC_CHEMICAL_OPEN_PAREN = 0x0B ;
static const uint32_t ARC_CHEMICAL_CLOSE_PAREN = 0x0C ;
static const uint32_t ARC_CHEMICAL_ASTERISK = 0x0D ;
static const uint32_t ARC_CHEMICAL_PLUS = 0x0E ;
static const uint32_t ARC_CHEMICAL_COMMA = 0x0F ;
static const uint32_t ARC_CHEMICAL_MINUS = 0x10 ;
static const uint32_t ARC_CHEMICAL_PERIOD = 0x11 ;
static const uint32_t ARC_CHEMICAL_SLASH = 0x12 ;
static const uint32_t ARC_CHEMICAL_NUMBER = 0x13 ;
static const uint32_t ARC_CHEMICAL_COLON = 0x14 ;
static const uint32_t ARC_CHEMICAL_SEMICOLON = 0x15 ;
static const uint32_t ARC_CHEMICAL_LESS_THAN = 0x16 ;
static const uint32_t ARC_CHEMICAL_GREATER_THAN = 0x17 ;
static const uint32_t ARC_CHEMICAL_EQUAL = 0x18 ;
static const uint32_t ARC_CHEMICAL_QUESTION_MARK = 0x19 ;
static const uint32_t ARC_CHEMICAL_AT = 0x1A ;
static const uint32_t ARC_CHEMICAL_ALPHA_UPPER_CHAR = 0x1B ;
static const uint32_t ARC_CHEMICAL_OPEN_BRACKET = 0x1C ;
static const uint32_t ARC_CHEMICAL_BACKSLASH = 0x1D ;
static const uint32_t ARC_CHEMICAL_CLOSE_BRACKET = 0x1E ;
static const uint32_t ARC_CHEMICAL_CARET = 0x1F ;
static const uint32_t ARC_CHEMICAL_UNDERSCORE = 0x20 ;
static const uint32_t ARC_CHEMICAL_GRAVE = 0x21 ;
static const uint32_t ARC_CHEMICAL_ALPHA_LOWER_CHAR = 0x22 ;
static const uint32_t ARC_CHEMICAL_OPEN_CURLY_BRACE = 0x23 ;
static const uint32_t ARC_CHEMICAL_VERTICAL_LINE = 0x24 ;
static const uint32_t ARC_CHEMICAL_CLOSE_CURLY_BRACE = 0x25 ;
static const uint32_t ARC_CHEMICAL_TILDE = 0x26 ;
static const uint32_t ARC_CHEMICAL_LANGUAGE = 0x27 ;
static const uint32_t ARC_CHEMICAL_VARIABLE_LINES = 0x28 ;
static const uint32_t ARC_CHEMICAL_VARIABLE_LINE = 0x29 ;
static const uint32_t ARC_CHEMICAL_ALLOW_SPACE = 0x2A ;
static const uint32_t ARC_CHEMICAL_GROUP_NAME = 0x2B ;
static const uint32_t ARC_CHEMICAL_TYPE = 0x2C ;
static const uint32_t ARC_CHEMICAL_VALUE = 0x2D ;
static const uint32_t ARC_CHEMICAL_NESTED_VALUE = 0x2E ;
static const uint32_t ARC_CHEMICAL_VALUE_ARGS = 0x2F ;
static const uint32_t ARC_CHEMICAL_VARIABLE = 0x30 ;
static const uint32_t ARC_CHEMICAL_VARIABLE_NAME = 0x31 ;
static const uint32_t ARC_CHEMICAL_VARIABLE_CHAR = 0x32 ;
static const uint32_t ARC_CHEMICAL_STRING = 0x33 ;
static const uint32_t ARC_CHEMICAL_STRING_CHARS = 0x34 ;
static const uint32_t ARC_CHEMICAL_STRING_CHAR = 0x35 ;
static const uint32_t ARC_CHEMICAL_ESCAPE_CHAR = 0x36 ;
static const uint32_t ARC_CHEMICAL_WHITESPACE = 0x37 ;
static const uint32_t ARC_CHEMICAL_NUMBER_TAG = 0x38 ;
2024-12-23 00:16:32 -07:00
void ARC_Chemical_InitLexerRulesFn ( ARC_Lexer * lexer ) {
2025-01-29 17:31:18 -07:00
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_TAB , ' \t ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_NEWLINE , ' \n ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_SPACE , ' ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_BANG , ' ! ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_QUOTE , ' " ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_HASH , ' # ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_DOLLAR , ' $ ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_PERCENT , ' % ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_AMPERSAND , ' & ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_SINGLE_QUOTE , ' \' ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_OPEN_PAREN , ' ( ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_CLOSE_PAREN , ' ) ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_ASTERISK , ' * ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_PLUS , ' + ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_COMMA , ' , ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_MINUS , ' - ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_PERIOD , ' . ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_SLASH , ' / ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharOrBetween ( ARC_CHEMICAL_NUMBER , ' 0 ' , ' 9 ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_COLON , ' : ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_SEMICOLON , ' ; ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_LESS_THAN , ' < ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_GREATER_THAN , ' > ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_EQUAL , ' = ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_QUESTION_MARK , ' ? ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_AT , ' @ ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharOrBetween ( ARC_CHEMICAL_ALPHA_UPPER_CHAR , ' A ' , ' Z ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_OPEN_BRACKET , ' [ ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_BACKSLASH , ' \\ ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_CLOSE_BRACKET , ' ] ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_CARET , ' ^ ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_UNDERSCORE , ' _ ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_GRAVE , ' ` ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharOrBetween ( ARC_CHEMICAL_ALPHA_LOWER_CHAR , ' a ' , ' z ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_OPEN_CURLY_BRACE , ' { ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_VERTICAL_LINE , ' | ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_CLOSE_CURLY_BRACE , ' } ' ) ) ;
ARC_Lexer_RegisterTokenRule ( lexer , ARC_LexerTokenRule_CreateAndReturnMatchCharRule ( ARC_CHEMICAL_TILDE , ' ~ ' ) ) ;
2024-12-22 23:31:37 -07:00
}
2024-12-23 00:16:32 -07:00
uint32_t ARC_Chemical_GetStringIdFn ( ARC_String * string ) {
2024-12-22 23:31:37 -07:00
if ( ARC_String_EqualsCStringWithStrlen ( string , " LAMBDA " ) ) {
return ARC_PARSER_TAG_LAMBDA ;
}
2025-01-29 17:31:18 -07:00
if ( ARC_String_EqualsCStringWithStrlen ( string , " TAB " ) ) {
return ARC_CHEMICAL_TAB ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " NEWLINE " ) ) {
return ARC_CHEMICAL_NEWLINE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " SPACE " ) ) {
return ARC_CHEMICAL_SPACE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " BANG " ) ) {
return ARC_CHEMICAL_BANG ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " QUOTE " ) ) {
return ARC_CHEMICAL_QUOTE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " HASH " ) ) {
return ARC_CHEMICAL_HASH ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " DOLLAR " ) ) {
return ARC_CHEMICAL_DOLLAR ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " PERCENT " ) ) {
return ARC_CHEMICAL_PERCENT ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " AMPERSAND " ) ) {
return ARC_CHEMICAL_AMPERSAND ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " SINGLE_QUOTE " ) ) {
return ARC_CHEMICAL_SINGLE_QUOTE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " OPEN_PAREN " ) ) {
return ARC_CHEMICAL_OPEN_PAREN ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " CLOSE_PAREN " ) ) {
return ARC_CHEMICAL_CLOSE_PAREN ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " ASTERISK " ) ) {
return ARC_CHEMICAL_ASTERISK ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " PLUS " ) ) {
return ARC_CHEMICAL_PLUS ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " COMMA " ) ) {
return ARC_CHEMICAL_COMMA ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " MINUS " ) ) {
return ARC_CHEMICAL_MINUS ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " PERIOD " ) ) {
return ARC_CHEMICAL_PERIOD ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " SLASH " ) ) {
return ARC_CHEMICAL_SLASH ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " NUMBER " ) ) {
return ARC_CHEMICAL_NUMBER ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " COLON " ) ) {
return ARC_CHEMICAL_COLON ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " SEMICOLON " ) ) {
return ARC_CHEMICAL_SEMICOLON ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " LESS_THAN " ) ) {
return ARC_CHEMICAL_LESS_THAN ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " GREATER_THAN " ) ) {
return ARC_CHEMICAL_GREATER_THAN ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " EQUAL " ) ) {
return ARC_CHEMICAL_EQUAL ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " QUESTION_MARK " ) ) {
return ARC_CHEMICAL_QUESTION_MARK ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " AT " ) ) {
return ARC_CHEMICAL_AT ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " ALPHA_UPPER_CHAR " ) ) {
return ARC_CHEMICAL_ALPHA_UPPER_CHAR ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " OPEN_BRACKET " ) ) {
return ARC_CHEMICAL_OPEN_BRACKET ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " BACKSLASH " ) ) {
return ARC_CHEMICAL_BACKSLASH ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " CLOSE_BRACKET " ) ) {
return ARC_CHEMICAL_CLOSE_BRACKET ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " CARET " ) ) {
return ARC_CHEMICAL_CARET ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " UNDERSCORE " ) ) {
return ARC_CHEMICAL_UNDERSCORE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " GRAVE " ) ) {
return ARC_CHEMICAL_GRAVE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " ALPHA_LOWER_CHAR " ) ) {
return ARC_CHEMICAL_ALPHA_LOWER_CHAR ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " OPEN_CURLY_BRACE " ) ) {
return ARC_CHEMICAL_OPEN_CURLY_BRACE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " VERTICAL_LINE " ) ) {
return ARC_CHEMICAL_VERTICAL_LINE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " CLOSE_CURLY_BRACE " ) ) {
return ARC_CHEMICAL_CLOSE_CURLY_BRACE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " TILDE " ) ) {
return ARC_CHEMICAL_TILDE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <language> " ) ) {
return ARC_CHEMICAL_LANGUAGE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <variableLines> " ) ) {
return ARC_CHEMICAL_VARIABLE_LINES ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <variableLine> " ) ) {
return ARC_CHEMICAL_VARIABLE_LINE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <allowSpace> " ) ) {
return ARC_CHEMICAL_ALLOW_SPACE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <groupName> " ) ) {
return ARC_CHEMICAL_GROUP_NAME ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <type> " ) ) {
return ARC_CHEMICAL_TYPE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <value> " ) ) {
return ARC_CHEMICAL_VALUE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <nestedValue> " ) ) {
return ARC_CHEMICAL_NESTED_VALUE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <valueArgs> " ) ) {
return ARC_CHEMICAL_VALUE_ARGS ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <variable> " ) ) {
return ARC_CHEMICAL_VARIABLE ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <variableName> " ) ) {
return ARC_CHEMICAL_VARIABLE_NAME ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <variableChar> " ) ) {
return ARC_CHEMICAL_VARIABLE_CHAR ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <string> " ) ) {
return ARC_CHEMICAL_STRING ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <stringChars> " ) ) {
return ARC_CHEMICAL_STRING_CHARS ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <stringChar> " ) ) {
return ARC_CHEMICAL_STRING_CHAR ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <escapeChar> " ) ) {
return ARC_CHEMICAL_ESCAPE_CHAR ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <number> " ) ) {
return ARC_CHEMICAL_NUMBER_TAG ;
}
if ( ARC_String_EqualsCStringWithStrlen ( string , " <whitespace> " ) ) {
return ARC_CHEMICAL_WHITESPACE ;
}
2024-12-22 23:31:37 -07:00
return ~ ( uint32_t ) 0 ;
}
2024-12-23 00:16:32 -07:00
void ARC_ChemicalData_CreateFn ( void * * data , ARC_ParserTagToken * parsedData , void * userData ) {
2024-12-22 23:31:37 -07:00
* data = NULL ;
if ( data = = NULL | | userData = = NULL ) {
//TODO: error here?
* data = NULL ;
return ;
}
2024-12-23 00:16:32 -07:00
}
2024-12-22 23:31:37 -07:00
2025-01-29 17:31:18 -07:00
void ARC_ChemicalData_DestroyFn ( void * data , ARC_Bool clear , void * userData ) {
return ;
}
2024-12-23 00:16:32 -07:00
void ARC_Chemical_Create ( ARC_Chemical * * chemical ) {
* chemical = ( ARC_Chemical * ) malloc ( sizeof ( ARC_Chemical ) ) ;
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
/* ~ define the language as a string ~ */
char * languageCString =
2025-01-29 17:31:18 -07:00
" <language> -> <variableLine> <language> | <whitespace> <language> | LAMBDA \n "
2024-12-22 23:31:37 -07:00
2025-01-29 17:31:18 -07:00
" <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 "
2024-12-22 23:31:37 -07:00
2025-01-29 17:31:18 -07:00
" <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 "
2024-12-22 23:31:37 -07:00
2025-01-29 17:31:18 -07:00
" <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 "
2024-12-22 23:31:37 -07:00
2025-01-29 17:31:18 -07:00
" <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 "
2024-12-22 23:31:37 -07:00
2025-01-29 17:31:18 -07:00
" <number> -> NUMBER <number> | NUMBER \n "
2024-12-22 23:31:37 -07:00
2025-01-29 17:31:18 -07:00
" <whitespace> -> SPACE <whitespace> | TAB <whitespace> | SPACE | TAB \n " ;
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
/* ~ define the language as a string ~ */
ARC_String * languageString ;
ARC_String_CreateWithStrlen ( & languageString , languageCString ) ;
2024-12-22 23:31:37 -07:00
2025-01-29 17:31:18 -07:00
/* ~ set chemical as userdata ~ */
void * userdata = * chemical ;
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
/* ~ create the language ~ */
2025-01-29 17:31:18 -07:00
ARC_ParserData_CreateFn createCharFn = ARC_ChemicalData_CreateFn ;
ARC_ParserData_DestroyFn destroyCharFn = ARC_ChemicalData_DestroyFn ;
ARC_Parser_CreateFromString ( & ( ( * chemical ) - > parser ) , languageString , ARC_Chemical_InitLexerRulesFn , ARC_Chemical_GetStringIdFn , & createCharFn , & destroyCharFn , userdata ) ;
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
//cleanup
ARC_String_Destroy ( languageString ) ;
2024-12-22 23:31:37 -07:00
}
2024-12-23 00:16:32 -07:00
void ARC_Chemical_Destroy ( ARC_Chemical * chemical ) {
2025-01-29 17:31:18 -07:00
free ( chemical ) ;
2024-12-23 00:16:32 -07:00
}
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
void ARC_Chemical_RegisterType ( ARC_Chemical * chemical , ARC_String * typeName , ARC_ChemicalData_CopyToTypeFn * copyToTypeFn , ARC_ParserCSV_DestroyTypeFn destroyTypeFn ) {
}
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
void ARC_Chemical_SetGroup ( ARC_Chemical * chemical , ARC_String * groupName ) {
2024-12-22 23:31:37 -07:00
}
2024-12-23 00:16:32 -07:00
void * ARC_Chemical_Get ( ARC_Chemical * chemical , ARC_String * element ) {
return NULL ;
}
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
void ARC_Chemical_LoadFromString ( ARC_String * path ) {
}
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
void ARC_Chemical_LoadFromFile ( ARC_String * path ) {
}
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
void ARC_Chemical_UnloadFromString ( ARC_String * data ) {
}
2024-12-22 23:31:37 -07:00
2024-12-23 00:16:32 -07:00
void ARC_Chemical_UnloadFromFile ( ARC_String * data ) {
2024-12-22 23:31:37 -07:00
}
2025-01-29 17:31:18 -07:00