mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-03 17:56:21 +03:00
0031970: Data Exchange, STEP reader - parser syntax error messages are inaccessible
- Upgraded files using new version of WinFlexBison - Removed global variables within StepFile_Read.cxx - Upgraded error message during bison analyzing ( added a expected expression information ) - Used 'Interface_ParamType' as argument type for the StepFile_ReadData::Argument for a compatibility with the StepData/StepData_StepReaderData - Added handling parse errors and transferring it to the StepData_StepReaderData - Now parsing and referencing errors save in the check and non output by default - Step_file's and Step_Data's output info prints according by trace level of printer - Removed useless location.hxx - Removed TraceLevel for the StepFile_Reader ( now it useless, it is 0 by default and newer and nowhere change ) - Translate error message into English within StepData_StepReaderData - Replace "Error" word in the output messages
This commit is contained in:
parent
1ac837b2c2
commit
0c38be8f8d
@ -1,4 +1,4 @@
|
||||
/* A Bison parser, made by GNU Bison 3.7.1. */
|
||||
/* A Bison parser, made by GNU Bison 3.7.4. */
|
||||
|
||||
/* Bison implementation for Yacc-like parsers in C
|
||||
|
||||
@ -45,11 +45,11 @@
|
||||
define necessary library symbols; they are noted "INFRINGES ON
|
||||
USER NAME SPACE" below. */
|
||||
|
||||
/* Identify Bison output. */
|
||||
#define YYBISON 1
|
||||
/* Identify Bison output, and Bison version. */
|
||||
#define YYBISON 30704
|
||||
|
||||
/* Bison version. */
|
||||
#define YYBISON_VERSION "3.7.1"
|
||||
/* Bison version string. */
|
||||
#define YYBISON_VERSION "3.7.4"
|
||||
|
||||
/* Skeleton name. */
|
||||
#define YYSKELETON_NAME "yacc.c"
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* A Bison parser, made by GNU Bison 3.7.1. */
|
||||
/* A Bison parser, made by GNU Bison 3.7.4. */
|
||||
|
||||
/* Bison interface for Yacc-like parsers in C
|
||||
|
||||
|
@ -1515,7 +1515,7 @@ static int yy_get_next_buffer (void)
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
|
||||
yy_is_jam = (yy_current_state == 54);
|
||||
|
||||
return yy_is_jam ? 0 : yy_current_state;
|
||||
return yy_is_jam ? 0 : yy_current_state;
|
||||
}
|
||||
|
||||
#ifndef YY_NO_UNPUT
|
||||
|
@ -381,16 +381,15 @@ void StepData_StepReaderData::SetRecord(const Standard_Integer num,
|
||||
errm.AssignCat(" / ");
|
||||
errm.AssignCat(thenametypes.FindKey(thetypes.Value(num)));
|
||||
errm.AssignCat(" ... ");
|
||||
#ifdef OCCT_DEBUG
|
||||
while (theidents(prev) <= 0) {
|
||||
prev--; if (prev <= 0) break;
|
||||
}
|
||||
Message_Messenger::StreamBuffer sout = Message::SendInfo();
|
||||
sout << " *** Error on Record " << num << " (on " << NbRecords()
|
||||
<< " -> " << num * 100 / NbRecords() << " % in File) ***";
|
||||
|
||||
Message_Messenger::StreamBuffer sout = Message::SendTrace();
|
||||
sout << " *** Incorrect record " << num << " (on " << NbRecords()
|
||||
<< " -> " << num * 100 / NbRecords() << " % in File) ***";
|
||||
if (prev > 0) sout << " Ident #" << theidents(prev);
|
||||
sout << "\n" << errm << std::endl;
|
||||
#endif
|
||||
thecheck->AddWarning(errm.ToCString(), "Complex Type incorrect : ");
|
||||
}
|
||||
break;
|
||||
@ -1730,7 +1729,7 @@ Standard_Integer StepData_StepReaderData::FindEntityNumber(const Standard_Intege
|
||||
|
||||
void StepData_StepReaderData::SetEntityNumbers(const Standard_Boolean withmap)
|
||||
{
|
||||
Message_Messenger::StreamBuffer sout = Message::SendInfo();
|
||||
Message_Messenger::StreamBuffer sout = Message::SendTrace();
|
||||
// Passe initiale : Resolution directe par Map
|
||||
// si tout passe (pas de collision), OK. Sinon, autres passes a prevoir
|
||||
// On resoud du meme coup les sous-listes
|
||||
@ -1775,7 +1774,8 @@ void StepData_StepReaderData::SetEntityNumbers(const Standard_Boolean withmap)
|
||||
if (letype == Interface_ParamSub) {
|
||||
Standard_Integer numsub = FP.EntityNumber();
|
||||
if (numsub > thelastn) {
|
||||
sout << "Bad Sub.N0, Record " << num << " Param " << na << ":$" << numsub << std::endl;
|
||||
Message::SendInfo()
|
||||
<< "Bad Sub.N0, Record " << num << " Param " << na << ":$" << numsub << std::endl;
|
||||
continue;
|
||||
}
|
||||
FP.SetEntityNumber(subn(numsub));
|
||||
@ -1798,9 +1798,9 @@ void StepData_StepReaderData::SetEntityNumbers(const Standard_Boolean withmap)
|
||||
ident, na, id);
|
||||
thecheck->AddFail(failmess, "Unresolved Reference");
|
||||
// ... Et sortir message un peu plus complet
|
||||
sout << "*** ERR StepReaderData *** Pour Entite #" << ident
|
||||
<< "\n Type:" << RecordType(num)
|
||||
<< " Param.n0 " << na << ": #" << id << " Non trouve" << std::endl;
|
||||
sout << "*** ERR StepReaderData *** Entite #" << ident
|
||||
<< "\n Type:" << RecordType(num)
|
||||
<< " Param.n0 " << na << ": #" << id << " Not found" << std::endl;
|
||||
} // FIN Mapping
|
||||
} // FIN Traitement Reference
|
||||
} // FIN Boucle Parametres
|
||||
@ -1867,7 +1867,7 @@ void StepData_StepReaderData::SetEntityNumbers(const Standard_Boolean withmap)
|
||||
char ligne[80];
|
||||
sprintf(ligne, "Ident defined SEVERAL TIMES : #%d", ident);
|
||||
thecheck->AddFail(ligne, "Ident defined SEVERAL TIMES : #%d");
|
||||
sout << "StepReaderData:SetEntityNumbers, " << ligne << std::endl;
|
||||
sout << "StepReaderData : SetEntityNumbers, " << ligne << std::endl;
|
||||
}
|
||||
if (indm(indmap) > 0) indm(indmap) = -indm(indmap); // Pas pour Map
|
||||
// Cas Normal pour la Map
|
||||
@ -2056,11 +2056,13 @@ void StepData_StepReaderData::SetEntityNumbers(const Standard_Boolean withmap)
|
||||
"Unresolved Reference, Ent.n0 %d (Id.#%d) Param.n0 %d (Id.#%d)",
|
||||
nument, ident, na, id);
|
||||
thecheck->AddFail(failmess, "Unresolved Reference");
|
||||
|
||||
// ... Et sortir message un peu plus complet
|
||||
sout << "*** ERR StepReaderData *** Pour Entite " << nument
|
||||
<< ", a " << (nr * 100) / nbseq << "% de DATA : #" << ident
|
||||
<< "\n Type:" << RecordType(num)
|
||||
<< " Param.n0 " << na << ": #" << id << " Non trouve" << std::endl;
|
||||
sout << "*** ERR StepReaderData *** Entite " << nument
|
||||
<< ", a " << (nr * 100) / nbseq << "% de DATA : #" << ident
|
||||
<< "\n Type:" << RecordType(num)
|
||||
<< " Param.n0 " << na << ": #" << id << " Not found" << std::endl;
|
||||
|
||||
FP.SetEntityNumber(0); // -> Reference non resolue
|
||||
}
|
||||
}
|
||||
|
@ -159,7 +159,7 @@ void StepData_StepReaderTool::PrepareHeader
|
||||
void StepData_StepReaderTool::BeginRead
|
||||
(const Handle(Interface_InterfaceModel)& amodel)
|
||||
{
|
||||
Message_Messenger::StreamBuffer sout = Message::SendInfo();
|
||||
Message_Messenger::StreamBuffer sout = Message::SendTrace();
|
||||
DeclareAndCast(StepData_StepModel,model,amodel);
|
||||
DeclareAndCast(StepData_StepReaderData,stepdat,Data());
|
||||
|
||||
@ -185,16 +185,20 @@ void StepData_StepReaderTool::BeginRead
|
||||
Standard_Integer nbmess = ach->NbWarnings();
|
||||
sout<<nbmess<<" Warnings on Reading Header Entity N0."<<i<<":";
|
||||
if (!ent.IsNull()) sout << ent->DynamicType()->Name() << std::endl;
|
||||
for (Standard_Integer nf = 1; nf <= nbmess; nf ++)
|
||||
sout << ach->CWarning(nf) << "\n";
|
||||
for (Standard_Integer nf = 1; nf <= nbmess; nf++)
|
||||
{
|
||||
sout << ach->CWarning(nf) << "\n";
|
||||
}
|
||||
}
|
||||
if (ach->HasFailed()) {
|
||||
Handle(Interface_Check) mch = model->GlobalCheck();
|
||||
Standard_Integer nbmess = ach->NbFails();
|
||||
sout << " Errors on Reading Header Entity N0."<<i<<":";
|
||||
sout << " Fails on Reading Header Entity N0." << i << ":";
|
||||
if (!ent.IsNull()) sout << ent->DynamicType()->Name() << std::endl;
|
||||
for (Standard_Integer nf = 1; nf <= nbmess; nf ++)
|
||||
sout << ach->CFail(nf) << "\n";
|
||||
for (Standard_Integer nf = 1; nf <= nbmess; nf++)
|
||||
{
|
||||
sout << ach->CFail(nf) << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -8,4 +8,3 @@ StepFile_Read.hxx
|
||||
step.lex
|
||||
step.yacc
|
||||
FlexLexer.h
|
||||
location.hh
|
||||
|
@ -27,24 +27,27 @@
|
||||
|
||||
#include <stdio.h>
|
||||
#include <iostream>
|
||||
#include <StepFile_ReadData.hxx>
|
||||
#include <step.tab.hxx>
|
||||
|
||||
#include <step.tab.hxx>
|
||||
#include <StepFile_Read.hxx>
|
||||
#include <StepFile_ReadData.hxx>
|
||||
|
||||
#include <Interface_Check.hxx>
|
||||
#include <Interface_InterfaceError.hxx>
|
||||
#include <Interface_ParamType.hxx>
|
||||
#include <Interface_Protocol.hxx>
|
||||
#include <Interface_Check.hxx>
|
||||
#include <StepData_Protocol.hxx>
|
||||
|
||||
#include <StepData_FileRecognizer.hxx>
|
||||
#include <StepData_Protocol.hxx>
|
||||
#include <StepData_StepModel.hxx>
|
||||
#include <StepData_StepReaderData.hxx>
|
||||
#include <StepData_StepReaderTool.hxx>
|
||||
#include <StepFile_Read.hxx>
|
||||
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <Standard_Failure.hxx>
|
||||
#include <Interface_InterfaceError.hxx>
|
||||
|
||||
#include <Message_Messenger.hxx>
|
||||
#include <Message.hxx>
|
||||
#include <Message_Messenger.hxx>
|
||||
|
||||
#include <OSD_OpenFile.hxx>
|
||||
#include <OSD_Timer.hxx>
|
||||
@ -53,31 +56,22 @@
|
||||
#define CHRONOMESURE
|
||||
#endif
|
||||
|
||||
// ## ## ## ## ON SAURA AU MOINS TRAITER UndefinedEntity ## ## ## ##
|
||||
|
||||
extern "C" void recfile_modeprint (int mode); // controle trace recfile
|
||||
|
||||
static Handle(Interface_Check) checkread = new Interface_Check;
|
||||
static Standard_Integer modepr = 1;
|
||||
|
||||
void StepFile_ReadTrace (const Standard_Integer mode)
|
||||
void StepFile_Interrupt(Standard_CString theErrorMessage, const Standard_Boolean theIsFail)
|
||||
{
|
||||
modepr = mode; // recfile_modeprint est rappele a chaque lecture de fichier
|
||||
if (theErrorMessage == NULL)
|
||||
return;
|
||||
|
||||
Message_Messenger::StreamBuffer sout = theIsFail ? Message::SendFail() : Message::SendTrace();
|
||||
sout << "**** ERR StepFile : " << theErrorMessage << " ****" << std::endl;
|
||||
}
|
||||
|
||||
// ## ## ## ## ## ## Corps de la Routine ## ## ## ## ## ##
|
||||
|
||||
static Interface_ParamType LesTypes[10]; // passage types (recstep/Interface)
|
||||
|
||||
static Standard_Integer StepFile_Read (const char* theName,
|
||||
std::istream* theIStream,
|
||||
const Handle(StepData_StepModel)& stepmodel,
|
||||
const Handle(StepData_Protocol)& protocol,
|
||||
const Handle(StepData_FileRecognizer)& recoheader,
|
||||
const Handle(StepData_FileRecognizer)& recodata)
|
||||
const Handle(StepData_StepModel)& theStepModel,
|
||||
const Handle(StepData_Protocol)& theProtocol,
|
||||
const Handle(StepData_FileRecognizer)& theRecogHeader,
|
||||
const Handle(StepData_FileRecognizer)& theRecogData)
|
||||
{
|
||||
StepFile_ReadData aFileDataModel;
|
||||
aFileDataModel.SetModePrint(modepr > 0 ? modepr - 1 : 0);
|
||||
// if stream is not provided, open file stream here
|
||||
std::istream *aStreamPtr = theIStream;
|
||||
std::ifstream aFileStream;
|
||||
@ -95,8 +89,12 @@ static Standard_Integer StepFile_Read (const char* theName,
|
||||
OSD_Timer c;
|
||||
c.Reset();
|
||||
c.Start();
|
||||
Message::SendInfo() << " ... Step File Reading : '" << theName << "'";
|
||||
#endif
|
||||
|
||||
Message_Messenger::StreamBuffer sout = Message::SendTrace();
|
||||
sout << " ... Step File Reading : '" << theName << "'";
|
||||
|
||||
StepFile_ReadData aFileDataModel;
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
int aLetat = 0;
|
||||
@ -105,123 +103,101 @@ static Standard_Integer StepFile_Read (const char* theName,
|
||||
step::parser aParser(&aScanner);
|
||||
aLetat = aParser.parse();
|
||||
if (aLetat != 0) {
|
||||
StepFile_Interrupt(aFileDataModel.GetLastError(), Standard_True);
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
catch (Standard_Failure const& anException) {
|
||||
#ifdef OCCT_DEBUG
|
||||
Message::SendAlarm() << " ... Exception Raised while reading Step File : '" << theName << "':\n"
|
||||
<< anException.GetMessageString()
|
||||
<< " ...";
|
||||
#endif
|
||||
(void)anException;
|
||||
Message::SendFail() << " ... Exception Raised while reading Step File : '" << theName << "':\n"
|
||||
<< anException << " ...";
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Continue reading of file despite of possible fails
|
||||
// if (checkread->HasFailed()) { lir_file_fin(3); stepread_endinput(newifstream, ficnom); return 1; }
|
||||
#ifdef CHRONOMESURE
|
||||
{
|
||||
Message_Messenger::StreamBuffer sout = Message::SendInfo();
|
||||
sout << " ... STEP File Read ...\n";
|
||||
c.Show (sout);
|
||||
}
|
||||
c.Show(sout);
|
||||
#endif
|
||||
|
||||
// Creation du StepReaderData
|
||||
|
||||
LesTypes[ArgumentType_Nondef] = Interface_ParamVoid ;
|
||||
LesTypes[ArgumentType_Sub] = Interface_ParamSub ;
|
||||
LesTypes[ArgumentType_Ident] = Interface_ParamIdent ;
|
||||
LesTypes[ArgumentType_Integer] = Interface_ParamInteger ;
|
||||
LesTypes[ArgumentType_Float] = Interface_ParamReal ;
|
||||
LesTypes[ArgumentType_Enum] = Interface_ParamEnum ;
|
||||
LesTypes[ArgumentType_Binary] = Interface_ParamBinary ;
|
||||
LesTypes[ArgumentType_Text] = Interface_ParamText ;
|
||||
LesTypes[ArgumentType_Hexa] = Interface_ParamHexa ;
|
||||
LesTypes[ArgumentType_Misc] = Interface_ParamMisc ;
|
||||
sout << " ... STEP File Read ...\n";
|
||||
|
||||
Standard_Integer nbhead, nbrec, nbpar;
|
||||
aFileDataModel.GetFileNbR (&nbhead,&nbrec,&nbpar); // renvoi par lex/yacc
|
||||
Handle(StepData_StepReaderData) undirec =
|
||||
new StepData_StepReaderData(nbhead,nbrec,nbpar, stepmodel->SourceCodePage()); // creation tableau de records
|
||||
|
||||
new StepData_StepReaderData(nbhead,nbrec,nbpar, theStepModel->SourceCodePage()); // creation tableau de records
|
||||
for ( Standard_Integer nr = 1; nr <= nbrec; nr ++) {
|
||||
int nbarg; char* ident; char* typrec = 0;
|
||||
aFileDataModel.GetRecordDescription(&ident, &typrec, &nbarg);
|
||||
undirec->SetRecord (nr, ident, typrec, nbarg);
|
||||
|
||||
if (nbarg>0) {
|
||||
ArgumentType typa; char* val;
|
||||
Interface_ParamType newtype;
|
||||
Interface_ParamType typa; char* val;
|
||||
while(aFileDataModel.GetArgDescription (&typa, &val) == 1) {
|
||||
newtype = LesTypes[typa] ;
|
||||
undirec->AddStepParam (nr, val, newtype);
|
||||
undirec->AddStepParam (nr, val, typa);
|
||||
}
|
||||
}
|
||||
undirec->InitParams(nr);
|
||||
aFileDataModel.NextRecord();
|
||||
}
|
||||
|
||||
aFileDataModel.ErrorHandle(undirec->GlobalCheck());
|
||||
Standard_Integer anFailsCount = undirec->GlobalCheck()->NbFails();
|
||||
if (anFailsCount > 0)
|
||||
{
|
||||
Message::SendInfo() << "**** ERR StepFile : Incorrect Syntax : Fails Count : "
|
||||
<< anFailsCount << " ****";
|
||||
}
|
||||
|
||||
aFileDataModel.ClearRecorder(1);
|
||||
// on a undirec pret pour la suite
|
||||
|
||||
sout << " ... Step File loaded ...\n";
|
||||
sout << " " << undirec->NbRecords() << " records (entities,sub-lists,scopes), " << nbpar << " parameters";
|
||||
|
||||
#ifdef CHRONOMESURE
|
||||
{
|
||||
Message_Messenger::StreamBuffer sout = Message::SendInfo();
|
||||
sout << " ... Step File loaded ...\n";
|
||||
c.Show (sout);
|
||||
sout << " "<< undirec->NbRecords() << " records (entities,sub-lists,scopes), "<< nbpar << " parameters";
|
||||
}
|
||||
c.Show(sout);
|
||||
#endif
|
||||
|
||||
// Analyse : par StepReaderTool
|
||||
|
||||
StepData_StepReaderTool readtool (undirec,protocol);
|
||||
StepData_StepReaderTool readtool (undirec, theProtocol);
|
||||
readtool.SetErrorHandle (Standard_True);
|
||||
|
||||
readtool.PrepareHeader(recoheader); // Header. reco nul -> pour Protocol
|
||||
readtool.Prepare(recodata); // Data. reco nul -> pour Protocol
|
||||
readtool.PrepareHeader(theRecogHeader); // Header. reco nul -> pour Protocol
|
||||
readtool.Prepare(theRecogData); // Data. reco nul -> pour Protocol
|
||||
|
||||
sout << " ... Parameters prepared ...\n";
|
||||
|
||||
#ifdef CHRONOMESURE
|
||||
{
|
||||
Message_Messenger::StreamBuffer sout = Message::SendInfo();
|
||||
sout << " ... Parameters prepared ...\n";
|
||||
c.Show (sout);
|
||||
}
|
||||
c.Show(sout)
|
||||
#endif
|
||||
|
||||
readtool.LoadModel(stepmodel);
|
||||
if (stepmodel->Protocol().IsNull()) stepmodel->SetProtocol (protocol);
|
||||
readtool.LoadModel(theStepModel);
|
||||
if (theStepModel->Protocol().IsNull()) theStepModel->SetProtocol (theProtocol);
|
||||
aFileDataModel.ClearRecorder(2);
|
||||
|
||||
anFailsCount = undirec->GlobalCheck()->NbFails() - anFailsCount;
|
||||
if (anFailsCount > 0)
|
||||
{
|
||||
Message::SendInfo() << "*** ERR StepReaderData : Unresolved Reference : Fails Count : "
|
||||
<< anFailsCount << " ***";
|
||||
}
|
||||
|
||||
readtool.Clear();
|
||||
undirec.Nullify();
|
||||
|
||||
sout << " ... Objects analysed ...\n";
|
||||
Standard_Integer n = theStepModel->NbEntities();
|
||||
sout << " STEP Loading done : " << n << " Entities";
|
||||
|
||||
#ifdef CHRONOMESURE
|
||||
{
|
||||
Message_Messenger::StreamBuffer sout = Message::SendInfo();
|
||||
sout << " ... Objets analysed ...\n";
|
||||
c.Show (sout);
|
||||
Standard_Integer n = stepmodel->NbEntities();
|
||||
sout << " STEP Loading done : " << n << " Entities";
|
||||
}
|
||||
c.Show(sout);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Standard_Integer StepFile_Read(const char* theName,
|
||||
std::istream* theIStream,
|
||||
const Handle(StepData_StepModel)& stepmodel,
|
||||
const Handle(StepData_Protocol)& protocol)
|
||||
const Handle(StepData_StepModel)& theStepModel,
|
||||
const Handle(StepData_Protocol)& theProtocol)
|
||||
{
|
||||
Handle(StepData_FileRecognizer) nulreco;
|
||||
return StepFile_Read (theName,theIStream,stepmodel,protocol,nulreco,nulreco);
|
||||
}
|
||||
|
||||
void StepFile_Interrupt (char* mess)
|
||||
{
|
||||
#ifdef OCCT_DEBUG
|
||||
Message_Messenger::StreamBuffer sout = Message::SendInfo();
|
||||
sout << " **** StepFile Error : " << mess << " ****" << std::endl;
|
||||
#endif
|
||||
checkread->AddFail(mess);
|
||||
Handle(StepData_FileRecognizer) aNulRecog;
|
||||
return StepFile_Read(theName, theIStream, theStepModel, theProtocol, aNulRecog, aNulRecog);
|
||||
}
|
||||
|
@ -14,27 +14,19 @@
|
||||
// Alternatively, this file may be used under the terms of Open CASCADE
|
||||
// commercial license or contractual agreement.
|
||||
|
||||
// StepFile_Read.hxx
|
||||
|
||||
// routine assurant l'enchainement des operations de lecture d'un fichier
|
||||
// STEP dans un StepModel, en fonction d'une cle de reconnaissance
|
||||
// Retour de la fonction :
|
||||
// 0 si OK (le StepModel a ete charge)
|
||||
// -1 si abandon car fichier pas pu etre ouvert
|
||||
// 1 si erreur en cours de lecture
|
||||
|
||||
|
||||
#ifndef StepFile_Read_HeaderFile
|
||||
#define StepFile_Read_HeaderFile
|
||||
|
||||
#include <iostream>
|
||||
//# include <stepread.h> : sauf recfile_modeprint, declare ici
|
||||
# include <StepData_StepModel.hxx>
|
||||
# include <StepData_FileRecognizer.hxx>
|
||||
# include <StepData_Protocol.hxx>
|
||||
#include <iostream>
|
||||
|
||||
Standard_EXPORT void StepFile_ReadTrace (const Standard_Integer mode);
|
||||
// Modal : 0 pas de trace, 1 trace LoadModel, 2 & 3 + trace interne lex-yac
|
||||
class StepData_StepModel;
|
||||
class StepData_Protocol;
|
||||
|
||||
//! Prints the error message
|
||||
//! @param theErrorMessage - error message for output
|
||||
//! @param theFail - if true output as a fail info, else output as a trace info ( log )
|
||||
void StepFile_Interrupt(Standard_CString theErrorMessage,
|
||||
const Standard_Boolean theIsFail = Standard_True);
|
||||
|
||||
//! Working function reading STEP file or stream.
|
||||
//! @param theName - name of the file or stream
|
||||
|
@ -15,6 +15,9 @@
|
||||
|
||||
#include <StepFile_ReadData.hxx>
|
||||
|
||||
#include <Interface_Check.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
// Constant litterales
|
||||
namespace TextValue
|
||||
{
|
||||
@ -61,7 +64,7 @@ public:
|
||||
|
||||
public:
|
||||
|
||||
Argument() :myNext(NULL), myValue(NULL), myType(ArgumentType_Sub) {}
|
||||
Argument() :myNext(NULL), myValue(NULL), myType(Interface_ParamSub) {}
|
||||
|
||||
~Argument() {}
|
||||
|
||||
@ -69,7 +72,7 @@ public:
|
||||
|
||||
Argument* myNext; //!< Next argument in the list for this record
|
||||
char* myValue; //!< Character value of the argument
|
||||
ArgumentType myType; //!< Type of the argument
|
||||
Interface_ParamType myType; //!< Type of the argument
|
||||
};
|
||||
|
||||
class StepFile_ReadData::ArgumentsPage {
|
||||
@ -143,7 +146,6 @@ public:
|
||||
Record* myRecord; //!< Record interrupted by the scope (to resume)
|
||||
};
|
||||
|
||||
|
||||
class StepFile_ReadData::RecordsPage
|
||||
{
|
||||
|
||||
@ -170,6 +172,29 @@ public:
|
||||
int myUsed; //!< Counter employed records
|
||||
};
|
||||
|
||||
class StepFile_ReadData::ErrorsPage
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
ErrorsPage(Standard_CString theError) :myNext(NULL), myError(theError)
|
||||
{}
|
||||
|
||||
//! Returns point to the next ErrorsPage
|
||||
ErrorsPage* NextErrorPage() const { return myNext; }
|
||||
|
||||
//! Sets the next ErrorPage
|
||||
void SetNextErrorPage(ErrorsPage* theNextErrorsPage) { myNext = theNextErrorsPage; }
|
||||
|
||||
//! Returns an error message
|
||||
Standard_CString ErrorMessage() const { return myError.ToCString(); }
|
||||
|
||||
private:
|
||||
|
||||
ErrorsPage* myNext; //!< Chaining of records pages
|
||||
TCollection_AsciiString myError; //!< Own error message
|
||||
};
|
||||
|
||||
//=======================================================================
|
||||
//function : StepFile_ReadData
|
||||
//purpose :
|
||||
@ -179,8 +204,8 @@ StepFile_ReadData::StepFile_ReadData()
|
||||
:myMaxChar(50000), myMaxRec(5000), myMaxArg(10000), myModePrint(0),
|
||||
myNbRec(0), myNbHead(0), myNbPar(0), myYaRec(0),
|
||||
myNumSub(0), myErrorArg(Standard_False), myResText(NULL), myCurrType(TextValue::SubList),
|
||||
mySubArg(NULL), myTypeArg(ArgumentType_Sub), myCurrArg(NULL), myFirstRec(NULL),
|
||||
myCurRec(NULL), myLastRec(NULL), myCurScope(NULL)
|
||||
mySubArg(NULL), myTypeArg(Interface_ParamSub), myCurrArg(NULL), myFirstRec(NULL),
|
||||
myCurRec(NULL), myLastRec(NULL), myCurScope(NULL), myFirstError(NULL), myCurError(NULL)
|
||||
{
|
||||
myOneCharPage = new CharactersPage(myMaxChar);
|
||||
myOneArgPage = new ArgumentsPage(myMaxArg);
|
||||
@ -238,7 +263,7 @@ void StepFile_ReadData::RecordNewEntity()
|
||||
{
|
||||
myErrorArg = Standard_False; // Reset error argument mod
|
||||
AddNewRecord(myCurRec);
|
||||
SetTypeArg(ArgumentType_Sub);
|
||||
SetTypeArg(Interface_ParamSub);
|
||||
mySubArg = myCurRec->myIdent;
|
||||
myCurRec = myCurRec->myNext;
|
||||
myLastRec->myNext = NULL;
|
||||
@ -331,12 +356,12 @@ void StepFile_ReadData::CreateNewArg()
|
||||
aNewArg = &myOneArgPage->myArgs[myOneArgPage->myUsed];
|
||||
myOneArgPage->myUsed++;
|
||||
aNewArg->myType = myTypeArg;
|
||||
if (myTypeArg == ArgumentType_Sub)
|
||||
if (myTypeArg == Interface_ParamSub)
|
||||
aNewArg->myValue = mySubArg;
|
||||
else
|
||||
GetResultText(&aNewArg->myValue);
|
||||
|
||||
if (myTypeArg == ArgumentType_Misc)
|
||||
if (myTypeArg == Interface_ParamMisc)
|
||||
myErrorArg = Standard_True;
|
||||
|
||||
if (myCurRec->myFirst == NULL)
|
||||
@ -364,7 +389,7 @@ void StepFile_ReadData::CreateErrorArg()
|
||||
// If already exists - update text value
|
||||
if (!myErrorArg)
|
||||
{
|
||||
SetTypeArg(ArgumentType_Misc);
|
||||
SetTypeArg(Interface_ParamMisc);
|
||||
CreateNewArg();
|
||||
myErrorArg = Standard_True;
|
||||
return;
|
||||
@ -421,7 +446,7 @@ void StepFile_ReadData::FinalOfScope()
|
||||
PrintRecord(myLastRec);
|
||||
}
|
||||
myCurRec = aRecord;
|
||||
myTypeArg = ArgumentType_Sub;
|
||||
myTypeArg = Interface_ParamSub;
|
||||
CreateNewArg();
|
||||
}
|
||||
|
||||
@ -445,26 +470,28 @@ void StepFile_ReadData::ClearRecorder(const Standard_Integer theMode)
|
||||
{
|
||||
while (myOneRecPage != NULL)
|
||||
{
|
||||
RecordsPage* aNewPage;
|
||||
aNewPage = myOneRecPage->myNext;
|
||||
RecordsPage* aNewPage = myOneRecPage->myNext;
|
||||
delete myOneRecPage;
|
||||
myOneRecPage = NULL;
|
||||
myOneRecPage = aNewPage;
|
||||
}
|
||||
while (myOneArgPage != NULL) {
|
||||
ArgumentsPage* aNewPage; aNewPage = myOneArgPage->myNext;
|
||||
ArgumentsPage* aNewPage = myOneArgPage->myNext;
|
||||
delete myOneArgPage;
|
||||
myOneArgPage = NULL;
|
||||
myOneArgPage = aNewPage;
|
||||
}
|
||||
while (myFirstError != NULL)
|
||||
{
|
||||
ErrorsPage* aNewErrorPage = myFirstError->NextErrorPage();
|
||||
delete myFirstError;
|
||||
myFirstError = aNewErrorPage;
|
||||
}
|
||||
}
|
||||
if (theMode & 2)
|
||||
{
|
||||
while (myOneCharPage != NULL)
|
||||
{
|
||||
CharactersPage* aNewPage; aNewPage = myOneCharPage->myNext;
|
||||
CharactersPage* aNewPage = myOneCharPage->myNext;
|
||||
delete myOneCharPage;
|
||||
myOneCharPage = NULL;
|
||||
myOneCharPage = aNewPage;
|
||||
}
|
||||
}
|
||||
@ -475,7 +502,7 @@ void StepFile_ReadData::ClearRecorder(const Standard_Integer theMode)
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean StepFile_ReadData::GetArgDescription(ArgumentType* theType, char** theValue)
|
||||
Standard_Boolean StepFile_ReadData::GetArgDescription(Interface_ParamType* theType, char** theValue)
|
||||
{
|
||||
if (myCurrArg == NULL)
|
||||
return Standard_False;
|
||||
@ -491,8 +518,8 @@ Standard_Boolean StepFile_ReadData::GetArgDescription(ArgumentType* theType, cha
|
||||
//=======================================================================
|
||||
|
||||
void StepFile_ReadData::GetFileNbR(Standard_Integer* theNbHead,
|
||||
Standard_Integer* theNbRec,
|
||||
Standard_Integer* theNbPage)
|
||||
Standard_Integer* theNbRec,
|
||||
Standard_Integer* theNbPage)
|
||||
{
|
||||
myCurRec = myFirstRec;
|
||||
*theNbHead = myNbHead;
|
||||
@ -506,8 +533,8 @@ void StepFile_ReadData::GetFileNbR(Standard_Integer* theNbHead,
|
||||
//=======================================================================
|
||||
|
||||
Standard_Boolean StepFile_ReadData::GetRecordDescription(char** theIdent,
|
||||
char** theType,
|
||||
int* theNbArg)
|
||||
char** theType,
|
||||
int* theNbArg)
|
||||
{
|
||||
if (myCurRec == NULL)
|
||||
return Standard_False;
|
||||
@ -573,7 +600,7 @@ void StepFile_ReadData::FinalOfHead()
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
|
||||
void StepFile_ReadData::SetTypeArg(const ArgumentType theArgType)
|
||||
void StepFile_ReadData::SetTypeArg(const Interface_ParamType theArgType)
|
||||
{
|
||||
myTypeArg = theArgType;
|
||||
}
|
||||
@ -608,6 +635,51 @@ Standard_Integer StepFile_ReadData::GetNbRecord() const
|
||||
return myNbRec;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : AddError
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
void StepFile_ReadData::AddError(Standard_CString theErrorMessage)
|
||||
{
|
||||
if (myFirstError == NULL)
|
||||
{
|
||||
myFirstError = new ErrorsPage(theErrorMessage);
|
||||
myCurError = myFirstError;
|
||||
}
|
||||
else
|
||||
{
|
||||
myCurError->SetNextErrorPage(new ErrorsPage(theErrorMessage));
|
||||
myCurError = myCurError->NextErrorPage();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : ErrorHandle
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_Boolean StepFile_ReadData::ErrorHandle(const Handle(Interface_Check)& theCheck) const
|
||||
{
|
||||
if (myFirstError != NULL)
|
||||
{
|
||||
ErrorsPage* aCurrent = myFirstError;
|
||||
while (aCurrent != NULL)
|
||||
{
|
||||
theCheck->AddFail(aCurrent->ErrorMessage(), "Undefined Parsing");
|
||||
aCurrent = aCurrent->NextErrorPage();
|
||||
}
|
||||
}
|
||||
return myFirstError == NULL;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : GetLastError
|
||||
//purpose :
|
||||
//=======================================================================
|
||||
Standard_CString StepFile_ReadData::GetLastError() const
|
||||
{
|
||||
return myCurError != NULL ? myCurError->ErrorMessage() : NULL;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
//function : RecordNewText
|
||||
//purpose :
|
||||
|
@ -16,23 +16,12 @@
|
||||
#ifndef _StepFile_ReadData_HeaderFile
|
||||
#define _StepFile_ReadData_HeaderFile
|
||||
|
||||
// Types of arguments
|
||||
enum ArgumentType {
|
||||
ArgumentType_Sub = 0,
|
||||
ArgumentType_Integer,
|
||||
ArgumentType_Float,
|
||||
ArgumentType_Ident,
|
||||
ArgumentType_Text,
|
||||
ArgumentType_Nondef,
|
||||
ArgumentType_Enum,
|
||||
ArgumentType_Hexa,
|
||||
ArgumentType_Binary,
|
||||
ArgumentType_Misc
|
||||
};
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Handle.hxx>
|
||||
#include <Standard_DefineAlloc.hxx>
|
||||
|
||||
#include <Interface_ParamType.hxx>
|
||||
|
||||
//! Provides data structures and tools to collect and store the data
|
||||
//! read from the STEP file.
|
||||
//! This class is designed to work in collaboration with STEP parser
|
||||
@ -114,6 +103,8 @@ enum ArgumentType {
|
||||
//! threads) provided that each file is read using its own instances of Flex, Bison
|
||||
//! and StepFile_ReadData tools.
|
||||
|
||||
class Interface_Check;
|
||||
|
||||
class StepFile_ReadData
|
||||
{
|
||||
public:
|
||||
@ -128,6 +119,7 @@ private:
|
||||
class ArgumentsPage; //!< List of arguments pages, contains all text derived from Flex
|
||||
class Scope; //!< List of scopes pages, contains all records for external processing
|
||||
class RecordsPage; //!< List of records pages, contains all records
|
||||
class ErrorsPage; //!< List of errors messages, containts all errors
|
||||
|
||||
public:
|
||||
|
||||
@ -178,7 +170,7 @@ public:
|
||||
void ClearRecorder(const Standard_Integer theMode);
|
||||
|
||||
//! Returns a value of fields of current argument
|
||||
Standard_Boolean GetArgDescription(ArgumentType* theType, char** theValue);
|
||||
Standard_Boolean GetArgDescription(Interface_ParamType* theType, char** theValue);
|
||||
|
||||
//! Returns a value of all file counters
|
||||
void GetFileNbR(Standard_Integer* theNbHead, Standard_Integer* theNbRec, Standard_Integer* theNbPage);
|
||||
@ -203,7 +195,7 @@ public:
|
||||
void FinalOfHead();
|
||||
|
||||
//! Sets type of the current argument
|
||||
void SetTypeArg(const ArgumentType theArgType);
|
||||
void SetTypeArg(const Interface_ParamType theArgType);
|
||||
|
||||
//! Initializes the print mode
|
||||
//! 0 - don't print descriptions
|
||||
@ -217,6 +209,15 @@ public:
|
||||
//! Returns number of records
|
||||
Standard_Integer GetNbRecord() const;
|
||||
|
||||
//! Adds an error message
|
||||
void AddError(Standard_CString theErrorMessage);
|
||||
|
||||
//! Transfers error messages to checker
|
||||
Standard_Boolean ErrorHandle(const Handle(Interface_Check)& theCheck) const;
|
||||
|
||||
//! Returns the message of the last error
|
||||
Standard_CString GetLastError() const;
|
||||
|
||||
private:
|
||||
|
||||
//! Prepare text to analyze
|
||||
@ -250,12 +251,14 @@ private:
|
||||
char* myResText; //!< Text value written by Flex and passed to Bison to create record
|
||||
char* myCurrType; //!< Type of last record read
|
||||
char* mySubArg; //!< Ident last record (possible sub-list)
|
||||
ArgumentType myTypeArg; //!< Type of last argument read
|
||||
Interface_ParamType myTypeArg; //!< Type of last argument read
|
||||
Argument* myCurrArg; //!< Current node of the argumets list
|
||||
Record* myFirstRec; //!< First node of the records list
|
||||
Record* myCurRec; //!< Current node of the records list
|
||||
Record* myLastRec; //!< Last node of the records list
|
||||
Scope* myCurScope; //!< Current node of the scopes list
|
||||
ErrorsPage* myFirstError; //!< First node of the errors pages list
|
||||
ErrorsPage* myCurError; //!< Current node of the errors pages list
|
||||
RecordsPage* myOneRecPage; //!< Current node of the records pages list
|
||||
CharactersPage* myOneCharPage; //!< Current node of the characters pages list
|
||||
ArgumentsPage* myOneArgPage; //!< Current node of the arguments pages list
|
||||
|
@ -653,7 +653,7 @@ goto find_rule; \
|
||||
#ifdef YY_DECL
|
||||
# undef YY_DECL
|
||||
#endif
|
||||
#define YY_DECL int step::scanner::lex (step::parser::semantic_type* /*yylval*/, step::parser::location_type* /*yylloc*/)
|
||||
#define YY_DECL int step::scanner::lex (step::parser::semantic_type* /*yylval*/)
|
||||
|
||||
typedef step::parser::token token;
|
||||
|
||||
@ -959,7 +959,7 @@ YY_LINENO_REWIND_TO(yy_bp + 1);
|
||||
(yy_c_buf_p) = yy_cp = yy_bp + 1;
|
||||
YY_DO_BEFORE_ACTION; /* set up yytext again */
|
||||
YY_RULE_SETUP
|
||||
{ BEGIN(INITIAL); CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Text); return(token::QUID); } /* end of string (apostrophe followed by comma or closing parenthesis) - reset the scanner to initial state, record the value of all yytext collected */
|
||||
{ BEGIN(INITIAL); CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamText); return(token::QUID); } /* end of string (apostrophe followed by comma or closing parenthesis) - reset the scanner to initial state, record the value of all yytext collected */
|
||||
YY_BREAK
|
||||
case 10:
|
||||
YY_RULE_SETUP
|
||||
@ -999,23 +999,23 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 18:
|
||||
YY_RULE_SETUP
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Integer); return(token::QUID); }
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamInteger); return(token::QUID); }
|
||||
YY_BREAK
|
||||
case 19:
|
||||
YY_RULE_SETUP
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Float); return(token::QUID); }
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamReal); return(token::QUID); }
|
||||
YY_BREAK
|
||||
case 20:
|
||||
YY_RULE_SETUP
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Float); return(token::QUID); }
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamReal); return(token::QUID); }
|
||||
YY_BREAK
|
||||
case 21:
|
||||
YY_RULE_SETUP
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Hexa); return(token::QUID); }
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamHexa); return(token::QUID); }
|
||||
YY_BREAK
|
||||
case 22:
|
||||
YY_RULE_SETUP
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Enum); return(token::QUID); }
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamEnum); return(token::QUID); }
|
||||
YY_BREAK
|
||||
case 23:
|
||||
YY_RULE_SETUP
|
||||
@ -1031,7 +1031,7 @@ YY_RULE_SETUP
|
||||
YY_BREAK
|
||||
case 26:
|
||||
YY_RULE_SETUP
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Nondef); return(token::QUID); }
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamVoid); return(token::QUID); }
|
||||
YY_BREAK
|
||||
case 27:
|
||||
YY_RULE_SETUP
|
||||
@ -1096,7 +1096,7 @@ YY_RULE_SETUP
|
||||
case 42:
|
||||
/* rule 42 can match eol */
|
||||
YY_RULE_SETUP
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Misc); return(token::QUID); }
|
||||
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamMisc); return(token::QUID); }
|
||||
YY_BREAK
|
||||
case 43:
|
||||
YY_RULE_SETUP
|
||||
|
@ -1,302 +0,0 @@
|
||||
// A Bison parser, made by GNU Bison 3.7.1.
|
||||
|
||||
// Locations for Bison parsers in C++
|
||||
|
||||
// Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
|
||||
|
||||
// This program is free software: you can redistribute it and/or modify
|
||||
// it under the terms of the GNU 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
|
||||
// GNU General Public License for more details.
|
||||
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
// As a special exception, you may create a larger work that contains
|
||||
// part or all of the Bison parser skeleton and distribute that work
|
||||
// under terms of your choice, so long as that work isn't itself a
|
||||
// parser generator using the skeleton or a modified version thereof
|
||||
// as a parser skeleton. Alternatively, if you modify or redistribute
|
||||
// the parser skeleton itself, you may (at your option) remove this
|
||||
// special exception, which will cause the skeleton and the resulting
|
||||
// Bison output files to be licensed under the GNU General Public
|
||||
// License without this special exception.
|
||||
|
||||
// This special exception was added by the Free Software Foundation in
|
||||
// version 2.2 of Bison.
|
||||
|
||||
/**
|
||||
** \file StepFile/location.hh
|
||||
** Define the step::location class.
|
||||
*/
|
||||
|
||||
#ifndef YY_STEP_STEPFILE_LOCATION_HH_INCLUDED
|
||||
# define YY_STEP_STEPFILE_LOCATION_HH_INCLUDED
|
||||
|
||||
# include <iostream>
|
||||
# include <string>
|
||||
|
||||
# ifndef YY_NULLPTR
|
||||
# if defined __cplusplus
|
||||
# if 201103L <= __cplusplus
|
||||
# define YY_NULLPTR nullptr
|
||||
# else
|
||||
# define YY_NULLPTR 0
|
||||
# endif
|
||||
# else
|
||||
# define YY_NULLPTR ((void*)0)
|
||||
# endif
|
||||
# endif
|
||||
|
||||
namespace step {
|
||||
|
||||
/// A point in a source file.
|
||||
class position
|
||||
{
|
||||
public:
|
||||
/// Type for file name.
|
||||
typedef const std::string filename_type;
|
||||
/// Type for line and column numbers.
|
||||
typedef int counter_type;
|
||||
|
||||
/// Construct a position.
|
||||
explicit position (filename_type* f = YY_NULLPTR,
|
||||
counter_type l = 1,
|
||||
counter_type c = 1)
|
||||
: filename (f)
|
||||
, line (l)
|
||||
, column (c)
|
||||
{}
|
||||
|
||||
|
||||
/// Initialization.
|
||||
void initialize (filename_type* fn = YY_NULLPTR,
|
||||
counter_type l = 1,
|
||||
counter_type c = 1)
|
||||
{
|
||||
filename = fn;
|
||||
line = l;
|
||||
column = c;
|
||||
}
|
||||
|
||||
/** \name Line and Column related manipulators
|
||||
** \{ */
|
||||
/// (line related) Advance to the COUNT next lines.
|
||||
void lines (counter_type count = 1)
|
||||
{
|
||||
if (count)
|
||||
{
|
||||
column = 1;
|
||||
line = add_ (line, count, 1);
|
||||
}
|
||||
}
|
||||
|
||||
/// (column related) Advance to the COUNT next columns.
|
||||
void columns (counter_type count = 1)
|
||||
{
|
||||
column = add_ (column, count, 1);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
/// File name to which this position refers.
|
||||
filename_type* filename;
|
||||
/// Current line number.
|
||||
counter_type line;
|
||||
/// Current column number.
|
||||
counter_type column;
|
||||
|
||||
private:
|
||||
/// Compute max (min, lhs+rhs).
|
||||
static counter_type add_ (counter_type lhs, counter_type rhs, counter_type min)
|
||||
{
|
||||
return lhs + rhs < min ? min : lhs + rhs;
|
||||
}
|
||||
};
|
||||
|
||||
/// Add \a width columns, in place.
|
||||
inline position&
|
||||
operator+= (position& res, position::counter_type width)
|
||||
{
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add \a width columns.
|
||||
inline position
|
||||
operator+ (position res, position::counter_type width)
|
||||
{
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns, in place.
|
||||
inline position&
|
||||
operator-= (position& res, position::counter_type width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns.
|
||||
inline position
|
||||
operator- (position res, position::counter_type width)
|
||||
{
|
||||
return res -= width;
|
||||
}
|
||||
|
||||
/** \brief Intercept output stream redirection.
|
||||
** \param ostr the destination output stream
|
||||
** \param pos a reference to the position to redirect
|
||||
*/
|
||||
template <typename YYChar>
|
||||
std::basic_ostream<YYChar>&
|
||||
operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
|
||||
{
|
||||
if (pos.filename)
|
||||
ostr << *pos.filename << ':';
|
||||
return ostr << pos.line << '.' << pos.column;
|
||||
}
|
||||
|
||||
/// Two points in a source file.
|
||||
class location
|
||||
{
|
||||
public:
|
||||
/// Type for file name.
|
||||
typedef position::filename_type filename_type;
|
||||
/// Type for line and column numbers.
|
||||
typedef position::counter_type counter_type;
|
||||
|
||||
/// Construct a location from \a b to \a e.
|
||||
location (const position& b, const position& e)
|
||||
: begin (b)
|
||||
, end (e)
|
||||
{}
|
||||
|
||||
/// Construct a 0-width location in \a p.
|
||||
explicit location (const position& p = position ())
|
||||
: begin (p)
|
||||
, end (p)
|
||||
{}
|
||||
|
||||
/// Construct a 0-width location in \a f, \a l, \a c.
|
||||
explicit location (filename_type* f,
|
||||
counter_type l = 1,
|
||||
counter_type c = 1)
|
||||
: begin (f, l, c)
|
||||
, end (f, l, c)
|
||||
{}
|
||||
|
||||
|
||||
/// Initialization.
|
||||
void initialize (filename_type* f = YY_NULLPTR,
|
||||
counter_type l = 1,
|
||||
counter_type c = 1)
|
||||
{
|
||||
begin.initialize (f, l, c);
|
||||
end = begin;
|
||||
}
|
||||
|
||||
/** \name Line and Column related manipulators
|
||||
** \{ */
|
||||
public:
|
||||
/// Reset initial location to final location.
|
||||
void step ()
|
||||
{
|
||||
begin = end;
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next columns.
|
||||
void columns (counter_type count = 1)
|
||||
{
|
||||
end += count;
|
||||
}
|
||||
|
||||
/// Extend the current location to the COUNT next lines.
|
||||
void lines (counter_type count = 1)
|
||||
{
|
||||
end.lines (count);
|
||||
}
|
||||
/** \} */
|
||||
|
||||
|
||||
public:
|
||||
/// Beginning of the located region.
|
||||
position begin;
|
||||
/// End of the located region.
|
||||
position end;
|
||||
};
|
||||
|
||||
/// Join two locations, in place.
|
||||
inline location&
|
||||
operator+= (location& res, const location& end)
|
||||
{
|
||||
res.end = end.end;
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Join two locations.
|
||||
inline location
|
||||
operator+ (location res, const location& end)
|
||||
{
|
||||
return res += end;
|
||||
}
|
||||
|
||||
/// Add \a width columns to the end position, in place.
|
||||
inline location&
|
||||
operator+= (location& res, location::counter_type width)
|
||||
{
|
||||
res.columns (width);
|
||||
return res;
|
||||
}
|
||||
|
||||
/// Add \a width columns to the end position.
|
||||
inline location
|
||||
operator+ (location res, location::counter_type width)
|
||||
{
|
||||
return res += width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns to the end position, in place.
|
||||
inline location&
|
||||
operator-= (location& res, location::counter_type width)
|
||||
{
|
||||
return res += -width;
|
||||
}
|
||||
|
||||
/// Subtract \a width columns to the end position.
|
||||
inline location
|
||||
operator- (location res, location::counter_type width)
|
||||
{
|
||||
return res -= width;
|
||||
}
|
||||
|
||||
/** \brief Intercept output stream redirection.
|
||||
** \param ostr the destination output stream
|
||||
** \param loc a reference to the location to redirect
|
||||
**
|
||||
** Avoid duplicate information.
|
||||
*/
|
||||
template <typename YYChar>
|
||||
std::basic_ostream<YYChar>&
|
||||
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
||||
{
|
||||
location::counter_type end_col
|
||||
= 0 < loc.end.column ? loc.end.column - 1 : 0;
|
||||
ostr << loc.begin;
|
||||
if (loc.end.filename
|
||||
&& (!loc.begin.filename
|
||||
|| *loc.begin.filename != *loc.end.filename))
|
||||
ostr << '-' << loc.end.filename << ':' << loc.end.line << '.' << end_col;
|
||||
else if (loc.begin.line < loc.end.line)
|
||||
ostr << '-' << loc.end.line << '.' << end_col;
|
||||
else if (loc.begin.column < end_col)
|
||||
ostr << '-' << end_col;
|
||||
return ostr;
|
||||
}
|
||||
|
||||
} // step
|
||||
|
||||
#endif // !YY_STEP_STEPFILE_LOCATION_HH_INCLUDED
|
@ -44,7 +44,7 @@
|
||||
#ifdef YY_DECL
|
||||
# undef YY_DECL
|
||||
#endif
|
||||
#define YY_DECL int step::scanner::lex (step::parser::semantic_type* /*yylval*/, step::parser::location_type* /*yylloc*/)
|
||||
#define YY_DECL int step::scanner::lex (step::parser::semantic_type* /*yylval*/)
|
||||
|
||||
typedef step::parser::token token;
|
||||
|
||||
@ -97,7 +97,7 @@ long string in files Henri.stp and 401.stp*/
|
||||
<Text>[\n] { yymore(); yylineno ++; } /* newline in text string - increment line counter and keep collecting yytext */
|
||||
<Text>['] { yymore(); } /* single ' inside text string - keep collecting yytext*/
|
||||
<Text>[^\n']+ { yymore(); } /* a sequence of any characters except ' and \n - keep collecting yytext */
|
||||
<Text>[']/[" "\n\r]*[\)\,] { BEGIN(INITIAL); CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Text); return(token::QUID); } /* end of string (apostrophe followed by comma or closing parenthesis) - reset the scanner to initial state, record the value of all yytext collected */
|
||||
<Text>[']/[" "\n\r]*[\)\,] { BEGIN(INITIAL); CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamText); return(token::QUID); } /* end of string (apostrophe followed by comma or closing parenthesis) - reset the scanner to initial state, record the value of all yytext collected */
|
||||
|
||||
" " {;}
|
||||
" " {;}
|
||||
@ -108,15 +108,15 @@ long string in files Henri.stp and 401.stp*/
|
||||
#[0-9]+/= { CreateNewText(YYText(),YYLeng()); return(token::ENTITY); }
|
||||
#[0-9]+/[ ]*= { CreateNewText(YYText(),YYLeng()); return(token::ENTITY); }
|
||||
#[0-9]+ { CreateNewText(YYText(),YYLeng()); return(token::IDENT); }
|
||||
[-+0-9][0-9]* { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Integer); return(token::QUID); }
|
||||
[-+\.0-9][\.0-9]+ { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Float); return(token::QUID); }
|
||||
[-+\.0-9][\.0-9]+E[-+0-9][0-9]* { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Float); return(token::QUID); }
|
||||
["][0-9A-F]+["] { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Hexa); return(token::QUID); }
|
||||
[.]*[A-Z0-9_]+[.] { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Enum); return(token::QUID); }
|
||||
[-+0-9][0-9]* { CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamInteger); return(token::QUID); }
|
||||
[-+\.0-9][\.0-9]+ { CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamReal); return(token::QUID); }
|
||||
[-+\.0-9][\.0-9]+E[-+0-9][0-9]* { CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamReal); return(token::QUID); }
|
||||
["][0-9A-F]+["] { CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamHexa); return(token::QUID); }
|
||||
[.]*[A-Z0-9_]+[.] { CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamEnum); return(token::QUID); }
|
||||
[(] { return ('('); }
|
||||
[)] { return (')'); }
|
||||
[,] { myDataModel->PrepareNewArg(); return (','); }
|
||||
[$] { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Nondef); return(token::QUID); }
|
||||
[$] { CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamVoid); return(token::QUID); }
|
||||
[=] { return ('='); }
|
||||
[;] { return (';'); }
|
||||
|
||||
@ -134,7 +134,7 @@ long string in files Henri.stp and 401.stp*/
|
||||
(?i:ENDSCOPE) { return(token::ENDSCOPE); }
|
||||
[a-zA-Z0-9_]+ { CreateNewText(YYText(),YYLeng()); return(token::TYPE); }
|
||||
![a-zA-Z0-9_]+ { CreateNewText(YYText(),YYLeng()); return(token::TYPE); }
|
||||
[^)] { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Misc); return(token::QUID); }
|
||||
[^)] { CreateNewText(YYText(),YYLeng()); SetTypeArg(Interface_ParamMisc); return(token::QUID); }
|
||||
|
||||
<End>[^\n] {;} /* skip any characters (except newlines) */
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
// A Bison parser, made by GNU Bison 3.7.1.
|
||||
// A Bison parser, made by GNU Bison 3.7.4.
|
||||
|
||||
// Skeleton implementation for Bison LALR(1) parsers in C++
|
||||
|
||||
@ -50,21 +50,17 @@
|
||||
|
||||
// Unqualified %code blocks.
|
||||
|
||||
|
||||
#undef yylex
|
||||
#define yylex scanner->lex
|
||||
#define StepData scanner->myDataModel
|
||||
|
||||
#define stepclearin yychar = -1
|
||||
#define steperrok yyerrflag = 0
|
||||
|
||||
// disable MSVC warnings in bison code
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4065 4244 4131 4127 4702)
|
||||
#define YYMALLOC malloc
|
||||
#define YYFREE free
|
||||
#endif
|
||||
void StepFile_Interrupt (char* nomfic); /* rln 13.09.00 port on HP*/
|
||||
void StepFile_Interrupt (Standard_CString theErrorMessage, const Standard_Boolean theIsFail);
|
||||
|
||||
|
||||
|
||||
@ -90,25 +86,6 @@ void StepFile_Interrupt (char* nomfic); /* rln 13.09.00 port on HP*/
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#define YYRHSLOC(Rhs, K) ((Rhs)[K].location)
|
||||
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
|
||||
If N is 0, then set CURRENT to the empty location which ends
|
||||
the previous symbol: RHS[0] (always defined). */
|
||||
|
||||
# ifndef YYLLOC_DEFAULT
|
||||
# define YYLLOC_DEFAULT(Current, Rhs, N) \
|
||||
do \
|
||||
if (N) \
|
||||
{ \
|
||||
(Current).begin = YYRHSLOC (Rhs, 1).begin; \
|
||||
(Current).end = YYRHSLOC (Rhs, N).end; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
(Current).begin = (Current).end = YYRHSLOC (Rhs, 0).end; \
|
||||
} \
|
||||
while (false)
|
||||
# endif
|
||||
|
||||
|
||||
// Enable debugging if requested.
|
||||
@ -184,23 +161,20 @@ namespace step {
|
||||
parser::basic_symbol<Base>::basic_symbol (const basic_symbol& that)
|
||||
: Base (that)
|
||||
, value (that.value)
|
||||
, location (that.location)
|
||||
{}
|
||||
|
||||
|
||||
/// Constructor for valueless symbols.
|
||||
template <typename Base>
|
||||
parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, YY_MOVE_REF (location_type) l)
|
||||
parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t)
|
||||
: Base (t)
|
||||
, value ()
|
||||
, location (l)
|
||||
{}
|
||||
|
||||
template <typename Base>
|
||||
parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, YY_RVREF (semantic_type) v, YY_RVREF (location_type) l)
|
||||
parser::basic_symbol<Base>::basic_symbol (typename Base::kind_type t, YY_RVREF (semantic_type) v)
|
||||
: Base (t)
|
||||
, value (YY_MOVE (v))
|
||||
, location (YY_MOVE (l))
|
||||
{}
|
||||
|
||||
template <typename Base>
|
||||
@ -223,7 +197,6 @@ namespace step {
|
||||
{
|
||||
super_type::move (s);
|
||||
value = YY_MOVE (s.value);
|
||||
location = YY_MOVE (s.location);
|
||||
}
|
||||
|
||||
// by_kind.
|
||||
@ -312,7 +285,7 @@ namespace step {
|
||||
{}
|
||||
|
||||
parser::stack_symbol_type::stack_symbol_type (YY_RVREF (stack_symbol_type) that)
|
||||
: super_type (YY_MOVE (that.state), YY_MOVE (that.value), YY_MOVE (that.location))
|
||||
: super_type (YY_MOVE (that.state), YY_MOVE (that.value))
|
||||
{
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
// that is emptied.
|
||||
@ -321,7 +294,7 @@ namespace step {
|
||||
}
|
||||
|
||||
parser::stack_symbol_type::stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) that)
|
||||
: super_type (s, YY_MOVE (that.value), YY_MOVE (that.location))
|
||||
: super_type (s, YY_MOVE (that.value))
|
||||
{
|
||||
// that is emptied.
|
||||
that.kind_ = symbol_kind::S_YYEMPTY;
|
||||
@ -333,7 +306,6 @@ namespace step {
|
||||
{
|
||||
state = that.state;
|
||||
value = that.value;
|
||||
location = that.location;
|
||||
return *this;
|
||||
}
|
||||
|
||||
@ -342,7 +314,6 @@ namespace step {
|
||||
{
|
||||
state = that.state;
|
||||
value = that.value;
|
||||
location = that.location;
|
||||
// that is emptied.
|
||||
that.state = empty_state;
|
||||
return *this;
|
||||
@ -373,8 +344,7 @@ namespace step {
|
||||
{
|
||||
symbol_kind_type yykind = yysym.kind ();
|
||||
yyo << (yykind < YYNTOKENS ? "token" : "nterm")
|
||||
<< ' ' << yysym.name () << " ("
|
||||
<< yysym.location << ": ";
|
||||
<< ' ' << yysym.name () << " (";
|
||||
YYUSE (yykind);
|
||||
yyo << ')';
|
||||
}
|
||||
@ -475,9 +445,6 @@ namespace step {
|
||||
/// The lookahead symbol.
|
||||
symbol_type yyla;
|
||||
|
||||
/// The locations where the error started and ended.
|
||||
stack_symbol_type yyerror_range[3];
|
||||
|
||||
/// The return value of parse ().
|
||||
int yyresult;
|
||||
|
||||
@ -526,7 +493,7 @@ namespace step {
|
||||
try
|
||||
#endif // YY_EXCEPTIONS
|
||||
{
|
||||
yyla.kind_ = yytranslate_ (yylex (&yyla.value, &yyla.location));
|
||||
yyla.kind_ = yytranslate_ (yylex (&yyla.value));
|
||||
}
|
||||
#if YY_EXCEPTIONS
|
||||
catch (const syntax_error& yyexc)
|
||||
@ -605,12 +572,6 @@ namespace step {
|
||||
else
|
||||
yylhs.value = yystack_[0].value;
|
||||
|
||||
// Default location.
|
||||
{
|
||||
stack_type::slice range (yystack_, yylen);
|
||||
YYLLOC_DEFAULT (yylhs.location, range, yylen);
|
||||
yyerror_range[1].location = yylhs.location;
|
||||
}
|
||||
|
||||
// Perform the reduction.
|
||||
YY_REDUCE_PRINT (yyn);
|
||||
@ -629,7 +590,7 @@ namespace step {
|
||||
break;
|
||||
|
||||
case 17: // unarg: IDENT
|
||||
{ StepData->SetTypeArg(ArgumentType_Ident); StepData->CreateNewArg(); }
|
||||
{ StepData->SetTypeArg(Interface_ParamIdent); StepData->CreateNewArg(); }
|
||||
break;
|
||||
|
||||
case 18: // unarg: QUID
|
||||
@ -667,7 +628,7 @@ namespace step {
|
||||
break;
|
||||
|
||||
case 40: // unid: IDENT
|
||||
{ StepData->SetTypeArg(ArgumentType_Ident); StepData->CreateNewArg(); }
|
||||
{ StepData->SetTypeArg(Interface_ParamIdent); StepData->CreateNewArg(); }
|
||||
break;
|
||||
|
||||
case 43: // debexp: '/'
|
||||
@ -723,12 +684,12 @@ namespace step {
|
||||
if (!yyerrstatus_)
|
||||
{
|
||||
++yynerrs_;
|
||||
std::string msg = YY_("syntax error");
|
||||
error (yyla.location, YY_MOVE (msg));
|
||||
context yyctx (*this, yyla);
|
||||
std::string msg = yysyntax_error_ (yyctx);
|
||||
error (YY_MOVE (msg));
|
||||
}
|
||||
|
||||
|
||||
yyerror_range[1].location = yyla.location;
|
||||
if (yyerrstatus_ == 3)
|
||||
{
|
||||
/* If just tried and failed to reuse lookahead token after an
|
||||
@ -790,7 +751,6 @@ namespace step {
|
||||
if (yystack_.size () == 1)
|
||||
YYABORT;
|
||||
|
||||
yyerror_range[1].location = yystack_[0].location;
|
||||
yy_destroy_ ("Error: popping", yystack_[0]);
|
||||
yypop_ ();
|
||||
YY_STACK_PRINT ();
|
||||
@ -798,8 +758,6 @@ namespace step {
|
||||
{
|
||||
stack_symbol_type error_token;
|
||||
|
||||
yyerror_range[2].location = yyla.location;
|
||||
YYLLOC_DEFAULT (error_token.location, yyerror_range, 2);
|
||||
|
||||
// Shift the error token.
|
||||
error_token.state = state_type (yyn);
|
||||
@ -865,19 +823,178 @@ namespace step {
|
||||
void
|
||||
parser::error (const syntax_error& yyexc)
|
||||
{
|
||||
error (yyexc.location, yyexc.what ());
|
||||
error (yyexc.what ());
|
||||
}
|
||||
|
||||
#if YYDEBUG || 0
|
||||
const char *
|
||||
/* Return YYSTR after stripping away unnecessary quotes and
|
||||
backslashes, so that it's suitable for yyerror. The heuristic is
|
||||
that double-quoting is unnecessary unless the string contains an
|
||||
apostrophe, a comma, or backslash (other than backslash-backslash).
|
||||
YYSTR is taken from yytname. */
|
||||
std::string
|
||||
parser::yytnamerr_ (const char *yystr)
|
||||
{
|
||||
if (*yystr == '"')
|
||||
{
|
||||
std::string yyr;
|
||||
char const *yyp = yystr;
|
||||
|
||||
for (;;)
|
||||
switch (*++yyp)
|
||||
{
|
||||
case '\'':
|
||||
case ',':
|
||||
goto do_not_strip_quotes;
|
||||
|
||||
case '\\':
|
||||
if (*++yyp != '\\')
|
||||
goto do_not_strip_quotes;
|
||||
else
|
||||
goto append;
|
||||
|
||||
append:
|
||||
default:
|
||||
yyr += *yyp;
|
||||
break;
|
||||
|
||||
case '"':
|
||||
return yyr;
|
||||
}
|
||||
do_not_strip_quotes: ;
|
||||
}
|
||||
|
||||
return yystr;
|
||||
}
|
||||
|
||||
std::string
|
||||
parser::symbol_name (symbol_kind_type yysymbol)
|
||||
{
|
||||
return yytname_[yysymbol];
|
||||
return yytnamerr_ (yytname_[yysymbol]);
|
||||
}
|
||||
#endif // #if YYDEBUG || 0
|
||||
|
||||
|
||||
|
||||
// parser::context.
|
||||
parser::context::context (const parser& yyparser, const symbol_type& yyla)
|
||||
: yyparser_ (yyparser)
|
||||
, yyla_ (yyla)
|
||||
{}
|
||||
|
||||
int
|
||||
parser::context::expected_tokens (symbol_kind_type yyarg[], int yyargn) const
|
||||
{
|
||||
// Actual number of expected tokens
|
||||
int yycount = 0;
|
||||
|
||||
int yyn = yypact_[+yyparser_.yystack_[0].state];
|
||||
if (!yy_pact_value_is_default_ (yyn))
|
||||
{
|
||||
/* Start YYX at -YYN if negative to avoid negative indexes in
|
||||
YYCHECK. In other words, skip the first -YYN actions for
|
||||
this state because they are default actions. */
|
||||
int yyxbegin = yyn < 0 ? -yyn : 0;
|
||||
// Stay within bounds of both yycheck and yytname.
|
||||
int yychecklim = yylast_ - yyn + 1;
|
||||
int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS;
|
||||
for (int yyx = yyxbegin; yyx < yyxend; ++yyx)
|
||||
if (yycheck_[yyx + yyn] == yyx && yyx != symbol_kind::S_YYerror
|
||||
&& !yy_table_value_is_error_ (yytable_[yyx + yyn]))
|
||||
{
|
||||
if (!yyarg)
|
||||
++yycount;
|
||||
else if (yycount == yyargn)
|
||||
return 0;
|
||||
else
|
||||
yyarg[yycount++] = YY_CAST (symbol_kind_type, yyx);
|
||||
}
|
||||
}
|
||||
|
||||
if (yyarg && yycount == 0 && 0 < yyargn)
|
||||
yyarg[0] = symbol_kind::S_YYEMPTY;
|
||||
return yycount;
|
||||
}
|
||||
|
||||
|
||||
|
||||
int
|
||||
parser::yy_syntax_error_arguments_ (const context& yyctx,
|
||||
symbol_kind_type yyarg[], int yyargn) const
|
||||
{
|
||||
/* There are many possibilities here to consider:
|
||||
- If this state is a consistent state with a default action, then
|
||||
the only way this function was invoked is if the default action
|
||||
is an error action. In that case, don't check for expected
|
||||
tokens because there are none.
|
||||
- The only way there can be no lookahead present (in yyla) is
|
||||
if this state is a consistent state with a default action.
|
||||
Thus, detecting the absence of a lookahead is sufficient to
|
||||
determine that there is no unexpected or expected token to
|
||||
report. In that case, just report a simple "syntax error".
|
||||
- Don't assume there isn't a lookahead just because this state is
|
||||
a consistent state with a default action. There might have
|
||||
been a previous inconsistent state, consistent state with a
|
||||
non-default action, or user semantic action that manipulated
|
||||
yyla. (However, yyla is currently not documented for users.)
|
||||
- Of course, the expected token list depends on states to have
|
||||
correct lookahead information, and it depends on the parser not
|
||||
to perform extra reductions after fetching a lookahead from the
|
||||
scanner and before detecting a syntax error. Thus, state merging
|
||||
(from LALR or IELR) and default reductions corrupt the expected
|
||||
token list. However, the list is correct for canonical LR with
|
||||
one exception: it will still contain any token that will not be
|
||||
accepted due to an error action in a later state.
|
||||
*/
|
||||
|
||||
if (!yyctx.lookahead ().empty ())
|
||||
{
|
||||
if (yyarg)
|
||||
yyarg[0] = yyctx.token ();
|
||||
int yyn = yyctx.expected_tokens (yyarg ? yyarg + 1 : yyarg, yyargn - 1);
|
||||
return yyn + 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Generate an error message.
|
||||
std::string
|
||||
parser::yysyntax_error_ (const context& yyctx) const
|
||||
{
|
||||
// Its maximum.
|
||||
enum { YYARGS_MAX = 5 };
|
||||
// Arguments of yyformat.
|
||||
symbol_kind_type yyarg[YYARGS_MAX];
|
||||
int yycount = yy_syntax_error_arguments_ (yyctx, yyarg, YYARGS_MAX);
|
||||
|
||||
char const* yyformat = YY_NULLPTR;
|
||||
switch (yycount)
|
||||
{
|
||||
#define YYCASE_(N, S) \
|
||||
case N: \
|
||||
yyformat = S; \
|
||||
break
|
||||
default: // Avoid compiler warnings.
|
||||
YYCASE_ (0, YY_("syntax error"));
|
||||
YYCASE_ (1, YY_("syntax error, unexpected %s"));
|
||||
YYCASE_ (2, YY_("syntax error, unexpected %s, expecting %s"));
|
||||
YYCASE_ (3, YY_("syntax error, unexpected %s, expecting %s or %s"));
|
||||
YYCASE_ (4, YY_("syntax error, unexpected %s, expecting %s or %s or %s"));
|
||||
YYCASE_ (5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"));
|
||||
#undef YYCASE_
|
||||
}
|
||||
|
||||
std::string yyres;
|
||||
// Argument number.
|
||||
std::ptrdiff_t yyi = 0;
|
||||
for (char const* yyp = yyformat; *yyp; ++yyp)
|
||||
if (yyp[0] == '%' && yyp[1] == 's' && yyi < yycount)
|
||||
{
|
||||
yyres += symbol_name (yyarg[yyi++]);
|
||||
++yyp;
|
||||
}
|
||||
else
|
||||
yyres += *yyp;
|
||||
return yyres;
|
||||
}
|
||||
|
||||
|
||||
const signed char parser::yypact_ninf_ = -24;
|
||||
@ -991,7 +1108,7 @@ namespace step {
|
||||
};
|
||||
|
||||
|
||||
#if YYDEBUG
|
||||
#if YYDEBUG || 1
|
||||
// YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
|
||||
// First, the terminals, then, starting at \a YYNTOKENS, nonterminals.
|
||||
const char*
|
||||
@ -1013,11 +1130,11 @@ namespace step {
|
||||
const unsigned char
|
||||
parser::yyrline_[] =
|
||||
{
|
||||
0, 103, 103, 104, 105, 106, 107, 108, 109, 110,
|
||||
110, 110, 113, 114, 116, 117, 119, 122, 123, 124,
|
||||
125, 126, 129, 132, 135, 140, 141, 143, 144, 146,
|
||||
147, 149, 150, 151, 152, 154, 155, 157, 158, 160,
|
||||
163, 166, 167, 169, 172, 174, 179, 182
|
||||
0, 98, 98, 99, 100, 101, 102, 103, 104, 105,
|
||||
105, 105, 108, 109, 111, 112, 114, 117, 118, 119,
|
||||
120, 121, 124, 127, 130, 135, 136, 138, 139, 141,
|
||||
142, 144, 145, 146, 147, 149, 150, 152, 153, 155,
|
||||
158, 161, 162, 164, 167, 169, 174, 177
|
||||
};
|
||||
|
||||
void
|
||||
@ -1099,10 +1216,18 @@ namespace step {
|
||||
} // step
|
||||
|
||||
|
||||
|
||||
void step::parser::error(const location_type& /*loc*/, const std::string& m)
|
||||
void step::parser::error(const std::string& m)
|
||||
{
|
||||
char newmess[80];
|
||||
sprintf(newmess, "At line %d : %s", scanner->lineno() + 1, m.c_str());
|
||||
StepFile_Interrupt(newmess);
|
||||
char newmess[120];
|
||||
Standard_Boolean isSyntax = (Standard_Boolean)strncmp(m.c_str(), "syntax error", 13);
|
||||
if (isSyntax && strlen(m.c_str()) > 13)
|
||||
sprintf(newmess, "Undefined Parsing: Line %d: %s: %s", scanner->lineno() + 1, "Incorrect syntax", m.c_str() + 14);
|
||||
else if (isSyntax)
|
||||
sprintf(newmess, "Undefined Parsing: Line %d: Incorrect syntax", scanner->lineno() + 1);
|
||||
else
|
||||
sprintf(newmess, "Undefined Parsing: Line %d: %s", scanner->lineno() + 1, m.c_str());
|
||||
|
||||
StepFile_Interrupt(newmess, Standard_False);
|
||||
|
||||
StepData->AddError(newmess);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
// A Bison parser, made by GNU Bison 3.7.1.
|
||||
// A Bison parser, made by GNU Bison 3.7.4.
|
||||
|
||||
// Skeleton interface for Bison LALR(1) parsers in C++
|
||||
|
||||
@ -106,7 +106,7 @@ namespace step {
|
||||
#else
|
||||
# define YY_CONSTEXPR
|
||||
#endif
|
||||
# include "location.hh"
|
||||
|
||||
|
||||
|
||||
#ifndef YY_ATTRIBUTE_PURE
|
||||
@ -204,25 +204,19 @@ namespace step {
|
||||
#else
|
||||
typedef YYSTYPE semantic_type;
|
||||
#endif
|
||||
/// Symbol locations.
|
||||
typedef location location_type;
|
||||
|
||||
/// Syntax errors thrown from user actions.
|
||||
struct syntax_error : std::runtime_error
|
||||
{
|
||||
syntax_error (const location_type& l, const std::string& m)
|
||||
syntax_error (const std::string& m)
|
||||
: std::runtime_error (m)
|
||||
, location (l)
|
||||
{}
|
||||
|
||||
syntax_error (const syntax_error& s)
|
||||
: std::runtime_error (s.what ())
|
||||
, location (s.location)
|
||||
{}
|
||||
|
||||
~syntax_error () YY_NOEXCEPT YY_NOTHROW;
|
||||
|
||||
location_type location;
|
||||
};
|
||||
|
||||
/// Token kinds.
|
||||
@ -337,7 +331,7 @@ namespace step {
|
||||
/// Expects its Base type to provide access to the symbol kind
|
||||
/// via kind ().
|
||||
///
|
||||
/// Provide access to semantic value and location.
|
||||
/// Provide access to semantic value.
|
||||
template <typename Base>
|
||||
struct basic_symbol : Base
|
||||
{
|
||||
@ -347,7 +341,6 @@ namespace step {
|
||||
/// Default constructor.
|
||||
basic_symbol ()
|
||||
: value ()
|
||||
, location ()
|
||||
{}
|
||||
|
||||
#if 201103L <= YY_CPLUSPLUS
|
||||
@ -355,20 +348,17 @@ namespace step {
|
||||
basic_symbol (basic_symbol&& that)
|
||||
: Base (std::move (that))
|
||||
, value (std::move (that.value))
|
||||
, location (std::move (that.location))
|
||||
{}
|
||||
#endif
|
||||
|
||||
/// Copy constructor.
|
||||
basic_symbol (const basic_symbol& that);
|
||||
/// Constructor for valueless symbols.
|
||||
basic_symbol (typename Base::kind_type t,
|
||||
YY_MOVE_REF (location_type) l);
|
||||
basic_symbol (typename Base::kind_type t);
|
||||
|
||||
/// Constructor for symbols with semantic value.
|
||||
basic_symbol (typename Base::kind_type t,
|
||||
YY_RVREF (semantic_type) v,
|
||||
YY_RVREF (location_type) l);
|
||||
YY_RVREF (semantic_type) v);
|
||||
|
||||
/// Destroy the symbol.
|
||||
~basic_symbol ()
|
||||
@ -382,14 +372,11 @@ namespace step {
|
||||
Base::clear ();
|
||||
}
|
||||
|
||||
#if YYDEBUG || 0
|
||||
/// The user-facing name of this symbol.
|
||||
const char *name () const YY_NOEXCEPT
|
||||
std::string name () const YY_NOEXCEPT
|
||||
{
|
||||
return parser::symbol_name (this->kind ());
|
||||
}
|
||||
#endif // #if YYDEBUG || 0
|
||||
|
||||
|
||||
/// Backward compatibility (Bison 3.6).
|
||||
symbol_kind_type type_get () const YY_NOEXCEPT;
|
||||
@ -403,9 +390,6 @@ namespace step {
|
||||
/// The semantic value.
|
||||
semantic_type value;
|
||||
|
||||
/// The location.
|
||||
location_type location;
|
||||
|
||||
private:
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
/// Assignment operator.
|
||||
@ -492,21 +476,33 @@ namespace step {
|
||||
#endif
|
||||
|
||||
/// Report a syntax error.
|
||||
/// \param loc where the syntax error is found.
|
||||
/// \param msg a description of the syntax error.
|
||||
virtual void error (const location_type& loc, const std::string& msg);
|
||||
virtual void error (const std::string& msg);
|
||||
|
||||
/// Report a syntax error.
|
||||
void error (const syntax_error& err);
|
||||
|
||||
#if YYDEBUG || 0
|
||||
/// The user-facing name of the symbol whose (internal) number is
|
||||
/// YYSYMBOL. No bounds checking.
|
||||
static const char *symbol_name (symbol_kind_type yysymbol);
|
||||
#endif // #if YYDEBUG || 0
|
||||
static std::string symbol_name (symbol_kind_type yysymbol);
|
||||
|
||||
|
||||
|
||||
class context
|
||||
{
|
||||
public:
|
||||
context (const parser& yyparser, const symbol_type& yyla);
|
||||
const symbol_type& lookahead () const { return yyla_; }
|
||||
symbol_kind_type token () const { return yyla_.kind (); }
|
||||
/// Put in YYARG at most YYARGN of the expected tokens, and return the
|
||||
/// number of tokens stored in YYARG. If YYARG is null, return the
|
||||
/// number of expected tokens (guaranteed to be less than YYNTOKENS).
|
||||
int expected_tokens (symbol_kind_type yyarg[], int yyargn) const;
|
||||
|
||||
private:
|
||||
const parser& yyparser_;
|
||||
const symbol_type& yyla_;
|
||||
};
|
||||
|
||||
private:
|
||||
#if YY_CPLUSPLUS < 201103L
|
||||
@ -520,6 +516,13 @@ namespace step {
|
||||
/// Stored state numbers (used for stacks).
|
||||
typedef signed char state_type;
|
||||
|
||||
/// The arguments of the error message.
|
||||
int yy_syntax_error_arguments_ (const context& yyctx,
|
||||
symbol_kind_type yyarg[], int yyargn) const;
|
||||
|
||||
/// Generate an error message.
|
||||
/// \param yyctx the context in which the error occurred.
|
||||
virtual std::string yysyntax_error_ (const context& yyctx) const;
|
||||
/// Compute post-reduction state.
|
||||
/// \param yystate the current state
|
||||
/// \param yysym the nonterminal to push on the stack
|
||||
@ -541,10 +544,11 @@ namespace step {
|
||||
/// are valid, yet not members of the token_type enum.
|
||||
static symbol_kind_type yytranslate_ (int t);
|
||||
|
||||
#if YYDEBUG || 0
|
||||
/// Convert the symbol name \a n to a form suitable for a diagnostic.
|
||||
static std::string yytnamerr_ (const char *yystr);
|
||||
|
||||
/// For a symbol, its name in clear.
|
||||
static const char* const yytname_[];
|
||||
#endif // #if YYDEBUG || 0
|
||||
|
||||
|
||||
// Tables.
|
||||
@ -847,8 +851,7 @@ namespace step {
|
||||
public:
|
||||
explicit scanner(StepFile_ReadData* theDataModel, std::istream* in = 0, std::ostream* out = 0);
|
||||
|
||||
int lex(step::parser::semantic_type* yylval,
|
||||
step::parser::location_type* yylloc);
|
||||
int lex(step::parser::semantic_type* yylval);
|
||||
|
||||
StepFile_ReadData* myDataModel;
|
||||
};
|
||||
|
@ -26,7 +26,7 @@
|
||||
|
||||
%parse-param {step::scanner* scanner}
|
||||
|
||||
%locations
|
||||
%define parse.error verbose
|
||||
|
||||
%token STEP HEADER ENDSEC DATA ENDSTEP SCOPE ENDSCOPE ENTITY TYPE INTEGER FLOAT IDENT TEXT NONDEF ENUM HEXA QUID
|
||||
%start stepf
|
||||
@ -48,23 +48,19 @@ namespace step {
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
%code {
|
||||
|
||||
%code {
|
||||
#undef yylex
|
||||
#define yylex scanner->lex
|
||||
#define StepData scanner->myDataModel
|
||||
|
||||
#define stepclearin yychar = -1
|
||||
#define steperrok yyerrflag = 0
|
||||
|
||||
// disable MSVC warnings in bison code
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable:4065 4244 4131 4127 4702)
|
||||
#define YYMALLOC malloc
|
||||
#define YYFREE free
|
||||
#endif
|
||||
void StepFile_Interrupt (char* nomfic); /* rln 13.09.00 port on HP*/
|
||||
void StepFile_Interrupt (Standard_CString theErrorMessage, const Standard_Boolean theIsFail);
|
||||
}
|
||||
|
||||
%code provides {
|
||||
@ -88,8 +84,7 @@ namespace step {
|
||||
public:
|
||||
explicit scanner(StepFile_ReadData* theDataModel, std::istream* in = 0, std::ostream* out = 0);
|
||||
|
||||
int lex(step::parser::semantic_type* yylval,
|
||||
step::parser::location_type* yylloc);
|
||||
int lex(step::parser::semantic_type* yylval);
|
||||
|
||||
StepFile_ReadData* myDataModel;
|
||||
};
|
||||
@ -119,7 +114,7 @@ headent : enttype listarg ';'
|
||||
endhead : DATA
|
||||
{ StepData->FinalOfHead(); }
|
||||
;
|
||||
unarg : IDENT { StepData->SetTypeArg(ArgumentType_Ident); StepData->CreateNewArg(); }
|
||||
unarg : IDENT { StepData->SetTypeArg(Interface_ParamIdent); StepData->CreateNewArg(); }
|
||||
| QUID { /* deja fait par lex*/ StepData->CreateNewArg(); }
|
||||
| listarg /* rec_newent lors du ')' */ { StepData->CreateNewArg(); }
|
||||
| listype listarg /* liste typee */ { StepData->CreateNewArg(); }
|
||||
@ -161,7 +156,7 @@ debscop : SCOPE
|
||||
{ StepData->AddNewScope(); }
|
||||
;
|
||||
unid : IDENT
|
||||
{ StepData->SetTypeArg(ArgumentType_Ident); StepData->CreateNewArg(); }
|
||||
{ StepData->SetTypeArg(Interface_ParamIdent); StepData->CreateNewArg(); }
|
||||
;
|
||||
export : unid
|
||||
| export ',' unid
|
||||
@ -183,10 +178,18 @@ enttype : TYPE
|
||||
{ StepData->RecordType (); }
|
||||
;
|
||||
%%
|
||||
|
||||
void step::parser::error(const location_type& /*loc*/, const std::string& m)
|
||||
void step::parser::error(const std::string& m)
|
||||
{
|
||||
char newmess[80];
|
||||
sprintf(newmess, "At line %d : %s", scanner->lineno() + 1, m.c_str());
|
||||
StepFile_Interrupt(newmess);
|
||||
char newmess[120];
|
||||
Standard_Boolean isSyntax = (Standard_Boolean)strncmp(m.c_str(), "syntax error", 13);
|
||||
if (isSyntax && strlen(m.c_str()) > 13)
|
||||
sprintf(newmess, "Undefined Parsing: Line %d: %s: %s", scanner->lineno() + 1, "Incorrect syntax", m.c_str() + 14);
|
||||
else if (isSyntax)
|
||||
sprintf(newmess, "Undefined Parsing: Line %d: Incorrect syntax", scanner->lineno() + 1);
|
||||
else
|
||||
sprintf(newmess, "Undefined Parsing: Line %d: %s", scanner->lineno() + 1, m.c_str());
|
||||
|
||||
StepFile_Interrupt(newmess, Standard_False);
|
||||
|
||||
StepData->AddError(newmess);
|
||||
}
|
||||
|
@ -72,7 +72,6 @@ Standard_Integer StepSelect_WorkLibrary::ReadFile
|
||||
if (stepro.IsNull()) return 1;
|
||||
Handle(StepData_StepModel) stepmodel = new StepData_StepModel;
|
||||
model = stepmodel;
|
||||
StepFile_ReadTrace (0);
|
||||
status = StepFile_Read(name, 0, stepmodel, stepro);
|
||||
return status;
|
||||
}
|
||||
@ -87,7 +86,6 @@ Standard_Integer StepSelect_WorkLibrary::ReadStream (const Standard_CString the
|
||||
if (stepro.IsNull()) return 1;
|
||||
Handle(StepData_StepModel) stepmodel = new StepData_StepModel;
|
||||
model = stepmodel;
|
||||
StepFile_ReadTrace(0);
|
||||
status = StepFile_Read(theName, &theIStream, stepmodel, stepro);
|
||||
return status;
|
||||
}
|
||||
|
@ -4,7 +4,7 @@ set filename stepBF3.stp
|
||||
puts "TODO 29269 ALL: B_SPLINE_CURVE_WITH_KNOTS: Update of 3D-Parameters has failed"
|
||||
|
||||
set ref_data {
|
||||
DATA : Faulties = 0 ( 22 ) Warnings = 0 ( 0 ) Summary = 0 ( 22 )
|
||||
DATA : Faulties = 0 ( 23 ) Warnings = 0 ( 0 ) Summary = 0 ( 23 )
|
||||
TPSTAT : Faulties = 0 ( 0 ) Warnings = 4 ( 88 ) Summary = 4 ( 88 )
|
||||
CHECKSHAPE : Wires = 1 ( 1 ) Faces = 1 ( 1 ) Shells = 0 ( 0 ) Solids = 0 ( 0 )
|
||||
NBSHAPES : Solid = 1 ( 1 ) Shell = 1 ( 1 ) Face = 153 ( 153 )
|
||||
|
Loading…
x
Reference in New Issue
Block a user