libabacus/include/parser.h
Danila Fedorin 2487cdebe0 Add the ability to parse types.
This ability is not integrated with the rest of the parser - in fact, the grammar for things like function declarations (where type declarations are necessary) is not yet determined.
2018-03-06 16:47:11 -08:00

44 lines
1.2 KiB
C

#ifndef LIBABACUS_PARSER_H
#define LIBABACUS_PARSER_H
#include "table.h"
#include "ll.h"
#include "tree.h"
#include "parsetype.h"
/**
* The parser that is used by libabacus
* to store information for converting
* tokens into trees.
*/
struct libab_parser_s {
libab_table* base_table;
};
typedef struct libab_parser_s libab_parser;
/**
* Initializes the parser.
* @param parser the parser to intialize.
* @param table the table of "reserved" entries like operators.
*/
void libab_parser_init(libab_parser* parser, libab_table* table);
/**
* Parses the given list of tokens into the given tree pointer.
* @param parser the parser to use for parsing text.
* @param tokens the tokens to use for parsing.
* @param string the string to use for determining token values.
* @param store_into tree pointer to store the new data into.
*/
libab_result libab_parser_parse(libab_parser* parser, ll* tokens,
const char* string, libab_tree** store_into);
libab_result libab_parser_parse_type(libab_parser* parser, ll* tokens,
const char* string, libab_parsetype** store_into);
/**
* Releases the resources allocated by the parser.
* @param parser the parser to release.
*/
void libab_parser_free(libab_parser* parser);
#endif