basic tests for chemical parsing, still need to write create and destroy functions for passed back data
This commit is contained in:
parent
18fc05d3d4
commit
b2aec6be00
2 changed files with 53 additions and 39 deletions
|
|
@ -70,23 +70,25 @@ 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;
|
||||
static const uint32_t ARC_CHEMICAL_GROUP = 0x28;
|
||||
static const uint32_t ARC_CHEMICAL_GROUP_NAME = 0x29;
|
||||
static const uint32_t ARC_CHEMICAL_GROUP_ARGS = 0x2A;
|
||||
static const uint32_t ARC_CHEMICAL_VARIABLE_LINES = 0x2B;
|
||||
static const uint32_t ARC_CHEMICAL_VARIABLE_LINE = 0x2C;
|
||||
static const uint32_t ARC_CHEMICAL_ALLOW_SPACE = 0x2D;
|
||||
static const uint32_t ARC_CHEMICAL_TYPE = 0x2E;
|
||||
static const uint32_t ARC_CHEMICAL_VALUE = 0x2F;
|
||||
static const uint32_t ARC_CHEMICAL_NESTED_VALUE = 0x30;
|
||||
static const uint32_t ARC_CHEMICAL_VALUE_ARGS = 0x31;
|
||||
static const uint32_t ARC_CHEMICAL_VARIABLE = 0x32;
|
||||
static const uint32_t ARC_CHEMICAL_VARIABLE_NAME = 0x33;
|
||||
static const uint32_t ARC_CHEMICAL_VARIABLE_CHAR = 0x34;
|
||||
static const uint32_t ARC_CHEMICAL_STRING = 0x35;
|
||||
static const uint32_t ARC_CHEMICAL_STRING_CHARS = 0x36;
|
||||
static const uint32_t ARC_CHEMICAL_STRING_CHAR = 0x37;
|
||||
static const uint32_t ARC_CHEMICAL_ESCAPE_CHAR = 0x38;
|
||||
static const uint32_t ARC_CHEMICAL_WHITESPACE = 0x39;
|
||||
static const uint32_t ARC_CHEMICAL_NUMBER_TAG = 0x3A;
|
||||
|
||||
void ARC_Chemical_InitLexerRulesFn(ARC_Lexer *lexer){
|
||||
ARC_Lexer_RegisterTokenRule(lexer, ARC_LexerTokenRule_CreateAndReturnMatchCharRule(ARC_CHEMICAL_TAB , '\t'));
|
||||
|
|
@ -262,6 +264,15 @@ uint32_t ARC_Chemical_GetStringIdFn(ARC_String *string){
|
|||
if(ARC_String_EqualsCStringWithStrlen(string, "<language>")){
|
||||
return ARC_CHEMICAL_LANGUAGE;
|
||||
}
|
||||
if(ARC_String_EqualsCStringWithStrlen(string, "<group>")){
|
||||
return ARC_CHEMICAL_GROUP;
|
||||
}
|
||||
if(ARC_String_EqualsCStringWithStrlen(string, "<groupName>")){
|
||||
return ARC_CHEMICAL_GROUP_NAME;
|
||||
}
|
||||
if(ARC_String_EqualsCStringWithStrlen(string, "<groupArgs>")){
|
||||
return ARC_CHEMICAL_GROUP_ARGS;
|
||||
}
|
||||
if(ARC_String_EqualsCStringWithStrlen(string, "<variableLines>")){
|
||||
return ARC_CHEMICAL_VARIABLE_LINES;
|
||||
}
|
||||
|
|
@ -271,9 +282,6 @@ uint32_t ARC_Chemical_GetStringIdFn(ARC_String *string){
|
|||
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;
|
||||
}
|
||||
|
|
@ -321,6 +329,7 @@ void ARC_ChemicalData_CreateFn(void **data, ARC_ParserTagToken *parsedData, void
|
|||
printf("HERE??\n");
|
||||
*data = NULL;
|
||||
if(parsedData == NULL || userData == NULL){
|
||||
printf("Parsed Data was NULL\n");
|
||||
//TODO: error here?
|
||||
*data = NULL;
|
||||
return;
|
||||
|
|
@ -364,30 +373,33 @@ void ARC_Chemical_Create(ARC_Chemical **chemical){
|
|||
|
||||
/* ~ define the language as a string ~ */
|
||||
char *languageCString =
|
||||
"<language> -> <variableLine> <language> | <whitespace> <language> | LAMBDA\n"
|
||||
"<language> -> <group> <language> | <variableLines> <language> | LAMBDA\n"
|
||||
|
||||
"<variableLine> -> <allowSpace> <type> <whitespace> <variable> <whitespace> EQUAL <whitespace> <value> <whitespace> SEMICOLON <allowSpace>\n"
|
||||
"<allowSpace> -> SPACE <allowSpace> | TAB <allowSpace> | LAMBDA\n"
|
||||
"<group> -> <whitespace> <groupName> <whitespace> <variable> <whitespace> OPEN_CURLY_BRACE <groupArgs> <whitespace> CLOSE_CURLY_BRACE\n"
|
||||
"<groupName> -> <variable>\n"
|
||||
"<groupArgs> -> <whitespace> <variableLines> | LAMBDA\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"
|
||||
"<variableLines> -> <variableLine> <whitespace> <variableLines> | <variableLine>\n"
|
||||
"<variableLine> -> <whitespace> <type> <whitespace> <variable> <whitespace> EQUAL <whitespace> <value> <whitespace> SEMICOLON\n"
|
||||
"<allowSpace> -> SPACE <allowSpace> | TAB <allowSpace> | LAMBDA\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"
|
||||
"<type> -> <variable>\n"
|
||||
"<value> -> <variable> | <number> | <string> | <nestedValue>\n"
|
||||
"<nestedValue> -> OPEN_CURLY_BRACE <whitespace> <valueArgs> <whitespace> CLOSE_CURLY_BRACE\n"
|
||||
"<valueArgs> -> <value> COMMA <valueArgs> | <value>\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"
|
||||
"<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"
|
||||
|
||||
"<number> -> NUMBER <number> | 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"
|
||||
|
||||
"<whitespace> -> SPACE <whitespace> | TAB <whitespace> | NEWLINE <whitespace> | LAMBDA\n";
|
||||
"<number> -> NUMBER <number> | NUMBER\n"
|
||||
|
||||
"<whitespace> -> SPACE <whitespace> | TAB <whitespace> | NEWLINE <whitespace> | LAMBDA\n";
|
||||
|
||||
/* ~ define the language as a string ~ */
|
||||
ARC_String *languageString;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue