libabacus/include/parser.h

55 lines
1.6 KiB
C
Raw Permalink Normal View History

#ifndef LIBABACUS_PARSER_H
#define LIBABACUS_PARSER_H
#include "ll.h"
#include "parsetype.h"
2018-04-21 14:09:01 -07:00
#include "table.h"
#include "tree.h"
2018-05-11 20:36:27 -07:00
struct libab_s;
2018-02-11 22:23:02 -08:00
/**
* The parser that is used by libabacus
* to store information for converting
* tokens into trees.
*/
struct libab_parser_s {
2018-05-11 20:36:27 -07:00
struct libab_s* ab;
2018-02-11 22:23:02 -08:00
};
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.
*/
2018-05-11 20:36:27 -07:00
void libab_parser_init(libab_parser* parser, struct libab_s* ab);
/**
* Parses the given list of tokens into the given tree pointer.
2018-02-11 22:23:02 -08:00
* @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.
2018-05-17 15:33:38 -07:00
* @return the result of parsing the tree.
*/
2018-02-11 22:23:02 -08:00
libab_result libab_parser_parse(libab_parser* parser, ll* tokens,
2018-04-21 14:09:01 -07:00
const char* string, libab_tree** store_into);
2018-05-17 15:33:38 -07:00
/**
* Parses a type into the given reference.
* @param parser the parser to use for parsing text.
* @param tokens the tokens to use for parsing.
* @param string the string from which the tokens came from.
* @param store_into the reference into which to place the type.
* @return the result of parsing the type.
*/
libab_result libab_parser_parse_type(libab_parser* parser, ll* tokens,
2018-04-21 14:09:01 -07:00
const char* string, libab_ref* store_into);
2018-02-11 22:23:02 -08:00
/**
* Releases the resources allocated by the parser.
* @param parser the parser to release.
*/
void libab_parser_free(libab_parser* parser);
#endif