Skip to content
Authors

File toml_parser.c

FileList > source > toml_parser > src > toml_parser.c

Go to the source code of this file

Parses a TOML string into a production store and frees a store created with the module. More...

  • #include "toml_parser.h"
  • #include "stdio.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdlib.h>
  • #include <string.h>
  • #include <pdgl_defs.h>
  • #include <prod_pure.h>
  • #include <prod_range.h>
  • #include <prod_janet.h>
  • #include <prod_weighted.h>
  • #include <production_store.h>
  • #include <tomlc17.h>

Classes

Type Name
class prodstr_builder_set_t
Structure for a production object type specific data.

Public Types

Type Name
typedef prodstr_obj_t *(* prod_builder_funptr_t
Function pointer for production builder functions.
typedef void(* prod_free_funptr_t
Function pointer for production free functions.

Public Static Attributes

Type Name
prodstr_builder_set_t registed_prod_builders = /* multi line expression */
List of productions configured for building a production store.

Public Functions

Type Name
void tomlprsr_free (prodstr_store_t * store)
Free a store created by the TOML parsing Function.
prodstr_store_t *const tomlprsr_parse (const char * toml_data)
Parse a language spec TOML string into a production store.
STATIC_INLINE prodstr_obj_t * tomlprsr_prod_janet_builder (toml_datum_t tbl)
Builder function for a Janet production.
STATIC_INLINE void tomlprsr_prod_janet_free (prodstr_obj_t * prd)
Free an allocated Janet production.
STATIC_INLINE prodstr_obj_t * tomlprsr_prod_pure_builder (toml_datum_t tbl)
Builder function for a pure production.
STATIC_INLINE char ** tomlprsr_prod_pure_builder_list (toml_datum_t ary)
Parse TOML array into a list of strings for a pure production.
STATIC_INLINE void tomlprsr_prod_pure_free (prodstr_obj_t * prd)
Free an allocated pure production.
STATIC_INLINE prodstr_obj_t * tomlprsr_prod_range_builder (toml_datum_t tbl)
Builder function for a range production.
STATIC_INLINE void tomlprsr_prod_range_free (prodstr_obj_t * prd)
Free an allocated range production.
STATIC_INLINE prodstr_obj_t * tomlprsr_prod_weighted_builder (toml_datum_t tbl)
Builder function for a weighted production.
STATIC_INLINE prod_weighted_pair_t * tomlprsr_prod_weighted_builder_list (toml_datum_t ary)
Parse TOML array into a list of strings for a pure production.
STATIC_INLINE void tomlprsr_prod_weighted_free (prodstr_obj_t * prd)
Free an allocated weighted production.

Detailed Description

Author:

Joe Starr

Public Types Documentation

typedef prod_builder_funptr_t

Function pointer for production builder functions.

typedef prodstr_obj_t *(* prod_builder_funptr_t) (toml_datum_t tbl);


typedef prod_free_funptr_t

Function pointer for production free functions.

typedef void(* prod_free_funptr_t) (prodstr_obj_t *prd);


Public Static Attributes Documentation

variable registed_prod_builders

List of productions configured for building a production store.

prodstr_builder_set_t registed_prod_builders[];


Public Functions Documentation

function tomlprsr_free

Free a store created by the TOML parsing Function.

void tomlprsr_free (
    prodstr_store_t * store
) 

Free each pointer allocated by the parsing function.

Parameters:

  • store The store to free.

function tomlprsr_parse

Parse a language spec TOML string into a production store.

prodstr_store_t *const tomlprsr_parse (
    const char * toml_data
) 

Read the TOML into an object. From the object parse into a production store. Ensure the existence of an entry symbol production.

Parameters:

  • toml_data String TOML data to parse.

Returns:

A pointer to a production store on success. A NULL pointer on failure.


function tomlprsr_prod_janet_builder

Builder function for a Janet production.

STATIC_INLINE  prodstr_obj_t * tomlprsr_prod_janet_builder (
    toml_datum_t tbl
) 

Parses a pure production from TOML to a prodstr_obj_t configured as a Janet production.

Parameters:

  • tbl TOML production data to parse

Returns:

A pointer to a prodstr_obj_t when successful and a NULL pointer when unsuccessful.


function tomlprsr_prod_janet_free

Free an allocated Janet production.

STATIC_INLINE void tomlprsr_prod_janet_free (
    prodstr_obj_t * prd
) 

Parameters:

  • prd The production object to free.

function tomlprsr_prod_pure_builder

Builder function for a pure production.

STATIC_INLINE  prodstr_obj_t * tomlprsr_prod_pure_builder (
    toml_datum_t tbl
) 

Parses a pure production from TOML to a prodstr_obj_t configured as a pure production.

Parameters:

  • tbl TOML production data to parse

Returns:

A pointer to a prodstr_obj_t when successful and a NULL pointer when unsuccessful.


function tomlprsr_prod_pure_builder_list

Parse TOML array into a list of strings for a pure production.

STATIC_INLINE char ** tomlprsr_prod_pure_builder_list (
    toml_datum_t ary
) 

Parse the given TOML array of strings into an array of c strings for a pure production.

Parameters:

  • ary A TOML array of strings.

Returns:

A list of strings when successful and a NULL pointer when unsuccessful.


function tomlprsr_prod_pure_free

Free an allocated pure production.

STATIC_INLINE void tomlprsr_prod_pure_free (
    prodstr_obj_t * prd
) 

Parameters:

  • prd The production object to free.

function tomlprsr_prod_range_builder

Builder function for a range production.

STATIC_INLINE  prodstr_obj_t * tomlprsr_prod_range_builder (
    toml_datum_t tbl
) 

Parses a pure production from TOML to a prodstr_obj_t configured as a range production.

Parameters:

  • tbl TOML production data to parse

Returns:

A pointer to a prodstr_obj_t when successful and a NULL pointer when unsuccessful.


function tomlprsr_prod_range_free

Free an allocated range production.

STATIC_INLINE void tomlprsr_prod_range_free (
    prodstr_obj_t * prd
) 

Parameters:

  • prd The production object to free.

function tomlprsr_prod_weighted_builder

Builder function for a weighted production.

STATIC_INLINE  prodstr_obj_t * tomlprsr_prod_weighted_builder (
    toml_datum_t tbl
) 

Parses a pure production from TOML to a prodstr_obj_t configured as a weighted production.

Parameters:

  • tbl TOML production data to parse

Returns:

A pointer to a prodstr_obj_t when successful and a NULL pointer when unsuccessful.


function tomlprsr_prod_weighted_builder_list

Parse TOML array into a list of strings for a pure production.

STATIC_INLINE  prod_weighted_pair_t * tomlprsr_prod_weighted_builder_list (
    toml_datum_t ary
) 

Parse the given TOML array of strings into an array of c strings for a pure production.

Parameters:

  • ary A TOML array of strings.

Returns:

A list of strings when successful and a NULL pointer when unsuccessful.


function tomlprsr_prod_weighted_free

Free an allocated weighted production.

STATIC_INLINE void tomlprsr_prod_weighted_free (
    prodstr_obj_t * prd
) 

Parameters:

  • prd The production object to free.


The documentation for this class was generated from the following file source/toml_parser/src/toml_parser.c