www.pudn.com > cppcc.rar > dfa_generator.cc


/*
 *  File:       dfa_generator.cc
 *              $Id: dfa_generator.cc,v 1.2 2002/05/04 17:39:22 alec Exp $
 *
 *  Author:     Alec Panoviciu (alecu@email.com)
 * 
 *  Comments:
 *
 *  Revision history:
 *
 *  $Log: dfa_generator.cc,v $
 *  Revision 1.2  2002/05/04 17:39:22  alec
 *  the scanner works (slightly tested)
 *
 *  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

 */


#include "dfa_generator.hh"
#include "scanner_dfa_spec.hh"
#include "scanner_spec.hh"
#include "basic_dfa_generator.hh"

ScannerDfaSpec& DfaGenerator::createScannerDfa (PropRegistry ®istry,
                                                ScannerSpec &scanner,
                                                ITokenSpec &tokens)
{
  ScannerDfaSpec &dfa = *new ScannerDfaSpec(scanner.className,
                                            scanner.preambleCode,
                                            scanner.userCode,
                                            scanner.inheritance);

  BasicDfaGenerator bdg(tokens, registry);

  for (int i = 0; i < scanner.states.size(); i++)
    dfa.addBasicDfa(bdg.createBasicDfa(scanner.states[i]));
  
  return dfa;
}