"Fossies" - the Fresh Open Source Software Archive

Member "erltools/pub/library/itptree.h" (25 Jul 1999, 4142 Bytes) of package /linux/misc/old/erltools-4.0.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "itptree.h" see the Fossies "Dox" file reference documentation.

    1 /*************************************************************************/
    2 /*                                                                       */
    3 /*        itptree.h - Built by Eric Lavillonniere on Tandon 486 - 96       */
    4 /*                                                                       */
    5 /*************************************************************************/
    6 /* This file is part of metagen                                             
    7    
    8    Metagen is a syntaxic analyser generator with backtrack.
    9    
   10    It runs on dos and unix. It generates c code. */
   11 /* Copyright(C) 1989 Eric Lavillonniere */
   12 /*
   13    This program is free software; you can redistribute it and/or modify
   14    it under the terms of the GNU General Public License as published by
   15    the Free Software Foundation; either version 1, or (at your option)
   16    any later version.
   17    
   18    This program is distributed in the hope that it will be useful,
   19    but WITHOUT ANY WARRANTY; without even the implied warranty of
   20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   21    GNU General Public License for more details.
   22    
   23    You should have received a copy of the GNU General Public License
   24    along with this program; see the file COPYING. If not, write to 
   25    the Free Software
   26    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
   27    
   28    */
   29 #include "token.h"
   30 
   31 #ifndef ITPTREE_FILE
   32 #define ITPTREE_FILE 1
   33 
   34 class ItPtree {
   35     
   36     public :
   37     
   38         ItPtree ()
   39         {
   40             searched = (PPTREE)0 ;
   41             end = (PPTREE)0 ;
   42             current = (PPTREE)0 ;
   43             allSearch = skipSon = 0 ;
   44             justStarted = 1 ;
   45         }
   46         
   47         ItPtree ( PPTREE currTree, PPTREE searchedTree = (PPTREE)0 )
   48         {
   49             current = currTree ;
   50             end = FSNextTree(current, (PPTREE)0);
   51             searched = searchedTree ;
   52             allSearch = skipSon = 0 ;
   53             justStarted = 1 ;
   54         }
   55         
   56         ItPtree ( ItPtree &itPtree )
   57         {
   58             current = itPtree.current ;
   59             end = itPtree.end ;
   60             searched = itPtree.searched ;
   61             skipSon = itPtree.skipSon ;
   62             allSearch = itPtree.allSearch ;
   63             justStarted = itPtree.justStarted ;
   64         }
   65         
   66         PPTREE operator++ ( int )
   67         {
   68             if ( !justStarted ) 
   69                 if ( skipSon ) {
   70                     current = SNextTree(current, (PPTREE)end, allSearch);
   71                     skipSon = 0 ;
   72                 } else 
   73                     current = NextTree(current, (PPTREE)end, allSearch);
   74             justStarted = 0 ;
   75             if ( searched ) 
   76                 return current = FindNext(searched, current, end);
   77             else 
   78                 return current ;
   79         }
   80         
   81         void Current ( PPTREE currTree )
   82         {
   83             current = currTree ;
   84             justStarted = 0 ;
   85         }
   86         
   87         void Searched ( PPTREE currTree )
   88         {
   89             searched = currTree ;
   90         }
   91         
   92         void End ( PPTREE currTree )
   93         {
   94             end = currTree ;
   95         }
   96         
   97         void AllSearch ( int search )
   98         {
   99             allSearch = search ;
  100         }
  101         
  102         void SkipSon ( int skip )
  103         {
  104             skipSon = skip ;
  105         }
  106         
  107         virtual ~ItPtree () {}
  108         
  109         static PPTREE   NextTree (PPTREE elem, PPTREE stop, int all = 0) ;
  110         static PPTREE   SNextTree (PPTREE elem, PPTREE stop, int all = 0) ;
  111         static PPTREE   FSNextTree (PPTREE elem, PPTREE stop) ;
  112         static PPTREE   FindNoUp (PPTREE elem, PPTREE start, PPTREE stop) ;
  113         static PPTREE   FindInternal (PPTREE elem, PPTREE start
  114             , PPTREE stop) ;
  115         static PPTREE   FindNext (PPTREE elem, PPTREE start, PPTREE stop) ;
  116         static PPTREE   FindRank (PPTREE elem, PPTREE start, PPTREE stop
  117             , int rank) ;
  118     
  119     private :
  120     
  121         PPTREE  searched ; // searched tree
  122         PPTREE  end ;      // end tree
  123         PPTREE  current ;  // current tree
  124         int     skipSon ;
  125         int     allSearch ;
  126         int     justStarted ;
  127 };
  128 #endif