Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

kygrammar.cpp File Reference

Definitions of KYGrammar class methods. More...

#include "kygrammar.h"

Go to the source code of this file.

Defines

#define DECREASE_INPUT_QUEUE_LENGTH(_amount_)   inputQueueLength -= _amount_
 Decrease the length of the input queue by given amount. More...

#define INCREASE_INPUT_QUEUE_LENGTH(_amount_)
 Increase the length of the input queue by given amount. More...

#define TESTEDRULES_POP(_val_, _stack_, _tmpStack_)
 Pop one tested rule from the stack. More...

#define TESTEDRULES_PUSH(_val_, _stack_, _tmpStack_)
 Push one tested rule onto the stack. More...

#define DIGRAM_REMOVE(_el1_, _el2_)
 Remove specified digram. More...

#define DIGRAM_ADD(_el1_, _el2_, _rulePtr_)
 Add specified digram. More...

#define DIGRAM_CHANGE(_el1_, _el2_, _rulePtr_)
 Change of the rule info in specified digram. More...

#define RIGHT_SIDE_APPEND(_rule_, _el_)
 Append symbol to specified rule. More...

#define RIGHT_SIDE_IS_EMPTY(_rule_)   (_rule_->last == 0)
 Test whether given rule is empty. More...

#define REPRESENTED_BY_APPEND(_list_, _rule_)
 Append new rule to the list of representatives of the rule element. More...


Detailed Description

Definitions of KYGrammar class methods.

This file contains the definitions of KYGrammar class

Definition in file kygrammar.cpp.


Define Documentation

#define DECREASE_INPUT_QUEUE_LENGTH _amount_       inputQueueLength -= _amount_
 

Decrease the length of the input queue by given amount.

Parameters:
_amount_  Given amount.

Definition at line 40 of file kygrammar.cpp.

Referenced by KYGrammar::eatData.

#define DIGRAM_ADD _el1_,
_el2_,
_rulePtr_   
 

Add specified digram.

Add digram (el1, el2) to list of digrams for symbol el1 (el2 is located in rule rulePtr).

Definition at line 122 of file kygrammar.cpp.

Referenced by KYGrammar::appendToRootRule, KYGrammar::reductionRule1, KYGrammar::reductionRule2, and KYGrammar::reductionRule3.

#define DIGRAM_CHANGE _el1_,
_el2_,
_rulePtr_   
 

Value:

{                                                                               \
  if (_el1_->type == Terminal)                                                  \
    nd = terminalDigrams->find(_el1_->value);                                   \
  else                                                                          \
    nd = variableDigrams->find(_el1_->rule->id);                                \
                                                                                \
  if (nd)                                                                       \
    for (r = nd->neighbours.first(); r; r = nd->neighbours.next())              \
      if (r->origin == _el2_)                                                   \
        {                                                                       \
          r->rule = _rulePtr_;                                                  \
          break;                                                                \
        }                                                                       \
}
Change of the rule info in specified digram.

Change rule info for digram (el1, el2). Used when this digram goes to another rule (with pointer rulePtr).

Definition at line 165 of file kygrammar.cpp.

Referenced by KYGrammar::reductionRule1, KYGrammar::reductionRule2, and KYGrammar::reductionRule3.

#define DIGRAM_REMOVE _el1_,
_el2_   
 

Value:

{                                                                               \
  if (_el1_->type == Terminal)                                                  \
    {nd = terminalDigrams->find(_el1_->value);}                                 \
  else                                                                          \
    {nd = variableDigrams->find(_el1_->rule->id);}                              \
                                                                                \
  if (nd)                                                                       \
    for (r = nd->neighbours.first(); r; r = nd->neighbours.next())              \
      if (r->origin == _el2_)                                                   \
        {                                                                       \
          nd->neighbours.remove();                                              \
          DELETE(r);                                                            \
          break;                                                                \
        }                                                                       \
}
Remove specified digram.

Remove digram (el1, el2) from list of digrams for symbol el1.

Definition at line 99 of file kygrammar.cpp.

Referenced by KYGrammar::reductionRule1, KYGrammar::reductionRule2, and KYGrammar::reductionRule3.

#define INCREASE_INPUT_QUEUE_LENGTH _amount_   
 

Value:

{                                               \
  inputQueueLength += _amount_;                 \
  if (inputQueueLength > maxInputQueueLength)   \
    maxInputQueueLength = inputQueueLength;     \
}
Increase the length of the input queue by given amount.

If necessary, maxInputQueueLength is adjusted.

Parameters:
_amount_  Given amount.

Definition at line 50 of file kygrammar.cpp.

Referenced by KYGrammar::append.

#define REPRESENTED_BY_APPEND _list_,
_rule_   
 

Value:

{                                                               \
  bool _needInsert_ = true;                                     \
                                                                \
  for (Rule *_rr_ = _list_.first(); _rr_; _rr_ = _list_.next()) \
    {                                                           \
      if (_rr_ == _rule_)                                       \
        {                                                       \
          _needInsert_ = false;                                 \
          break;                                                \
        }                                                       \
    }                                                           \
  if (_needInsert_)                                             \
    _list_.append(_rule_);                                      \
}
Append new rule to the list of representatives of the rule element.

The _rule_ is appended only if is not contained in the list.

Parameters:
_list_  Linked list of representatives of given rule element.
_rule_  RUle that represents the rule element.

Definition at line 220 of file kygrammar.cpp.

Referenced by KYGrammar::reductionRule1, KYGrammar::reductionRule2, and KYGrammar::reductionRule3.

#define RIGHT_SIDE_APPEND _rule_,
_el_   
 

Value:

if (!_rule_->body)                      \
{                                       \
  _rule_->body = _el_;                  \
  _rule_->last = _el_;                  \
  _el_->next = 0;                       \
  _el_->prev = 0;                       \
}                                       \
else                                    \
{                                       \
  _rule_->last->next = _el_;            \
  _el_->prev = _rule_->last;            \
  _el_->next = 0;                       \
  _rule_->last = _el_;                  \
}
Append symbol to specified rule.

Symbol el is appended to the end of rule.

Definition at line 187 of file kygrammar.cpp.

Referenced by KYGrammar::appendToRootRule.

#define RIGHT_SIDE_IS_EMPTY _rule_       (_rule_->last == 0)
 

Test whether given rule is empty.

This macro returns true when rule is empty, otherwise it returns false.

Definition at line 209 of file kygrammar.cpp.

Referenced by KYGrammar::print.

#define TESTEDRULES_POP _val_,
_stack_,
_tmpStack_   
 

Value:

{                                                       \
  _val_ = _stack_->rel;                                 \
  _tmpStack_ = _stack_;                                 \
  _stack_ = _stack_->next;                              \
  DELETE(_tmpStack_);                                   \
}
Pop one tested rule from the stack.

Value of the top item on the _stack_ is stored in _val_.

Parameters:
_val_  Value of the top item on the stack.
_stack_  The stack with tested rules.
_tmpStack_  Temporary variable for deleting the top item from the stack.

Definition at line 67 of file kygrammar.cpp.

Referenced by KYGrammar::ruleMatchesInput.

#define TESTEDRULES_PUSH _val_,
_stack_,
_tmpStack_   
 

Value:

{                                                       \
  NEW(_tmpStack_, TestedElement);                       \
  _tmpStack_->rel = _val_;                              \
  _tmpStack_->next = _stack_;                           \
  _stack_ = _tmpStack_;                                 \
}
Push one tested rule onto the stack.

New tested rule with value _val_ is pushed onto the _stack_

Parameters:
_val_  Value of the new item.
_stack_  The stack with tested rules.
_tmpStack_  Temporary variable for creating the top item on the stack.

Definition at line 85 of file kygrammar.cpp.

Referenced by KYGrammar::ruleMatchesInput.


Generated on Wed Feb 5 10:43:03 2003 for Exalt by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002