SphinxBase
0.6
|
00001 /* -*- c-basic-offset: 4; indent-tabs-mode: nil -*- */ 00002 /* ==================================================================== 00003 * Copyright (c) 2007 Carnegie Mellon University. All rights 00004 * reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 00010 * 1. Redistributions of source code must retain the above copyright 00011 * notice, this list of conditions and the following disclaimer. 00012 * 00013 * 2. Redistributions in binary form must reproduce the above copyright 00014 * notice, this list of conditions and the following disclaimer in 00015 * the documentation and/or other materials provided with the 00016 * distribution. 00017 * 00018 * This work was supported in part by funding from the Defense Advanced 00019 * Research Projects Agency and the National Science Foundation of the 00020 * United States of America, and the CMU Sphinx Speech Consortium. 00021 * 00022 * THIS SOFTWARE IS PROVIDED BY CARNEGIE MELLON UNIVERSITY ``AS IS'' AND 00023 * ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 00024 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 00025 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CARNEGIE MELLON UNIVERSITY 00026 * NOR ITS EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00027 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00028 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 00029 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00030 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00031 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 00032 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00033 * 00034 * ==================================================================== 00035 * 00036 */ 00037 00038 #ifndef __JSGF_INTERNAL_H__ 00039 #define __JSGF_INTERNAL_H__ 00040 00045 #define YY_NO_UNISTD_H 1 00046 #include <stdio.h> 00047 00048 #include <sphinxbase/hash_table.h> 00049 #include <sphinxbase/glist.h> 00050 #include <sphinxbase/fsg_model.h> 00051 #include <sphinxbase/logmath.h> 00052 #include <sphinxbase/strfuncs.h> 00053 #include <sphinxbase/jsgf.h> 00054 00055 #ifdef __cplusplus 00056 extern "C" { 00057 #endif 00058 #if 0 00059 /* Fool Emacs. */ 00060 } 00061 #endif 00062 00063 #define YY_NO_INPUT /* Silence a compiler warning. */ 00064 00065 typedef struct jsgf_rhs_s jsgf_rhs_t; 00066 typedef struct jsgf_atom_s jsgf_atom_t; 00067 typedef struct jsgf_link_s jsgf_link_t; 00068 00069 struct jsgf_s { 00070 char *version; 00071 char *charset; 00072 char *locale; 00073 char *name; 00075 hash_table_t *rules; 00076 hash_table_t *imports; 00077 jsgf_t *parent; 00078 glist_t searchpath; 00080 /* Scratch variables for FSG conversion. */ 00081 int nstate; 00082 glist_t links; 00083 glist_t rulestack; 00084 }; 00085 00086 struct jsgf_rule_s { 00087 int refcnt; 00088 char *name; 00089 int public; 00090 jsgf_rhs_t *rhs; 00092 int entry; 00093 int exit; 00094 }; 00095 00096 struct jsgf_rhs_s { 00097 glist_t atoms; 00098 jsgf_rhs_t *alt; 00099 }; 00100 00101 struct jsgf_atom_s { 00102 char *name; 00103 glist_t tags; 00104 float weight; 00105 }; 00106 00107 struct jsgf_link_s { 00108 jsgf_atom_t *atom; 00109 int from; 00110 int to; 00111 }; 00112 00113 #define jsgf_atom_is_rule(atom) ((atom)->name[0] == '<') 00114 00115 void jsgf_add_link(jsgf_t *grammar, jsgf_atom_t *atom, int from, int to); 00116 jsgf_atom_t *jsgf_atom_new(char *name, float weight); 00117 jsgf_atom_t *jsgf_kleene_new(jsgf_t *jsgf, jsgf_atom_t *atom, int plus); 00118 jsgf_rule_t *jsgf_optional_new(jsgf_t *jsgf, jsgf_rhs_t *exp); 00119 jsgf_rule_t *jsgf_define_rule(jsgf_t *jsgf, char *name, jsgf_rhs_t *rhs, int public); 00120 jsgf_rule_t *jsgf_import_rule(jsgf_t *jsgf, char *name); 00121 00122 int jsgf_atom_free(jsgf_atom_t *atom); 00123 int jsgf_rule_free(jsgf_rule_t *rule); 00124 jsgf_rule_t *jsgf_rule_retain(jsgf_rule_t *rule); 00125 00126 #ifdef __cplusplus 00127 } 00128 #endif 00129 00130 00131 #endif /* __JSGF_H__ */