//
// Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo
//
// The contents of this file are covered under the licence agreement in the
// file "LICENCE" distributed with Cforall.
//
// NameMatcher.h -- 
//
// Author           : Rodolfo G. Esteves
// Created On       : Mon May 18 07:44:20 2015
// Last Modified By : Peter A. Buhr
// Last Modified On : Mon May 18 15:01:37 2015
// Update Count     : 3
//

#ifndef _NAMEMATCHER_H_
#define _NAMEMATCHER_H_

#include <map>
#include <vector>
#include <string>

#include "SynTree/SynTree.h"
#include "SynTree/Mutator.h"

#include "SynTree/Type.h"
#include "SynTree/Declaration.h"
#include "SynTree/Expression.h"
#include "SynTree/Statement.h"

#include "ResolvExpr/Alternative.h"

namespace Tuples {
	struct NoMoreElements {};
	struct NoMatch {
		NoMatch( std::string msg ) : message( msg ) {}
		std::string message;
	};

	class NameMatcher {
	  public:
		NameMatcher( std::list< DeclarationWithType* >& );
		~NameMatcher();

		void match( ResolvExpr::AltList &alternatives ) throw (NoMatch) ;
		ResolvExpr::Alternative &get_next() throw (NoMoreElements);

	  private:
		int current;
		std::vector< DeclarationWithType* > index;
		std::vector< const ResolvExpr::Alternative * > exprs;
		std::map< std::string, int> table;
	};
} // namespace Tuples

#endif // _NAMEMATCHER_H_

// Local Variables: //
// tab-width: 4 //
// mode: c++ //
// compile-command: "make install" //
// End: //
