www.pudn.com > cppcc.rar > basic_dfa_generator.hh


/*
 *  File:       basic_dfa_generator.hh
 *              $Id: basic_dfa_generator.hh,v 1.4 2002/05/27 02:58:24 alec Exp $
 *
 *  Author:     Alec Panovici (alecu@email.com)
 * 
 *  Comments:
 *
 *  Revision history:
 *
 *  $Log: basic_dfa_generator.hh,v $
 *  Revision 1.4  2002/05/27 02:58:24  alec
 *  doc update
 *
 *  Revision 1.3  2002/05/04 17:39:22  alec
 *  the scanner works (slightly tested)
 *
 *  Revision 1.2  2002/05/01 09:18:26  alec
 *  - vBitset fixes
 *  - FOLLOWPOS written (not tested yet)
 *
 *  Revision 1.1  2002/04/30 16:26:38  alec
 *  my big endian will eat your little endian
 *
 */


/*
  Copyright (C) 2002 Alexandru Panoviciu (alecu@email.com)

  This program is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 2 of the License, or
  (at your option) any later version.

  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this program; if not, write to the Free Software
  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

 */

#ifndef __BASIC_DFA_GENERATOR_HH__
#define __BASIC_DFA_GENERATOR_HH__

#include 

#include "debug.h"

class LexicalStateSpec;
class PropRegistry;
class ITokenSpec;
class BasicDfaSpec;

/**
 * This is the core of DFA generating process. This class takes as its input a
 * regular expression parse tree and produces a DFA that accepts strings from
 * the language described by the regular expression.
 */
class BasicDfaGenerator
{
public:

  /**
   * Creates a new BasicDfaGenerator object.
   */
  BasicDfaGenerator (ITokenSpec &tokens_, PropRegistry ®istry_);


  /**
   * Creates a new BasicDfaSpec object for the given scanner lexical
   * state. The steps performed are:
   *
   * \li number all the regexp tree leafs, in left-to-right order (this is
   * consistent with the textual order in which tokens appeared inside the
   * source file.
   *
   * \li compute the nullable, firstpos and lastpos attributes for each node
   *
   * \li compute the followpos attribute for each leaf node
   *
   * \li compute the states and transitions and add them into the BasicDfaSpec
   *     result object 
   */
  BasicDfaSpec& createBasicDfa(const LexicalStateSpec &state);
  
private:

  /**
   * The list of tokens of the scanner for which this DFA is generated.
   */
  ITokenSpec &tokens;

  /**
   * The registry object from where options are read. If CppCC was compiled
   * with debug support, internal data is dumped if the "debug" option is
   * enabled.
   */
  PropRegistry ®istry;
};

#endif /* #ifndef __BASIC_DFA_GENERATOR_HH__ */