Added GPLv2+ as license for libgrammatic
[cascardo/grammar.git] / lr0.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 LR0_H
22 #define LR0_H
23
24 #include "parser.h"
25
26 typedef enum
27   {
28     PARSER_SHIFT,
29     PARSER_REDUCE,
30     PARSER_ACCEPT,
31   } action_t;
32
33 typedef struct
34 {
35   gint state;
36   gpointer attrib;
37 } state_t;
38
39 typedef struct
40 {
41   gint action;
42   gint state;
43 } transition_t;
44
45 typedef struct
46 {
47   nextcb cb;
48   gpointer data;
49   GList* stack;
50   GHashTable* table;
51   GList* rules;
52 } lr0_t;
53
54 transition_t* transition_new (gint, gint);
55 lr0_t* lr0_new (nextcb, gpointer);
56 void lr0_delete (lr0_t*);
57 void lr0_add (lr0_t*, gint, symbol_t*, transition_t*);
58 gpointer lr0_build (lr0_t*);
59
60 #endif