/*******************************************************************************
 * Copyright (c) 2015-2016 ONERA.
 * Ce logiciel est la propriété de l’ONERA (the French Aerospace Lab).
 * Tous droits réservés.
 *
 * Ce programme et les éléments qui l'accompagnent sont mis à disposition
 * aux conditions définies par le contrat de licence logiciel CeCILL-C soumise
 * au droit français et respectant les principes de diffusion des logiciels libres.
 * Vous pouvez utiliser, modifier et/ou redistribuer ce programme
 * sous les conditions de la licence CeCILL-C (http://www.cecill.info).

 * This software is property of ONERA (the French Aerospace Lab).
 * All rights reserved.
 *
 * This program and the accompanying materials are made available under
 * the terms of the CeCILL-C license under French law and
 * abiding by the rules of distribution of free software.
 * You can  use, modify and/ or redistribute the software under the terms of
 * the CeCILL-C license (http://www.cecill.info).
 *
 * Contributeurs/contributors:
 *     Guillaume Infantes (ONERA - Centre de Toulouse) - initial API and implementation
 *
 *******************************************************************************/

#include "altarica_driver.hh"
#include "altarica_parser.hh"
#include "altarica_lexer.h"
#include "grammars/details/parsingdriverbaseimpl.hh"

#include <boost/throw_exception.hpp>
#include <stdexcept>

altarica_driver::altarica_driver(epoch::ParsingDriverReporter& reporter, const std::string& parsedRessource,
					bool traceScanning, bool traceParsing) 
    : epoch::ParsingDriverBase(reporter, parsedRessource, traceScanning, traceParsing)
{
    amodel = new epoch::altarica::AltaricaModel();
}


altarica_driver::~altarica_driver() {}



int altarica_driver::Parse () {
    int parsingResult = epoch::ParsingDriverBase::ParseFile(*this);
    ClearRuleStack();
    return parsingResult;
}



void altarica_driver::DeleteRule(boost::any& rule) {
	if (DeleteRuleHelper<std::string>(rule)) return;
	// No match: memory leak!
	BOOST_THROW_EXCEPTION(std::runtime_error(std::string("Rule with type ") + rule.type().name() + " not deleted!"));
}
