00001 // $Id: CCL.cc,v 1.2 2005/09/02 23:00:06 vern Exp $ 00002 // 00003 // Copyright (c) 1998, 1999, 2002 00004 // The Regents of the University of California. All rights reserved. 00005 // 00006 // Redistribution and use in source and binary forms, with or without 00007 // modification, are permitted provided that: (1) source code distributions 00008 // retain the above copyright notice and this paragraph in its entirety, (2) 00009 // distributions including binary code include the above copyright notice and 00010 // this paragraph in its entirety in the documentation or other materials 00011 // provided with the distribution, and (3) all advertising materials mentioning 00012 // features or use of this software display the following acknowledgement: 00013 // ``This product includes software developed by the University of California, 00014 // Lawrence Berkeley Laboratory and its contributors.'' Neither the name of 00015 // the University nor the names of its contributors may be used to endorse 00016 // or promote products derived from this software without specific prior 00017 // written permission. 00018 // THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED 00019 // WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF 00020 // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 00021 00022 #include "config.h" 00023 00024 #include "CCL.h" 00025 #include "RE.h" 00026 #include "DFA.h" 00027 00028 CCL::CCL() 00029 { 00030 syms = new int_list; 00031 index = -(rem->InsertCCL(this) + 1); 00032 negated = 0; 00033 } 00034 00035 CCL::~CCL() 00036 { 00037 delete syms; 00038 } 00039 00040 void CCL::Negate() 00041 { 00042 negated = 1; 00043 Add(SYM_BOL); 00044 Add(SYM_EOL); 00045 } 00046 00047 void CCL::Add(int sym) 00048 { 00049 ptr_compat_int sym_p = ptr_compat_int(sym); 00050 00051 // Check to see if the character is already in the ccl. 00052 for ( int i = 0; i < syms->length(); ++i ) 00053 if ( (*syms)[i] == sym_p ) 00054 return; 00055 00056 syms->append(sym_p); 00057 } 00058 00059 void CCL::Sort() 00060 { 00061 syms->sort(int_list_cmp); 00062 }
1.3.5