%{
//===========================================================================
// @(#) $Name: arts++-1-1-a8 $
// @(#) $Id: ArtsObjectTypeSelectionSet.lex,v 1.4 2000/10/02 17:05:26 dwm Exp $
//===========================================================================
//  Copyright Notice
//
//  By accessing this software, arts++, you are duly informed
//  of and agree to be bound by the conditions described below in this
//  notice:
//
//  This software product, arts++, is developed by Daniel W. McRobb, and
//  copyrighted(C) 1998 by the University of California, San Diego
//  (UCSD), with all rights reserved.  UCSD administers the CAIDA grant,
//  NCR-9711092, under which part of this code was developed.
//
//  There is no charge for arts++ software.  You can redistribute it
//  and/or modify it under the terms of the GNU Lesser General Public
//  License, Version 2.1, February 1999, which is incorporated by
//  reference herein.
//
//  arts++ is distributed WITHOUT ANY WARRANTY, IMPLIED OR EXPRESS, OF
//  MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE or that the use
//  of it will not infringe on any third party's intellectual
//  property rights.
//
//  You should have received a copy of the GNU Lesser General Public
//  License along with arts++.  Copies can also be obtained from:
//
//    http://www.gnu.org/copyleft/lesser.html
//
//  or by writing to:
//
//  Free Software Foundation, Inc.
//  59 Temple Place, Suite 330
//  Boston, MA 02111-1307
//  USA
//
//  Or contact:
//
//    info@caida.org
//===========================================================================

extern "C" {
#include "artslocal.h"
}

#include <string>

#ifdef HAVE_STRSTREAM
  #include <strstream>
#else
  #include <strstream.h>
#endif

#include "ArtsHeader.hh"
#include "ArtsObjectTypeSelectionSet.hh"

static const string rcsid = "@(#) $Name: arts++-1-1-a8 $ $Id: ArtsObjectTypeSelectionSet.lex,v 1.4 2000/10/02 17:05:26 dwm Exp $";
%}

%option noyywrap

%%

<INITIAL>portm			{return(artsC_OBJECT_PORT_MATRIX);}
<INITIAL>proto(col){0,1}	{return(artsC_OBJECT_PROTO);}
<INITIAL>asm			{return(artsC_OBJECT_AS_MATRIX);}
<INITIAL>netm			{return(artsC_OBJECT_NET);}
<INITIAL>tos			{return(artsC_OBJECT_TOS);}
<INITIAL>nexthop		{return(artsC_OBJECT_NEXT_HOP);}
<INITIAL>intfm			{return(artsC_OBJECT_INTERFACE_MATRIX);}
.

%%

//----------------------------------------------------------------------------
//  void
//  ArtsObjectTypeSelectionSet::Load(const char *objTypeSelectionExpression) 
//............................................................................
//  
//----------------------------------------------------------------------------
void ArtsObjectTypeSelectionSet::Load(const char *objTypeSelectionExpression)
{
  int                  test;
  int                  firstIfIndex, lastIfIndex, portNum;
  istrstream           inStream(objTypeSelectionExpression);

  ObjectTypeFlexLexer *lexer = new ObjectTypeFlexLexer(&inStream,0);
  
  while ((test = lexer->yylex())) {
    switch (test) {
      case artsC_OBJECT_PORT_MATRIX:
      case artsC_OBJECT_PROTO:
      case artsC_OBJECT_AS_MATRIX:
      case artsC_OBJECT_NET:
      case artsC_OBJECT_TOS:
      case artsC_OBJECT_NEXT_HOP:
      case artsC_OBJECT_INTERFACE_MATRIX:
        this->Add(test);
        break;
      default:
        break;
    }
  }
  delete(lexer);

  return;
}
  

