src/libsphinxbase/lm/jsgf.c File Reference

This file implements the data structures for parsing JSGF grammars into Sphinx finite-state grammars. More...

#include <string.h>
#include <assert.h>
#include "ckd_alloc.h"
#include "strfuncs.h"
#include "hash_table.h"
#include "err.h"
#include "jsgf_internal.h"
#include "jsgf_parser.h"
#include "jsgf_scanner.h"

Go to the source code of this file.

Functions

int yyparse (yyscan_t yyscanner, jsgf_t *jsgf)
jsgf_atom_t * jsgf_atom_new (char *name, float weight)
int jsgf_atom_free (jsgf_atom_t *atom)
jsgf_t * jsgf_grammar_new (jsgf_t *parent)
 Create a new JSGF grammar.
void jsgf_grammar_free (jsgf_t *jsgf)
 Free a JSGF grammar.
jsgf_atom_t * jsgf_kleene_new (jsgf_t *jsgf, jsgf_atom_t *atom, int plus)
jsgf_rule_t * jsgf_optional_new (jsgf_t *jsgf, jsgf_rhs_t *exp)
void jsgf_add_link (jsgf_t *grammar, jsgf_atom_t *atom, int from, int to)
jsgf_rule_iter_tjsgf_rule_iter (jsgf_t *grammar)
 Get an iterator over all rules in a grammar.
jsgf_rule_t * jsgf_get_rule (jsgf_t *grammar, char const *name)
 Get a rule by name from a grammar.
char const * jsgf_rule_name (jsgf_rule_t *rule)
 Get the rule name from a rule.
int jsgf_rule_public (jsgf_rule_t *rule)
 Test if a rule is public or not.
fsg_model_tjsgf_build_fsg (jsgf_t *grammar, jsgf_rule_t *rule, logmath_t *lmath, float32 lw)
 Build a Sphinx FSG object from a JSGF rule.
int jsgf_write_fsg (jsgf_t *grammar, jsgf_rule_t *rule, FILE *outfh)
 Convert a JSGF rule to Sphinx FSG text form.
jsgf_rule_t * jsgf_define_rule (jsgf_t *jsgf, char *name, jsgf_rhs_t *rhs, int public)
jsgf_rule_t * jsgf_rule_retain (jsgf_rule_t *rule)
int jsgf_rule_free (jsgf_rule_t *rule)
jsgf_rule_t * jsgf_import_rule (jsgf_t *jsgf, char *name)
jsgf_t * jsgf_parse_file (const char *filename, jsgf_t *parent)
 Parse a JSGF grammar from a file.


Detailed Description

This file implements the data structures for parsing JSGF grammars into Sphinx finite-state grammars.

Definition in file jsgf.c.


Function Documentation

jsgf_t* jsgf_grammar_new ( jsgf_t *  parent  ) 

Create a new JSGF grammar.

Parameters:
parent optional parent grammar for this one (NULL, usually).
Returns:
new JSGF grammar object, or NULL on failure.

Definition at line 81 of file jsgf.c.

References ckd_calloc, ckd_salloc, glist_add_ptr(), glist_reverse(), and hash_table_new().

Referenced by jsgf_parse_file().

jsgf_t* jsgf_parse_file ( const char *  filename,
jsgf_t *  parent 
)

Parse a JSGF grammar from a file.

Parameters:
filename the name of the file to parse.
parent optional parent grammar for this one (NULL, usually).
Returns:
new JSGF grammar object, or NULL on failure.

Definition at line 709 of file jsgf.c.

References jsgf_grammar_free(), and jsgf_grammar_new().

int jsgf_write_fsg ( jsgf_t *  grammar,
jsgf_rule_t *  rule,
FILE *  outfh 
)

Convert a JSGF rule to Sphinx FSG text form.

This does a direct conversion without doing transitive closure on null transitions and so forth.

Definition at line 486 of file jsgf.c.

References ckd_free(), glist_free(), glist_reverse(), and gnode_ptr.


Generated on Mon Aug 24 16:06:37 2009 for SphinxBase by  doxygen 1.5.8