fcml  1.2.2
Classes | Macros | Typedefs | Functions
fcml_parser.h File Reference

Structures and functions declarations related to FCML parsers. More...

#include "fcml_lib_export.h"
#include "fcml_types.h"
#include "fcml_errors.h"
#include "fcml_common.h"
#include "fcml_dialect.h"
#include "fcml_symbols.h"
Include dependency graph for fcml_parser.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  fcml_st_parser_config
 Parser configuration. More...
 
struct  fcml_st_parser_context
 Parser runtime context. More...
 
struct  fcml_st_parser_result
 Reusable result holder. More...
 

Macros

#define FCML_PARSER_MAX_INSTRUCTION_LEN   1024
 Maximal number of character for parsed instruction. More...
 

Typedefs

typedef struct fcml_st_parser_config fcml_st_parser_config
 Parser configuration. More...
 
typedef struct fcml_st_parser_context fcml_st_parser_context
 Parser runtime context. More...
 
typedef struct fcml_st_parser_result fcml_st_parser_result
 Reusable result holder.
 

Functions

LIB_EXPORT fcml_ceh_error LIB_CALL fcml_fn_parse (fcml_st_parser_context *context, const fcml_string instruction, fcml_st_parser_result *result)
 Parses given instruction into the generic instruction model. More...
 
LIB_EXPORT void LIB_CALL fcml_fn_parser_result_prepare (fcml_st_parser_result *result)
 Prepares reusable result holder for parser. More...
 
LIB_EXPORT void LIB_CALL fcml_fn_parser_result_free (fcml_st_parser_result *result)
 Cleans result holder. More...
 

Detailed Description

Structures and functions declarations related to FCML parsers.

Macro Definition Documentation

◆ FCML_PARSER_MAX_INSTRUCTION_LEN

#define FCML_PARSER_MAX_INSTRUCTION_LEN   1024

Maximal number of character for parsed instruction.

Typedef Documentation

◆ fcml_st_parser_config

Parser configuration.

◆ fcml_st_parser_context

Parser runtime context.

Function Documentation

◆ fcml_fn_parse()

LIB_EXPORT fcml_ceh_error LIB_CALL fcml_fn_parse ( fcml_st_parser_context context,
const fcml_string  instruction,
fcml_st_parser_result result 
)

Parses given instruction into the generic instruction model.

Parses the textual representation of the instruction using dialect and configuration provided by the parser context. Parsed instruction is returned in the reusable result holder. Result holder has to be allocated by the user and appropriately prepared using fcml_fn_parser_result_prepare() function. As long as the instruction context and the result holder are not shared across multiple function calls parsing process is thread safe.

Remember that textual representation of the instruction has to be written using syntax supported by the dialect parser is going to use.

Parameters
contextParser runtime context.
instructiontextual representation of the instruction to be parsed.
resultReusable result holder.
Returns
Error code or FCML_CEH_GEC_NO_ERROR.

◆ fcml_fn_parser_result_free()

LIB_EXPORT void LIB_CALL fcml_fn_parser_result_free ( fcml_st_parser_result result)

Cleans result holder.

Frees all memory blocks allocated by the parser and held inside the result holder (Instructions, errors etc.). Notice that result holder itself is not freed and can be even safety reused after call to this function. In fact this function is also called internally by the parser in order to clean result holder before reusing it.

Parameters
resultResult holder to clean.

◆ fcml_fn_parser_result_prepare()

LIB_EXPORT void LIB_CALL fcml_fn_parser_result_prepare ( fcml_st_parser_result result)

Prepares reusable result holder for parser.

Every instance of fcml_st_parser_result structure is reusable from the parser's point of view, so it has to be prepared in the right way in order to allow parser to reuse it correctly. It is up to the library user to allocate space for the holder itself. This function is only responsible for cleaning the structure correctly and preparing it for the first parsing process. Notice that parser has to clean the result holder at the beginning so you can not pass an uninitialized memory block because it can even cause a crash due to illegal memory access.

Parameters
resultResult holder instance to be prepared.