merged with old parser stuff, and worked on parser a bit more
This commit is contained in:
commit
e4aa4a8b6d
8 changed files with 180 additions and 30 deletions
|
|
@ -5,7 +5,10 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "arc/std/string.h"
|
||||
#include "arc/std/array.h"
|
||||
//#include "arc/std/bool.h"
|
||||
//#include "arc/std/lexer.h"
|
||||
#include <stdint.h>
|
||||
|
||||
/**
|
||||
* @brief a parser type
|
||||
|
|
@ -13,17 +16,56 @@ extern "C" {
|
|||
typedef struct ARC_Parser ARC_Parser;
|
||||
|
||||
/**
|
||||
* @brief a parser node
|
||||
* @brief a langue tag type for the parser //TODO: explain this better
|
||||
*/
|
||||
typedef struct ARC_ParserNode ARC_ParserNode;
|
||||
typedef struct ARC_ParserLanguageTag {
|
||||
uint32_t tagId;
|
||||
|
||||
uint32_t **tokensOrTags;
|
||||
uint32_t tokensOrTagsSize;
|
||||
} ARC_ParserLanguageTag;
|
||||
|
||||
/**
|
||||
* @brief a callback function to initialize the lexer the parser uses with rules
|
||||
*
|
||||
* @param lexer the lexer used by the parser that rules should be added to
|
||||
*/
|
||||
typedef void (* ARC_Parser_InitLexerRulesFn)(ARC_Lexer *lexer);
|
||||
|
||||
/**
|
||||
* @brief creates an ARC_Parser type
|
||||
*
|
||||
* @param[out] parser
|
||||
* @param[in] language ..., can be NULL
|
||||
* @TODO: probs want to move the note to another file
|
||||
* @note array of tokens for langauge? like
|
||||
* ARC_ParserTag tag = {
|
||||
* VARIABLE_NAME, //tagId
|
||||
* {
|
||||
* { 2, CHAR_OR_NUM, VARIABLE_NAME },
|
||||
* { 1, LAMBDA },
|
||||
* }, //components
|
||||
* 2 //componentsSize
|
||||
* };
|
||||
*
|
||||
* @param[out] parser ARC_Parser to create
|
||||
* @param[in] language an arry of ARC_ParserLanguageTags defining a langauge
|
||||
* @param[in] initLexerRulesFn a callback used to initalize the token rules the lexer within the parser will use
|
||||
*/
|
||||
void ARC_Parser_Create(ARC_Parser **parser, ARC_String *language);
|
||||
void ARC_Parser_Create(ARC_Parser **parser, ARC_Array *language, ARC_Parser_InitLexerRulesFn initLexerRulesFn);
|
||||
|
||||
/**
|
||||
* @brief creates an ARC_Parser type from a string
|
||||
*
|
||||
* @TODO: probs want to move the note to another file
|
||||
* @note the syntax looks like:
|
||||
* <variable> -> CHAR <variableName> EOF
|
||||
* <variableName> -> <charOrNum> <variableName> | LAMBDA
|
||||
* <charOrNum> -> CHAR | NUM
|
||||
*
|
||||
* @param[out] parser ARC_Parser to create
|
||||
* @param[in] language an arry of ARC_ParserLanguageTags defining a langauge
|
||||
* @param[in] initLexerRulesFn a callback used to initalize the token rules the lexer within the parser will use
|
||||
*/
|
||||
void ARC_Parser_CreateFromString(ARC_Parser **parser, ARC_String *languageString, ARC_Parser_InitLexerRulesFn initLexerRulesFn);
|
||||
|
||||
/**
|
||||
* @brief destroys an ARC_Parser type
|
||||
|
|
@ -33,26 +75,18 @@ void ARC_Parser_Create(ARC_Parser **parser, ARC_String *language);
|
|||
void ARC_Parser_Destroy(ARC_Parser *parser);
|
||||
|
||||
/**
|
||||
* @brief sets the definition of the parser, the language itself is parsed and will throw an error if invalid
|
||||
* @brief
|
||||
*
|
||||
* @param[in] parser ARC_Parser to set the language to
|
||||
* @param[in] language the language as a string the parser should use
|
||||
*/
|
||||
void ARC_Parser_SetLanguage(ARC_Parser *parser, ARC_String *language);
|
||||
|
||||
/**
|
||||
* @brief sets the definition of the parser, the language itself is parsed and will throw an error if invalid
|
||||
*
|
||||
* @param[in] parser ARC_Parser to set the language to
|
||||
* @param[in] language the language as a string the parser should use
|
||||
* @param[in] parser
|
||||
* @param[in] language
|
||||
*/
|
||||
void ARC_Parser_Parse(ARC_Parser *parser, ARC_String *data);
|
||||
|
||||
/**
|
||||
* @brief sets the definition of the parser, the language itself is parsed and will throw an error if invalid
|
||||
* @brief
|
||||
*
|
||||
* @param[in] parser ARC_Parser to set the language to
|
||||
* @param[in] language the language as a string the parser should use
|
||||
* @param[in] parser
|
||||
* @param[in] language
|
||||
*/
|
||||
void ARC_Parser_ParseFile(ARC_Parser *parser, ARC_String *path);
|
||||
|
||||
|
|
@ -60,4 +94,4 @@ void ARC_Parser_ParseFile(ARC_Parser *parser, ARC_String *path);
|
|||
}
|
||||
#endif
|
||||
|
||||
#endif // !ARC_STD_LEXER_H_
|
||||
#endif // !ARC_STD_PARSER_H_
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue