forked from joefutrelle/rmutt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrammar.h
30 lines (22 loc) · 1.01 KB
/
grammar.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include "dict.h"
#include "grambit.h"
typedef struct _grammar {
struct _grammar *parent;
DICT *contents;
} GRAMMAR;
/* rmutt grammar implementation */
extern GRAMMAR *grammar_new(); /* create a grammar */
extern void grammar_free(GRAMMAR *); /* free a grammar */
extern void grammar_add(GRAMMAR *, RULE *); /* add a rule to a grammar */
extern void grammar_addAll(GRAMMAR *, LIST *); /* add rules to a grammar */
extern RULE *grammar_lookUp(GRAMMAR *, char *); /* look up a named rule in the grammar */
/* expand the grambit of the grammar into a sequence of
grambits, selected according to the rules of the grammar */
extern LIST *grammar_expand(GRAMMAR *, GRAMBIT *g);
/* do the same thing but actually produce a string */
extern char *grammar_produce(GRAMMAR *, GRAMBIT *g);
/* produce the string for just one grambit */
extern char *grambit_toString(GRAMMAR *, GRAMBIT *);
/* apply a transformation to a string in the context of a grammar */
extern char *transform(GRAMMAR *g, char *, GRAMBIT *);