1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-06 18:26:22 +03:00

0031756: Data Exchange - broken parsing of STEP entity in case of missing last parameter

- Parser is corrected to handle case of missing arguments properly (report error without corruption of the next entity)
- Added counter of entity arguments for appropriate error messages
- Plain C tools and data structures (recfile.*, stepfile.*) are converted to C++ class (StepFile_ReadData) to avoid use of static variables, so that reader can be safely used in a multi-threaded environment
This commit is contained in:
dpasukhi 2020-11-27 22:32:18 +03:00 committed by bugmaster
parent 3273937d01
commit 2057c37b67
14 changed files with 1396 additions and 1063 deletions

View File

@ -1,12 +1,10 @@
lex.step.cxx
recfile.pc
recfile.ph
step.tab.cxx
step.tab.hxx
StepFile_ReadData.cxx
StepFile_ReadData.hxx
StepFile_Read.cxx
StepFile_Read.hxx
stepread.cxx
stepread.ph
step.lex
step.yacc
FlexLexer.h

View File

@ -27,8 +27,8 @@
#include <stdio.h>
#include <iostream>
#include "recfile.ph"
#include "stepread.ph"
#include <StepFile_ReadData.hxx>
#include <step.tab.hxx>
#include <Interface_ParamType.hxx>
#include <Interface_Protocol.hxx>
@ -76,9 +76,8 @@ static Standard_Integer StepFile_Read (const char* theName,
const Handle(StepData_FileRecognizer)& recoheader,
const Handle(StepData_FileRecognizer)& recodata)
{
checkread->Clear();
recfile_modeprint ( (modepr > 0 ? modepr-1 : 0) );
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;
@ -98,11 +97,14 @@ static Standard_Integer StepFile_Read (const char* theName,
c.Start();
Message::SendInfo() << " ... Step File Reading : '" << theName << "'";
#endif
try {
OCC_CATCH_SIGNALS
if (stepread(*aStreamPtr) != 0) {
lir_file_fin(3);
int aLetat = 0;
step::scanner aScanner(&aFileDataModel, aStreamPtr);
aScanner.yyrestart(aStreamPtr);
step::parser aParser(&aScanner);
aLetat = aParser.parse();
if (aLetat != 0) {
return 1;
}
}
@ -113,7 +115,6 @@ static Standard_Integer StepFile_Read (const char* theName,
<< " ...";
#endif
(void)anException;
lir_file_fin(3);
return 1;
}
@ -129,39 +130,39 @@ static Standard_Integer StepFile_Read (const char* theName,
// Creation du StepReaderData
LesTypes[rec_argNondef] = Interface_ParamVoid ;
LesTypes[rec_argSub] = Interface_ParamSub ;
LesTypes[rec_argIdent] = Interface_ParamIdent ;
LesTypes[rec_argInteger] = Interface_ParamInteger ;
LesTypes[rec_argFloat] = Interface_ParamReal ;
LesTypes[rec_argEnum] = Interface_ParamEnum ;
LesTypes[rec_argBinary] = Interface_ParamBinary ;
LesTypes[rec_argText] = Interface_ParamText ;
LesTypes[rec_argHexa] = Interface_ParamHexa ;
LesTypes[rec_argMisc] = Interface_ParamMisc ;
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 ;
Standard_Integer nbhead, nbrec, nbpar;
lir_file_nbr (&nbhead,&nbrec,&nbpar); // renvoi par lex/yacc
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
for ( Standard_Integer nr = 1; nr <= nbrec; nr ++) {
int nbarg; char* ident; char* typrec = 0;
lir_file_rec (&ident, &typrec, &nbarg);
aFileDataModel.GetRecordDescription(&ident, &typrec, &nbarg);
undirec->SetRecord (nr, ident, typrec, nbarg);
if (nbarg>0) {
int typa; char* val;
ArgumentType typa; char* val;
Interface_ParamType newtype;
while(lir_file_arg (&typa, &val) == 1) {
while(aFileDataModel.GetArgDescription (&typa, &val) == 1) {
newtype = LesTypes[typa] ;
undirec->AddStepParam (nr, val, newtype);
}
}
undirec->InitParams(nr);
lir_file_finrec();
aFileDataModel.NextRecord();
}
lir_file_fin(1);
aFileDataModel.ClearRecorder(1);
// on a undirec pret pour la suite
#ifdef CHRONOMESURE
@ -191,7 +192,7 @@ static Standard_Integer StepFile_Read (const char* theName,
readtool.LoadModel(stepmodel);
if (stepmodel->Protocol().IsNull()) stepmodel->SetProtocol (protocol);
lir_file_fin(2);
aFileDataModel.ClearRecorder(2);
readtool.Clear();
undirec.Nullify();

View File

@ -0,0 +1,699 @@
/*
Copyright (c) 1999-2020 OPEN CASCADE SAS
This file is part of Open CASCADE Technology software library.
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 2.1 as published
by the Free Software Foundation, with special exception defined in the file
OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
distribution for complete text of the license and disclaimer of any warranty.
Alternatively, this file may be used under the terms of Open CASCADE
commercial license or contractual agreement.
*/
#include <StepFile_ReadData.hxx>
// Constant litterales
namespace TextValue
{
static char SubList[] = "/* (SUB) */";
static char Scope[] = "SCOPE";
static char Nil[] = " ";
static char Sub1[] = "$1"; /* optimisation ... */
static char Sub2[] = "$2";
static char ArgType1[] = "(IF#TnEHBx"; /* types arguments (2 1es lettres) */
static char ArgType2[] = ")nlIxdnxix";
static char IdZero[] = "#0";
}
class StepFile_ReadData::CharactersPage {
public:
CharactersPage(const Standard_Integer theMaxCar) :myNext(NULL), myUsed(0)
{
myCharacters = new char[theMaxCar];
}
~CharactersPage()
{
if (myCharacters != NULL)
{
delete[] myCharacters;
myCharacters = NULL;
}
}
public:
CharactersPage* myNext; //!< Chaining of character pages
char* myCharacters; //!< Own characters page
int myUsed; //!< Counter employed characters
};
class StepFile_ReadData::Argument {
public:
// Standard OCCT memory allocation stuff
DEFINE_STANDARD_ALLOC
public:
Argument() :myNext(NULL), myValue(NULL), myType(ArgumentType_Sub) {}
~Argument() {}
public:
Argument* myNext; //!< Next argument in the list for this record
char* myValue; //!< Character value of the argument
ArgumentType myType; //!< Type of the argument
};
class StepFile_ReadData::ArgumentsPage {
public:
// Standard OCCT memory allocation stuff
DEFINE_STANDARD_ALLOC
public:
ArgumentsPage(Standard_Integer theMaxArg) :myNext(NULL), myUsed(0)
{
myArgs = new Argument[theMaxArg];
}
~ArgumentsPage()
{
delete[] myArgs;
myArgs = NULL;
}
public:
ArgumentsPage* myNext; //!< Chaining of arguments pages
Argument* myArgs; //!< Own arguments page
int myUsed; //!< Counter employed arguments
};
class StepFile_ReadData::Record {
public:
// Standard OCCT memory allocation stuff
DEFINE_STANDARD_ALLOC
public:
Record() :myNext(NULL), myFirst(NULL), myIdent(NULL), myType(NULL) {}
~Record() {}
public:
Record* myNext; //!< Next record in the list
Argument* myFirst; //!< First argument in the record
char* myIdent; //!< Record identifier (Example: "#12345") or scope-end
char* myType; //!< Type of the record
};
class StepFile_ReadData::Scope {
public:
// Standard OCCT memory allocation stuff
DEFINE_STANDARD_ALLOC
public:
Scope() :myPrevious(NULL), myRecord(NULL) {}
~Scope()
{
if (myRecord != NULL)
{
delete[] myRecord;
myRecord = NULL;
}
}
public:
Scope* myPrevious; //!< Previous scope, to which it will be necessary to return
Record* myRecord; //!< Record interrupted by the scope (to resume)
};
class StepFile_ReadData::RecordsPage
{
public:
RecordsPage(const Standard_Integer theMaxRec) :myNext(NULL), myUsed(0)
{
myRecords = new Record[theMaxRec];
}
~RecordsPage()
{
if (myRecords != NULL)
{
delete[] myRecords;
myRecords = NULL;
}
}
public:
RecordsPage* myNext; //!< Chaining of records pages
Record* myRecords; //!< Own records page
int myUsed; //!< Counter employed records
};
//=======================================================================
//function : StepFile_ReadData
//purpose :
//=======================================================================
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)
{
myOneCharPage = new CharactersPage(myMaxChar);
myOneArgPage = new ArgumentsPage(myMaxArg);
myOneRecPage = new RecordsPage(myMaxRec);
};
//=======================================================================
//function : CreateNewText
//purpose :
//=======================================================================
void StepFile_ReadData::CreateNewText(const char* theNewText, int theLenText)
{
// Optimization for most frequent entity, CARTESIAN_POINT
static char aTextOfCarPnt[] = "CARTESIAN_POINT";
if (strcmp(theNewText, aTextOfCarPnt) == 0) {
myResText = aTextOfCarPnt;
return;
}
// If error argument exists - prepare size to new text value and old result text
int aLenght = (myErrorArg) ? theLenText + (int)strlen(myResText) : theLenText;
if (myOneCharPage->myUsed > myMaxChar - aLenght - 1)
{
int aSizeOfPage = myMaxChar + 1;
if (aLenght >= myMaxChar) aSizeOfPage += (aLenght + 1 - myMaxChar);
CharactersPage* aNewPage = new CharactersPage(aSizeOfPage);
aNewPage->myNext = myOneCharPage;
myOneCharPage = aNewPage;
myOneCharPage->myUsed = 0;
}
char* anOldResText = myResText;
myResText = myOneCharPage->myCharacters + myOneCharPage->myUsed;
myOneCharPage->myUsed += (aLenght + 1);
// If error argument exists - append new text to old result text
// Else create new result text
if (myErrorArg)
{
strcpy(myResText, anOldResText);
strcpy(myResText + (int)strlen(anOldResText), theNewText);
return;
}
strcpy(myResText, theNewText);
}
//=======================================================================
//function : RecordNewEntity
//purpose :
//=======================================================================
void StepFile_ReadData::RecordNewEntity()
{
myErrorArg = Standard_False; // Reset error argument mod
AddNewRecord(myCurRec);
SetTypeArg(ArgumentType_Sub);
mySubArg = myCurRec->myIdent;
myCurRec = myCurRec->myNext;
myLastRec->myNext = NULL;
}
//=======================================================================
//function : RecordIdent
//purpose :
//=======================================================================
void StepFile_ReadData::RecordIdent()
{
myCurRec = CreateNewRecord();
GetResultText(&myCurRec->myIdent);
myCurRec->myNext = NULL;
myCurRec->myFirst = NULL;
myYaRec = 1;
}
//=======================================================================
//function : RecordType
//purpose :
//=======================================================================
void StepFile_ReadData::RecordType()
{
if (!myYaRec)
{
myCurRec = CreateNewRecord();
myCurRec->myIdent = TextValue::IdZero;
myCurRec->myNext = NULL;
myCurRec->myFirst = NULL;
}
GetResultText(&myCurRec->myType);
myYaRec = myNumSub = 0;
}
//=======================================================================
//function : RecordListStart
//purpose :
//=======================================================================
void StepFile_ReadData::RecordListStart()
{
if (myNumSub > 0)
{
Record* aSubRec;
aSubRec = CreateNewRecord();
switch (myNumSub)
{
case 1:
aSubRec->myIdent = TextValue::Sub1; break;
case 2:
aSubRec->myIdent = TextValue::Sub2; break;
default:
{
char aBufSub[10];
if (myNumSub > 9) Sprintf(aBufSub, "$%d", myNumSub);
else { aBufSub[0] = '$'; aBufSub[1] = (char)(myNumSub + 48); aBufSub[2] = '\0'; }
aSubRec->myIdent = RecordNewText(aBufSub);
}
}
aSubRec->myType = myCurrType;
myCurrType = TextValue::SubList;
aSubRec->myNext = myCurRec;
aSubRec->myFirst = NULL;
myCurRec = aSubRec;
}
myErrorArg = Standard_False; // Reset error arguments mode
myNumSub++;
}
//=======================================================================
//function : CreateNewArg
//purpose :
//=======================================================================
void StepFile_ReadData::CreateNewArg()
{
Argument* aNewArg;
myNbPar++;
if (myOneArgPage->myUsed >= myMaxArg)
{
ArgumentsPage* aNewArgPage;
aNewArgPage = new ArgumentsPage(myMaxArg);
aNewArgPage->myNext = myOneArgPage;
myOneArgPage = aNewArgPage;
}
aNewArg = &myOneArgPage->myArgs[myOneArgPage->myUsed];
myOneArgPage->myUsed++;
aNewArg->myType = myTypeArg;
if (myTypeArg == ArgumentType_Sub)
aNewArg->myValue = mySubArg;
else
GetResultText(&aNewArg->myValue);
if (myTypeArg == ArgumentType_Misc)
myErrorArg = Standard_True;
if (myCurRec->myFirst == NULL)
{
myCurRec->myFirst = aNewArg;
}
else
{
Argument* aNextArg = myCurRec->myFirst;
while (aNextArg->myNext != NULL)
aNextArg = aNextArg->myNext;
aNextArg->myNext = aNewArg;
}
aNewArg->myNext = NULL;
}
//=======================================================================
//function : CreateErrorArg
//purpose :
//=======================================================================
void StepFile_ReadData::CreateErrorArg()
{
// If already exists - update text value
if (!myErrorArg)
{
SetTypeArg(ArgumentType_Misc);
CreateNewArg();
myErrorArg = Standard_True;
return;
}
Argument* aCurrArg = myCurRec->myFirst;
while (aCurrArg->myNext != NULL)
aCurrArg = aCurrArg->myNext;
GetResultText(&aCurrArg->myValue);
}
//=======================================================================
//function : AddNewScope
//purpose :
//=======================================================================
void StepFile_ReadData::AddNewScope()
{
Scope* aNewScope;
Record* aRecord;
aNewScope = new Scope;
aNewScope->myRecord = myCurRec;
aNewScope->myPrevious = myCurScope;
myCurScope = aNewScope;
aRecord = CreateNewRecord();
aRecord->myIdent = TextValue::Scope;
aRecord->myType = TextValue::Nil;
aRecord->myFirst = NULL;
AddNewRecord(aRecord);
}
//=======================================================================
//function : FinalOfScope
//purpose :
//=======================================================================
void StepFile_ReadData::FinalOfScope()
{
Scope* anOldScope;
Record* aRecord;
if (myCurScope == NULL) return;
aRecord = CreateNewRecord();
aRecord->myIdent = TextValue::Scope;
aRecord->myType = TextValue::Nil;
aRecord->myFirst = NULL;
if (mySubArg[0] == '$')
{
if (myModePrint > 0)
{
Printf("Export List : (List in Record n0 %d) -- ", myNbRec);
PrintRecord(myLastRec);
}
myCurRec = aRecord;
myTypeArg = ArgumentType_Sub;
CreateNewArg();
}
AddNewRecord(aRecord);
myCurRec = myCurScope->myRecord;
myYaRec = 1;
anOldScope = myCurScope;
myCurScope = anOldScope->myPrevious;
delete anOldScope;
}
//=======================================================================
//function : ClearRecorder
//purpose :
//=======================================================================
void StepFile_ReadData::ClearRecorder(const Standard_Integer theMode)
{
if (theMode & 1)
{
while (myOneRecPage != NULL)
{
RecordsPage* aNewPage;
aNewPage = myOneRecPage->myNext;
delete myOneRecPage;
myOneRecPage = NULL;
myOneRecPage = aNewPage;
}
while (myOneArgPage != NULL) {
ArgumentsPage* aNewPage; aNewPage = myOneArgPage->myNext;
delete myOneArgPage;
myOneArgPage = NULL;
myOneArgPage = aNewPage;
}
}
if (theMode & 2)
{
while (myOneCharPage != NULL)
{
CharactersPage* aNewPage; aNewPage = myOneCharPage->myNext;
delete myOneCharPage;
myOneCharPage = NULL;
myOneCharPage = aNewPage;
}
}
}
//=======================================================================
//function : GetArgDescription
//purpose :
//=======================================================================
Standard_Boolean StepFile_ReadData::GetArgDescription(ArgumentType* theType, char** theValue)
{
if (myCurrArg == NULL)
return Standard_False;
*theType = myCurrArg->myType;
*theValue = myCurrArg->myValue;
myCurrArg = myCurrArg->myNext;
return Standard_True;
}
//=======================================================================
//function : GetFileNbR
//purpose :
//=======================================================================
void StepFile_ReadData::GetFileNbR(Standard_Integer* theNbHead,
Standard_Integer* theNbRec,
Standard_Integer* theNbPage)
{
myCurRec = myFirstRec;
*theNbHead = myNbHead;
*theNbRec = myNbRec;
*theNbPage = myNbPar;
}
//=======================================================================
//function : GetRecordDescription
//purpose :
//=======================================================================
Standard_Boolean StepFile_ReadData::GetRecordDescription(char** theIdent,
char** theType,
int* theNbArg)
{
if (myCurRec == NULL)
return Standard_False;
*theIdent = myCurRec->myIdent;
*theType = myCurRec->myType;
*theNbArg = (myCurRec->myFirst != NULL);
myCurrArg = myCurRec->myFirst;
return Standard_True;
}
//=======================================================================
//function : RecordTypeText
//purpose :
//=======================================================================
void StepFile_ReadData::RecordTypeText()
{
GetResultText(&myCurrType);
}
//=======================================================================
//function : NextRecord
//purpose :
//=======================================================================
void StepFile_ReadData::NextRecord()
{
myCurRec = myCurRec->myNext;
}
//=======================================================================
//function : PrintRecord
//purpose :
//=======================================================================
void StepFile_ReadData::PrintCurrentRecord()
{
PrintRecord(myCurRec);
}
//=======================================================================
//function : PrepareNewArg
//purpose :
//=======================================================================
void StepFile_ReadData::PrepareNewArg()
{
myErrorArg = Standard_False;
}
//=======================================================================
//function : FinalOfHead
//purpose :
//=======================================================================
void StepFile_ReadData::FinalOfHead()
{
myNbHead = myNbRec;
}
//=======================================================================
//function : SetTypeArg
//purpose :
//=======================================================================
void StepFile_ReadData::SetTypeArg(const ArgumentType theArgType)
{
myTypeArg = theArgType;
}
//=======================================================================
//function : SetModePrint
//purpose :
//=======================================================================
void StepFile_ReadData::SetModePrint(const Standard_Integer theMode)
{
myModePrint = theMode;
}
//=======================================================================
//function : GetModePrint
//purpose :
//=======================================================================
Standard_Integer StepFile_ReadData::GetModePrint() const
{
return myModePrint;
}
//=======================================================================
//function : GetNbRecord
//purpose :
//=======================================================================
Standard_Integer StepFile_ReadData::GetNbRecord() const
{
return myNbRec;
}
//=======================================================================
//function : RecordNewText
//purpose :
//=======================================================================
char* StepFile_ReadData::RecordNewText(char* theText)
{
char* aSavResText;
char* aNewText;
aSavResText = myResText;
CreateNewText(theText, (int)strlen(theText));
aNewText = myResText;
myResText = aSavResText;
return aNewText;
}
//=======================================================================
//function : GetResultText
//purpose :
//=======================================================================
void StepFile_ReadData::GetResultText(char** theText)
{
*theText = myResText;
}
//=======================================================================
//function : AddNewRecord
//purpose :
//=======================================================================
void StepFile_ReadData::AddNewRecord(Record* theNewRecord)
{
myNbRec++;
if (myFirstRec == NULL) myFirstRec = theNewRecord;
if (myLastRec != NULL) myLastRec->myNext = theNewRecord;
myLastRec = theNewRecord;
}
//=======================================================================
//function : CreateNewRecord
//purpose :
//=======================================================================
StepFile_ReadData::Record* StepFile_ReadData::CreateNewRecord()
{
Record* aNewRecord;
if (myOneRecPage->myUsed >= myMaxRec)
{
RecordsPage* aNewRecPage;
aNewRecPage = new RecordsPage(myMaxRec);
aNewRecPage->myNext = myOneRecPage;
myOneRecPage = aNewRecPage;
}
aNewRecord = &myOneRecPage->myRecords[myOneRecPage->myUsed];
myOneRecPage->myUsed++;
return aNewRecord;
}
//=======================================================================
//function : PrintRecord
//purpose :
//=======================================================================
void StepFile_ReadData::PrintRecord(Record* theRecord)
{
int aNumArg = 0;
int aNumLen = 0;
int anArgLen = 0;
if (theRecord == NULL) { Printf("Non defini\n"); return; }
Printf("Ident : %s Type : %s Nb.Arg.s : %s\n",
theRecord->myIdent, theRecord->myType,
(theRecord->myFirst ? theRecord->myFirst->myValue : ""));
if (myModePrint < 2) return;
myCurrArg = theRecord->myFirst;
while (myCurrArg != NULL)
{
aNumArg++;
anArgLen = (int)strlen(myCurrArg->myValue) + 18;
aNumLen += anArgLen;
if (aNumLen > 132) { Printf("\n"); aNumLen = anArgLen; }
Printf(" - Arg.%d[%c%c] : %s",
aNumArg, TextValue::ArgType1[myCurrArg->myType],
TextValue::ArgType2[myCurrArg->myType], myCurrArg->myValue);
myCurrArg = myCurrArg->myNext;
}
if (anArgLen > 0) Printf("\n");
}

View File

@ -0,0 +1,264 @@
/*
Copyright (c) 1999-2020 OPEN CASCADE SAS
This file is part of Open CASCADE Technology software library.
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 2.1 as published
by the Free Software Foundation, with special exception defined in the file
OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
distribution for complete text of the license and disclaimer of any warranty.
Alternatively, this file may be used under the terms of Open CASCADE
commercial license or contractual agreement.
*/
#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_DefineAlloc.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
//! built using flex and bison (receives the data generated by the parser).
//!
//! All text (sequence of characters) received in the parsing process
//! is stored in the CharacterPage, but the last received text value is
//! stored in a pointer to an own page position.
//!
//! This value is used to initialize a new record (representation of the
//! STEP entity) and its arguments (parameters of the STEP entity).
//! All created arguments are stored in the ArgumentsPage, records in the RecordsPage.
//!
//! NOTE:
//! - Arguments used in the record are pointers to the element of the page,
//! - All records are pointers to the element of the record page.
//!
//! EXAMPLE of parsing STEP file (flex & bison):
//!
//! 1. Initial state:
//! - Input stream to the Flex is "#123=ADVANCED_FACE('',(#124),#125,.F.)"
//! - State of Flex is "INITIAL"
//! - Stack of Bison states : STEP HEADER ENDSEC endhead model block
//! 2. Flex rule detected "#123" - call CreateNewText("#123", 4)
//! and sends a token "ENTITY".
//! Now class contains "#123", as current text value.
//! 3. Bison receive a token and call RecordIdent (), it
//! creates a new record in the records page with "#123" identifier.
//! Now current record has ident, but args and types are empty.
//! 4. Flex rule detected "ADVANCED_FACE" call CreateNewText and send a token "TYPE".
//! Now class contains "ADVANCED_FACE", as current text value.
//! 5. Bison receive a token and call RecordType (), it
//! set "ADVANCED_FACE" to the current record as a type.
//! Now current record has ident and type, but args are empty.
//! 6. Flex rule detected "(" send token "(".
//! Now class continues to contain "ADVANCED_FACE", as current text value.
//! 7. Bison receive a token and call RecordListStart (),
//! it does nothing via the current state.
//! Now current record is not update.
//! 8. Flex rule detected ('') call CreateNewText and SetTypeArg and
//! send token TEXT.
//! Now class contains empty current text value.
//! 9. Bison receive a token and call CreateNewArg (), it
//! creates a new argument with empty text value and 'Text' type.
//! Now current record has ident, type and one argument.
//! 10. Flex rule detected "," call PrepareNewArg(",",1), it
//! controls arguments count to protect from a skip or double creating a new argument.
//! Bison does nothing and the current text value and record are not updated.
//! 11. Flex rule detected "(" send token "(".
//! Now class continues to contain empty current text value.
//! 12. Bison receive a token and call RecordListStart (), it
//! creates a new record with "$1" ident and "ADVANCED_FACE" type
//! old record is the next of the new record.
//! Now current record has ident, type, but args are empty.
//! 13. Flex rule detected "#124" call CreateNewText("#124",4) and send token "IDENT",
//! Now class contains "#124", as current text value.
//! 14. Bison receive a token and call CreateNewArg (), it
//! creates a new argument with "#124" text value and 'Ident' type.
//! Now current record has ident, type and one argument.
//! 15. Flex rule detected ")" send token ")".
//! Now class continues to contain "#124", as a current text value.
//! 16. Bison receive a token and call RecordNewEntity (), it
//! contain record to the records page, prepare to the new record
//! and get next record as a current record and set a new arg as a sub_record.
//! Now current record is a old record, it has ident, type and two args.
//! 17. Flex rule detected "#125" call CreateNewText, SetTypeArg and send token IDEND.
//! Now class contains "#125", as a current text value.
//! 18. Bison receive a token and call CreateNewArg (), it
//! creates a new argument with "#125" text value and 'Ident' type.
//! Now current record has ident, type and three argument.
//! 19. Flex rule detected "#125" call CreateNewText, SetTypeArg and send token IDEND.
//! Now class contains "#125", as a current text value.
//! 20. Bison receive a token and call CreateNewArg (), it
//! creates a new argument with "#125" text value and 'Ident' type.
//! Now current record has ident, type and three argument.
//! ...
//!
//! Reading of several STEP files simultaneously is possible (e.g. in multiple
//! threads) provided that each file is read using its own instances of Flex, Bison
//! and StepFile_ReadData tools.
class StepFile_ReadData
{
public:
// Standard OCCT memory allocation stuff
DEFINE_STANDARD_ALLOC
private:
class CharactersPage; //!< List of characters pages, contains all text derived from Flex
class Record; //!< List of records, contains all text processed by Bison
class Argument; //!< List of arguments, contains all argument descriptions
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
public:
//! Constructs an uninitialized tool
StepFile_ReadData();
//! Destructor cleans allocated memory of all fields
~StepFile_ReadData() { ClearRecorder(3); }
//! Preperes the text value for analysis.
//! It is the main tool for transferring data from flex to bison
//! If characters page is full, allocates a new page.
void CreateNewText(const char* theNewText, int theLenText);
//! Adds the current record to the list
void RecordNewEntity();
//! Creates a new record and sets Ident from myResText
void RecordIdent();
//! Starts reading of the type (entity)
void RecordType();
//! Prepares and saves a record or sub-record
void RecordListStart();
//! Prepares new arguments.
//! Type and value already known.
//! If arguments page is full, allocates a new page
void CreateNewArg();
//! Prepares error arguments, controls count of error arguments.
//! If bison handles a sequence of error types,
//! creates only one argument and updates text value
void CreateErrorArg();
//! Creates a new scope, containing the current record
void AddNewScope();
//! Ends the scope
void FinalOfScope();
//! Releases memory.
//! @param theMode
//! * 1 - clear pages of records and arguments
//! * 2 - clear pages of characters
//! * 3 - clear all data
void ClearRecorder(const Standard_Integer theMode);
//! Returns a value of fields of current argument
Standard_Boolean GetArgDescription(ArgumentType* theType, char** theValue);
//! Returns a value of all file counters
void GetFileNbR(Standard_Integer* theNbHead, Standard_Integer* theNbRec, Standard_Integer* theNbPage);
//! Returns a value of fields of current record
Standard_Boolean GetRecordDescription(char** theIdent, char** theType, int* theNbArg);
//! Initializes the record type with myResText
void RecordTypeText();
//! Skips to next record
void NextRecord();
//! Prints data of current record according to the modeprint
void PrintCurrentRecord();
//! Controls the correct argument count for the record.
//! Resets error argyment mode
void PrepareNewArg();
//! Prepares the end of the head section
void FinalOfHead();
//! Sets type of the current argument
void SetTypeArg(const ArgumentType theArgType);
//! Initializes the print mode
//! 0 - don't print descriptions
//! 1 - print only descriptions of record
//! 2 - print descriptions of records and its arguments
void SetModePrint(const Standard_Integer theMode);
//! Returns mode print
Standard_Integer GetModePrint() const;
//! Returns number of records
Standard_Integer GetNbRecord() const;
private:
//! Prepare text to analyze
char* RecordNewText(char* theText);
//! Get current text value
void GetResultText(char** theText);
//! Add a record to the current records page
void AddNewRecord(Record* theNewRecord);
//! Create new empty record
//! If records page is fill, add a new page
Record* CreateNewRecord();
//! Print data of the record according to the modeprint
void PrintRecord(Record* theRecord);
private:
Standard_Integer myMaxChar; //!< Maximum number of characters in a characters page
Standard_Integer myMaxRec; //!< Maximum number of records in a records page
Standard_Integer myMaxArg; //!< Maximum number of arguments in a arguments page
Standard_Integer myModePrint; //!< Control print output (for call from yacc)
Standard_Integer myNbRec; //!< Total number of data records read
Standard_Integer myNbHead; //!< Number of records taken by the Header
Standard_Integer myNbPar; //!< Total number of parameters read
Standard_Integer myYaRec; //!< Presence record already created (after 1 Ident)
Standard_Integer myNumSub; //!< Number of current sublist
Standard_Boolean myErrorArg; //!< Control of error argument (true - error argument was created)
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
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
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
};
#endif // _StepFile_ReadData_HeaderFile

View File

@ -444,7 +444,7 @@ struct yy_trans_info
flex_int32_t yy_verify;
flex_int32_t yy_nxt;
};
static const flex_int16_t yy_acclist[166] =
static const flex_int16_t yy_acclist[213] =
{ 0,
2, 2, 45, 42, 44, 10, 42, 44, 12, 42,
44, 13, 42, 44, 11, 42, 44, 42, 44, 42,
@ -453,35 +453,44 @@ static const flex_int16_t yy_acclist[166] =
42, 44, 42, 44, 37, 42, 44, 18, 40, 42,
44, 28, 42, 44, 27, 42, 44, 40, 42, 44,
40, 42, 44, 40, 42, 44, 40, 42, 44, 40,
42, 44, 40, 42, 44, 14, 42, 44, 2, 44,
12, 44, 3, 44, 43, 44, 8, 44, 6, 12,
44, 7, 44, 41, 17,16400, 19, 18, 19, 19,
42, 44, 40, 42, 44, 40, 42, 44, 40, 42,
44, 40, 42, 44, 40, 42, 44, 40, 42, 44,
40, 42, 44, 14, 42, 44, 2, 44, 12, 44,
1, 18, 19, 40, 40, 40, 40, 40, 40, 40,
14, 2, 3, 3, 4, 8, 9, 21, 15, 8208,
19, 22, 22, 40, 40, 40, 40, 40, 40, 8208,
20, 20, 20, 40, 40, 40, 40, 40, 36, 40,
20, 20, 20, 40, 32, 40, 40, 40, 40, 29,
38, 40, 40, 40, 40, 40, 31, 40, 30, 35,
39, 40, 33, 34, 34
3, 44, 43, 44, 8, 44, 6, 12, 44, 7,
44, 41, 17,16400, 19, 18, 19, 19, 19, 1,
19, 22, 18, 19, 40, 40, 40, 22, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 14, 2,
3, 3, 4, 8, 9, 21, 15, 8208, 40, 40,
40, 40, 40, 40, 40, 40, 40, 40, 40, 8208,
20, 20, 20, 40, 40, 40, 40, 40, 40, 40,
40, 36, 40, 40, 40, 20, 20, 20, 40, 32,
40, 40, 40, 40, 40, 40, 40, 40, 29, 38,
40, 40, 40, 40, 40, 40, 40, 40, 40, 40,
31, 40, 40, 30, 35, 39, 40, 39, 40, 33,
34, 34
} ;
static const flex_int16_t yy_accept[124] =
static const flex_int16_t yy_accept[158] =
{ 0,
1, 1, 1, 2, 3, 3, 3, 3, 3, 4,
6, 9, 12, 15, 18, 20, 22, 24, 27, 29,
32, 35, 37, 40, 43, 45, 48, 52, 55, 58,
61, 64, 67, 70, 73, 76, 79, 81, 83, 85,
87, 89, 92, 94, 95, 95, 97, 97, 98, 100,
101, 101, 102, 105, 106, 107, 108, 109, 110, 111,
112, 113, 114, 115, 116, 117, 117, 118, 119, 119,
121, 121, 121, 123, 123, 124, 125, 126, 127, 128,
129, 130, 131, 131, 132, 133, 135, 136, 136, 137,
138, 138, 139, 140, 141, 141, 142, 143, 145, 146,
61, 64, 67, 70, 73, 76, 79, 82, 85, 88,
91, 94, 97, 99, 101, 103, 105, 107, 110, 112,
113, 113, 115, 115, 116, 118, 119, 120, 120, 121,
123, 126, 127, 128, 129, 130, 131, 132, 133, 134,
135, 136, 137, 138, 139, 140, 141, 142, 143, 144,
145, 145, 146, 147, 147, 149, 149, 149, 149, 150,
151, 152, 153, 154, 155, 156, 157, 158, 159, 160,
146, 147, 148, 149, 150, 151, 152, 152, 153, 154,
155, 156, 156, 157, 158, 159, 160, 160, 161, 163,
165, 166, 166
161, 161, 162, 163, 165, 166, 167, 167, 168, 169,
170, 171, 171, 172, 173, 174, 175, 176, 176, 177,
178, 180, 181, 181, 182, 183, 184, 185, 186, 187,
188, 189, 190, 191, 191, 192, 193, 194, 195, 196,
197, 198, 199, 199, 200, 201, 202, 203, 204, 205,
205, 206, 208, 210, 212, 213, 213
} ;
static const YY_CHAR yy_ec[256] =
@ -525,132 +534,168 @@ static const YY_CHAR yy_meta[51] =
7, 7, 7, 7, 7, 7, 7, 7, 7, 1
} ;
static const flex_int16_t yy_base[133] =
static const flex_int16_t yy_base[167] =
{ 0,
0, 0, 48, 49, 256, 255, 50, 53, 257, 327,
327, 327, 327, 327, 0, 45, 225, 327, 19, 327,
327, 327, 37, 327, 40, 228, 55, 327, 327, 223,
56, 58, 59, 48, 62, 154, 0, 327, 68, 327,
0, 327, 100, 0, 94, 86, 53, 104, 105, 108,
181, 327, 109, 122, 63, 112, 72, 115, 116, 89,
0, 96, 123, 327, 0, 146, 327, 327, 139, 327,
52, 148, 128, 149, 327, 155, 153, 160, 156, 163,
161, 327, 112, 74, 136, 167, 168, 158, 173, 175,
198, 203, 327, 185, 170, 65, 207, 208, 327, 157,
0, 0, 48, 49, 310, 307, 50, 53, 306, 452,
452, 452, 452, 452, 0, 45, 281, 452, 19, 452,
452, 452, 37, 452, 40, 272, 55, 452, 452, 56,
87, 88, 93, 94, 97, 0, 86, 87, 89, 87,
89, 175, 0, 452, 107, 452, 0, 452, 136, 0,
130, 142, 120, 140, 143, 148, 151, 204, 452, 154,
174, 159, 0, 452, 162, 137, 165, 125, 169, 153,
175, 152, 176, 161, 150, 0, 185, 194, 452, 0,
211, 452, 452, 207, 452, 178, 211, 215, 219, 220,
218, 227, 225, 228, 223, 249, 244, 238, 226, 452,
199, 211, 212, 214, 327, 327, 201, 216, 192, 219,
217, 234, 229, 327, 222, 327, 243, 327, 41, 0,
0, 327, 270, 277, 284, 286, 289, 291, 298, 305,
312, 319
241, 128, 201, 232, 258, 115, 247, 273, 256, 262,
258, 287, 298, 452, 300, 305, 107, 261, 107, 233,
276, 452, 276, 309, 310, 316, 299, 307, 306, 319,
304, 452, 452, 310, 330, 312, 341, 56, 347, 323,
350, 45, 357, 355, 345, 452, 363, 38, 452, 368,
452, 372, 0, 0, 0, 452, 396, 403, 410, 412,
415, 416, 423, 430, 437, 444
} ;
static const flex_int16_t yy_def[133] =
static const flex_int16_t yy_def[167] =
{ 0,
122, 1, 123, 123, 124, 124, 125, 125, 122, 122,
122, 122, 122, 122, 126, 122, 122, 122, 122, 122,
122, 122, 122, 122, 127, 122, 128, 122, 122, 128,
128, 128, 128, 128, 128, 122, 129, 122, 130, 122,
131, 122, 122, 126, 122, 122, 122, 122, 122, 127,
127, 122, 128, 128, 128, 128, 128, 128, 128, 122,
129, 130, 130, 122, 131, 122, 122, 122, 122, 122,
122, 122, 122, 127, 122, 128, 128, 128, 128, 128,
128, 122, 122, 122, 127, 128, 128, 122, 128, 128,
122, 128, 122, 128, 122, 122, 127, 128, 122, 122,
156, 1, 157, 157, 158, 158, 159, 159, 156, 156,
156, 156, 156, 156, 160, 156, 156, 156, 156, 156,
156, 156, 156, 156, 161, 156, 156, 156, 156, 27,
27, 27, 27, 27, 27, 162, 162, 162, 162, 162,
162, 156, 163, 156, 164, 156, 165, 156, 156, 160,
156, 156, 156, 156, 156, 161, 161, 161, 156, 156,
27, 27, 162, 156, 27, 162, 27, 162, 27, 162,
27, 162, 27, 162, 156, 163, 164, 164, 156, 165,
156, 156, 156, 156, 156, 156, 156, 161, 27, 27,
162, 27, 162, 27, 162, 27, 162, 27, 162, 156,
128, 128, 128, 128, 122, 122, 122, 128, 128, 128,
128, 122, 128, 122, 128, 122, 122, 122, 128, 132,
132, 0, 122, 122, 122, 122, 122, 122, 122, 122,
122, 122
156, 156, 161, 27, 27, 162, 156, 27, 162, 27,
162, 156, 27, 156, 162, 27, 162, 156, 156, 161,
27, 156, 156, 27, 27, 27, 162, 162, 162, 27,
162, 156, 156, 156, 27, 162, 27, 162, 27, 162,
27, 162, 156, 27, 162, 156, 27, 162, 156, 156,
156, 27, 162, 166, 166, 0, 156, 156, 156, 156,
156, 156, 156, 156, 156, 156
} ;
static const flex_int16_t yy_nxt[378] =
static const flex_int16_t yy_nxt[503] =
{ 0,
10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
20, 21, 22, 10, 23, 24, 23, 25, 26, 27,
28, 29, 30, 30, 30, 31, 32, 30, 33, 34,
30, 30, 30, 30, 35, 30, 30, 30, 30, 31,
32, 33, 34, 30, 30, 30, 30, 35, 30, 36,
38, 38, 42, 47, 48, 42, 49, 48, 122, 50,
43, 39, 39, 43, 45, 122, 47, 45, 45, 45,
45, 45, 48, 122, 53, 122, 122, 71, 55, 122,
122, 63, 58, 83, 96, 57, 64, 69, 56, 122,
69, 71, 55, 96, 79, 58, 83, 59, 77, 57,
30, 30, 30, 30, 35, 30, 36, 36, 36, 37,
38, 39, 40, 36, 36, 36, 36, 41, 36, 42,
44, 44, 48, 53, 54, 48, 55, 56, 154, 57,
49, 45, 45, 49, 51, 149, 53, 51, 51, 51,
51, 51, 60, 64, 61, 62, 146, 62, 62, 62,
62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
62, 63, 63, 63, 63, 63, 63, 63, 63, 63,
68, 56, 66, 66, 66, 46, 66, 70, 79, 122,
59, 77, 67, 45, 122, 67, 45, 45, 45, 45,
45, 48, 48, 48, 49, 73, 48, 50, 53, 122,
72, 72, 122, 122, 74, 76, 63, 78, 60, 122,
69, 64, 81, 69, 95, 48, 80, 48, 66, 66,
66, 78, 66, 75, 72, 97, 81, 95, 67, 80,
82, 67, 84, 84, 84, 84, 75, 84, 85, 84,
122, 84, 122, 122, 86, 87, 88, 122, 122, 91,
122, 90, 92, 93, 122, 122, 98, 100, 99, 87,
122, 107, 122, 94, 89, 90, 106, 101, 75, 102,
63, 63, 63, 63, 64, 64, 62, 62, 66, 65,
64, 64, 62, 62, 64, 70, 62, 68, 67, 69,
78, 72, 66, 66, 74, 79, 119, 132, 71, 70,
68, 68, 73, 70, 72, 122, 83, 74, 81, 81,
81, 72, 81, 84, 86, 74, 84, 119, 82, 51,
93, 82, 51, 51, 51, 51, 51, 54, 86, 54,
54, 52, 55, 85, 93, 56, 87, 57, 60, 87,
57, 54, 91, 54, 88, 95, 64, 88, 62, 64,
87, 62, 64, 97, 62, 91, 64, 99, 62, 95,
92, 94, 64, 64, 62, 62, 97, 90, 156, 75,
100, 104, 122, 60, 107, 105, 94, 89, 103, 122,
106, 101, 114, 102, 91, 104, 122, 91, 93, 91,
122, 103, 92, 93, 75, 122, 97, 98, 122, 122,
108, 122, 112, 122, 122, 109, 122, 116, 110, 122,
122, 52, 120, 108, 46, 112, 122, 111, 113, 109,
117, 115, 110, 117, 118, 119, 122, 38, 38, 117,
111, 113, 117, 118, 115, 122, 122, 122, 122, 119,
37, 37, 37, 37, 37, 37, 37, 40, 40, 40,
40, 40, 40, 40, 41, 41, 41, 41, 41, 41,
41, 44, 44, 51, 51, 54, 54, 54, 61, 122,
89, 99, 98, 156, 93, 95, 96, 78, 84, 101,
91, 84, 79, 81, 81, 81, 99, 81, 64, 97,
120, 64, 101, 82, 75, 102, 82, 102, 100, 102,
102, 102, 64, 102, 103, 102, 64, 64, 104, 62,
106, 107, 105, 107, 64, 64, 62, 62, 111, 64,
64, 121, 120, 110, 106, 64, 106, 62, 117, 109,
112, 108, 111, 115, 114, 112, 64, 111, 113, 114,
116, 117, 109, 118, 109, 64, 123, 62, 122, 64,
127, 62, 128, 117, 131, 59, 118, 133, 130, 123,
64, 129, 62, 64, 127, 121, 128, 124, 131, 125,
61, 122, 61, 61, 61, 62, 122, 62, 62, 62,
62, 62, 65, 122, 122, 65, 65, 65, 65, 121,
122, 121, 121, 121, 121, 121, 9, 122, 122, 122,
122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
122, 122, 122, 122, 122, 122, 122
52, 133, 131, 112, 129, 156, 112, 114, 126, 44,
134, 127, 44, 128, 112, 64, 112, 113, 114, 115,
114, 129, 64, 134, 62, 132, 64, 64, 62, 62,
136, 138, 140, 64, 137, 62, 64, 142, 62, 156,
135, 143, 139, 136, 145, 138, 140, 64, 138, 62,
142, 156, 141, 136, 143, 148, 140, 145, 64, 156,
62, 146, 144, 156, 64, 142, 62, 64, 148, 62,
149, 153, 64, 150, 62, 145, 150, 151, 156, 147,
64, 152, 62, 154, 150, 153, 156, 150, 151, 64,
156, 62, 148, 156, 156, 153, 43, 43, 43, 43,
43, 43, 43, 46, 46, 46, 46, 46, 46, 46,
47, 47, 47, 47, 47, 47, 47, 50, 50, 58,
58, 63, 63, 76, 156, 76, 156, 76, 76, 76,
77, 156, 77, 77, 77, 77, 77, 80, 156, 156,
80, 80, 80, 80, 155, 156, 155, 155, 155, 155,
155, 9, 156, 156, 156, 156, 156, 156, 156, 156,
156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
156, 156
} ;
static const flex_int16_t yy_chk[378] =
static const flex_int16_t yy_chk[503] =
{ 0,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
3, 4, 7, 19, 23, 8, 23, 25, 119, 25,
7, 3, 4, 8, 16, 34, 19, 16, 16, 16,
16, 16, 27, 31, 27, 32, 33, 47, 31, 35,
55, 39, 34, 71, 96, 33, 39, 46, 32, 57,
46, 47, 31, 84, 57, 34, 71, 35, 55, 33,
3, 4, 7, 19, 23, 8, 23, 25, 148, 25,
7, 3, 4, 8, 16, 142, 19, 16, 16, 16,
16, 16, 27, 30, 27, 30, 138, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
45, 32, 43, 43, 43, 46, 43, 46, 57, 62,
35, 55, 43, 45, 62, 43, 45, 45, 45, 45,
45, 48, 49, 48, 49, 50, 53, 50, 53, 56,
48, 49, 58, 59, 50, 53, 63, 56, 60, 54,
69, 63, 59, 69, 83, 73, 58, 73, 66, 66,
66, 56, 66, 85, 73, 85, 59, 83, 66, 58,
69, 66, 72, 74, 72, 74, 74, 72, 74, 76,
77, 76, 76, 79, 76, 77, 78, 78, 81, 80,
80, 79, 80, 80, 86, 87, 86, 88, 87, 77,
89, 100, 90, 81, 78, 79, 95, 89, 51, 89,
27, 27, 27, 27, 31, 32, 31, 32, 37, 31,
33, 34, 33, 34, 35, 39, 35, 38, 32, 33,
45, 40, 37, 31, 41, 45, 119, 117, 34, 39,
38, 32, 35, 33, 40, 106, 51, 41, 49, 49,
49, 34, 49, 52, 53, 35, 52, 102, 49, 51,
68, 49, 51, 51, 51, 51, 51, 54, 53, 54,
55, 52, 55, 52, 68, 56, 54, 56, 57, 55,
57, 60, 66, 60, 56, 70, 62, 57, 62, 65,
60, 65, 67, 72, 67, 66, 69, 74, 69, 70,
67, 69, 71, 73, 71, 73, 72, 65, 77, 75,
88, 90, 94, 36, 100, 94, 81, 78, 89, 109,
95, 89, 109, 89, 91, 90, 101, 91, 91, 92,
92, 89, 92, 92, 97, 98, 97, 98, 102, 103,
101, 104, 107, 108, 111, 102, 110, 111, 103, 115,
30, 26, 115, 101, 17, 107, 113, 104, 108, 102,
112, 110, 103, 112, 112, 113, 9, 6, 5, 117,
104, 108, 117, 117, 110, 0, 0, 0, 0, 113,
123, 123, 123, 123, 123, 123, 123, 124, 124, 124,
124, 124, 124, 124, 125, 125, 125, 125, 125, 125,
125, 126, 126, 127, 127, 128, 128, 128, 129, 0,
61, 74, 73, 77, 67, 69, 71, 78, 84, 86,
65, 84, 78, 81, 81, 81, 73, 81, 103, 71,
103, 58, 86, 81, 42, 87, 81, 87, 84, 88,
87, 88, 88, 89, 88, 89, 89, 90, 89, 90,
91, 93, 90, 92, 92, 94, 92, 94, 95, 104,
120, 104, 120, 94, 91, 98, 90, 98, 99, 93,
97, 92, 95, 97, 97, 96, 96, 94, 96, 96,
98, 99, 93, 101, 92, 105, 107, 105, 105, 110,
109, 110, 109, 98, 111, 26, 101, 118, 110, 107,
108, 109, 108, 121, 109, 121, 109, 108, 111, 108,
129, 0, 129, 129, 129, 130, 0, 130, 130, 130,
130, 130, 131, 0, 0, 131, 131, 131, 131, 132,
0, 132, 132, 132, 132, 132, 122, 122, 122, 122,
122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
122, 122, 122, 122, 122, 122, 122, 122, 122, 122,
122, 122, 122, 122, 122, 122, 122
17, 118, 110, 112, 109, 9, 112, 112, 108, 6,
123, 108, 5, 108, 113, 113, 115, 113, 113, 115,
115, 108, 116, 123, 116, 116, 124, 125, 124, 125,
127, 128, 129, 126, 125, 126, 130, 131, 130, 0,
124, 134, 126, 127, 136, 128, 129, 135, 125, 135,
131, 0, 130, 124, 134, 140, 126, 136, 137, 0,
137, 137, 135, 0, 139, 130, 139, 141, 140, 141,
141, 145, 144, 143, 144, 135, 143, 143, 0, 139,
147, 144, 147, 147, 150, 145, 0, 150, 150, 152,
0, 152, 139, 0, 0, 144, 157, 157, 157, 157,
157, 157, 157, 158, 158, 158, 158, 158, 158, 158,
159, 159, 159, 159, 159, 159, 159, 160, 160, 161,
161, 162, 162, 163, 0, 163, 0, 163, 163, 163,
164, 0, 164, 164, 164, 164, 164, 165, 0, 0,
165, 165, 165, 165, 166, 0, 166, 166, 166, 166,
166, 156, 156, 156, 156, 156, 156, 156, 156, 156,
156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
156, 156, 156, 156, 156, 156, 156, 156, 156, 156,
156, 156
} ;
@ -694,8 +739,7 @@ goto find_rule; \
yyclass define name of the scanner class
*/
#include "step.tab.hxx"
#include "recfile.ph"
#include <step.tab.hxx>
#include "stdio.h"
// Tell flex which function to define
@ -736,12 +780,15 @@ long string in files Henri.stp and 401.stp*/
#endif /* MSC_VER */
void rec_restext(const char *constnewtext, int lentext);
void rec_typarg(int argtype);
#define CreateNewText myDataModel->CreateNewText
#define SetTypeArg myDataModel->SetTypeArg
// disable GCC warnings in flex code
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-function"
#if (__GNUC__ > 5)
#pragma GCC diagnostic ignored "-Wmisleading-indentation"
#endif
#endif
@ -959,14 +1006,14 @@ yy_match:
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 123 )
if ( yy_current_state >= 157 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
*(yy_state_ptr)++ = yy_current_state;
++yy_cp;
}
while ( yy_base[yy_current_state] != 327 );
while ( yy_base[yy_current_state] != 452 );
yy_find_action:
yy_current_state = *--(yy_state_ptr);
@ -1056,7 +1103,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); rec_restext(YYText(),YYLeng()); rec_typarg(rec_argText); 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(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 */
YY_BREAK
case 10:
YY_RULE_SETUP
@ -1084,35 +1131,35 @@ case 15:
(yy_c_buf_p) = yy_cp -= 1;
YY_DO_BEFORE_ACTION; /* set up yytext again */
YY_RULE_SETUP
{ rec_restext(YYText(),YYLeng()); return(token::ENTITY); }
{ CreateNewText(YYText(),YYLeng()); return(token::ENTITY); }
YY_BREAK
case 16:
YY_RULE_SETUP
{ rec_restext(YYText(),YYLeng()); return(token::ENTITY); }
{ CreateNewText(YYText(),YYLeng()); return(token::ENTITY); }
YY_BREAK
case 17:
YY_RULE_SETUP
{ rec_restext(YYText(),YYLeng()); return(token::IDENT); }
{ CreateNewText(YYText(),YYLeng()); return(token::IDENT); }
YY_BREAK
case 18:
YY_RULE_SETUP
{ rec_restext(YYText(),YYLeng()); rec_typarg(rec_argInteger); return(token::QUID); }
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Integer); return(token::QUID); }
YY_BREAK
case 19:
YY_RULE_SETUP
{ rec_restext(YYText(),YYLeng()); rec_typarg(rec_argFloat); return(token::QUID); }
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Float); return(token::QUID); }
YY_BREAK
case 20:
YY_RULE_SETUP
{ rec_restext(YYText(),YYLeng()); rec_typarg(rec_argFloat); return(token::QUID); }
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Float); return(token::QUID); }
YY_BREAK
case 21:
YY_RULE_SETUP
{ rec_restext(YYText(),YYLeng()); rec_typarg(rec_argHexa); return(token::QUID); }
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Hexa); return(token::QUID); }
YY_BREAK
case 22:
YY_RULE_SETUP
{ rec_restext(YYText(),YYLeng()); rec_typarg(rec_argEnum); return(token::QUID); }
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Enum); return(token::QUID); }
YY_BREAK
case 23:
YY_RULE_SETUP
@ -1124,11 +1171,11 @@ YY_RULE_SETUP
YY_BREAK
case 25:
YY_RULE_SETUP
{ return (','); }
{ myDataModel->PrepareNewArg(); return (','); }
YY_BREAK
case 26:
YY_RULE_SETUP
{ rec_restext(YYText(),YYLeng()); rec_typarg(rec_argNondef); return(token::QUID); }
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Nondef); return(token::QUID); }
YY_BREAK
case 27:
YY_RULE_SETUP
@ -1184,16 +1231,16 @@ YY_RULE_SETUP
YY_BREAK
case 40:
YY_RULE_SETUP
{ rec_restext(YYText(),YYLeng()); return(token::TYPE); }
{ CreateNewText(YYText(),YYLeng()); return(token::TYPE); }
YY_BREAK
case 41:
YY_RULE_SETUP
{ rec_restext(YYText(),YYLeng()); return(token::TYPE); }
{ CreateNewText(YYText(),YYLeng()); return(token::TYPE); }
YY_BREAK
case 42:
/* rule 42 can match eol */
YY_RULE_SETUP
{ rec_restext(YYText(),YYLeng()); rec_typarg(rec_argMisc); return(token::QUID); }
{ CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Misc); return(token::QUID); }
YY_BREAK
case 43:
YY_RULE_SETUP
@ -1597,7 +1644,7 @@ int yyFlexLexer::yy_get_next_buffer()
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 123 )
if ( yy_current_state >= 157 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
@ -1621,11 +1668,11 @@ int yyFlexLexer::yy_get_next_buffer()
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
{
yy_current_state = (int) yy_def[yy_current_state];
if ( yy_current_state >= 123 )
if ( yy_current_state >= 157 )
yy_c = yy_meta[yy_c];
}
yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
yy_is_jam = (yy_current_state == 122);
yy_is_jam = (yy_current_state == 156);
if ( ! yy_is_jam )
*(yy_state_ptr)++ = yy_current_state;
@ -2200,8 +2247,8 @@ void yyfree (void * ptr )
step::scanner::scanner(std::istream* in, std::ostream* out)
: stepFlexLexer(in, out)
step::scanner::scanner(StepFile_ReadData* theDataModel, std::istream* in, std::ostream* out)
: stepFlexLexer(in, out), myDataModel(theDataModel)
{
}

View File

@ -1,602 +0,0 @@
/*
Copyright (c) 1999-2014 OPEN CASCADE SAS
This file is part of Open CASCADE Technology software library.
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 2.1 as published
by the Free Software Foundation, with special exception defined in the file
OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
distribution for complete text of the license and disclaimer of any warranty.
Alternatively, this file may be used under the terms of Open CASCADE
commercial license or contractual agreement.
*/
#include "stdio.h"
#include "string.h"
#include "stdlib.h"
#if (!defined(_WIN32) && !defined(__APPLE__))
#include "malloc.h"
#endif
#include "recfile.ph"
/* enregistrement d'un fichier d'interface sous forme de records
gere les scopes
Ce fichier comprend 3 parties
- les routines traitant les char*, avec la notion de texte courant
- les declarations des donnees de travail proprement dites pour le fichier
- le corps des programmes d'enregistrement
*/
/* ROUTINES UTILITAIRES de traitement des textes (char*) */
/* Gestion du texte courant : c'est un texte alloue dynamiquement
rec_restext en alloue un (jete le precedent alloue si pas lu)
rec_gettext lit le texte en cours, qui ne sera pas desalloue ensuite
rec_settext en force un autre en jetant le precedent (idem rec_newtext)
tandis que rec_newtext alloue un texte, sans lien avec le courant
*/
#define Maxcar 50000
static struct carpage {
struct carpage* next; /* chainage des pages de caracteres */
int used; /* place deja prise */
char cars[Maxcar+1]; /* page de caracteres */
} *onecarpage;
static char* restext = NULL ; /* texte courant (allocation dynamique) */
/* static int resalloc = 0 ;*/ /* alloue (memoire a liberer) ou non */
void rec_restext(const char* theNewText, int theLenText) /* destine a etre appele de l'exterieur */
{
// optimization for most frequent entity, CARTESIAN_POINT
static char txt_cart_p[] = "CARTESIAN_POINT";
if(strcmp(theNewText,txt_cart_p)==0) {
restext = txt_cart_p;
return;
}
if (onecarpage->used > Maxcar-theLenText-1) { /* allouer nouvelle page */
struct carpage *newpage;
int sizepage = sizeof(struct carpage);
if (theLenText >= Maxcar) sizepage += (theLenText+1 - Maxcar);
newpage = (struct carpage*) malloc (sizepage);
newpage->next = onecarpage;
onecarpage = newpage;
onecarpage->used = 0;
}
restext = onecarpage->cars + onecarpage->used;
onecarpage->used += (theLenText + 1);
/* strcpy */
char *aRes = restext ;
const char *aText = theNewText;
while (*aText != '\0') { *aRes=*aText ; aRes++ ; aText++ ; }
*aRes = '\0' ;
}
void rec_gettext(char* *r)
/* Le resultat retourne (pointeur) est destine a etre inclus dans un struct */
{ *r = restext; }
void rec_settext(char* s)
/* substituer le texte courant par un autre deja alloue */
{ restext = s ; }
char* rec_newtext(char* r)
/* routine utilitaire creant une chaine dynamique a partir d'un char[] */
{
char* savrestext;
char* s0;
savrestext = restext;
rec_restext(r,(int)strlen(r));
s0 = restext;
restext = savrestext;
return (s0);
}
static int modeprint = 0 ; /* CONTROLE D'IMPRESSION (pour appel depuis yacc)*/
/* DECLARATIONS des donnees de travail (en cours d'enregistrement) */
static int typarg ; /* type du dernier argument lu */
static int nbrec = 0; /* nombre total d'enregistrements de donnees */
static int nbhead = 0; /* nb de records pris par le Header */
static int nbpar = 0; /* nb de parametres lus au total */
static int yarec = 0; /* presence Record deja cree (1 apres Ident) */
static struct rec { /* DESCRIPTION D'UN RECORD */
char* ident ; /* identifieur du record (en #12345...) ou scope-end */
char* type ; /* type du record (peut etre sublist) */
/* int nbarg ; nombre de parametres (arguments) du record, not used */
struct unarg* first ; /* 1er argument */
/* struct unarg* last ;dernier argument, not used */
struct rec* next ; /* record suivant */
} *currec ; /* currec meme : record courant */
#define Maxrec 5000
static struct recpage {
struct recpage* next;
int used;
struct rec args[Maxrec+1];
} *onerecpage;
static struct rec* firstrec ; /* 1er record du fichier */
static struct rec* lastrec ; /* dernier record du fichier */
static char* curtype; /* type dernier record (ou = sublist) */
static char* subarg ; /* ident dernier record (sub-list eventuel) */
static int numsub ; /* numero de sous-liste en cours */
static struct unarg { /* DESCRIPTION D'UN ARGUMENT */
int type ; /* type de l'arg, dans une liste courte : entier, reel ... */
char* val ; /* valeur alphanum de l'arg */
struct unarg* next ; /* argument suivant dans la liste pour ce record */
} *curarg ;
#define Maxarg 10000
static struct argpage { /* Allocation optimisee des arguments */
struct argpage* next;
int used;
struct unarg args[Maxarg+1];
} *oneargpage;
static struct scope { /* DESCRIPTION D'UN SCOPE */
/* les scopes sont empilables sans limite */
struct scope* prev; /* scope precedent, auquel il faudra revenir */
struct rec* rec; /* record interrompu par le scope (a reprendre) */
} *curscope ; /* curscope est le scope en cours */
/* Constantes litterales */
static char txt_sublist[] = "/* (SUB) */" ;
static char txt_scope[] = "SCOPE" ;
static char txt_endscope[] = "ENDSCOPE" ;
static char txt_nil[] = " " ;
static char sub1[] = "$1" ; /* optimisation ... */
static char sub2[] = "$2" ;
static char argtype1[] = "(IF#TnEHBx"; /* types arguments (2 1es lettres) */
static char argtype2[] = ")nlIxdnxix";
static char idzero[] = "#0";
/* Trace pour controle */
#ifdef __cplusplus
extern "C" {
#endif
void recfile_modeprint(int mode)
{ modeprint = mode; }
#ifdef __cplusplus
}
#endif
/* INITIALISATION */
void rec_debfile()
{
/*initialization of recpage*/
onerecpage = (struct recpage*) malloc ( sizeof(struct recpage) );
onerecpage->used = 0; onerecpage->next = NULL;
onecarpage = (struct carpage*) malloc ( sizeof(struct carpage) );
onecarpage->used = 0; onecarpage->next = NULL; restext = NULL;
yarec = 0; nbhead = nbrec = nbpar = 0 ; firstrec = NULL ; lastrec = NULL ;
curtype = txt_sublist;
currec = NULL ; curarg = NULL ;
curscope = NULL ;
oneargpage = (struct argpage*) malloc ( sizeof(struct argpage) );
oneargpage->next = NULL; oneargpage->used = 0;
}
/* INTERMEDIAIRE : passage de Header a Data */
void rec_finhead() { nbhead = nbrec; }
/* CONCLUSION : actuellement, ne fait rien */
void rec_finfile() { }
/* GESTION DES RECORDS */
/* ENREGISTRER UN RECORD (deja pret) */
static void rec_new(struct rec* newrec)
/* nouveau record a enregistrer */
{
nbrec ++ ;
if ( firstrec == NULL ) firstrec = newrec ;
if ( lastrec != NULL ) lastrec->next = newrec ;
lastrec = newrec ;
}
/* type du dernier argument lu */
void rec_typarg(int argtype)
{ typarg = argtype; }
/* ENREGISTRER UNE ENTITE (record courant) */
void rec_newent()
{
rec_new(currec) ; /* le record courant (currec) est enregistre */
/* gestion des sous-listes : si currec a un suivant note (cf pointeur suite),
alors c'est une sous-liste et le suivant est son contenant
EN CE CAS, il faut memoriser cette sous-liste en argument courant
En effet, d'une part la liste est reconnue comme un argument, d'autre part
part elle se termine par ")" : c'est donc ici qu'elle sera enregistree */
rec_typarg (rec_argSub) ;
subarg = currec->ident ; /* si sous-liste, sera argument du contenant */
/* rec_check(1) ; */
currec = currec->next ; /* si nul, c'est qu'une autre entite suit */
lastrec->next = NULL ;
}
static struct rec*rec_newrec()
{
struct rec* newrec;
if (onerecpage->used >= Maxrec) {
struct recpage* newrecpage;
newrecpage = (struct recpage*) malloc ( sizeof (struct recpage) );
newrecpage->next = onerecpage;
onerecpage = newrecpage;
onerecpage->used = 0;
}
newrec = &(onerecpage->args[onerecpage->used]);
onerecpage->used++;
return newrec;
}
/* RECORD COURANT : */
/* creer et preciser l'identifieur */
void rec_ident()
{
currec = rec_newrec();
/*currec = (struct rec*) malloc (sizeof (struct rec)) ;*/
/*currec->nbarg = 0 ;*/
rec_gettext(&(currec->ident)) ;
currec->next = NULL ; currec->first = NULL ; /*currec->last = NULL ;*/
yarec = 1;
}
/* preciser le type ; demarrage de la description de l'entite */
void rec_type()
{
/* Pour le header : pas d'ident, donc en simuler un : derive de rec_ident */
if (!yarec) {
/*currec = (struct rec*) malloc (sizeof (struct rec)) ;*/
currec = rec_newrec();
/*currec->nbarg = 0 ;*/
currec->ident = idzero; /* Ident bidon (il en faut un ...) */
currec->next = NULL ; currec->first = NULL ; /*currec->last = NULL ;*/
}
rec_gettext(&(currec->type)) ;
yarec = numsub = 0 ; /* debut de l'entite */
}
/* type d une liste qui n est pas une entite mais un argument
par defaut (cf rec_deblist) il n est pas defini donc mis = "/ (SUB) /" */
void rec_listype()
{ rec_gettext(&(curtype)); }
/* ajouter un argument (type & valeur deja connus) */
void rec_newarg()
{
struct unarg *newarg;
nbpar ++;
/*currec->nbarg ++ ;*/
/* newarg = (struct unarg*) malloc (sizeof (struct unarg)) ; */
if (oneargpage->used >= Maxarg) {
struct argpage* newargpage;
newargpage = (struct argpage*) malloc ( sizeof(struct argpage) );
newargpage->next = oneargpage;
oneargpage = newargpage;
oneargpage->used = 0;
}
newarg = &(oneargpage->args[oneargpage->used]);
oneargpage->used ++;
newarg->type = typarg ;
if (typarg == rec_argSub) newarg->val = subarg ;
else rec_gettext (&(newarg->val));
/* if (currec->first == NULL) currec->first = newarg;
else currec->last->next = newarg;
currec->last = newarg;*/
if (currec->first == NULL) currec->first = newarg;
else {
struct unarg* nextarg = currec->first;
while(nextarg->next != NULL)
nextarg = nextarg->next;
nextarg->next = newarg;
}
newarg->next = NULL ;
/* rec_check(0) ; */
}
/* Ajouter une sous-liste
Une ouverture de parentheses A L'INTERIEUR d'une liste de parametres
signale une sous-liste : c'est une entite non identifiee, directement
utilisee comme argument de la liste contenante) d'un type reserve(SUB)
Elle est enregistree avec un identifieur special : '$' suivi d'un numero
de sous-liste dans l'entite en cours.
Son enregistrement consiste a definir un nouveau record courant, pour la
sous-liste, qui note comme suivant l'ancien courant, qui est son contenant
A la fin de la sous-liste, elle est enregistree comme toute entite (cf
rec_new) mais le suivant devient le nouveau courant dont l'enregistrement
des parametres continue
La premiere ouverture de parentheses dans l'entite est celle de la liste
principale de parametres et non d'une sous-liste
*/
void rec_deblist()
{
if (numsub > 0) { /* enregistrement d'une sous-liste */
/* int i ; */ struct rec* subrec ;
/* creation du nouvel enregistrement et chainage au precedent */
subrec = rec_newrec();
/*subrec = (struct rec*) malloc (sizeof (struct rec)) ;*/
switch (numsub) {
case 1: subrec->ident = sub1; break;
case 2: subrec->ident = sub2; break;
default: {
char bufsub[10];
if (numsub > 9) sprintf (bufsub,"$%d",numsub) ;
else { bufsub[0] = '$'; bufsub[1] = (char)(numsub + 48); bufsub[2] = '\0'; }
subrec->ident = rec_newtext(bufsub) ;
}
}
subrec->type = curtype ;
curtype = txt_sublist; /* type reserve par defaut */
/*subrec->nbarg = 0 ;*/ subrec->next = currec ;
subrec->first = NULL ; /*subrec->last = NULL ;*/
/* les arguments de la sous-liste vont suivre ;
elle meme est argument de son contenant, ce qui est pris en compte
a la fermeture de la parenthese */
currec = subrec ; /* substitution finale */
}
numsub ++ ; /* numero de la prochaine sous-liste (la principale est en 0) */
/* rec_check(0) ; */
}
/* Affichage du contenu d'un record */
void rec_print(struct rec* unrec)
{
int numa = 0; int numl = 0; int argl = 0;
if (unrec == NULL) { printf ("Non defini\n") ; return; }
printf ("Ident : %s Type : %s Nb.Arg.s : %s\n",
unrec->ident,unrec->type, (unrec->first ? unrec->first->val : "")) ;
if (modeprint < 2) return ;
curarg = unrec->first ;
while (curarg != NULL) {
numa ++;
argl = (int)strlen(curarg->val) + 18;
numl += argl;
if (numl > 132) { printf("\n"); numl = argl; }
printf (" - Arg.%d[%c%c] : %s",
numa,argtype1[curarg->type],argtype2[curarg->type],curarg->val);
curarg = curarg->next ;
}
if (argl > 0) printf("\n");
return ;
}
/* GESTION DES SCOPES */
/* Ouverture de scope :
un scope est un record particulier (pas de type ni d'argument)
d'une part il est enregistre, d'autre part il faut gerer le record en cours
En effet, une entite step etait en cours d'enregistrement (ident deja connu),
mais son type et ses arguments seront fournis apres fermeture du scope ...
Il faut donc la mettre de cote (c'est currec), pour la restaurer ensuite
Mais ATTENTION, il y a l'EXPORT : au ENDSCOPE, peut etre attachee une liste
d'Idents : ce sont les idents internes au SCOPE mais declares visibles de
l'exterieur du SCOPE (en plus de l''entite sur laquelle il porte)
*/
void scope_debut()
{
/* ouverture du scope et sauvegarde de l'entite en cours */
struct scope* newscope; struct rec* unscope;
newscope = (struct scope*) malloc (sizeof (struct scope)) ;
newscope->rec = currec ;
newscope->prev = curscope ;
curscope = newscope ;
/* enregistrement de ce scope comme un record */
unscope = rec_newrec();
/*unscope = (struct rec*) malloc (sizeof (struct rec)) ;*/
unscope->ident = txt_scope ;
unscope->type = txt_nil ;
unscope->first = NULL;
/*unscope->nbarg = 0 ;*/
rec_new(unscope) ;
}
/* Fermeture de scope :
La fin de scope est, comme son debut, un enregistrement special.
Il faut donc l'enregistrer.
Il faut aussi restaurer l'entite concernee par le scope, afin de terminer
son enregistrement (manquent ses arguments) */
void scope_fin()
{ struct scope* oldscope ; struct rec* unscope;
if (curscope == NULL) return ; /* cela dit, c'est anormal ... */
/* enregistrement de cette fin de scope comme un record */
unscope = rec_newrec();
/* unscope = (struct rec*) malloc (sizeof (struct rec)) ;*/
unscope->ident = txt_endscope ;
unscope->type = txt_nil ;
unscope->first = NULL;
/*unscope->nbarg = 0 ;*/
/* Si on doit prendre en compte une Export List ... */
if (subarg[0] == '$') {
if (modeprint > 0) {
printf("Export List : (List in Record n0 %d) -- ",nbrec);
rec_print(lastrec);
}
currec = unscope;
typarg = rec_argSub;
rec_newarg();
}
rec_new(unscope) ;
/* fermeture effective du scope */
currec = curscope->rec ; /* restaurer l'entite en cours d'enreg. */
yarec = 1;
oldscope = curscope ;
curscope = oldscope->prev ; /* restauration de l'etat precedent */
free (oldscope) ; /* suppression "physique" */
}
/* CONCLUSION : retour des valeurs pour constituer la liste des records,
sous forme de directory / tableau
La liberation de la memoire est faite par lir_file_fin, en une fois
*/
#ifdef __cplusplus
extern "C" {
#endif
void lir_file_nbr(int* nbh, int* nbr, int* nbp)
/* initialise le traitement et retourne la taille du directory et du header */
{
currec = firstrec ;
/* rec_check(0) ; */
*nbh = nbhead; *nbr = nbrec; *nbp = nbpar;
}
void lir_file_fin(int mode)
/* fin du traitement : regroupe les liberations de memoire en une phase */
/* mode = 1 : rec+arg. 2 : carpage; 3 : 1+2 */
{
if (mode & 1) {
while(onerecpage != NULL) {
struct recpage* newpage; newpage = onerecpage->next;
free(onerecpage);
onerecpage = newpage;
}
/* struct rec* oldrec;
oldrec = NULL;
currec = firstrec;
while (currec != NULL) {
oldrec = currec;
currec = currec->next;*/
/* liberation memoire pour type & ident : si scope-endscope rien a liberer
si sous-liste : type pas a liberer, ident partage aussi par l'argument sera
libere par lui ... donc ici aussi, rien a liberer. CQFD */
/* free (oldrec) ;
}*/
while (oneargpage != NULL) {
struct argpage* newpage; newpage = oneargpage->next;
free (oneargpage);
oneargpage = newpage;
}
}
if (mode & 2) {
while (onecarpage != NULL) {
struct carpage* newpage; newpage = onecarpage->next;
free (onecarpage);
onecarpage = newpage;
}
}
}
int lir_file_rec(char* *ident, char* *type, int *nbarg)
/* retourne les parametres du record courant
retour de fonction ; 1 si ok, 0 si liste epuisee */
{
if (currec == NULL) return (0) ;
/* rec_check(2) ; */
*ident = currec->ident ;
*type = currec->type ;
*nbarg = (currec->first != NULL);
curarg = currec->first ; /* prepare lecture arg.s */
return (1) ;
}
void lir_file_finrec()
/* fait le menage et passe au record suivant
ne pas appeler apres l'indication de fin mais apres chaque record ok ! */
{
currec = currec->next ;
/* rec_check(2) ; */
}
int lir_file_arg(int* type, char* *val)
/* lit l'argument courant (au debut le 1er), fait le menage, prepare suivant
retourne 1 si ok, 0 si c'est fini
attention, suppose que nbarg > 0 ... (bref, pas de protection) */
{
if (curarg == NULL) return (0) ;
*type = curarg->type ;
*val = curarg->val ;
curarg = curarg->next ;
return (1) ;
}
#ifdef __cplusplus
}
#endif
/* Verification de l'integrite des donnees */
/* Affiche ce qui ne va pas, mais aussi accede a tout : ainsi, les adresses
verolees aparaissent au grand jour du dbx */
void rec_check(int mode)
/* mode=1 pas de controle nbrec (en cours d'enregistrement) */
{
struct rec* lerec ; struct unarg* larg ; int nr,na ;
lerec = firstrec ;
if (mode == 2) lerec = currec ;
nr = 0 ;
while (lerec != NULL) {
nr ++ ;
if (lerec->ident == NULL) printf("Record %d : ident null\n",nr) ;
if (lerec->type == NULL) printf("Record %d : type null\n",nr) ;
/*if (mode < 2 && (lerec->nbarg < 0 || lerec->nbarg > 10) ) printf
("N.B.: Record %d : nbarg pas entre 0 & 10, vaut %d\n",nr,lerec->nbarg);
*/
na = 0 ;
larg = lerec->first ;
while (larg != NULL) {
na ++ ;
if (larg->type < 0 || larg->type > 9) printf
("Record %d , Arg. %d : type incorrect : %d\n",nr,na,larg->type) ;
if (larg->val == NULL) printf("Record %d , Arg %d : val null\n",nr,na) ;
larg = larg->next ;
}
/*if (na != lerec->nbarg) printf
("Record %d : arglist pourrie, nb note %d relu %d\n",nr,lerec->nbarg,na) ;*/
lerec = lerec->next ;
}
if (mode == 0 && nr != nbrec) printf
("Liste des records pourrie, nb note %d relu %d\n",nbrec,nr) ;
}

View File

@ -1,62 +0,0 @@
/*
Copyright (c) 1999-2014 OPEN CASCADE SAS
This file is part of Open CASCADE Technology software library.
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 2.1 as published
by the Free Software Foundation, with special exception defined in the file
OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
distribution for complete text of the license and disclaimer of any warranty.
Alternatively, this file may be used under the terms of Open CASCADE
commercial license or contractual agreement.
*/
#ifndef StepFile_recfile_HeaderFile
#define StepFile_recfile_HeaderFile
/*Types d'arguments (parametres) d'entites STEP (sans entrer dans le detail) */
#define rec_argSub 0
#define rec_argInteger 1
#define rec_argFloat 2
#define rec_argIdent 3
#define rec_argText 4
#define rec_argNondef 5
#define rec_argEnum 6
#define rec_argHexa 7
#define rec_argBinary 8
#define rec_argMisc 9
#ifdef __cplusplus
// Define stepFlexLexer class by inclusion of FlexLexer.h,
// but only if this has not been done yet, to avoid redefinition
#if !defined(yyFlexLexer) && !defined(FlexLexerOnce)
#define yyFlexLexer stepFlexLexer
#include <FlexLexer.h>
#endif
#include "step.tab.hxx"
namespace step
{
// To feed data back to bison, the yylex method needs yylval and
// yylloc parameters. Since the stepFlexLexer class is defined in the
// system header <FlexLexer.h> the signature of its yylex() method
// can not be changed anymore. This makes it necessary to derive a
// scanner class that provides a method with the desired signature:
class scanner : public stepFlexLexer
{
public:
explicit scanner(std::istream* in = 0, std::ostream* out = 0);
int lex(step::parser::semantic_type* /*yylval*/,
step::parser::location_type* /*yylloc*/);
};
}
#endif /* __cplusplus */
#endif // _StepFile_recfile_HeaderFile

View File

@ -37,8 +37,7 @@
}
%{
#include "step.tab.hxx"
#include "recfile.ph"
#include <step.tab.hxx>
#include "stdio.h"
// Tell flex which function to define
@ -79,12 +78,15 @@ long string in files Henri.stp and 401.stp*/
#endif /* MSC_VER */
void rec_restext(const char *constnewtext, int lentext);
void rec_typarg(int argtype);
#define CreateNewText myDataModel->CreateNewText
#define SetTypeArg myDataModel->SetTypeArg
// disable GCC warnings in flex code
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-function"
#if (__GNUC__ > 5)
#pragma GCC diagnostic ignored "-Wmisleading-indentation"
#endif
#endif
%}
%x Com End Text
@ -98,7 +100,7 @@ void rec_typarg(int argtype);
<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); rec_restext(YYText(),YYLeng()); rec_typarg(rec_argText); 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(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 */
" " {;}
" " {;}
@ -106,18 +108,18 @@ void rec_typarg(int argtype);
[\r] {;} /* abv 30.06.00: for reading DOS files */
[\0]+ {;} /* fix from C21. for test load e3i file with line 15 with null symbols */
#[0-9]+/= { rec_restext(YYText(),YYLeng()); return(token::ENTITY); }
#[0-9]+/[ ]*= { rec_restext(YYText(),YYLeng()); return(token::ENTITY); }
#[0-9]+ { rec_restext(YYText(),YYLeng()); return(token::IDENT); }
[-+0-9][0-9]* { rec_restext(YYText(),YYLeng()); rec_typarg(rec_argInteger); return(token::QUID); }
[-+\.0-9][\.0-9]+ { rec_restext(YYText(),YYLeng()); rec_typarg(rec_argFloat); return(token::QUID); }
[-+\.0-9][\.0-9]+E[-+0-9][0-9]* { rec_restext(YYText(),YYLeng()); rec_typarg(rec_argFloat); return(token::QUID); }
["][0-9A-F]+["] { rec_restext(YYText(),YYLeng()); rec_typarg(rec_argHexa); return(token::QUID); }
[.][A-Z0-9_]+[.] { rec_restext(YYText(),YYLeng()); rec_typarg(rec_argEnum); return(token::QUID); }
#[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); }
[(] { return ('('); }
[)] { return (')'); }
[,] { return (','); }
[$] { rec_restext(YYText(),YYLeng()); rec_typarg(rec_argNondef); return(token::QUID); }
[,] { myDataModel->PrepareNewArg(); return (','); }
[$] { CreateNewText(YYText(),YYLeng()); SetTypeArg(ArgumentType_Nondef); return(token::QUID); }
[=] { return ('='); }
[;] { return (';'); }
@ -133,15 +135,15 @@ void rec_typarg(int argtype);
[/] { return ('/'); }
&(?i:SCOPE) { return(token::SCOPE); }
(?i:ENDSCOPE) { return(token::ENDSCOPE); }
[a-zA-Z0-9_]+ { rec_restext(YYText(),YYLeng()); return(token::TYPE); }
![a-zA-Z0-9_]+ { rec_restext(YYText(),YYLeng()); return(token::TYPE); }
[^)] { rec_restext(YYText(),YYLeng()); rec_typarg(rec_argMisc); return(token::QUID); }
[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); }
<End>[^\n] {;} /* skip any characters (except newlines) */
%%
step::scanner::scanner(std::istream* in, std::ostream* out)
: stepFlexLexer(in, out)
step::scanner::scanner(StepFile_ReadData* theDataModel, std::istream* in, std::ostream* out)
: stepFlexLexer(in, out), myDataModel(theDataModel)
{
}

View File

@ -50,11 +50,10 @@
// Unqualified %code blocks.
#include "recfile.ph" /* definitions des types d'arguments */
#include "recfile.pc" /* la-dedans, tout y est */
#undef yylex
#define yylex scanner->lex
#define StepData scanner->myDataModel
#define stepclearin yychar = -1
#define steperrok yyerrflag = 0
@ -622,75 +621,74 @@ namespace step {
switch (yyn)
{
case 11: // stepf: stepf3
{ rec_finfile(); return(0); /* fini pour celui-la */ }
{ return(0); /* fini pour celui-la */ }
break;
case 16: // endhead: DATA
{ rec_finhead(); }
{ StepData->FinalOfHead(); }
break;
case 17: // unarg: IDENT
{ rec_typarg(rec_argIdent); rec_newarg(); }
{ StepData->SetTypeArg(ArgumentType_Ident); StepData->CreateNewArg(); }
break;
case 18: // unarg: QUID
{ /* deja fait par lex*/ rec_newarg(); }
{ /* deja fait par lex*/ StepData->CreateNewArg(); }
break;
case 19: // unarg: listarg
{ rec_newarg(); }
{ StepData->CreateNewArg(); }
break;
case 20: // unarg: listype listarg
{ rec_newarg(); }
{ StepData->CreateNewArg(); }
break;
case 21: // unarg: error
{ rec_typarg(rec_argMisc); rec_newarg();
yyerrstatus_ = 1; yyclearin; }
{ StepData->CreateErrorArg(); }
break;
case 22: // listype: TYPE
{ rec_listype(); }
{ StepData->RecordTypeText(); }
break;
case 23: // deblist: '('
{ rec_deblist(); }
{ StepData->RecordListStart(); }
break;
case 24: // finlist: ')'
{ if (modeprint > 0)
{ printf("Record no : %d -- ",nbrec+1); rec_print(currec); }
rec_newent (); yyerrstatus_ = 0; }
{ if (StepData->GetModePrint() > 0)
{ printf("Record no : %d -- ", StepData->GetNbRecord()+1); StepData->PrintCurrentRecord(); }
StepData->RecordNewEntity (); yyerrstatus_ = 0; }
break;
case 42: // debscop: SCOPE
{ scope_debut(); }
case 39: // debscop: SCOPE
{ StepData->AddNewScope(); }
break;
case 43: // unid: IDENT
{ rec_typarg(rec_argIdent); rec_newarg(); }
case 40: // unid: IDENT
{ StepData->SetTypeArg(ArgumentType_Ident); StepData->CreateNewArg(); }
break;
case 46: // debexp: '/'
{ rec_deblist(); }
case 43: // debexp: '/'
{ StepData->RecordListStart(); }
break;
case 47: // finscop: ENDSCOPE
{ scope_fin(); }
case 44: // finscop: ENDSCOPE
{ StepData->FinalOfScope(); }
break;
case 48: // finscop: ENDSCOPE debexp export '/'
case 45: // finscop: ENDSCOPE debexp export '/'
{ printf("*** Warning : Export List not yet processed\n");
rec_newent(); scope_fin() ; }
StepData->RecordNewEntity(); StepData->FinalOfScope() ; }
break;
case 49: // entlab: ENTITY
{ rec_ident(); }
case 46: // entlab: ENTITY
{ StepData->RecordIdent(); }
break;
case 50: // enttype: TYPE
{ rec_type (); }
case 47: // enttype: TYPE
{ StepData->RecordType (); }
break;
@ -884,78 +882,78 @@ namespace step {
const signed char parser::yypact_ninf_ = -24;
const signed char parser::yytable_ninf_ = -29;
const signed char parser::yytable_ninf_ = -9;
const signed char
parser::yypact_[] =
{
6, 9, -24, -24, -24, 10, 30, -24, -24, 23,
-24, 31, -24, 21, -24, 14, 23, -24, -24, 11,
25, -24, -24, 52, -24, -8, 14, 27, -24, -24,
-24, -24, -24, 21, -24, -24, 3, -24, 49, 44,
-24, -3, 55, -24, -24, 36, -24, -24, -24, 56,
45, 60, 21, 61, -24, -24, -24, 0, 21, -24,
48, 60, -4, -24, 51, -24, -24, 21, -24, -24,
62, -4, 54, -24, 57, -24, -24, -24, -10, 58,
-24, -24, 62, -24, -24, -24
26, 5, -24, -24, -24, 35, 29, -24, -24, 41,
-24, 43, -24, 36, -24, 45, 41, -24, -24, 3,
38, -24, -24, 40, -24, 32, 45, -24, -24, -24,
-24, -24, -24, 36, -24, -24, 9, -24, 60, 56,
-24, -3, 51, -24, 17, -24, -24, -24, 53, 44,
6, 36, 59, -24, 0, 36, -24, 42, 6, 2,
-24, 47, -24, -24, 36, -24, -24, 55, 2, 49,
-24, 52, -24, -24, -24, -14, 50, -24, -24, 55,
-24, -24, -24
};
const signed char
parser::yydefact_[] =
{
0, 0, 9, 10, 11, 0, 0, 1, 15, 0,
50, 0, 12, 0, 16, 0, 0, 13, 23, 0,
0, 37, 49, 0, 32, 0, 0, 21, 22, 17,
18, 24, 29, 0, 25, 19, 0, 14, 37, 0,
33, 0, 0, 20, 31, 0, 26, 7, 42, 0,
0, 0, 0, 0, 21, 30, 27, 0, 0, 34,
47, 0, 0, 40, 4, 6, 41, 0, 38, 46,
0, 0, 0, 2, 5, 39, 43, 44, 0, 0,
36, 3, 0, 48, 35, 45
47, 0, 12, 0, 16, 0, 0, 13, 23, 0,
0, 34, 46, 0, 29, 0, 0, 21, 22, 17,
18, 24, 27, 0, 25, 19, 0, 14, 34, 0,
30, 0, 0, 20, 0, 26, 7, 39, 0, 0,
0, 0, 0, 28, 0, 0, 31, 44, 0, 0,
37, 4, 6, 38, 0, 35, 43, 0, 0, 0,
2, 5, 36, 40, 41, 0, 0, 33, 3, 0,
45, 32, 42
};
const signed char
parser::yypgoto_[] =
{
-24, -24, -24, -24, -24, -24, -24, -24, 67, 64,
37, -24, -24, 28, -13, -24, -23, -21, -24, 1,
-24, -1, -24, -24, 22, -24, -5
-24, -24, -24, -24, -24, -24, -24, -24, 62, 58,
31, -24, -24, 46, -13, -24, -23, -21, -24, -6,
-24, -2, -24, -24, 18, -24, -5
};
const signed char
parser::yydefgoto_[] =
{
-1, 74, 65, 2, 3, 4, 5, 11, 12, 15,
32, 33, 19, 34, 35, 36, 23, 24, 57, 50,
51, 77, 78, 70, 62, 25, 52
-1, 71, 62, 2, 3, 4, 5, 11, 12, 15,
32, 33, 19, 34, 35, 36, 23, 24, 54, 49,
50, 74, 75, 67, 59, 25, 51
};
const signed char
parser::yytable_[] =
{
20, 13, 40, 42, 44, 48, 13, 10, 10, 1,
7, 10, 27, 6, 82, 21, 83, 41, 49, 49,
43, 40, 28, 66, 22, 29, 31, 45, 61, 14,
30, 8, 8, 18, 31, 9, 16, 54, -28, 63,
40, 10, 10, 18, 58, 68, 37, 28, -28, -8,
29, 47, 67, 38, 75, 30, 21, 39, 18, 31,
53, 21, 22, 72, 46, 22, 59, 10, 64, 60,
22, 73, 79, 56, 69, 80, 76, 81, 17, 84,
26, 85, 55, 71
20, 13, 40, 42, 27, 47, 13, 21, 10, 6,
79, 10, 80, 10, 28, 57, 22, 29, 27, 48,
43, 40, 30, 63, 48, 18, 31, 58, 28, 1,
8, 29, 31, 44, 9, 7, 30, 40, 60, 18,
10, 38, 65, 55, 8, 39, 21, 14, 16, 64,
22, 72, 21, 69, 10, 22, 52, 41, 18, 37,
-8, 22, 76, 46, 10, 56, 61, 70, 66, 73,
77, 81, 78, 17, 26, 53, 68, 82, 0, 0,
0, 0, 45
};
const signed char
parser::yycheck_[] =
{
13, 6, 23, 26, 1, 8, 11, 11, 11, 3,
0, 11, 1, 4, 24, 1, 26, 25, 22, 22,
33, 42, 11, 23, 10, 14, 23, 24, 51, 6,
19, 1, 1, 22, 23, 5, 5, 1, 11, 52,
61, 11, 11, 22, 49, 58, 21, 11, 21, 0,
14, 7, 57, 1, 67, 19, 1, 5, 22, 23,
5, 1, 10, 62, 36, 10, 21, 11, 7, 9,
10, 20, 71, 45, 26, 21, 14, 20, 11, 21,
16, 82, 45, 61
13, 6, 23, 26, 1, 8, 11, 1, 11, 4,
24, 11, 26, 11, 11, 9, 10, 14, 1, 22,
33, 42, 19, 23, 22, 22, 23, 50, 11, 3,
1, 14, 23, 24, 5, 0, 19, 58, 51, 22,
11, 1, 55, 48, 1, 5, 1, 6, 5, 54,
10, 64, 1, 59, 11, 10, 5, 25, 22, 21,
0, 10, 68, 7, 11, 21, 7, 20, 26, 14,
21, 21, 20, 11, 16, 44, 58, 79, -1, -1,
-1, -1, 36
};
const signed char
@ -965,11 +963,11 @@ namespace step {
11, 34, 35, 53, 6, 36, 5, 35, 22, 39,
41, 1, 10, 43, 44, 52, 36, 1, 11, 14,
19, 23, 37, 38, 40, 41, 42, 21, 1, 5,
44, 25, 43, 41, 1, 24, 40, 7, 8, 22,
46, 47, 53, 5, 1, 37, 40, 45, 53, 21,
9, 43, 51, 41, 7, 29, 23, 53, 41, 26,
50, 51, 46, 20, 28, 41, 14, 48, 49, 46,
21, 20, 24, 26, 21, 48
44, 25, 43, 41, 24, 40, 7, 8, 22, 46,
47, 53, 5, 37, 45, 53, 21, 9, 43, 51,
41, 7, 29, 23, 53, 41, 26, 50, 51, 46,
20, 28, 41, 14, 48, 49, 46, 21, 20, 24,
26, 21, 48
};
const signed char
@ -977,10 +975,9 @@ namespace step {
{
0, 27, 28, 28, 29, 29, 30, 31, 32, 33,
33, 33, 34, 34, 35, 35, 36, 37, 37, 37,
37, 37, 38, 39, 40, 41, 41, 41, 41, 42,
42, 42, 43, 43, 44, 44, 44, 44, 45, 45,
46, 46, 47, 48, 49, 49, 50, 51, 51, 52,
53
37, 37, 38, 39, 40, 41, 41, 42, 42, 43,
43, 44, 44, 44, 44, 45, 45, 46, 46, 47,
48, 49, 49, 50, 51, 51, 52, 53
};
const signed char
@ -988,10 +985,9 @@ namespace step {
{
0, 2, 1, 2, 1, 2, 8, 7, 6, 1,
1, 1, 1, 2, 3, 1, 1, 1, 1, 1,
2, 1, 1, 1, 1, 2, 3, 4, 2, 1,
3, 2, 1, 2, 4, 7, 6, 1, 2, 3,
2, 3, 1, 1, 1, 3, 1, 1, 4, 1,
1
2, 1, 1, 1, 1, 2, 3, 1, 3, 1,
2, 4, 7, 6, 1, 2, 3, 2, 3, 1,
1, 1, 3, 1, 1, 4, 1, 1
};
@ -1017,12 +1013,11 @@ namespace step {
const unsigned char
parser::yyrline_[] =
{
0, 71, 71, 72, 73, 74, 75, 76, 77, 78,
78, 78, 81, 82, 84, 85, 87, 90, 91, 92,
93, 94, 98, 101, 104, 109, 110, 111, 112, 114,
115, 116, 118, 119, 121, 122, 123, 124, 126, 127,
129, 130, 132, 135, 138, 139, 141, 144, 146, 151,
154
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
};
void

View File

@ -49,6 +49,7 @@
// This file is part of Open CASCADE Technology software library.
// This file is generated, do not modify it directly; edit source file step.yacc instead.
#include <StepFile_ReadData.hxx>
namespace step {
class scanner;
};
@ -809,7 +810,7 @@ namespace step {
/// Constants.
enum
{
yylast_ = 83, ///< Last index in yytable_.
yylast_ = 82, ///< Last index in yytable_.
yynnts_ = 27, ///< Number of nonterminal symbols.
yyfinal_ = 7 ///< Termination state number.
};
@ -824,6 +825,36 @@ namespace step {
} // step
// "%code provides" blocks.
// Define stepFlexLexer class by inclusion of FlexLexer.h,
// but only if this has not been done yet, to avoid redefinition
#if !defined(yyFlexLexer) && !defined(FlexLexerOnce)
#define yyFlexLexer stepFlexLexer
#include "FlexLexer.h"
#endif
namespace step {
// To feed data back to bison, the yylex method needs yylval and
// yylloc parameters. Since the stepFlexLexer class is defined in the
// system header <FlexLexer.h> the signature of its yylex() method
// can not be changed anymore. This makes it necessary to derive a
// scanner class that provides a method with the desired signature:
class scanner : public stepFlexLexer
{
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);
StepFile_ReadData* myDataModel;
};
};
#endif // !YY_STEP_STEPFILE_STEP_TAB_HXX_INCLUDED

View File

@ -35,6 +35,7 @@
// This file is part of Open CASCADE Technology software library.
// This file is generated, do not modify it directly; edit source file step.yacc instead.
#include <StepFile_ReadData.hxx>
namespace step {
class scanner;
};
@ -47,13 +48,12 @@ namespace step {
#endif
}
%code {
#include "recfile.ph" /* definitions des types d'arguments */
#include "recfile.pc" /* la-dedans, tout y est */
#undef yylex
#define yylex scanner->lex
#define StepData scanner->myDataModel
#define stepclearin yychar = -1
#define steperrok yyerrflag = 0
@ -67,6 +67,36 @@ namespace step {
void StepFile_Interrupt (char* nomfic); /* rln 13.09.00 port on HP*/
}
%code provides {
// Define stepFlexLexer class by inclusion of FlexLexer.h,
// but only if this has not been done yet, to avoid redefinition
#if !defined(yyFlexLexer) && !defined(FlexLexerOnce)
#define yyFlexLexer stepFlexLexer
#include "FlexLexer.h"
#endif
namespace step {
// To feed data back to bison, the yylex method needs yylval and
// yylloc parameters. Since the stepFlexLexer class is defined in the
// system header <FlexLexer.h> the signature of its yylex() method
// can not be changed anymore. This makes it necessary to derive a
// scanner class that provides a method with the desired signature:
class scanner : public stepFlexLexer
{
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);
StepFile_ReadData* myDataModel;
};
};
}
%%
/* N.B. : les commentaires sont filtres par LEX */
/* La fin vide (selon systeme emetteur) est filtree ici */
@ -78,7 +108,7 @@ stepf1 : STEP HEADER headl ENDSEC endhead model ENDSEC finstep ;
stepf2 : STEP HEADER ENDSEC endhead model ENDSEC ENDSTEP ;
stepf3 : STEP HEADER ENDSEC endhead model error ;
stepf : stepf1 | stepf2 | stepf3
{ rec_finfile(); return(0); /* fini pour celui-la */ }
{ return(0); /* fini pour celui-la */ }
;
headl : headent
| headl headent
@ -87,35 +117,31 @@ headent : enttype listarg ';'
| error /* Erreur sur Entite : la sauter */
;
endhead : DATA
{ rec_finhead(); }
{ StepData->FinalOfHead(); }
;
unarg : IDENT { rec_typarg(rec_argIdent); rec_newarg(); }
| QUID { /* deja fait par lex*/ rec_newarg(); }
| listarg /* rec_newent lors du ')' */ { rec_newarg(); }
| listype listarg /* liste typee */ { rec_newarg(); }
| error { rec_typarg(rec_argMisc); rec_newarg();
yyerrstatus_ = 1; yyclearin; }
unarg : IDENT { StepData->SetTypeArg(ArgumentType_Ident); StepData->CreateNewArg(); }
| QUID { /* deja fait par lex*/ StepData->CreateNewArg(); }
| listarg /* rec_newent lors du ')' */ { StepData->CreateNewArg(); }
| listype listarg /* liste typee */ { StepData->CreateNewArg(); }
| error { StepData->CreateErrorArg(); }
/* Erreur sur Parametre : tacher de le noter sans jeter l'Entite */
;
listype : TYPE
{ rec_listype(); }
{ StepData->RecordTypeText(); }
;
deblist : '('
{ rec_deblist(); }
{ StepData->RecordListStart(); }
;
finlist : ')'
{ if (modeprint > 0)
{ printf("Record no : %d -- ",nbrec+1); rec_print(currec); }
rec_newent (); yyerrstatus_ = 0; }
{ if (StepData->GetModePrint() > 0)
{ printf("Record no : %d -- ", StepData->GetNbRecord()+1); StepData->PrintCurrentRecord(); }
StepData->RecordNewEntity (); yyerrstatus_ = 0; }
;
listarg : deblist finlist /* liste vide (peut y en avoir) */
| deblist arglist finlist /* liste normale, non vide */
| deblist arglist ',' finlist /* broken list with missing last parameter, see #31756 */
| deblist error
;
arglist : unarg
| arglist ',' unarg
| arglist error
;
model : bloc
| model bloc
@ -132,29 +158,29 @@ unent : enttype listarg /* Entite de Type Simple */
| '(' plex ')' /* Entite de Type Complexe */
;
debscop : SCOPE
{ scope_debut(); }
{ StepData->AddNewScope(); }
;
unid : IDENT
{ rec_typarg(rec_argIdent); rec_newarg(); }
{ StepData->SetTypeArg(ArgumentType_Ident); StepData->CreateNewArg(); }
;
export : unid
| export ',' unid
;
debexp : '/'
{ rec_deblist(); }
{ StepData->RecordListStart(); }
;
finscop : ENDSCOPE
{ scope_fin(); }
{ StepData->FinalOfScope(); }
| ENDSCOPE debexp export '/'
{ printf("*** Warning : Export List not yet processed\n");
rec_newent(); scope_fin() ; }
StepData->RecordNewEntity(); StepData->FinalOfScope() ; }
/* La liste Export est prise comme ARGUMENT du EndScope */
;
entlab : ENTITY
{ rec_ident(); }
{ StepData->RecordIdent(); }
;
enttype : TYPE
{ rec_type (); }
{ StepData->RecordType (); }
;
%%

View File

@ -1,46 +0,0 @@
/*
Copyright (c) 1999-2014 OPEN CASCADE SAS
This file is part of Open CASCADE Technology software library.
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 2.1 as published
by the Free Software Foundation, with special exception defined in the file
OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
distribution for complete text of the license and disclaimer of any warranty.
Alternatively, this file may be used under the terms of Open CASCADE
commercial license or contractual agreement.
*/
/*
pdn PRO16162: do restart in order to restore after possible crash or wrong data
rln 10.01.99 - transmission of define's into this file
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <iostream>
#include "recfile.ph"
void rec_debfile();
void rec_finfile();
/*
Lecture d'un fichier ia grammaire lex-yacc
Appel : i = stepread() ; i est la valeur retournee par yyparse
(0 si OK, 1 si erreur)
*/
int stepread(std::istream& theStream)
{
int aLetat = 0;
rec_debfile();
step::scanner aScanner(&theStream);
aScanner.yyrestart(theStream);
step::parser aParser(&aScanner);
aLetat = aParser.parse();
rec_finfile();
return aLetat;
}

View File

@ -1,39 +0,0 @@
/*
Copyright (c) 1999-2014 OPEN CASCADE SAS
This file is part of Open CASCADE Technology software library.
This library is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License version 2.1 as published
by the Free Software Foundation, with special exception defined in the file
OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
distribution for complete text of the license and disclaimer of any warranty.
Alternatively, this file may be used under the terms of Open CASCADE
commercial license or contractual agreement.
*/
// stepread.h
/* lecture du fichier STEP (par appel a lex+yac) */
#include <iostream>
#ifdef __cplusplus
extern "C" {
#endif
void recfile_modeprint (int mode) ; /* controle trace recfile */
/* creation du Direc a partir de recfile : entrys connues de c++ */
void lir_file_nbr(int* nbh, int* nbr, int* nbp) ;
int lir_file_rec(char* *ident , char* *type , int* nbarg) ;
void lir_file_finrec() ;
int lir_file_arg(int* type , char* *val) ;
void lir_file_fin(int mode);
/* Interruption passant par C++ */
#ifdef __cplusplus
}
#endif
int stepread(std::istream& theStream);
void StepFile_Interrupt (char* theNomfic);

19
tests/bugs/step/bug31756 Normal file
View File

@ -0,0 +1,19 @@
puts "================"
puts "0031756: Data Exchange - broken parsing of STEP entity in case of missing last parameter"
puts "================"
puts ""
pload OCAF
stepread [locate_data_file bug26451_Test_STEP.stp] a *
set entityInfo1 [ entity #71919 ]
if { [regexp "'',83477:#84041,83477:#84041,#0,#0" $entityInfo1] != 1 } {
puts "Error : wrong arguments of parsed record"
}
set entityInfo2 [ entity #71920 ]
if { [regexp "71356:#71920 = FILL_AREA_STYLE" $entityInfo2] != 1 } {
puts "Error : wrong record, parser skip record"
}