/*
    Copyright (C) 2012 Bartosz Broda, Jacek Bochenek, Łukasz Biłeńkij, 
    Damian Jaworski, Wojciech Mazur, Dominik Piasecki, Maciej Piasecki, 
    Radosław Ramocki
    
    This program is free software; you can redistribute it and/or modify it
under the terms of the GNU Lesser General Public License as published by the Free
Software Foundation; either version 3 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 LICENSE and COPYING files for more details.
*/

#include "lex_headers.h"
#include "LexicalUnitType.h"

namespace LexicalUnits
{
	std::string LexicalUnitType::ToString(LexicalUnitType::TYPES type)
	{
		switch(type)
		{
		case FLEX:
			return "flex";
		case FIX:
			return "fix";
		case FLEXGAP:
			return "flexgap";
		case FIXGAP:
			return "fixgap";
		case SIMPLE_WORD:
			return "simple";
		}

		return "unknown";
	}

	bool LexicalUnitType::IsKnown(LexicalUnitType::TYPES type)
	{
		if( type == FLEX || type == FIX)
			return true;

		return false;
	}

	LexicalUnitType::TYPES LexicalUnitType::FromString(const std::string &s)
	{
		if( s == "flex" )
			return FLEX;
		if( s == "fix" )
			return FIX;
		if( s == "simple" )
			return SIMPLE_WORD;

		if( s == "fixgap" )
			return FIXGAP;

		if( s == "flexgap" )
			return FLEXGAP;

		throw std::string("Wrong lexical unit type: " + s);

		return SIMPLE_WORD;
	}

}//namespace LexicalUnits

std::ostream&  operator << (std::ostream& out, LexicalUnits::LexicalUnitType::TYPES type)
{
	out << LexicalUnits::LexicalUnitType::ToString(type);
	return out;
}
