blob: 1c0620a9feccaf006e2d0f06a9cf56ad8a90326e [file] [log] [blame] [edit]
//===========================================================================//
// Purpose : Methods for the 'TFP_FabricParser_c' class.
//
// Inline public methods include:
// - syn
// - SetInterface
// - SetScanner
// - SetFileName
// - SetFabricFile
// - SetFabricModel
//
//===========================================================================//
//---------------------------------------------------------------------------//
// Copyright (C) 2012-2013 Jeff Rudolph, Texas Instruments (jrudolph@ti.com) //
// //
// Permission is hereby granted, free of charge, to any person obtaining a //
// copy of this software and associated documentation files (the "Software"),//
// to deal in the Software without restriction, including without limitation //
// the rights to use, copy, modify, merge, publish, distribute, sublicense, //
// and/or sell copies of the Software, and to permit persons to whom the //
// Software is furnished to do so, subject to the following conditions: //
// //
// The above copyright notice and this permission notice shall be included //
// in all copies or substantial portions of the Software. //
// //
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS //
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF //
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN //
// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, //
// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR //
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE //
// USE OR OTHER DEALINGS IN THE SOFTWARE. //
//---------------------------------------------------------------------------//
//===========================================================================//
// Method : syn
// Author : Jeff Rudolph
//---------------------------------------------------------------------------//
// Version history
// 06/15/12 jeffr : Original
//===========================================================================//
void TFP_FabricParser_c::syn(
ANTLRAbstractToken* /* pToken */,
ANTLRChar* pszGroup,
SetWordType* /* pWordType */,
ANTLRTokenType tokenType,
int /* k */ )
{
if( LT( 1 ) && ( LT( 1 )->getType( ) != END_OF_FILE ))
{
int lineNum = LT( 1 )->getLine( );
string srFoundToken = this->token_tbl[LT( 1 )->getType( )];
string srFoundText = LT( 1 )->getText( );
string srMsg;
if( LT( 1 )->getType( ) == UNCLOSED_STRING )
{
srMsg = "at newline character. Closing quote is missing";
}
else
{
srMsg = "at " + srFoundToken + " token, ";
srMsg += "\"" + srFoundText + "\"";
if( tokenType && ( tokenType != DLGminToken ))
{
string srExpectToken = this->token_tbl[tokenType];
srMsg += ", expected a " + srExpectToken + " token";
}
if( strlen( pszGroup ) > 0 )
{
srMsg += " in ";
srMsg += pszGroup;
}
}
this->pfabricFile_->SyntaxError( lineNum,
this->srFileName_,
srMsg.data( ));
this->consumeUntilToken( END_OF_FILE );
}
}
//===========================================================================//
// Method : SetInterface
// Author : Jeff Rudolph
//---------------------------------------------------------------------------//
// Version history
// 06/15/12 jeffr : Original
//===========================================================================//
void TFP_FabricParser_c::SetInterface(
TFP_FabricInterface_c* pinterface )
{
this->pinterface_ = pinterface;
}
//===========================================================================//
// Method : SetScanner
// Author : Jeff Rudolph
//---------------------------------------------------------------------------//
// Version history
// 06/15/12 jeffr : Original
//===========================================================================//
void TFP_FabricParser_c::SetScanner(
TFP_FabricScanner_c* pscanner )
{
this->pscanner_ = pscanner;
}
//===========================================================================//
// Method : SetFileName
// Author : Jeff Rudolph
//---------------------------------------------------------------------------//
// Version history
// 06/15/12 jeffr : Original
//===========================================================================//
void TFP_FabricParser_c::SetFileName(
const char* pszFileName )
{
this->srFileName_ = TIO_PSZ_STR( pszFileName );
}
//===========================================================================//
// Method : SetFabricFile
// Author : Jeff Rudolph
//---------------------------------------------------------------------------//
// Version history
// 06/15/12 jeffr : Original
//===========================================================================//
void TFP_FabricParser_c::SetFabricFile(
TFP_FabricFile_c* pfabricFile )
{
this->pfabricFile_ = pfabricFile;
}
//===========================================================================//
// Method : SetFabricModel
// Author : Jeff Rudolph
//---------------------------------------------------------------------------//
// Version history
// 06/15/12 jeffr : Original
//===========================================================================//
void TFP_FabricParser_c::SetFabricModel(
TFM_FabricModel_c* pfabricModel )
{
this->pfabricModel_ = pfabricModel;
}