• Main Page
  • Related Pages
  • Data Structures
  • Files
  • File List
  • Globals

src/libsphinxbase/lm/jsgf_internal.h

Go to the documentation of this file.
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 <hash_table.h>
00047 #include <glist.h>
00048 #include <stdio.h>
00049 #include <fsg_model.h>
00050 #include <logmath.h>
00051 #include <strfuncs.h>
00052 #include <jsgf.h>
00053 
00054 #ifdef __cplusplus
00055 extern "C" {
00056 #endif
00057 #if 0
00058 /* Fool Emacs. */
00059 }
00060 #endif
00061 
00062 #define YY_NO_INPUT /* Silence a compiler warning. */
00063 
00064 typedef struct jsgf_rhs_s jsgf_rhs_t;
00065 typedef struct jsgf_atom_s jsgf_atom_t;
00066 typedef struct jsgf_link_s jsgf_link_t;
00067 
00068 struct jsgf_s {
00069     char *version;  
00070     char *charset;  
00071     char *locale;   
00072     char *name;     
00074     hash_table_t *rules;   
00075     hash_table_t *imports; 
00076     jsgf_t *parent;        
00077     glist_t searchpath;    
00079     /* Scratch variables for FSG conversion. */
00080     int nstate;            
00081     glist_t links;         
00082     glist_t rulestack;     
00083 };
00084 
00085 struct jsgf_rule_s {
00086     int refcnt;      
00087     char *name;      
00088     int public;      
00089     jsgf_rhs_t *rhs; 
00091     int entry;       
00092     int exit;        
00093 };
00094 
00095 struct jsgf_rhs_s {
00096     glist_t atoms;   
00097     jsgf_rhs_t *alt; 
00098 };
00099 
00100 struct jsgf_atom_s {
00101     char *name;        
00102     glist_t tags;      
00103     float weight;      
00104 };
00105 
00106 struct jsgf_link_s {
00107     jsgf_atom_t *atom; 
00108     int from;          
00109     int to;            
00110 };
00111 
00112 #define jsgf_atom_is_rule(atom) ((atom)->name[0] == '<')
00113 
00114 void jsgf_add_link(jsgf_t *grammar, jsgf_atom_t *atom, int from, int to);
00115 jsgf_atom_t *jsgf_atom_new(char *name, float weight);
00116 jsgf_atom_t *jsgf_kleene_new(jsgf_t *jsgf, jsgf_atom_t *atom, int plus);
00117 jsgf_rule_t *jsgf_optional_new(jsgf_t *jsgf, jsgf_rhs_t *exp);
00118 jsgf_rule_t *jsgf_define_rule(jsgf_t *jsgf, char *name, jsgf_rhs_t *rhs, int public);
00119 jsgf_rule_t *jsgf_import_rule(jsgf_t *jsgf, char *name);
00120 
00121 int jsgf_atom_free(jsgf_atom_t *atom);
00122 int jsgf_rule_free(jsgf_rule_t *rule);
00123 jsgf_rule_t *jsgf_rule_retain(jsgf_rule_t *rule);
00124 
00125 #ifdef __cplusplus
00126 }
00127 #endif
00128 
00129 
00130 #endif /* __JSGF_H__ */

Generated on Tue Aug 17 2010 for SphinxBase by  doxygen 1.7.1