SphinxBase 5prealpha
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#include <stdio.h>
46
48#include <sphinxbase/glist.h>
49#include <sphinxbase/fsg_model.h>
50#include <sphinxbase/logmath.h>
51#include <sphinxbase/strfuncs.h>
52#include <sphinxbase/jsgf.h>
53
54
55/* Flex uses strdup which is missing on WinCE */
56#if defined(_WIN32) || defined(_WIN32_WCE)
57#define strdup _strdup
58#endif
59
60#ifdef __cplusplus
61extern "C" {
62#endif
63#if 0
64/* Fool Emacs. */
65}
66#endif
67
68#define YY_NO_INPUT /* Silence a compiler warning. */
69
70typedef struct jsgf_rhs_s jsgf_rhs_t;
71typedef struct jsgf_atom_s jsgf_atom_t;
72typedef struct jsgf_link_s jsgf_link_t;
74
75struct jsgf_s {
76 char *version;
77 char *charset;
78 char *locale;
79 char *name;
86 /* Scratch variables for FSG conversion. */
87 int nstate;
90};
91
92/* A type to keep track of the stack of rules currently being expanded. */
95 int entry;
96};
97
99 int refcnt;
100 char *name;
103};
104
108};
109
111 char *name;
113 float weight;
114};
115
118 int from;
119 int to;
120};
121
122#define jsgf_atom_is_rule(atom) ((atom)->name[0] == '<')
123
124void jsgf_add_link(jsgf_t *grammar, jsgf_atom_t *atom, int from, int to);
125jsgf_atom_t *jsgf_atom_new(char *name, float weight);
126jsgf_atom_t *jsgf_kleene_new(jsgf_t *jsgf, jsgf_atom_t *atom, int plus);
127jsgf_rule_t *jsgf_optional_new(jsgf_t *jsgf, jsgf_rhs_t *exp);
128jsgf_rule_t *jsgf_define_rule(jsgf_t *jsgf, char *name, jsgf_rhs_t *rhs, int is_public);
129jsgf_rule_t *jsgf_import_rule(jsgf_t *jsgf, char *name);
130
131int jsgf_atom_free(jsgf_atom_t *atom);
132int jsgf_rule_free(jsgf_rule_t *rule);
133jsgf_rule_t *jsgf_rule_retain(jsgf_rule_t *rule);
134
135#ifdef __cplusplus
136}
137#endif
138
139
140#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.
char * name
Rule name (NULL for an alternation/grouping)
int is_public
Is this rule marked 'public'?
jsgf_rhs_t * rhs
Expansion.
int refcnt
Reference count.
Definition: jsgf_internal.h:99
int entry
The entry-state for this expansion.
Definition: jsgf_internal.h:95
jsgf_rule_t * rule
The rule being expanded.
Definition: jsgf_internal.h:94
char * locale
JSGF locale (default C)
Definition: jsgf_internal.h:78
glist_t rulestack
Stack of currently expanded rules.
Definition: jsgf_internal.h:89
int nstate
Number of generated states.
Definition: jsgf_internal.h:87
glist_t links
Generated FSG links.
Definition: jsgf_internal.h:88
hash_table_t * imports
Pointers to imported grammars.
Definition: jsgf_internal.h:82
glist_t searchpath
List of directories to search for grammars.
Definition: jsgf_internal.h:84
char * name
Grammar name.
Definition: jsgf_internal.h:79
char * charset
JSGF charset (default UTF-8)
Definition: jsgf_internal.h:77
char * version
JSGF version (from header)
Definition: jsgf_internal.h:76
jsgf_t * parent
Parent grammar (if this is an imported one)
Definition: jsgf_internal.h:83
hash_table_t * rules
Defined or imported rules in this grammar.
Definition: jsgf_internal.h:81