diff options
Diffstat (limited to 'expression.h')
| -rw-r--r-- | expression.h | 22 | 
1 files changed, 20 insertions, 2 deletions
| diff --git a/expression.h b/expression.h index 36a0e02..e288a77 100644 --- a/expression.h +++ b/expression.h @@ -1,6 +1,8 @@  #ifndef LICHEN_EXPRESSION_H  #define LICHEN_EXPRESSION_H +#include <stdint.h> +  /****************************************************************   *    * a grammar is built on both nonterminals and terminals. both are @@ -32,11 +34,27 @@ int li_prod_rule_add(struct li_production_rule_t *rule, size_t seq_len, int *seq  typedef struct li_grammar_t {    struct li_production_rule_t *rules; -  size_t num_nonterminal; +  int num_nonterminal;  } li_grammar_t; -li_rammar_t * li_grammar_alloc(size_t num_nonterminal); +li_grammar_t * li_grammar_alloc(int num_nonterminal);  void li_grammar_free(li_grammar_t *grammar);  int li_grammar_rule_add(li_grammar_t *grammar, int nonterminal, size_t seq_len, int *seq); +// expand a symbol into only nonterminals +// dst is a buffer to place the expansion into, and len should initially contain the size of the buffer +// stack is a buffer used internally to expand the rule, and stack_sz is the size of the stack +// symbol is the symbol to start with +// randomness is a sequence of random values, from any source, and rand_sz is the length of the sequence +// if successful, this function will return 0 and dst will contain the expanded sequence, with len containing +// the length of the actual expansion +// if unsuccessful, this function will return nonzero. dst, len, and stack may be modified in unpredictable ways. +int li_grammar_rule_expand( +  li_grammar_t *grammar,  +  int *dst, size_t *len,  +  int *stack, size_t stack_sz,  +  int symbol,  +  const uint8_t *randomness, size_t rand_sz +); +  #endif | 
