<?php $isip_window_title = "ISIP Homepage"; ?>
<?php include("/data/isip/www/templates/documentation/header/header.html"); ?>

<!--#set var="isip_page_title" value="ProductionRule" -->
<?php include("/data/isip/www/templates/documentation/body/index_class.html"); ?>
<?php include("/data/isip/www/templates/documentation/body/bar.html"); ?>

<a name="name">
<b>name: <a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule.h">ProductionRule</a></b>

<br><br>

<a name="synopsis">
<b>synopsis:</b>
<br><br>

<blockquote>
<pre> 
g++ [flags ...] file ... -l /isip/tools/lib/$ISIP_BINARY/lib_mmedia.a

#include &lt;ProductionRule.h&gt;

ProductionRuleTokenType::TYPE getType();
String getValue();
Float getWeight();
</pre>
</blockquote>

<a name="quick_start">
<b>quick start:</b>
<br><br>

<blockquote>
<pre>
ProductionRule prdrl;
prdrl.setRuleName(L"A");

prdrl.append(ProductionRuleTokenType::NONTERMINAL, L"a");
prdrl.append(ProductionRuleTokenType::KLEENE_STAR);
</pre>
</blockquote>

<a name="description"> 
<b>description:</b>
<br><br>
The purpose of the ProductionRule class is to provide a uniform method
for representing ABNF and BNF production rules in the LanguageModel classes
and to form the basis of the RuleModel typedef that serves as a common
grammar format.
<br><br>
Each ProductionRule is stored as a right-hand side (RHS) and a left-hand
side (LHS).  The RHS is stored as a String, and the LHS is stored as
a DoubleLinkedList< Triple<ProductionRuleTokenType, String, Float> >.  The
first field of each entry in the LHS is the token type.  The second field of
each entry is the token value (typically the name of a terminal or
nonterminal).  The final field of each entry is used for the storage of
weights (on concatenation, alternation, and kleene operators).
<br><br>

<a name="dependencies">
<b>dependencies:</b>
<br><br>

<ul>
  <li> <a href="../../math/scalar/String/index.html">String</a>
  <li> <a href="../../dstr/DoubleLinkedList/index.html">DoubleLinkedList</a>
  <li> <a href="../ProductionRuleTokenType/index.html">ProductionRuleTokenType</a>
  <li> <a href="../../math/scalar/Float/index.html">Float</a>
  <li> <a href="../../shell/Filename/index.html">Filename</a>
  <li> <a href="../../system/File/index.html">File</a>
  <li> <a href="../../shell/DebugLevel/index.html">DebugLevel</a>
  <li> <a href="../../dstr/Triple/index.html">Triple</a>
  <li> <a href="../../io/Sof/index.html">Sof</a>
</ul>

<a name="constants">
<b>public constants:</b>
<br><br>

<ul>
  <li> define the class name:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_00.cc&constant=CLASS_NAME">static const String ProductionRule::CLASS_NAME = L"ProductionRule";</a></pre>

  <li> definition of rule types:

       <pre>enum TYPE {NORMAL=0, START, DEF_TYPE = NORMAL};</pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_00.cc&constant=TYPE_MAP">static const String ProductionRule::TYPE_MAP(L"NORMAL, START");</a></pre>

  <li> define the file parameters:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_00.cc&constant=DEF_PARAM">static const String ProductionRule::DEF_PARAM = L"";</a></pre>


       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_00.cc&constant=DEF_TAG">static const long ProductionRule::DEF_TAG = 0;</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_00.cc&constant=PARAM_RULE_NAME">static const String ProductionRule::PARAM_RULE_NAME = L"rule_name";</a></pre>


      <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_00.cc&constant=RULE_NAME_BASE">static const String ProductionRule::RULE_NAME_BASE = L"R";</a></pre>

      <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_00.cc&constant=START_RULE_NAME">static const String ProductionRule::START_RULE_NAME = L"RS";</a></pre>

      <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_00.cc&constant=TERM_RULE_NAME">static const String ProductionRule::TERM_RULE_NAME= L"RT";</a></pre>

      <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_00.cc&constant=DEF_RULE_NAME">static const String ProductionRule::DEF_RULE_NAME= L"";</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_00.cc&constant=PARAM_RULE">static const String ProductionRule::PARAM_RULE = L"rule";</a></pre>

</ul>

<a name="error">
<b>error codes:</b>
<br><br>
<ul>
</ul>

<a name="protected">
<b>protected data:</b>
<br><br>

<ul> <!-- list of categories -->

  <li> declare a string to hold the rule name
    <pre>String rule_name_d;</pre>

  <li> declare the rule type
    <pre>String rule_type_d;</pre>

  <li> declare the RHS of the production rule
    <pre>DoubleLinkedList< Triple< ProductionRuleTokenType, String, Float> > rule_d;</pre>

  <li> declare the debug level
    <pre>DebugLevel debug_level_d;</pre>
</ul>

<a name="public">
<b>required public methods:</b>
<br><br>

<ul>
  <li> static methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/ProductionRule.h&method=name">static const String& name();</a></pre>
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_02.cc&method=diagnose">static boolean diagnose(Integral::DEBUG debug_level);</a></pre>

  <li> debug methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule.h&method=setDebug">boolean setDebug(Integral::DEBUG debug_level);</a></pre>
     
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_01.cc&method=debug">boolean debug(const unichar* msg) const;</a></pre>
       
  <li> constructor:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/ProductionRule.h&method=default+constructor">ProductionRule();</a></pre>
                          
  <li> i/o methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_03.cc&method=read">boolean read(Sof& sof, long tag, const String& cname = CLASS_NAME);</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_03.cc&method=readData">boolean readData(Sof& sof, const String& pname = DEF_PARAM, long size = SofParser::FULL_OBJECT, boolean param = true, boolean nested = false);</a></pre>
  
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_03.cc&method=write">boolean write(Sof& sof, long tag, const String& cname = CLASS_NAME) const;</a></pre>
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_03.cc&method=writeData">boolean writeData(Sof& sof, const String& pname = DEF_PARAM) const;</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/ProductionRule.h&method=sofSize">long sofSize() const;</a></pre>

  <li> assign methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_01.cc&method=assign&instance=0">boolean assign(const ProductionRule& prdrl_a);</a></pre>

  <li> operator= methods:
       
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_01.cc&method=operator%3D">ProductionRule& operator=(const ProductionRule& prdrl_a);</a></pre>

  <li> equality methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_01.cc.h&method=eq&instance=0">boolean eq(const ProductionRule& prdrl_a) const;</a></pre>

  <li> operator== methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_01.cc.h&method=operator%3D%3D&">ProductionRule& operator==(const ProductionRule& prdrl_a);</a></pre>

  <li> clear methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_01.cc&method=clear">boolean clear(Integral::CMODE ctype);</a></pre>

</ul>

<a name="specific">
<b>class-specific public methods:</b>
<br><br>

<ul>       

  <li> traversal methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_06.cc&method=gotoFirst">boolean gotoFirst();</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_06.cc&method=gotoNext">boolean gotoNext();</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_06.cc&method=gotoPrev">boolean gotoPrev();</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_06.cc&method=gotoPosition">boolean gotoPosition(long position);</a></pre>

  <li> operation methods:

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_06.cc&method=removeCurr">boolean removeCurr();</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_06.cc&method=getType">ProductionRuleTokenType::TYPE getType();</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_06.cc&method=getValue">String getValue();</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_06.cc&method=getWeight">Float getWeight();</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_06.cc&method=insert">boolean insert(const ProductionRuleTokenType::TYPE& type_a, const String& value_a=L"", Float weight_a=0);</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_06.cc&method=append">boolean append(const ProductionRuleTokenType::TYPE& type_a, const String& value_a, Float weight_a);</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_06.cc&method=append">boolean append(const ProductionRuleTokenType::TYPE& type_a, const String& value_a=L"");</a></pre>

       <li> get methods:
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_05.cc&method=getRuleName">String getRuleName();</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_05.cc&method=getRule">String getRule();</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/ProductionRule.h&method=getRuleType">TYPE getRuleType();</a></pre>

       <li> set methods:
       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/prdrl_05.cc&method=setRuleName">boolean setRuleName(const String& rule_name_a);</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/ProductionRule.h&method=setDebug">boolean setDebug(Integral::DEBUG level);</a></pre>

       <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/ProductionRule/ProductionRule.h&method=setRuleType">boolean setRuleType(TYPE type);</a></pre>

</ul>

<a name="protected">
<b>class-specific protected methods:</b>
<br><br>

<ul>
  <li> string conversion methods:
  <pre><a href="/perl/ifc_document.pl?file=$isip/class/pr/prdrl_06.cc&method=convertToString">String convertToString(Triple< ProductionRuleTokenType, String, Float >& item_a);</a></pre>
      

</ul>

<a name="examples">
<b>examples:</b>
<br><br>

<ul>
  <li> This example shows how create a ProductionRule for "A::=(a B)+" and retrieve the string representation.
   
<pre>

// declare the ProductionRule
//
ProductionRule prdrl;

// set the name
//
prdrl.setRuleName(L"A");

// construct the RHS
//
prdrl.append(ProductionRuleTokenType::OPEN_PAREN);
prdrl.append(ProductionRuleTokenType::TERMINAL, L"a");
prdrl.append(ProductionRuleTokenType::CONCATENATION);
prdrl.append(ProductionRuleTokenType::NON_TERMINAL, L"B");
prdrl.append(ProductionRuleTokenType::CONCATENATION);
prdrl.append(ProductionRuleTokenType::KLEENE_PLUS);

// output the string representation of the rule
//
Console::put(prdrl.getRule());

</pre>
</ul>

<a name="notes">
<b>notes:</b>
<br><br>


<!--#include virtual="/hse/ies/templates/documentation/footer/footer.html" -->
