2 * Copyright (C) 2005 Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
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.
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.
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.
22 * Copyright 2005 Thadeu Lima de Souza Cascardo
26 * Translate a grammar to a DFA table, if it is possible, i.e., it's a
27 * regular grammar and has no non-determinism.
34 void dfa_gen_add (gpointer key, gpointer val, gpointer data)
42 left = (symbol_t*) key;
43 right = (rule_t*) val;
48 dfa_t* dfa_gen (grammar_t* grammar, symbol_t* start, nextcb cb, gpointer data)
53 dfa = dfa_new (cb, data, dfa_state_new (start->value, FALSE));
55 g_hash_table_foreach (grammar->grammar, dfa_gen_add, dfa);