blob: 84f8e3c73089143a09df7e814cfe4441129589fd [file] [log] [blame] [edit]
//===========================================================================//
// Purpose : Methods for the 'TAP_ArchitectureParser_c' class.
//
// Inline public methods include:
// - syn
// - SetInterface
// - SetScanner
// - SetFileName
// - SetArchitectureFile
// - SetArchitectureSpec
//
//===========================================================================//
//---------------------------------------------------------------------------//
// 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
// 05/15/12 jeffr : Original
//===========================================================================//
void TAP_ArchitectureParser_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->parchitectureFile_->SyntaxError( lineNum,
this->srFileName_,
srMsg.data( ));
this->consumeUntilToken( END_OF_FILE );
}
}
//===========================================================================//
// Method : SetInterface
// Author : Jeff Rudolph
//---------------------------------------------------------------------------//
// Version history
// 05/15/12 jeffr : Original
//===========================================================================//
void TAP_ArchitectureParser_c::SetInterface(
TAP_ArchitectureInterface_c* pinterface )
{
this->pinterface_ = pinterface;
}
//===========================================================================//
// Method : SetScanner
// Author : Jeff Rudolph
//---------------------------------------------------------------------------//
// Version history
// 05/15/12 jeffr : Original
//===========================================================================//
void TAP_ArchitectureParser_c::SetScanner(
TAP_ArchitectureScanner_c* pscanner )
{
this->pscanner_ = pscanner;
}
//===========================================================================//
// Method : SetFileName
// Author : Jeff Rudolph
//---------------------------------------------------------------------------//
// Version history
// 05/15/12 jeffr : Original
//===========================================================================//
void TAP_ArchitectureParser_c::SetFileName(
const char* pszFileName )
{
this->srFileName_ = TIO_PSZ_STR( pszFileName );
}
//===========================================================================//
// Method : SetArchitectureFile
// Author : Jeff Rudolph
//---------------------------------------------------------------------------//
// Version history
// 05/15/12 jeffr : Original
//===========================================================================//
void TAP_ArchitectureParser_c::SetArchitectureFile(
TAP_ArchitectureFile_c* parchitectureFile )
{
this->parchitectureFile_ = parchitectureFile;
}
//===========================================================================//
// Method : SetArchitectureSpec
// Author : Jeff Rudolph
//---------------------------------------------------------------------------//
// Version history
// 05/15/12 jeffr : Original
//===========================================================================//
void TAP_ArchitectureParser_c::SetArchitectureSpec(
TAS_ArchitectureSpec_c* parchitectureSpec )
{
this->parchitectureSpec_ = parchitectureSpec;
}