Added GPLv2+ as license for libgrammatic
[cascardo/grammar.git] / grammar.h
1 /*
2  *  Copyright (C) 2005  Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
3  *
4  *  This program is free software; you can redistribute it and/or modify
5  *  it under the terms of the GNU General Public License as published by
6  *  the Free Software Foundation; either version 2 of the License, or
7  *  (at your option) any later version.
8  *
9  *  This program is distributed in the hope that it will be useful,
10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  *  GNU General Public License for more details.
13  *
14  *  You should have received a copy of the GNU General Public License along
15  *  with this program; if not, write to the Free Software Foundation, Inc.,
16  *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17  */
18
19
20
21 #ifndef GRAMMAR_H
22 #define GRAMMAR_H
23
24 #include <glib.h>
25
26 typedef gint (*nextcb) (gpointer, gpointer*);
27
28 typedef struct
29 {
30   gboolean terminal;
31   GQuark value;
32 } symbol_t;
33
34 typedef struct _rule rule_t;
35 typedef struct
36 {
37   GHashTable* grammar;
38 } grammar_t;
39
40 symbol_t* symbol_new (gboolean, GQuark);
41 symbol_t* symbol_copy (symbol_t*);
42 guint symbol_hash (gconstpointer);
43 gboolean symbol_equal (gconstpointer, gconstpointer);
44 gint symbol_cmp (symbol_t*, symbol_t*);
45
46 rule_t* rule_new ();
47 rule_t* rule_copy (rule_t*);
48 gint rule_cmp (rule_t*, rule_t*);
49 gboolean rule_equal (gconstpointer, gconstpointer);
50 guint rule_hash (gconstpointer);
51 symbol_t* rule_pop (rule_t*);
52 void rule_append (rule_t*, symbol_t*);
53 void rule_delete (rule_t*);
54
55 grammar_t* grammar_new ();
56 rule_t* grammar_rule_new (grammar_t*, symbol_t*);
57 GList* grammar_get_rules (grammar_t*, symbol_t*);
58 GList* grammar_get_rule (rule_t*);
59 void grammar_delete (grammar_t*);
60
61 #endif