Loading...
Searching...
No Matches
parser.h File Reference
`#include "arc/std/array.h"`
`#include "arc/std/lexer.h"`
`#include "arc/std/vector.h"`
`#include <stdint.h>`

Go to the source code of this file.

## Data Structures

struct | ARC_ParserTag
| a langue tag type for the parser //TODO: explain this better More...
struct | ARC_ParserTagToken
| a parser type used inside of the parser data create function More...

## Macros

#define | ARC_PARSER_TAG_LAMBDA 0
| basic tag for letting the parser know it is ok to end

## Typedefs

typedef struct ARC_Parser | ARC_Parser
| a parser type
typedef struct ARC_ParserTag | ARC_ParserTag
| a langue tag type for the parser //TODO: explain this better
typedef struct ARC_ParserTagToken | ARC_ParserTagToken
| a parser type used inside of the parser data create function
typedef void(* | ARC_Parser_InitLexerRulesFn) (ARC_Lexer *lexer)
| a callback function to initialize the lexer the parser uses with rules
typedef uint32_t(* | ARC_Parser_GetStringIdFn) (ARC_String *string)
| TODO: write this.
typedef void(* | ARC_ParserData_CreateFn) (void **data, ARC_ParserTagToken *parsedData, void *userData)
| TODO: write this.
typedef void(* | ARC_ParserData_DestroyFn) (void *data, ARC_Bool clear, void *userData)
| TODO: write this.

## Functions

void | ARC_Parser_Create (ARC_Parser **parser, ARC_Array *language, ARC_Parser_InitLexerRulesFn initLexerRulesFn, ARC_ParserData_CreateFn *createDataFn, ARC_ParserData_DestroyFn *destroyDataFn, void *userData)
| creates an ARC_Parser type
void | ARC_Parser_CreateFromVector (ARC_Parser **parser, ARC_Vector *language, ARC_Parser_InitLexerRulesFn initLexerRulesFn, ARC_ParserData_CreateFn *createDataFn, ARC_ParserData_DestroyFn *destroyDataFn, void *userData)
| creates an ARC_Parser type from an arc vector
void | ARC_Parser_CreateFromString (ARC_Parser **parser, ARC_String *languageString, ARC_Parser_InitLexerRulesFn initLexerRulesFn, ARC_Parser_GetStringIdFn getStringIdFn, ARC_ParserData_CreateFn *createDataFn, ARC_ParserData_DestroyFn *destroyDataFn, void *userData)
| creates an ARC_Parser type from a string
void | ARC_Parser_Destroy (ARC_Parser *parser)
| destroys an ARC_Parser type
void | ARC_Parser_Parse (ARC_Parser *parser, ARC_String **data)
void | ARC_Parser_ParseFile (ARC_Parser *parser, ARC_String *path)
void | ARC_Parser_ClearData (ARC_Parser *parser)
void * | ARC_Parser_GetData (ARC_Parser *parser)

## Macro Definition Documentation

## ARC_PARSER_TAG_LAMBDA

#define ARC_PARSER_TAG_LAMBDA 0

basic tag for letting the parser know it is ok to end

Definition at line 150 of file parser.h.

## Typedef Documentation

## ARC_Parser

typedef struct ARC_Parser ARC_Parser

a parser type

Definition at line 16 of file parser.h.

## ARC_Parser_GetStringIdFn

typedef uint32_t(* ARC_Parser_GetStringIdFn) (ARC_String *string)

TODO: write this.

Definition at line 52 of file parser.h.

## ARC_Parser_InitLexerRulesFn

typedef void(* ARC_Parser_InitLexerRulesFn) (ARC_Lexer *lexer)

a callback function to initialize the lexer the parser uses with rules

Parameters

  lexer | the lexer used by the parser that rules should be added to

Definition at line 47 of file parser.h.

## ARC_ParserData_CreateFn

typedef void(* ARC_ParserData_CreateFn) (void **data, ARC_ParserTagToken *parsedData, void *userData)

TODO: write this.

Definition at line 57 of file parser.h.

## ARC_ParserData_DestroyFn

typedef void(* ARC_ParserData_DestroyFn) (void *data, ARC_Bool clear, void *userData)

TODO: write this.

Definition at line 62 of file parser.h.

## ARC_ParserTag

typedef struct ARC_ParserTag ARC_ParserTag

a langue tag type for the parser //TODO: explain this better

## ARC_ParserTagToken

typedef struct ARC_ParserTagToken ARC_ParserTagToken

a parser type used inside of the parser data create function

Note
  there are no public creation and destruction functions for this type as it is only ment to be used within the creation callback
  if the parser tag token is a token then tagTokens will be NULL
  if the parser tag token is a tag then token will be NULL

## Function Documentation

## ARC_Parser_ClearData()

void ARC_Parser_ClearData | ( | ARC_Parser * | parser | ) |

Parameters

  [in] | parser |

## ARC_Parser_Create()

void ARC_Parser_Create | ( | ARC_Parser ** | parser,
|  | ARC_Array * | language,
|  | ARC_Parser_InitLexerRulesFn | initLexerRulesFn,
|  | ARC_ParserData_CreateFn * | createDataFn,
|  | ARC_ParserData_DestroyFn * | destroyDataFn,
|  | void * | userData )

creates an ARC_Parser type

@TODO: fix this documentation to reflect changes

@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 };

Parameters

  [out] | parser | ARC_Parser to create
  [in] | language | an arry of ARC_ParserLanguageTags defining a langauge
  [in] | initLexerRulesFn | a callback used to initalize the token rules the lexer within the parser will use

## ARC_Parser_CreateFromString()

void ARC_Parser_CreateFromString | ( | ARC_Parser ** | parser,
|  | ARC_String * | languageString,
|  | ARC_Parser_InitLexerRulesFn | initLexerRulesFn,
|  | ARC_Parser_GetStringIdFn | getStringIdFn,
|  | ARC_ParserData_CreateFn * | createDataFn,
|  | ARC_ParserData_DestroyFn * | destroyDataFn,
|  | void * | userData )

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

Parameters

  [out] | parser | ARC_Parser to create
  [in] | language | an arry of ARC_ParserLanguageTags defining a langauge
  [in] | initLexerRulesFn | a callback used to initalize the token rules the lexer within the parser will use

## ARC_Parser_CreateFromVector()

void ARC_Parser_CreateFromVector | ( | ARC_Parser ** | parser,
|  | ARC_Vector * | language,
|  | ARC_Parser_InitLexerRulesFn | initLexerRulesFn,
|  | ARC_ParserData_CreateFn * | createDataFn,
|  | ARC_ParserData_DestroyFn * | destroyDataFn,
|  | void * | userData )

creates an ARC_Parser type from an arc vector

Parameters

  [out] | parser | ARC_Parser to create
  [in] | language | an vector of ARC_ParserLanguageTags defining a langauge
  [in] | initLexerRulesFn | a callback used to initalize the token rules the lexer within the parser will use

## ARC_Parser_Destroy()

void ARC_Parser_Destroy | ( | ARC_Parser * | parser | ) |

destroys an ARC_Parser type

Parameters

  [in] | parser | ARC_Parser to free

## ARC_Parser_GetData()

void * ARC_Parser_GetData | ( | ARC_Parser * | parser | ) |

Parameters

  [in] | parser |

## ARC_Parser_Parse()

void ARC_Parser_Parse | ( | ARC_Parser * | parser,
|  | ARC_String ** | data )

Parameters

  [in] | parser |
  | [in/out] | data the string to parse, will be freed and set to NULL by the end of this function

## ARC_Parser_ParseFile()

void ARC_Parser_ParseFile | ( | ARC_Parser * | parser,
|  | ARC_String * | path )

Parameters

  [in] | parser |
  [in] | language |