SphinxBase 0.6
jsgf_internal.h
Go to the documentation of this file.
1/* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/* ====================================================================
3 * Copyright (c) 2007 Carnegie Mellon University. All rights
4 * reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 *
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 *
18 * This work was supported in part by funding from the Defense Advanced
19 * Research Projects Agency and the National Science Foundation of the
20 * United States of America, and the CMU Sphinx Speech Consortium.
21 *
22 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND
23 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
24 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
25 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY
26 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 *
34 * ====================================================================
35 *
36 */
37
38#ifndef __JSGF_INTERNAL_H__
39#define __JSGF_INTERNAL_H__
40
45#define YY_NO_UNISTD_H 1
46#include <stdio.h>
47
49#include <sphinxbase/glist.h>
50#include <sphinxbase/fsg_model.h>
51#include <sphinxbase/logmath.h>
52#include <sphinxbase/strfuncs.h>
53#include <sphinxbase/jsgf.h>
54
55#ifdef __cplusplus
56extern "C" {
57#endif
58#if 0
59/* Fool Emacs. */
60}
61#endif
62
63#define YY_NO_INPUT /* Silence a compiler warning. */
64
65typedef struct jsgf_rhs_s jsgf_rhs_t;
66typedef struct jsgf_atom_s jsgf_atom_t;
67typedef struct jsgf_link_s jsgf_link_t;
68
69struct jsgf_s {
70 char *version;
71 char *charset;
72 char *locale;
73 char *name;
80 /* Scratch variables for FSG conversion. */
81 int nstate;
84};
85
87 int refcnt;
88 char *name;
89 int public;
92 int entry;
93 int exit;
94};
95
100
102 char *name;
104 float weight;
105};
106
109 int from;
110 int to;
111};
112
113#define jsgf_atom_is_rule(atom) ((atom)->name[0] == '<')
114
115void jsgf_add_link(jsgf_t *grammar, jsgf_atom_t *atom, int from, int to);
116jsgf_atom_t *jsgf_atom_new(char *name, float weight);
117jsgf_atom_t *jsgf_kleene_new(jsgf_t *jsgf, jsgf_atom_t *atom, int plus);
118jsgf_rule_t *jsgf_optional_new(jsgf_t *jsgf, jsgf_rhs_t *exp);
119jsgf_rule_t *jsgf_define_rule(jsgf_t *jsgf, char *name, jsgf_rhs_t *rhs, int public);
120jsgf_rule_t *jsgf_import_rule(jsgf_t *jsgf, char *name);
121
122int jsgf_atom_free(jsgf_atom_t *atom);
123int jsgf_rule_free(jsgf_rule_t *rule);
124jsgf_rule_t *jsgf_rule_retain(jsgf_rule_t *rule);
125
126#ifdef __cplusplus
127}
128#endif
129
130
131#endif /* __JSGF_H__ */
Generic linked-lists maintenance.
Hash table implementation.
JSGF grammar compiler.
Fast integer logarithmic addition operations.
Miscellaneous useful string functions.
A node in a generic list.
Definition glist.h:100
glist_t tags
Tags, if any (glist_t of char *)
float weight
Weight (default 1)
char * name
Rule or token name.
glist_t atoms
Sequence of items.
jsgf_rhs_t * alt
Linked list of alternates.
int entry
Entry state for current instance of this rule.
char * name
Rule name (NULL for an alternation/grouping)
jsgf_rhs_t * rhs
Expansion.
int exit
Exit state for current instance of this rule.
int refcnt
Reference count.
char * locale
JSGF locale (default C)
glist_t rulestack
Stack of currently expanded rules.
int nstate
Number of generated states.
glist_t links
Generated FSG links.
hash_table_t * imports
Pointers to imported grammars.
glist_t searchpath
List of directories to search for grammars.
char * name
Grammar name.
char * charset
JSGF charset (default UTF-8)
char * version
JSGF version (from header)
jsgf_t * parent
Parent grammar (if this is an imported one)
hash_table_t * rules
Defined or imported rules in this grammar.