Class grammar implements a CFG, ready to be used from a chart parser. More...
#include <grammar.h>
Public Member Functions | |
grammar (const std::string &) | |
Create a grammar loading it from a file. | |
int | get_specificity (const std::string &) const |
int | get_priority (const std::string &) const |
std::string | get_start_symbol () const |
obtain the start symbol of the grammar | |
bool | is_hidden (const std::string &) const |
Check whether a symbol must disappear of final tree. | |
bool | is_flat (const std::string &) const |
Check whether a symbol must be flattened when recursive. | |
bool | is_notop (const std::string &) const |
Check whether a symbol can not be used as a tree root. | |
bool | is_onlytop (const std::string &) const |
Check whether a symbol is hidden unless when at tree root. | |
bool | is_terminal (const std::string &) const |
Check whether a symbol is terminal or not. | |
std::list< rule > | get_rules_right (const std::string &) const |
Get all rules with a right part beggining with the given category. | |
std::list< rule > | get_rules_right_wildcard (const std::string &) const |
Get all rules with a right part beggining with a wilcarded category. | |
bool | in_filemap (const std::string &, const std::string &) const |
search given string in filemap, and check whether it maps to the second | |
Static Public Attributes | |
static unsigned int | NOGOV |
static unsigned int | DEFGOV |
Private Member Functions | |
void | new_rule (const std::string &, const std::list< std::string > &, bool, const int rgov) |
Create and store a new rule, indexed by 1st category in its right part. | |
Private Attributes | |
std::set< std::string > | nonterminal |
Non-terminal symbols in the grammar. | |
std::multimap< std::string, rule > | wild |
rules starting with a wildcarded token, indexed by first char in category. | |
std::multimap< std::string, std::string > | filemap |
map to store files appearing in grammar rules | |
std::map< std::string, int > | prior |
symbol priorities to build the tree | |
std::set< std::string > | hidden |
Non-terminal symbols that must not be seen in the tree. | |
std::set< std::string > | flat |
Non-terminal symbols that must be flattened in final tree when recursive. | |
std::set< std::string > | notop |
Non-terminal symbols that must not be considered tree roots. | |
std::set< std::string > | onlytop |
Non-terminal symbols that are visible only when are at tree root. | |
std::string | start |
start symbol |
Class grammar implements a CFG, ready to be used from a chart parser.
grammar::grammar | ( | const std::string & | ) |
Create a grammar loading it from a file.
int grammar::get_priority | ( | const std::string & | ) | const |
std::list<rule> grammar::get_rules_right | ( | const std::string & | ) | const |
Get all rules with a right part beggining with the given category.
std::list<rule> grammar::get_rules_right_wildcard | ( | const std::string & | ) | const |
Get all rules with a right part beggining with a wilcarded category.
int grammar::get_specificity | ( | const std::string & | ) | const |
std::string grammar::get_start_symbol | ( | ) | const |
obtain the start symbol of the grammar
bool grammar::in_filemap | ( | const std::string & | , | |
const std::string & | ||||
) | const |
search given string in filemap, and check whether it maps to the second
bool grammar::is_flat | ( | const std::string & | ) | const |
Check whether a symbol must be flattened when recursive.
bool grammar::is_hidden | ( | const std::string & | ) | const |
Check whether a symbol must disappear of final tree.
bool grammar::is_notop | ( | const std::string & | ) | const |
Check whether a symbol can not be used as a tree root.
bool grammar::is_onlytop | ( | const std::string & | ) | const |
Check whether a symbol is hidden unless when at tree root.
bool grammar::is_terminal | ( | const std::string & | ) | const |
Check whether a symbol is terminal or not.
void grammar::new_rule | ( | const std::string & | , | |
const std::list< std::string > & | , | |||
bool | , | |||
const int | rgov | |||
) | [private] |
Create and store a new rule, indexed by 1st category in its right part.
unsigned int grammar::DEFGOV [static] |
std::multimap<std::string,std::string> grammar::filemap [private] |
map to store files appearing in grammar rules
std::set<std::string> grammar::flat [private] |
Non-terminal symbols that must be flattened in final tree when recursive.
std::set<std::string> grammar::hidden [private] |
Non-terminal symbols that must not be seen in the tree.
unsigned int grammar::NOGOV [static] |
std::set<std::string> grammar::nonterminal [private] |
Non-terminal symbols in the grammar.
std::set<std::string> grammar::notop [private] |
Non-terminal symbols that must not be considered tree roots.
std::set<std::string> grammar::onlytop [private] |
Non-terminal symbols that are visible only when are at tree root.
std::map<std::string,int> grammar::prior [private] |
symbol priorities to build the tree
std::string grammar::start [private] |
start symbol
std::multimap<std::string,rule> grammar::wild [private] |
rules starting with a wildcarded token, indexed by first char in category.