1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0027342: STEP - support C++ streams for import / export

- STEP low-level parser is converted to C++; required minimal version of flex is elevated to 2.5.37.
- Added possibility to import STEP from stream, see new method XSControl_Reader::ReadStream() (now implemented in STEP only).
- Parsers ported to win_flex_bison 2.5.23 (flex 2.6.4, bison 3.7.1)
- Added support of C++ flex and bison scanners in in CMake scripts
- Some code clean-up in StepFile and around (unused files and functions are eliminated)
- Option to read from stream is added in DRAW command testreadstep for testing ReadStream() function
- Added test bugs step bug27342
This commit is contained in:
imn 2016-04-06 16:09:55 +03:00 committed by bugmaster
parent ed75148574
commit 68922bccc4
38 changed files with 7084 additions and 5973 deletions

View File

@ -7,7 +7,7 @@ unset (3RDPARTY_BISON_EXECUTABLE CACHE)
# delete BISON_EXECUTABLE cache variable if it is empty, otherwise find_package will fail
# without reasonable diagnostic
if (NOT BISON_EXECUTABLE)
if (NOT BISON_EXECUTABLE OR NOT EXISTS "${BISON_EXECUTABLE}")
unset (BISON_EXECUTABLE CACHE)
endif()
@ -22,8 +22,6 @@ if (3RDPARTY_DIR)
endforeach()
endif()
find_package (BISON 2.7)
if (NOT BISON_FOUND OR NOT BISON_EXECUTABLE OR NOT EXISTS "${BISON_EXECUTABLE}")
list (APPEND 3RDPARTY_NOT_INCLUDED BISON_EXECUTABLE)
endif()
# bison 3.2 is required because it provides options to avoid generation of redundant header
# files and embedding of local paths in the generated code
find_package (BISON 3.2)

View File

@ -7,23 +7,29 @@ unset (3RDPARTY_FLEX_EXECUTABLE CACHE)
# delete FLEX_EXECUTABLE cache variable if it is empty, otherwise find_package will fail
# without reasonable diagnostic
if (NOT FLEX_EXECUTABLE)
if (NOT FLEX_EXECUTABLE OR NOT EXISTS "${FLEX_EXECUTABLE}")
unset (FLEX_EXECUTABLE CACHE)
endif()
if (NOT FLEX_INCLUDE_DIR OR NOT EXISTS "${FLEX_INCLUDE_DIR}")
unset (FLEX_INCLUDE_DIR CACHE)
endif()
# Add paths to 3rdparty subfolders containing name "flex" to CMAKE_PROGRAM_PATH variable to make
# these paths searhed by find_package
# Add paths to 3rdparty subfolders containing name "flex" to CMAKE_PROGRAM_PATH and
# CMAKE_INCLUDE_PATH variables to make these paths searhed by find_package
if (3RDPARTY_DIR)
file (GLOB FLEX_PATHS LIST_DIRECTORIES true "${3RDPARTY_DIR}/*flex*")
foreach (candidate_path ${FLEX_PATHS})
if (IS_DIRECTORY ${candidate_path})
list (APPEND CMAKE_PROGRAM_PATH ${candidate_path})
list (APPEND CMAKE_INCLUDE_PATH ${candidate_path})
endif()
endforeach()
endif()
find_package (FLEX 2.5.3)
# flex 2.5.37 is required because closest known lower version, 2.5.3 from WOK 6.8.0,
# generates code which is unusable on Windows (includes unistd.h without any way to avoid this)
find_package (FLEX 2.5.37)
if (NOT FLEX_FOUND OR NOT FLEX_EXECUTABLE OR NOT EXISTS "${FLEX_EXECUTABLE}")
list (APPEND 3RDPARTY_NOT_INCLUDED FLEX_EXECUTABLE)
endif()
if (NOT FLEX_FOUND OR NOT FLEX_INCLUDE_DIR OR NOT EXISTS "${FLEX_INCLUDE_DIR}/FlexLexer.h")
list (APPEND 3RDPARTY_NOT_INCLUDED FLEX_INCLUDE_DIR)
endif()

View File

@ -91,10 +91,40 @@ foreach (OCCT_PACKAGE ${USED_PACKAGES})
string (COMPARE EQUAL ${CURRENT_FLEX_FILE_NAME} ${CURRENT_BISON_FILE_NAME} ARE_FILES_EQUAL)
if (EXISTS "${CURRENT_FLEX_FILE}" AND EXISTS "${CURRENT_BISON_FILE}" AND ${ARE_FILES_EQUAL})
set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.c)
set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.c)
BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${BISON_OUTPUT_FILE} COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME} -l")
FLEX_TARGET (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}/${FLEX_OUTPUT_FILE} COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME} -L")
# Note: files are generated in original source directory (not in patch!)
set (FLEX_BISON_TARGET_DIR "${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/${OCCT_PACKAGE}")
# choose apropriate extension for generated files: "cxx" if source file contains
# instruction to generate C++ code, "c" otherwise
set (BISON_OUTPUT_FILE_EXT "c")
set (FLEX_OUTPUT_FILE_EXT "c")
file (STRINGS "${CURRENT_BISON_FILE}" FILE_BISON_CONTENT)
foreach (FILE_BISON_CONTENT_LINE ${FILE_BISON_CONTENT})
string (REGEX MATCH "%language \"C\\+\\+\"" CXX_BISON_LANGUAGE_FOUND ${FILE_BISON_CONTENT_LINE})
if (CXX_BISON_LANGUAGE_FOUND)
set (BISON_OUTPUT_FILE_EXT "cxx")
endif()
endforeach()
file (STRINGS "${CURRENT_FLEX_FILE}" FILE_FLEX_CONTENT)
foreach (FILE_FLEX_CONTENT_LINE ${FILE_FLEX_CONTENT})
string (REGEX MATCH "%option c\\+\\+" CXX_FLEX_LANGUAGE_FOUND ${FILE_FLEX_CONTENT_LINE})
if (CXX_FLEX_LANGUAGE_FOUND)
set (FLEX_OUTPUT_FILE_EXT "cxx")
# install copy of FlexLexer.h locally to allow further building without flex
if (FLEX_INCLUDE_DIR AND EXISTS "${FLEX_INCLUDE_DIR}/FlexLexer.h")
configure_file("${FLEX_INCLUDE_DIR}/FlexLexer.h" "${FLEX_BISON_TARGET_DIR}/FlexLexer.h" @ONLY NEWLINE_STYLE LF)
endif()
endif()
endforeach()
set (BISON_OUTPUT_FILE ${CURRENT_BISON_FILE_NAME}.tab.${BISON_OUTPUT_FILE_EXT})
set (FLEX_OUTPUT_FILE lex.${CURRENT_FLEX_FILE_NAME}.${FLEX_OUTPUT_FILE_EXT})
BISON_TARGET (Parser_${CURRENT_BISON_FILE_NAME} ${CURRENT_BISON_FILE} "${FLEX_BISON_TARGET_DIR}/${BISON_OUTPUT_FILE}"
COMPILE_FLAGS "-p ${CURRENT_BISON_FILE_NAME} -l -M ${CMAKE_SOURCE_DIR}/${RELATIVE_SOURCES_DIR}/=")
FLEX_TARGET (Scanner_${CURRENT_FLEX_FILE_NAME} ${CURRENT_FLEX_FILE} "${FLEX_BISON_TARGET_DIR}/${FLEX_OUTPUT_FILE}"
COMPILE_FLAGS "-P${CURRENT_FLEX_FILE_NAME} -L")
ADD_FLEX_BISON_DEPENDENCY (Scanner_${CURRENT_FLEX_FILE_NAME} Parser_${CURRENT_BISON_FILE_NAME})
list (APPEND SOURCE_FILES ${BISON_OUTPUT_FILE} ${FLEX_OUTPUT_FILE})

File diff suppressed because it is too large Load Diff

View File

@ -1,19 +1,20 @@
/* A Bison parser, made by GNU Bison 2.7. */
/* A Bison parser, made by GNU Bison 3.7.1. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2015, 2018-2020 Free Software Foundation,
Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
@ -26,13 +27,17 @@
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_EXPRINTRP_D_ABV_OCCT_OCCT_SRC_EXPRINTRP_EXPRINTRP_TAB_H_INCLUDED
# define YY_EXPRINTRP_D_ABV_OCCT_OCCT_SRC_EXPRINTRP_EXPRINTRP_TAB_H_INCLUDED
/* Enabling traces. */
/* DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
especially those whose name start with YY_ or yy_. They are
private implementation details that can be changed or removed. */
#ifndef YY_EXPRINTRP_EXPRINTRP_EXPRINTRP_TAB_H_INCLUDED
# define YY_EXPRINTRP_EXPRINTRP_EXPRINTRP_TAB_H_INCLUDED
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
@ -40,59 +45,51 @@
extern int ExprIntrpdebug;
#endif
/* Tokens. */
/* Token kinds. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
SUMOP = 258,
MINUSOP = 259,
DIVIDEOP = 260,
EXPOP = 261,
MULTOP = 262,
PARENTHESIS = 263,
BRACKET = 264,
ENDPARENTHESIS = 265,
ENDBRACKET = 266,
VALUE = 267,
IDENTIFIER = 268,
COMMA = 269,
DIFFERENTIAL = 270,
DERIVATE = 271,
DERIVKEY = 272,
ASSIGNOP = 273,
DEASSIGNKEY = 274,
EQUALOP = 275,
RELSEPARATOR = 276,
CONSTKEY = 277,
SUMKEY = 278,
PRODKEY = 279
};
enum yytokentype
{
YYEMPTY = -2,
YYEOF = 0, /* "end of file" */
YYerror = 256, /* error */
YYUNDEF = 257, /* "invalid token" */
SUMOP = 258, /* SUMOP */
MINUSOP = 259, /* MINUSOP */
DIVIDEOP = 260, /* DIVIDEOP */
EXPOP = 261, /* EXPOP */
MULTOP = 262, /* MULTOP */
PARENTHESIS = 263, /* PARENTHESIS */
BRACKET = 264, /* BRACKET */
ENDPARENTHESIS = 265, /* ENDPARENTHESIS */
ENDBRACKET = 266, /* ENDBRACKET */
VALUE = 267, /* VALUE */
IDENTIFIER = 268, /* IDENTIFIER */
COMMA = 269, /* COMMA */
DIFFERENTIAL = 270, /* DIFFERENTIAL */
DERIVATE = 271, /* DERIVATE */
DERIVKEY = 272, /* DERIVKEY */
ASSIGNOP = 273, /* ASSIGNOP */
DEASSIGNKEY = 274, /* DEASSIGNKEY */
EQUALOP = 275, /* EQUALOP */
RELSEPARATOR = 276, /* RELSEPARATOR */
CONSTKEY = 277, /* CONSTKEY */
SUMKEY = 278, /* SUMKEY */
PRODKEY = 279 /* PRODKEY */
};
typedef enum yytokentype yytoken_kind_t;
#endif
/* Value type. */
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE ExprIntrplval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int ExprIntrpparse (void *YYPARSE_PARAM);
#else
int ExprIntrpparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int ExprIntrpparse (void);
#else
int ExprIntrpparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_EXPRINTRP_D_ABV_OCCT_OCCT_SRC_EXPRINTRP_EXPRINTRP_TAB_H_INCLUDED */
#endif /* !YY_EXPRINTRP_EXPRINTRP_EXPRINTRP_TAB_H_INCLUDED */

View File

@ -1,4 +1,3 @@
/*
/* Copyright (c) 1997-1999 Matra Datavision
Copyright (c) 1999-2014 OPEN CASCADE SAS

File diff suppressed because it is too large Load Diff

View File

@ -87,3 +87,12 @@ IFSelect_WorkLibrary::IFSelect_WorkLibrary () { thelevdef = 0; }
if (str.IsNull()) return "";
return str->ToCString();
}
Standard_Integer IFSelect_WorkLibrary::ReadStream(const Standard_CString /*name*/,
std::istream& /*istream*/,
Handle(Interface_InterfaceModel)& /*model*/,
const Handle(Interface_Protocol)& /*protocol*/) const
{
return 1;
}

View File

@ -61,6 +61,16 @@ public:
//! and recognize the Entities)
Standard_EXPORT virtual Standard_Integer ReadFile (const Standard_CString name, Handle(Interface_InterfaceModel)& model, const Handle(Interface_Protocol)& protocol) const = 0;
//! Interface to read a data from the specified stream.
//! @param model is the resulting Model, which has to be created by this method.
//! In case of error, model must be returned Null
//! Return value is a status: 0 - OK, 1 - read failure, -1 - stream failure.
//!
//! Default implementation returns 1 (error).
Standard_EXPORT virtual Standard_Integer ReadStream (const Standard_CString theName, std::istream& theIStream,
Handle(Interface_InterfaceModel)& model,
const Handle(Interface_Protocol)& protocol) const;
//! Gives the way to Write a File from a Model.
//! <ctx> contains all necessary informations : the model, the
//! protocol, the file name, and the list of File Modifiers to be

View File

@ -207,8 +207,7 @@ void IFSelect_WorkSession::SetModel
//purpose :
//=======================================================================
IFSelect_ReturnStatus IFSelect_WorkSession::ReadFile
(const Standard_CString filename)
IFSelect_ReturnStatus IFSelect_WorkSession::ReadFile(const Standard_CString filename)
{
if (thelibrary.IsNull()) return IFSelect_RetVoid;
if (theprotocol.IsNull()) return IFSelect_RetVoid;
@ -216,7 +215,7 @@ IFSelect_ReturnStatus IFSelect_WorkSession::ReadFile
IFSelect_ReturnStatus status = IFSelect_RetVoid;
try {
OCC_CATCH_SIGNALS
Standard_Integer stat = thelibrary->ReadFile (filename,model,theprotocol);
Standard_Integer stat = thelibrary->ReadFile(filename, model, theprotocol);
if (stat == 0) status = IFSelect_RetDone;
else if (stat < 0) status = IFSelect_RetError;
else status = IFSelect_RetFail;
@ -235,6 +234,39 @@ IFSelect_ReturnStatus IFSelect_WorkSession::ReadFile
return status;
}
//=======================================================================
//function :
//purpose :
//=======================================================================
IFSelect_ReturnStatus IFSelect_WorkSession::ReadStream(const Standard_CString theName,
std::istream& theIStream)
{
if (thelibrary.IsNull()) return IFSelect_RetVoid;
if (theprotocol.IsNull()) return IFSelect_RetVoid;
Handle(Interface_InterfaceModel) model;
IFSelect_ReturnStatus status = IFSelect_RetVoid;
try {
OCC_CATCH_SIGNALS
Standard_Integer stat = thelibrary->ReadStream(theName, theIStream, model, theprotocol);
if (stat == 0) status = IFSelect_RetDone;
else if (stat < 0) status = IFSelect_RetError;
else status = IFSelect_RetFail;
}
catch (Standard_Failure const& anException) {
Message_Messenger::StreamBuffer sout = Message::SendInfo();
sout << " **** Interruption ReadFile par Exception : ****\n";
sout << anException.GetMessageString();
sout << "\n Abandon" << std::endl;
status = IFSelect_RetFail;
}
if (status != IFSelect_RetDone) return status;
if (model.IsNull()) return IFSelect_RetVoid;
SetModel(model);
SetLoadedFile(theName);
return status;
}
//=======================================================================
//function :

View File

@ -170,6 +170,12 @@ public:
//! RetDone if OK, RetVoid if no Protocol not defined,
//! RetError for file not found, RetFail if fail during read
Standard_EXPORT IFSelect_ReturnStatus ReadFile (const Standard_CString filename);
//! Reads a file from stream with the WorkLibrary (sets Model and LoadedFile)
//! Returns a integer status which can be :
//! RetDone if OK, RetVoid if no Protocol not defined,
//! RetError for file not found, RetFail if fail during read
Standard_EXPORT IFSelect_ReturnStatus ReadStream (const Standard_CString theName, std::istream& theIStream);
//! Returns the count of Entities stored in the Model, or 0
Standard_EXPORT Standard_Integer NbStartingEntities() const;

View File

@ -1,15 +1,13 @@
lex.step.c
lex.step.cxx
recfile.pc
recfile.ph
step.tab.c
step.tab.h
StepFile_CallFailure.cxx
StepFile_CallFailure.hxx
step.tab.cxx
step.tab.hxx
StepFile_Read.cxx
StepFile_Read.hxx
StepFile_Transfer.hxx
stepread.c
stepread.cxx
stepread.ph
step.lex
step.yacc
FlexLexer.h
location.hh

220
src/StepFile/FlexLexer.h Normal file
View File

@ -0,0 +1,220 @@
// -*-C++-*-
// FlexLexer.h -- define interfaces for lexical analyzer classes generated
// by flex
// Copyright (c) 1993 The Regents of the University of California.
// All rights reserved.
//
// This code is derived from software contributed to Berkeley by
// Kent Williams and Tom Epperly.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions
// are met:
// 1. Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright
// notice, this list of conditions and the following disclaimer in the
// documentation and/or other materials provided with the distribution.
// Neither the name of the University nor the names of its contributors
// may be used to endorse or promote products derived from this software
// without specific prior written permission.
// THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
// IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
// PURPOSE.
// This file defines FlexLexer, an abstract class which specifies the
// external interface provided to flex C++ lexer objects, and yyFlexLexer,
// which defines a particular lexer class.
//
// If you want to create multiple lexer classes, you use the -P flag
// to rename each yyFlexLexer to some other xxFlexLexer. You then
// include <FlexLexer.h> in your other sources once per lexer class:
//
// #undef yyFlexLexer
// #define yyFlexLexer xxFlexLexer
// #include <FlexLexer.h>
//
// #undef yyFlexLexer
// #define yyFlexLexer zzFlexLexer
// #include <FlexLexer.h>
// ...
#ifndef __FLEX_LEXER_H
// Never included before - need to define base class.
#define __FLEX_LEXER_H
#include <iostream>
extern "C++" {
struct yy_buffer_state;
typedef int yy_state_type;
class FlexLexer
{
public:
virtual ~FlexLexer() { }
const char* YYText() const { return yytext; }
int YYLeng() const { return yyleng; }
virtual void
yy_switch_to_buffer( yy_buffer_state* new_buffer ) = 0;
virtual yy_buffer_state* yy_create_buffer( std::istream* s, int size ) = 0;
virtual yy_buffer_state* yy_create_buffer( std::istream& s, int size ) = 0;
virtual void yy_delete_buffer( yy_buffer_state* b ) = 0;
virtual void yyrestart( std::istream* s ) = 0;
virtual void yyrestart( std::istream& s ) = 0;
virtual int yylex() = 0;
// Call yylex with new input/output sources.
int yylex( std::istream& new_in, std::ostream& new_out )
{
switch_streams( new_in, new_out );
return yylex();
}
int yylex( std::istream* new_in, std::ostream* new_out = 0)
{
switch_streams( new_in, new_out );
return yylex();
}
// Switch to new input/output streams. A nil stream pointer
// indicates "keep the current one".
virtual void switch_streams( std::istream* new_in,
std::ostream* new_out ) = 0;
virtual void switch_streams( std::istream& new_in,
std::ostream& new_out ) = 0;
int lineno() const { return yylineno; }
int debug() const { return yy_flex_debug; }
void set_debug( int flag ) { yy_flex_debug = flag; }
protected:
char* yytext;
int yyleng;
int yylineno; // only maintained if you use %option yylineno
int yy_flex_debug; // only has effect with -d or "%option debug"
};
}
#endif // FLEXLEXER_H
#if defined(yyFlexLexer) || ! defined(yyFlexLexerOnce)
// Either this is the first time through (yyFlexLexerOnce not defined),
// or this is a repeated include to define a different flavor of
// yyFlexLexer, as discussed in the flex manual.
# define yyFlexLexerOnce
extern "C++" {
class yyFlexLexer : public FlexLexer {
public:
// arg_yyin and arg_yyout default to the cin and cout, but we
// only make that assignment when initializing in yylex().
yyFlexLexer( std::istream& arg_yyin, std::ostream& arg_yyout );
yyFlexLexer( std::istream* arg_yyin = 0, std::ostream* arg_yyout = 0 );
private:
void ctor_common();
public:
virtual ~yyFlexLexer();
void yy_switch_to_buffer( yy_buffer_state* new_buffer );
yy_buffer_state* yy_create_buffer( std::istream* s, int size );
yy_buffer_state* yy_create_buffer( std::istream& s, int size );
void yy_delete_buffer( yy_buffer_state* b );
void yyrestart( std::istream* s );
void yyrestart( std::istream& s );
void yypush_buffer_state( yy_buffer_state* new_buffer );
void yypop_buffer_state();
virtual int yylex();
virtual void switch_streams( std::istream& new_in, std::ostream& new_out );
virtual void switch_streams( std::istream* new_in = 0, std::ostream* new_out = 0 );
virtual int yywrap();
protected:
virtual int LexerInput( char* buf, int max_size );
virtual void LexerOutput( const char* buf, int size );
virtual void LexerError( const char* msg );
void yyunput( int c, char* buf_ptr );
int yyinput();
void yy_load_buffer_state();
void yy_init_buffer( yy_buffer_state* b, std::istream& s );
void yy_flush_buffer( yy_buffer_state* b );
int yy_start_stack_ptr;
int yy_start_stack_depth;
int* yy_start_stack;
void yy_push_state( int new_state );
void yy_pop_state();
int yy_top_state();
yy_state_type yy_get_previous_state();
yy_state_type yy_try_NUL_trans( yy_state_type current_state );
int yy_get_next_buffer();
std::istream yyin; // input source for default LexerInput
std::ostream yyout; // output sink for default LexerOutput
// yy_hold_char holds the character lost when yytext is formed.
char yy_hold_char;
// Number of characters read into yy_ch_buf.
int yy_n_chars;
// Points to current character in buffer.
char* yy_c_buf_p;
int yy_init; // whether we need to initialize
int yy_start; // start state number
// Flag which is used to allow yywrap()'s to do buffer switches
// instead of setting up a fresh yyin. A bit of a hack ...
int yy_did_buffer_switch_on_eof;
size_t yy_buffer_stack_top; /**< index of top of stack. */
size_t yy_buffer_stack_max; /**< capacity of stack. */
yy_buffer_state ** yy_buffer_stack; /**< Stack as an array. */
void yyensure_buffer_stack(void);
// The following are not always needed, but may be depending
// on use of certain flex features (like REJECT or yymore()).
yy_state_type yy_last_accepting_state;
char* yy_last_accepting_cpos;
yy_state_type* yy_state_buf;
yy_state_type* yy_state_ptr;
char* yy_full_match;
int* yy_full_state;
int yy_full_lp;
int yy_lp;
int yy_looking_for_trail_begin;
int yy_more_flag;
int yy_more_len;
int yy_more_offset;
int yy_prev_more_offset;
};
}
#endif // yyFlexLexer || ! yyFlexLexerOnce

View File

@ -1,22 +0,0 @@
// Created on: 2002-02-05
// Created by: Sergey KUUL
// Copyright (c) 2002-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 <Standard_Failure.hxx>
#include <StepFile_CallFailure.hxx>
void StepFile_CallFailure(char * const message)
{
throw Standard_Failure(message);
}

View File

@ -1,17 +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.
#ifdef __cplusplus
extern "C"
#endif
void StepFile_CallFailure(char * const message);

View File

@ -25,12 +25,10 @@
// Compilation conditionnelle : concerne les mesures de performances
#include <stdio.h>
#include <iostream>
#include "recfile.ph"
#include "stepread.ph"
extern "C" void recfile_modeprint (int mode); // controle trace recfile
// recfile_modeprint est declare a part
#include <Interface_ParamType.hxx>
#include <Interface_Protocol.hxx>
@ -48,15 +46,17 @@ extern "C" void recfile_modeprint (int mode); // controle trace recfile
#include <Message_Messenger.hxx>
#include <Message.hxx>
#include <OSD_OpenFile.hxx>
#include <OSD_Timer.hxx>
#ifdef OCCT_DEBUG
#define CHRONOMESURE
#ifdef CHRONOMESURE
# include <OSD_Timer.hxx>
#endif
#endif
// ## ## ## ## ON SAURA AU MOINS TRAITER UndefinedEntity ## ## ## ##
extern "C" void recfile_modeprint (int mode); // controle trace recfile
static Handle(Interface_Check) checkread = new Interface_Check;
static Standard_Integer modepr = 1;
@ -65,95 +65,67 @@ void StepFile_ReadTrace (const Standard_Integer mode)
modepr = mode; // recfile_modeprint est rappele a chaque lecture de fichier
}
static Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_Protocol)& protocol,
const Handle(StepData_FileRecognizer)& recoheader,
const Handle(StepData_FileRecognizer)& recodata);
Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_FileRecognizer)& recoheader,
const Handle(StepData_FileRecognizer)& recodata)
{
return StepFile_Read
(nomfic,stepmodel,
Handle(StepData_Protocol)::DownCast(Interface_Protocol::Active()),
recoheader,recodata);
}
Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_FileRecognizer)& recoheader,
const Handle(StepData_Protocol)& protocol)
{
Handle(StepData_FileRecognizer) nulreco;
return StepFile_Read (nomfic,stepmodel,protocol,recoheader,nulreco);
}
Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_Protocol)& protocol)
{
Handle(StepData_FileRecognizer) nulreco;
return StepFile_Read (nomfic,stepmodel,protocol,nulreco,nulreco);
}
// ## ## ## ## ## ## Corps de la Routine ## ## ## ## ## ##
static Interface_ParamType LesTypes[10]; // passage types (recstep/Interface)
Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_Protocol)& protocol,
const Handle(StepData_FileRecognizer)& recoheader,
const Handle(StepData_FileRecognizer)& recodata)
static Standard_Integer StepFile_Read (const char* theName,
std::istream* theIStream,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_Protocol)& protocol,
const Handle(StepData_FileRecognizer)& recoheader,
const Handle(StepData_FileRecognizer)& recodata)
{
Message_Messenger::StreamBuffer sout = Message::SendInfo();
char *ficnom = nomfic ; // because const (non reconnu par C)
checkread->Clear();
recfile_modeprint ( (modepr > 0 ? modepr-1 : 0) );
FILE* newin = stepread_setinput(ficnom);
if (!newin) return -1;
// if stream is not provided, open file stream here
std::istream *aStreamPtr = theIStream;
std::ifstream aFileStream;
if (!aStreamPtr) {
OSD_OpenStream(aFileStream, theName, std::ios_base::in | std::ios_base::binary);
aStreamPtr = &aFileStream;
}
if (aStreamPtr->bad())
{
return -1;
}
#ifdef CHRONOMESURE
Standard_Integer n ;
OSD_Timer c ;
c.Reset () ;
OSD_Timer c;
c.Reset();
c.Start();
sout << " ... Step File Reading : " << ficnom << "" << std::endl;
Message::SendInfo() << " ... Step File Reading : '" << theName << "'";
#endif
try {
OCC_CATCH_SIGNALS
if (stepread () != 0) { lir_file_fin(3); stepread_endinput (newin,ficnom); return 1; }
if (stepread(*aStreamPtr) != 0) {
lir_file_fin(3);
return 1;
}
}
catch (Standard_Failure const& anException) {
#ifdef OCCT_DEBUG
sout << " ... Exception Raised while reading Step File : " << ficnom << ":\n" << std::endl;
sout << anException.GetMessageString();
sout << " ..." << std::endl;
Message::SendAlarm() << " ... Exception Raised while reading Step File : '" << theName << "':\n"
<< anException.GetMessageString()
<< " ...";
#endif
(void)anException;
lir_file_fin(3);
stepread_endinput (newin,ficnom);
return 1;
}
// Continue reading of file despite of possible fails
//if (checkread->HasFailed()) { lir_file_fin(3); stepread_endinput (newin,ficnom); return 1; }
#ifdef CHRONOMESURE
sout << " ... STEP File Read ... " << std::endl;
c.Show();
#endif
// Continue reading of file despite of possible fails
// if (checkread->HasFailed()) { lir_file_fin(3); stepread_endinput(newifstream, ficnom); return 1; }
#ifdef CHRONOMESURE
{
Message_Messenger::StreamBuffer sout = Message::SendInfo();
sout << " ... STEP File Read ...\n";
c.Show (sout);
}
#endif
// Creation du StepReaderData
@ -193,10 +165,12 @@ Standard_Integer StepFile_Read
// on a undirec pret pour la suite
#ifdef CHRONOMESURE
sout << " ... Step File loaded ... " << std::endl;
c.Show();
sout << " "<< undirec->NbRecords () <<
" records (entities,sub-lists,scopes), "<< nbpar << " parameters\n" << std::endl;
{
Message_Messenger::StreamBuffer sout = Message::SendInfo();
sout << " ... Step File loaded ...\n";
c.Show (sout);
sout << " "<< undirec->NbRecords() << " records (entities,sub-lists,scopes), "<< nbpar << " parameters";
}
#endif
// Analyse : par StepReaderTool
@ -208,8 +182,11 @@ Standard_Integer StepFile_Read
readtool.Prepare(recodata); // Data. reco nul -> pour Protocol
#ifdef CHRONOMESURE
sout << " ... Parameters prepared ... ";
c.Show();
{
Message_Messenger::StreamBuffer sout = Message::SendInfo();
sout << " ... Parameters prepared ...\n";
c.Show (sout);
}
#endif
readtool.LoadModel(stepmodel);
@ -219,13 +196,24 @@ Standard_Integer StepFile_Read
readtool.Clear();
undirec.Nullify();
#ifdef CHRONOMESURE
sout << " ... Objets analysed ... " << std::endl;
c.Show();
n = stepmodel->NbEntities() ;
sout << " STEP Loading done : " << n << " Entities" << std::endl;
{
Message_Messenger::StreamBuffer sout = Message::SendInfo();
sout << " ... Objets analysed ...\n";
c.Show (sout);
Standard_Integer n = stepmodel->NbEntities();
sout << " STEP Loading done : " << n << " Entities";
}
#endif
stepread_endinput (newin,ficnom); return 0 ;
return 0;
}
Standard_Integer StepFile_Read(const char* theName,
std::istream* theIStream,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_Protocol)& protocol)
{
Handle(StepData_FileRecognizer) nulreco;
return StepFile_Read (theName,theIStream,stepmodel,protocol,nulreco,nulreco);
}
void StepFile_Interrupt (char* mess)

View File

@ -27,30 +27,24 @@
#ifndef StepFile_Read_HeaderFile
#define StepFile_Read_HeaderFile
#include <iostream>
//# include <stepread.h> : sauf recfile_modeprint, declare ici
# include <StepData_StepModel.hxx>
# include <StepData_FileRecognizer.hxx>
# include <StepData_Protocol.hxx>
Standard_EXPORT void StepFile_ReadTrace (const Standard_Integer mode);
// Modal : 0 pas de trace, 1 trace LoadModel, 2 & 3 + trace interne lex-yac
Standard_EXPORT Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_FileRecognizer)& recoheader, // Reconnait le Header
const Handle(StepData_FileRecognizer)& recodata); // Entites du Data
Standard_EXPORT Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_FileRecognizer)& recoheader, // Reconnait le Header
const Handle(StepData_Protocol)& protocol); // Entites du Data
Standard_EXPORT Standard_Integer StepFile_Read
(char* nomfic,
const Handle(StepData_StepModel)& stepmodel,
const Handle(StepData_Protocol)& protocol); // Header & Data
//! Working function reading STEP file or stream.
//! @param theName - name of the file or stream
//! @param theIStream - pointer to stream to read; if null, file theName will be opened
//! @param theModel - STEP model
//! @param theProtocol - STEP protocol object
//! @return 0 on success, -1 if stream fails, 1 in case of parsing error
Standard_EXPORT Standard_Integer StepFile_Read (const char* theName,
std::istream* theIStream,
const Handle(StepData_StepModel)& theModel,
const Handle(StepData_Protocol)& theProtocol);
#endif

View File

@ -1,26 +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.
// General Purpose Include file
// provides all required Include directives to Load and Transfer (to Cas.Cade)
// the content of a Step File
#include <StepFile_Read.hxx>
#include <StepData_StepModel.hxx>
#include <Transfer_TransferOutput.hxx>
//#include <Transfer_PersistentProcess.hxx>
//#include <Transfer_IteratorOfPersistentProcess.hxx>
#include <Transfer_Binder.hxx>
// and, to allow easy DownCasting :
#include <Interface_Macros.hxx>

File diff suppressed because it is too large Load Diff

2193
src/StepFile/lex.step.cxx Normal file

File diff suppressed because it is too large Load Diff

302
src/StepFile/location.hh Normal file
View File

@ -0,0 +1,302 @@
// A Bison parser, made by GNU Bison 3.7.1.
// Locations for Bison parsers in C++
// Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// As a special exception, you may create a larger work that contains
// part or all of the Bison parser skeleton and distribute that work
// under terms of your choice, so long as that work isn't itself a
// parser generator using the skeleton or a modified version thereof
// as a parser skeleton. Alternatively, if you modify or redistribute
// the parser skeleton itself, you may (at your option) remove this
// special exception, which will cause the skeleton and the resulting
// Bison output files to be licensed under the GNU General Public
// License without this special exception.
// This special exception was added by the Free Software Foundation in
// version 2.2 of Bison.
/**
** \file StepFile/location.hh
** Define the step::location class.
*/
#ifndef YY_STEP_STEPFILE_LOCATION_HH_INCLUDED
# define YY_STEP_STEPFILE_LOCATION_HH_INCLUDED
# include <iostream>
# include <string>
# ifndef YY_NULLPTR
# if defined __cplusplus
# if 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# else
# define YY_NULLPTR 0
# endif
# else
# define YY_NULLPTR ((void*)0)
# endif
# endif
namespace step {
/// A point in a source file.
class position
{
public:
/// Type for file name.
typedef const std::string filename_type;
/// Type for line and column numbers.
typedef int counter_type;
/// Construct a position.
explicit position (filename_type* f = YY_NULLPTR,
counter_type l = 1,
counter_type c = 1)
: filename (f)
, line (l)
, column (c)
{}
/// Initialization.
void initialize (filename_type* fn = YY_NULLPTR,
counter_type l = 1,
counter_type c = 1)
{
filename = fn;
line = l;
column = c;
}
/** \name Line and Column related manipulators
** \{ */
/// (line related) Advance to the COUNT next lines.
void lines (counter_type count = 1)
{
if (count)
{
column = 1;
line = add_ (line, count, 1);
}
}
/// (column related) Advance to the COUNT next columns.
void columns (counter_type count = 1)
{
column = add_ (column, count, 1);
}
/** \} */
/// File name to which this position refers.
filename_type* filename;
/// Current line number.
counter_type line;
/// Current column number.
counter_type column;
private:
/// Compute max (min, lhs+rhs).
static counter_type add_ (counter_type lhs, counter_type rhs, counter_type min)
{
return lhs + rhs < min ? min : lhs + rhs;
}
};
/// Add \a width columns, in place.
inline position&
operator+= (position& res, position::counter_type width)
{
res.columns (width);
return res;
}
/// Add \a width columns.
inline position
operator+ (position res, position::counter_type width)
{
return res += width;
}
/// Subtract \a width columns, in place.
inline position&
operator-= (position& res, position::counter_type width)
{
return res += -width;
}
/// Subtract \a width columns.
inline position
operator- (position res, position::counter_type width)
{
return res -= width;
}
/** \brief Intercept output stream redirection.
** \param ostr the destination output stream
** \param pos a reference to the position to redirect
*/
template <typename YYChar>
std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& ostr, const position& pos)
{
if (pos.filename)
ostr << *pos.filename << ':';
return ostr << pos.line << '.' << pos.column;
}
/// Two points in a source file.
class location
{
public:
/// Type for file name.
typedef position::filename_type filename_type;
/// Type for line and column numbers.
typedef position::counter_type counter_type;
/// Construct a location from \a b to \a e.
location (const position& b, const position& e)
: begin (b)
, end (e)
{}
/// Construct a 0-width location in \a p.
explicit location (const position& p = position ())
: begin (p)
, end (p)
{}
/// Construct a 0-width location in \a f, \a l, \a c.
explicit location (filename_type* f,
counter_type l = 1,
counter_type c = 1)
: begin (f, l, c)
, end (f, l, c)
{}
/// Initialization.
void initialize (filename_type* f = YY_NULLPTR,
counter_type l = 1,
counter_type c = 1)
{
begin.initialize (f, l, c);
end = begin;
}
/** \name Line and Column related manipulators
** \{ */
public:
/// Reset initial location to final location.
void step ()
{
begin = end;
}
/// Extend the current location to the COUNT next columns.
void columns (counter_type count = 1)
{
end += count;
}
/// Extend the current location to the COUNT next lines.
void lines (counter_type count = 1)
{
end.lines (count);
}
/** \} */
public:
/// Beginning of the located region.
position begin;
/// End of the located region.
position end;
};
/// Join two locations, in place.
inline location&
operator+= (location& res, const location& end)
{
res.end = end.end;
return res;
}
/// Join two locations.
inline location
operator+ (location res, const location& end)
{
return res += end;
}
/// Add \a width columns to the end position, in place.
inline location&
operator+= (location& res, location::counter_type width)
{
res.columns (width);
return res;
}
/// Add \a width columns to the end position.
inline location
operator+ (location res, location::counter_type width)
{
return res += width;
}
/// Subtract \a width columns to the end position, in place.
inline location&
operator-= (location& res, location::counter_type width)
{
return res += -width;
}
/// Subtract \a width columns to the end position.
inline location
operator- (location res, location::counter_type width)
{
return res -= width;
}
/** \brief Intercept output stream redirection.
** \param ostr the destination output stream
** \param loc a reference to the location to redirect
**
** Avoid duplicate information.
*/
template <typename YYChar>
std::basic_ostream<YYChar>&
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
{
location::counter_type end_col
= 0 < loc.end.column ? loc.end.column - 1 : 0;
ostr << loc.begin;
if (loc.end.filename
&& (!loc.begin.filename
|| *loc.begin.filename != *loc.end.filename))
ostr << '-' << loc.end.filename << ':' << loc.end.line << '.' << end_col;
else if (loc.begin.line < loc.end.line)
ostr << '-' << loc.end.line << '.' << end_col;
else if (loc.begin.column < end_col)
ostr << '-' << end_col;
return ostr;
}
} // step
#endif // !YY_STEP_STEPFILE_LOCATION_HH_INCLUDED

View File

@ -50,31 +50,31 @@
static char* restext = NULL ; /* texte courant (allocation dynamique) */
/* static int resalloc = 0 ;*/ /* alloue (memoire a liberer) ou non */
static char txt_cart_p[] = "CARTESIAN_POINT";
void rec_restext(char* newtext, int lentext) /* destine a etre appele de l'exterieur */
void rec_restext(const char* theNewText, int theLenText) /* destine a etre appele de l'exterieur */
{
char *res, *text;
if(strcmp(newtext,txt_cart_p)==0) {
// 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-lentext-1) { /* allouer nouvelle page */
if (onecarpage->used > Maxcar-theLenText-1) { /* allouer nouvelle page */
struct carpage *newpage;
int sizepage = sizeof(struct carpage);
if (lentext >= Maxcar) sizepage += (lentext+1 - Maxcar);
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 += (lentext + 1);
onecarpage->used += (theLenText + 1);
/* strcpy */
res = restext ; text = newtext;
while (*text != '\0') { *res=*text ; res++ ; text++ ; }
*res = '\0' ;
char *aRes = restext ;
const char *aText = theNewText;
while (*aText != '\0') { *aRes=*aText ; aRes++ ; aText++ ; }
*aRes = '\0' ;
}
void rec_gettext(char* *r)
@ -167,10 +167,18 @@ static char idzero[] = "#0";
/* Trace pour controle */
#ifdef __cplusplus
extern "C" {
#endif
void recfile_modeprint(int mode)
{ modeprint = mode; }
void rec_inityyll ();
#ifdef __cplusplus
}
#endif
/* INITIALISATION */
@ -189,7 +197,6 @@ void rec_debfile()
curscope = NULL ;
oneargpage = (struct argpage*) malloc ( sizeof(struct argpage) );
oneargpage->next = NULL; oneargpage->used = 0;
rec_inityyll();
}
/* INTERMEDIAIRE : passage de Header a Data */
@ -471,7 +478,9 @@ void scope_fin()
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 */
{
@ -551,6 +560,9 @@ int lir_file_arg(int* type, char* *val)
return (1) ;
}
#ifdef __cplusplus
}
#endif
/* Verification de l'integrite des donnees */
@ -588,6 +600,3 @@ void rec_check(int mode)
("Liste des records pourrie, nb note %d relu %d\n",nbrec,nr) ;
}
void steperror (char *mess);
int steplex (void);

View File

@ -13,6 +13,9 @@
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
@ -24,3 +27,36 @@
#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

@ -13,15 +13,46 @@
commercial license or contractual agreement.
*/
/*
c++ generate C++ parser class
8bit don't fail on 8-bit input characters
warn warn about inconsistencies
nodefault don't create default echo-all rule
noyywrap don't use yywrap() function
yyclass define name of the scanner class
*/
%option c++
%option 8bit warn nodefault
%option noyywrap
%option yyclass="step::scanner"
%top{
// This file is part of Open CASCADE Technology software library.
// This file is generated, do not modify it directly; edit source file step.lex instead.
// Pre-include stdlib.h to avoid redefinition of integer type macros (INT8_MIN and similar in generated code)
#if !defined(_MSC_VER) || (_MSC_VER >= 1600) // Visual Studio 2010+
#include "stdint.h"
#endif
}
%{
#include "step.tab.h"
#include "step.tab.hxx"
#include "recfile.ph"
#include "stdio.h"
#include <StepFile_CallFailure.hxx>
// Tell flex which function to define
#ifdef YY_DECL
# undef YY_DECL
#endif
#define YY_DECL int step::scanner::lex (step::parser::semantic_type* /*yylval*/, step::parser::location_type* /*yylloc*/)
typedef step::parser::token token;
/* skl 31.01.2002 for OCC133(OCC96,97) - uncorrect
long string in files Henri.stp and 401.stp*/
#define YY_FATAL_ERROR(msg) StepFile_CallFailure( msg )
#include <Standard_Failure.hxx>
#define YY_FATAL_ERROR(msg) Standard_Failure::Raise(msg);
/* abv 07.06.02: force inclusion of stdlib.h on WNT to avoid warnings */
#ifdef _MSC_VER
@ -48,33 +79,13 @@ long string in files Henri.stp and 401.stp*/
#endif /* MSC_VER */
/*
void steperror ( FILE *input_file );
void steprestart ( FILE *input_file );
*/
void rec_restext(char *newtext, int lentext);
void rec_restext(const char *constnewtext, int lentext);
void rec_typarg(int argtype);
/* Counter of lines in the file */
int steplineno;
/* Reset the lexical scanner before reading */
void rec_inityyll()
{
yy_init = yy_start = 1;
}
/* Record current match (text string) for further processing */
void resultat()
{
rec_restext(yytext,yyleng);
}
// disable GCC warnings in flex code
#ifdef __GNUC__
#pragma GCC diagnostic ignored "-Wunused-function"
#endif
%}
%x Com End Text
%%
@ -84,46 +95,53 @@ void resultat()
<Com>[*]+[/] { BEGIN(INITIAL); } /* end of comment - reset the scanner to initial state */
['] { BEGIN(Text); yymore(); } /* start of quoted text string - put the scanner in the "Text" state, but keep ' as part of yytext */
<Text>[\n] { yymore(); steplineno ++; } /* newline in text string - increment line counter and keep collecting yytext */
<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); resultat(); rec_typarg(rec_argText); return(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); 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 */
" " {;}
" " {;}
<*>[\n] { steplineno ++; } /* count lines (one rule for all start conditions) */
<*>[\n] { yylineno ++; } /* count lines (one rule for all start conditions) */
[\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]+/= { resultat(); return(ENTITY); }
#[0-9]+/[ ]*= { resultat(); return(ENTITY); }
#[0-9]+ { resultat(); return(IDENT); }
[-+0-9][0-9]* { resultat(); rec_typarg(rec_argInteger); return(QUID); }
[-+\.0-9][\.0-9]+ { resultat(); rec_typarg(rec_argFloat); return(QUID); }
[-+\.0-9][\.0-9]+E[-+0-9][0-9]* { resultat(); rec_typarg(rec_argFloat); return(QUID); }
["][0-9A-F]+["] { resultat(); rec_typarg(rec_argHexa); return(QUID); }
[.][A-Z0-9_]+[.] { resultat(); rec_typarg(rec_argEnum); return(QUID); }
#[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); }
[(] { return ('('); }
[)] { return (')'); }
[,] { return (','); }
[$] { resultat(); rec_typarg(rec_argNondef); return(QUID); }
[$] { rec_restext(YYText(),YYLeng()); rec_typarg(rec_argNondef); return(token::QUID); }
[=] { return ('='); }
[;] { return (';'); }
STEP; { return(STEP); }
HEADER; { return(HEADER); }
ENDSEC; { return(ENDSEC); }
DATA; { return(DATA); }
ENDSTEP; { return(ENDSTEP);}
"ENDSTEP;".* { return(ENDSTEP);}
END-ISO[0-9\-]*; { BEGIN(End); return(ENDSTEP); } /* at the end of the STEP data, enter dedicated start condition "End" to skip everything that follows */
ISO[0-9\-]*; { return(STEP); }
STEP; { return(token::STEP); }
HEADER; { return(token::HEADER); }
ENDSEC; { return(token::ENDSEC); }
DATA; { return(token::DATA); }
ENDSTEP; { return(token::ENDSTEP);}
"ENDSTEP;".* { return(token::ENDSTEP);}
END-ISO[0-9\-]*; { BEGIN(End); return(token::ENDSTEP); } /* at the end of the STEP data, enter dedicated start condition "End" to skip everything that follows */
ISO[0-9\-]*; { return(token::STEP); }
[/] { return ('/'); }
&SCOPE { return(SCOPE); }
ENDSCOPE { return(ENDSCOPE); }
[a-zA-Z0-9_]+ { resultat(); return(TYPE); }
![a-zA-Z0-9_]+ { resultat(); return(TYPE); }
[^)] { resultat(); rec_typarg(rec_argMisc); return(QUID); }
&SCOPE { return(token::SCOPE); }
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); }
<End>[^\n] {;} /* skip any characters (except newlines) */
%%
step::scanner::scanner(std::istream* in, std::ostream* out)
: stepFlexLexer(in, out)
{
}

File diff suppressed because it is too large Load Diff

1113
src/StepFile/step.tab.cxx Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,93 +0,0 @@
/* A Bison parser, made by GNU Bison 2.7. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_STEP_D_ABV_OCCT_OCCT_SRC_STEPFILE_STEP_TAB_H_INCLUDED
# define YY_STEP_D_ABV_OCCT_OCCT_SRC_STEPFILE_STEP_TAB_H_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int stepdebug;
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
STEP = 258,
HEADER = 259,
ENDSEC = 260,
DATA = 261,
ENDSTEP = 262,
SCOPE = 263,
ENDSCOPE = 264,
ENTITY = 265,
TYPE = 266,
INTEGER = 267,
FLOAT = 268,
IDENT = 269,
TEXT = 270,
NONDEF = 271,
ENUM = 272,
HEXA = 273,
QUID = 274
};
#endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef int YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
extern YYSTYPE steplval;
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int stepparse (void *YYPARSE_PARAM);
#else
int stepparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int stepparse (void);
#else
int stepparse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_STEP_D_ABV_OCCT_OCCT_SRC_STEPFILE_STEP_TAB_H_INCLUDED */

829
src/StepFile/step.tab.hxx Normal file
View File

@ -0,0 +1,829 @@
// A Bison parser, made by GNU Bison 3.7.1.
// Skeleton interface for Bison LALR(1) parsers in C++
// Copyright (C) 2002-2015, 2018-2020 Free Software Foundation, Inc.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
// As a special exception, you may create a larger work that contains
// part or all of the Bison parser skeleton and distribute that work
// under terms of your choice, so long as that work isn't itself a
// parser generator using the skeleton or a modified version thereof
// as a parser skeleton. Alternatively, if you modify or redistribute
// the parser skeleton itself, you may (at your option) remove this
// special exception, which will cause the skeleton and the resulting
// Bison output files to be licensed under the GNU General Public
// License without this special exception.
// This special exception was added by the Free Software Foundation in
// version 2.2 of Bison.
/**
** \file StepFile/step.tab.hxx
** Define the step::parser class.
*/
// C++ LALR(1) parser skeleton written by Akim Demaille.
// DO NOT RELY ON FEATURES THAT ARE NOT DOCUMENTED in the manual,
// especially those whose name start with YY_ or yy_. They are
// private implementation details that can be changed or removed.
#ifndef YY_STEP_STEPFILE_STEP_TAB_HXX_INCLUDED
# define YY_STEP_STEPFILE_STEP_TAB_HXX_INCLUDED
// "%code requires" blocks.
// 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.
namespace step {
class scanner;
};
#ifdef _MSC_VER
// disable MSVC warning C4522: 'step::parser::stack_symbol_type': multiple assignment operators
#pragma warning(disable: 4522)
// disable MSVC warning C4512: 'step::parser::stack::slice' : assignment operator could not be generated
#pragma warning(disable: 4512)
#endif
# include <cstdlib> // std::abort
# include <iostream>
# include <stdexcept>
# include <string>
# include <vector>
#if defined __cplusplus
# define YY_CPLUSPLUS __cplusplus
#else
# define YY_CPLUSPLUS 199711L
#endif
// Support move semantics when possible.
#if 201103L <= YY_CPLUSPLUS
# define YY_MOVE std::move
# define YY_MOVE_OR_COPY move
# define YY_MOVE_REF(Type) Type&&
# define YY_RVREF(Type) Type&&
# define YY_COPY(Type) Type
#else
# define YY_MOVE
# define YY_MOVE_OR_COPY copy
# define YY_MOVE_REF(Type) Type&
# define YY_RVREF(Type) const Type&
# define YY_COPY(Type) const Type&
#endif
// Support noexcept when possible.
#if 201103L <= YY_CPLUSPLUS
# define YY_NOEXCEPT noexcept
# define YY_NOTHROW
#else
# define YY_NOEXCEPT
# define YY_NOTHROW throw ()
#endif
// Support constexpr when possible.
#if 201703 <= YY_CPLUSPLUS
# define YY_CONSTEXPR constexpr
#else
# define YY_CONSTEXPR
#endif
# include "location.hh"
#ifndef YY_ATTRIBUTE_PURE
# if defined __GNUC__ && 2 < __GNUC__ + (96 <= __GNUC_MINOR__)
# define YY_ATTRIBUTE_PURE __attribute__ ((__pure__))
# else
# define YY_ATTRIBUTE_PURE
# endif
#endif
#ifndef YY_ATTRIBUTE_UNUSED
# if defined __GNUC__ && 2 < __GNUC__ + (7 <= __GNUC_MINOR__)
# define YY_ATTRIBUTE_UNUSED __attribute__ ((__unused__))
# else
# define YY_ATTRIBUTE_UNUSED
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(E) /* empty */
#endif
#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"") \
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
# define YY_INITIAL_VALUE(Value) Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
#if defined __cplusplus && defined __GNUC__ && ! defined __ICC && 6 <= __GNUC__
# define YY_IGNORE_USELESS_CAST_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuseless-cast\"")
# define YY_IGNORE_USELESS_CAST_END \
_Pragma ("GCC diagnostic pop")
#endif
#ifndef YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_BEGIN
# define YY_IGNORE_USELESS_CAST_END
#endif
# ifndef YY_CAST
# ifdef __cplusplus
# define YY_CAST(Type, Val) static_cast<Type> (Val)
# define YY_REINTERPRET_CAST(Type, Val) reinterpret_cast<Type> (Val)
# else
# define YY_CAST(Type, Val) ((Type) (Val))
# define YY_REINTERPRET_CAST(Type, Val) ((Type) (Val))
# endif
# endif
# ifndef YY_NULLPTR
# if defined __cplusplus
# if 201103L <= __cplusplus
# define YY_NULLPTR nullptr
# else
# define YY_NULLPTR 0
# endif
# else
# define YY_NULLPTR ((void*)0)
# endif
# endif
/* Debug traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
namespace step {
/// A Bison parser.
class parser
{
public:
#ifndef YYSTYPE
/// Symbol semantic values.
typedef int semantic_type;
#else
typedef YYSTYPE semantic_type;
#endif
/// Symbol locations.
typedef location location_type;
/// Syntax errors thrown from user actions.
struct syntax_error : std::runtime_error
{
syntax_error (const location_type& l, const std::string& m)
: std::runtime_error (m)
, location (l)
{}
syntax_error (const syntax_error& s)
: std::runtime_error (s.what ())
, location (s.location)
{}
~syntax_error () YY_NOEXCEPT YY_NOTHROW;
location_type location;
};
/// Token kinds.
struct token
{
enum token_kind_type
{
YYEMPTY = -2,
YYEOF = 0, // "end of file"
YYerror = 256, // error
YYUNDEF = 257, // "invalid token"
STEP = 258, // STEP
HEADER = 259, // HEADER
ENDSEC = 260, // ENDSEC
DATA = 261, // DATA
ENDSTEP = 262, // ENDSTEP
SCOPE = 263, // SCOPE
ENDSCOPE = 264, // ENDSCOPE
ENTITY = 265, // ENTITY
TYPE = 266, // TYPE
INTEGER = 267, // INTEGER
FLOAT = 268, // FLOAT
IDENT = 269, // IDENT
TEXT = 270, // TEXT
NONDEF = 271, // NONDEF
ENUM = 272, // ENUM
HEXA = 273, // HEXA
QUID = 274 // QUID
};
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type yytokentype;
};
/// Token kind, as returned by yylex.
typedef token::yytokentype token_kind_type;
/// Backward compatibility alias (Bison 3.6).
typedef token_kind_type token_type;
/// Symbol kinds.
struct symbol_kind
{
enum symbol_kind_type
{
YYNTOKENS = 27, ///< Number of tokens.
S_YYEMPTY = -2,
S_YYEOF = 0, // "end of file"
S_YYerror = 1, // error
S_YYUNDEF = 2, // "invalid token"
S_STEP = 3, // STEP
S_HEADER = 4, // HEADER
S_ENDSEC = 5, // ENDSEC
S_DATA = 6, // DATA
S_ENDSTEP = 7, // ENDSTEP
S_SCOPE = 8, // SCOPE
S_ENDSCOPE = 9, // ENDSCOPE
S_ENTITY = 10, // ENTITY
S_TYPE = 11, // TYPE
S_INTEGER = 12, // INTEGER
S_FLOAT = 13, // FLOAT
S_IDENT = 14, // IDENT
S_TEXT = 15, // TEXT
S_NONDEF = 16, // NONDEF
S_ENUM = 17, // ENUM
S_HEXA = 18, // HEXA
S_QUID = 19, // QUID
S_20_ = 20, // ' '
S_21_ = 21, // ';'
S_22_ = 22, // '('
S_23_ = 23, // ')'
S_24_ = 24, // ','
S_25_ = 25, // '='
S_26_ = 26, // '/'
S_YYACCEPT = 27, // $accept
S_finvide = 28, // finvide
S_finstep = 29, // finstep
S_stepf1 = 30, // stepf1
S_stepf2 = 31, // stepf2
S_stepf3 = 32, // stepf3
S_stepf = 33, // stepf
S_headl = 34, // headl
S_headent = 35, // headent
S_endhead = 36, // endhead
S_unarg = 37, // unarg
S_listype = 38, // listype
S_deblist = 39, // deblist
S_finlist = 40, // finlist
S_listarg = 41, // listarg
S_arglist = 42, // arglist
S_model = 43, // model
S_bloc = 44, // bloc
S_plex = 45, // plex
S_unent = 46, // unent
S_debscop = 47, // debscop
S_unid = 48, // unid
S_export = 49, // export
S_debexp = 50, // debexp
S_finscop = 51, // finscop
S_entlab = 52, // entlab
S_enttype = 53 // enttype
};
};
/// (Internal) symbol kind.
typedef symbol_kind::symbol_kind_type symbol_kind_type;
/// The number of tokens.
static const symbol_kind_type YYNTOKENS = symbol_kind::YYNTOKENS;
/// A complete symbol.
///
/// Expects its Base type to provide access to the symbol kind
/// via kind ().
///
/// Provide access to semantic value and location.
template <typename Base>
struct basic_symbol : Base
{
/// Alias to Base.
typedef Base super_type;
/// Default constructor.
basic_symbol ()
: value ()
, location ()
{}
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
basic_symbol (basic_symbol&& that)
: Base (std::move (that))
, value (std::move (that.value))
, location (std::move (that.location))
{}
#endif
/// Copy constructor.
basic_symbol (const basic_symbol& that);
/// Constructor for valueless symbols.
basic_symbol (typename Base::kind_type t,
YY_MOVE_REF (location_type) l);
/// Constructor for symbols with semantic value.
basic_symbol (typename Base::kind_type t,
YY_RVREF (semantic_type) v,
YY_RVREF (location_type) l);
/// Destroy the symbol.
~basic_symbol ()
{
clear ();
}
/// Destroy contents, and record that is empty.
void clear ()
{
Base::clear ();
}
#if YYDEBUG || 0
/// The user-facing name of this symbol.
const char *name () const YY_NOEXCEPT
{
return parser::symbol_name (this->kind ());
}
#endif // #if YYDEBUG || 0
/// Backward compatibility (Bison 3.6).
symbol_kind_type type_get () const YY_NOEXCEPT;
/// Whether empty.
bool empty () const YY_NOEXCEPT;
/// Destructive move, \a s is emptied into this.
void move (basic_symbol& s);
/// The semantic value.
semantic_type value;
/// The location.
location_type location;
private:
#if YY_CPLUSPLUS < 201103L
/// Assignment operator.
basic_symbol& operator= (const basic_symbol& that);
#endif
};
/// Type access provider for token (enum) based symbols.
struct by_kind
{
/// Default constructor.
by_kind ();
#if 201103L <= YY_CPLUSPLUS
/// Move constructor.
by_kind (by_kind&& that);
#endif
/// Copy constructor.
by_kind (const by_kind& that);
/// The symbol kind as needed by the constructor.
typedef token_kind_type kind_type;
/// Constructor from (external) token numbers.
by_kind (kind_type t);
/// Record that this symbol is empty.
void clear ();
/// Steal the symbol kind from \a that.
void move (by_kind& that);
/// The (internal) type number (corresponding to \a type).
/// \a empty when empty.
symbol_kind_type kind () const YY_NOEXCEPT;
/// Backward compatibility (Bison 3.6).
symbol_kind_type type_get () const YY_NOEXCEPT;
/// The symbol kind.
/// \a S_YYEMPTY when empty.
symbol_kind_type kind_;
};
/// Backward compatibility for a private implementation detail (Bison 3.6).
typedef by_kind by_type;
/// "External" symbols: returned by the scanner.
struct symbol_type : basic_symbol<by_kind>
{};
/// Build a parser object.
parser (step::scanner* scanner_yyarg);
virtual ~parser ();
#if 201103L <= YY_CPLUSPLUS
/// Non copyable.
parser (const parser&) = delete;
/// Non copyable.
parser& operator= (const parser&) = delete;
#endif
/// Parse. An alias for parse ().
/// \returns 0 iff parsing succeeded.
int operator() ();
/// Parse.
/// \returns 0 iff parsing succeeded.
virtual int parse ();
#if YYDEBUG
/// The current debugging stream.
std::ostream& debug_stream () const YY_ATTRIBUTE_PURE;
/// Set the current debugging stream.
void set_debug_stream (std::ostream &);
/// Type for debugging levels.
typedef int debug_level_type;
/// The current debugging level.
debug_level_type debug_level () const YY_ATTRIBUTE_PURE;
/// Set the current debugging level.
void set_debug_level (debug_level_type l);
#endif
/// Report a syntax error.
/// \param loc where the syntax error is found.
/// \param msg a description of the syntax error.
virtual void error (const location_type& loc, const std::string& msg);
/// Report a syntax error.
void error (const syntax_error& err);
#if YYDEBUG || 0
/// The user-facing name of the symbol whose (internal) number is
/// YYSYMBOL. No bounds checking.
static const char *symbol_name (symbol_kind_type yysymbol);
#endif // #if YYDEBUG || 0
private:
#if YY_CPLUSPLUS < 201103L
/// Non copyable.
parser (const parser&);
/// Non copyable.
parser& operator= (const parser&);
#endif
/// Stored state numbers (used for stacks).
typedef signed char state_type;
/// Compute post-reduction state.
/// \param yystate the current state
/// \param yysym the nonterminal to push on the stack
static state_type yy_lr_goto_state_ (state_type yystate, int yysym);
/// Whether the given \c yypact_ value indicates a defaulted state.
/// \param yyvalue the value to check
static bool yy_pact_value_is_default_ (int yyvalue);
/// Whether the given \c yytable_ value indicates a syntax error.
/// \param yyvalue the value to check
static bool yy_table_value_is_error_ (int yyvalue);
static const signed char yypact_ninf_;
static const signed char yytable_ninf_;
/// Convert a scanner token kind \a t to a symbol kind.
/// In theory \a t should be a token_kind_type, but character literals
/// are valid, yet not members of the token_type enum.
static symbol_kind_type yytranslate_ (int t);
#if YYDEBUG || 0
/// For a symbol, its name in clear.
static const char* const yytname_[];
#endif // #if YYDEBUG || 0
// Tables.
// YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
// STATE-NUM.
static const signed char yypact_[];
// YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
// Performed when YYTABLE does not specify something else to do. Zero
// means the default is an error.
static const signed char yydefact_[];
// YYPGOTO[NTERM-NUM].
static const signed char yypgoto_[];
// YYDEFGOTO[NTERM-NUM].
static const signed char yydefgoto_[];
// YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If
// positive, shift that token. If negative, reduce the rule whose
// number is the opposite. If YYTABLE_NINF, syntax error.
static const signed char yytable_[];
static const signed char yycheck_[];
// YYSTOS[STATE-NUM] -- The (internal number of the) accessing
// symbol of state STATE-NUM.
static const signed char yystos_[];
// YYR1[YYN] -- Symbol number of symbol that rule YYN derives.
static const signed char yyr1_[];
// YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.
static const signed char yyr2_[];
#if YYDEBUG
// YYRLINE[YYN] -- Source line where rule number YYN was defined.
static const unsigned char yyrline_[];
/// Report on the debug stream that the rule \a r is going to be reduced.
virtual void yy_reduce_print_ (int r) const;
/// Print the state stack on the debug stream.
virtual void yy_stack_print_ () const;
/// Debugging level.
int yydebug_;
/// Debug stream.
std::ostream* yycdebug_;
/// \brief Display a symbol kind, value and location.
/// \param yyo The output stream.
/// \param yysym The symbol.
template <typename Base>
void yy_print_ (std::ostream& yyo, const basic_symbol<Base>& yysym) const;
#endif
/// \brief Reclaim the memory associated to a symbol.
/// \param yymsg Why this token is reclaimed.
/// If null, print nothing.
/// \param yysym The symbol.
template <typename Base>
void yy_destroy_ (const char* yymsg, basic_symbol<Base>& yysym) const;
private:
/// Type access provider for state based symbols.
struct by_state
{
/// Default constructor.
by_state () YY_NOEXCEPT;
/// The symbol kind as needed by the constructor.
typedef state_type kind_type;
/// Constructor.
by_state (kind_type s) YY_NOEXCEPT;
/// Copy constructor.
by_state (const by_state& that) YY_NOEXCEPT;
/// Record that this symbol is empty.
void clear () YY_NOEXCEPT;
/// Steal the symbol kind from \a that.
void move (by_state& that);
/// The symbol kind (corresponding to \a state).
/// \a symbol_kind::S_YYEMPTY when empty.
symbol_kind_type kind () const YY_NOEXCEPT;
/// The state number used to denote an empty symbol.
/// We use the initial state, as it does not have a value.
enum { empty_state = 0 };
/// The state.
/// \a empty when empty.
state_type state;
};
/// "Internal" symbol: element of the stack.
struct stack_symbol_type : basic_symbol<by_state>
{
/// Superclass.
typedef basic_symbol<by_state> super_type;
/// Construct an empty symbol.
stack_symbol_type ();
/// Move or copy construction.
stack_symbol_type (YY_RVREF (stack_symbol_type) that);
/// Steal the contents from \a sym to build this.
stack_symbol_type (state_type s, YY_MOVE_REF (symbol_type) sym);
#if YY_CPLUSPLUS < 201103L
/// Assignment, needed by push_back by some old implementations.
/// Moves the contents of that.
stack_symbol_type& operator= (stack_symbol_type& that);
/// Assignment, needed by push_back by other implementations.
/// Needed by some other old implementations.
stack_symbol_type& operator= (const stack_symbol_type& that);
#endif
};
/// A stack with random access from its top.
template <typename T, typename S = std::vector<T> >
class stack
{
public:
// Hide our reversed order.
typedef typename S::iterator iterator;
typedef typename S::const_iterator const_iterator;
typedef typename S::size_type size_type;
typedef typename std::ptrdiff_t index_type;
stack (size_type n = 200)
: seq_ (n)
{}
#if 201103L <= YY_CPLUSPLUS
/// Non copyable.
stack (const stack&) = delete;
/// Non copyable.
stack& operator= (const stack&) = delete;
#endif
/// Random access.
///
/// Index 0 returns the topmost element.
const T&
operator[] (index_type i) const
{
return seq_[size_type (size () - 1 - i)];
}
/// Random access.
///
/// Index 0 returns the topmost element.
T&
operator[] (index_type i)
{
return seq_[size_type (size () - 1 - i)];
}
/// Steal the contents of \a t.
///
/// Close to move-semantics.
void
push (YY_MOVE_REF (T) t)
{
seq_.push_back (T ());
operator[] (0).move (t);
}
/// Pop elements from the stack.
void
pop (std::ptrdiff_t n = 1) YY_NOEXCEPT
{
for (; 0 < n; --n)
seq_.pop_back ();
}
/// Pop all elements from the stack.
void
clear () YY_NOEXCEPT
{
seq_.clear ();
}
/// Number of elements on the stack.
index_type
size () const YY_NOEXCEPT
{
return index_type (seq_.size ());
}
/// Iterator on top of the stack (going downwards).
const_iterator
begin () const YY_NOEXCEPT
{
return seq_.begin ();
}
/// Bottom of the stack.
const_iterator
end () const YY_NOEXCEPT
{
return seq_.end ();
}
/// Present a slice of the top of a stack.
class slice
{
public:
slice (const stack& stack, index_type range)
: stack_ (stack)
, range_ (range)
{}
const T&
operator[] (index_type i) const
{
return stack_[range_ - i];
}
private:
const stack& stack_;
index_type range_;
};
private:
#if YY_CPLUSPLUS < 201103L
/// Non copyable.
stack (const stack&);
/// Non copyable.
stack& operator= (const stack&);
#endif
/// The wrapped container.
S seq_;
};
/// Stack type.
typedef stack<stack_symbol_type> stack_type;
/// The stack.
stack_type yystack_;
/// Push a new state on the stack.
/// \param m a debug message to display
/// if null, no trace is output.
/// \param sym the symbol
/// \warning the contents of \a s.value is stolen.
void yypush_ (const char* m, YY_MOVE_REF (stack_symbol_type) sym);
/// Push a new look ahead token on the state on the stack.
/// \param m a debug message to display
/// if null, no trace is output.
/// \param s the state
/// \param sym the symbol (for its value and location).
/// \warning the contents of \a sym.value is stolen.
void yypush_ (const char* m, state_type s, YY_MOVE_REF (symbol_type) sym);
/// Pop \a n symbols from the stack.
void yypop_ (int n = 1);
/// Constants.
enum
{
yylast_ = 83, ///< Last index in yytable_.
yynnts_ = 27, ///< Number of nonterminal symbols.
yyfinal_ = 7 ///< Termination state number.
};
// User arguments.
step::scanner* scanner;
};
} // step
#endif // !YY_STEP_STEPFILE_STEP_TAB_HXX_INCLUDED

View File

@ -18,23 +18,55 @@
// This file is generated, do not modify it directly; edit source file step.yacc instead.
}
%language "C++"
%require "3.2"
/* C++ parser interface */
%skeleton "lalr1.cc"
%parse-param {step::scanner* scanner}
%locations
%token STEP HEADER ENDSEC DATA ENDSTEP SCOPE ENDSCOPE ENTITY TYPE INTEGER FLOAT IDENT TEXT NONDEF ENUM HEXA QUID
%start stepf
%{
%code requires {
// 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.
namespace step {
class scanner;
};
#ifdef _MSC_VER
// disable MSVC warning C4522: 'step::parser::stack_symbol_type': multiple assignment operators
#pragma warning(disable: 4522)
// disable MSVC warning C4512: 'step::parser::stack::slice' : assignment operator could not be generated
#pragma warning(disable: 4512)
#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 stepclearin yychar = -1
#define steperrok yyerrflag = 0
// disable MSVC warnings in bison code
#ifdef _MSC_VER
#pragma warning(disable:4244 4131 4127 4702)
#pragma warning(disable:4065 4244 4131 4127 4702)
#define YYMALLOC malloc
#define YYFREE free
#endif
void StepFile_Interrupt (char* nomfic); /* rln 13.09.00 port on HP*/
}
%}
%%
/* N.B. : les commentaires sont filtres par LEX */
/* La fin vide (selon systeme emetteur) est filtree ici */
@ -62,7 +94,7 @@ unarg : IDENT { rec_typarg(rec_argIdent); 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; }
yyerrstatus_ = 1; yyclearin; }
/* Erreur sur Parametre : tacher de le noter sans jeter l'Entite */
;
listype : TYPE
@ -74,7 +106,7 @@ deblist : '('
finlist : ')'
{ if (modeprint > 0)
{ printf("Record no : %d -- ",nbrec+1); rec_print(currec); }
rec_newent (); yyerrstatus = 0; }
rec_newent (); yyerrstatus_ = 0; }
;
listarg : deblist finlist /* liste vide (peut y en avoir) */
| deblist arglist finlist /* liste normale, non vide */
@ -124,3 +156,11 @@ entlab : ENTITY
enttype : TYPE
{ rec_type (); }
;
%%
void step::parser::error(const location_type& /*loc*/, const std::string& m)
{
char newmess[80];
sprintf(newmess, "At line %d : %s", scanner->lineno() + 1, m.c_str());
StepFile_Interrupt(newmess);
}

View File

@ -1,120 +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 "recfile.ph"
#include <OSD_OpenFile.hxx>
/* StepFile_Error.c
Ce programme substitue au yyerror standard, qui fait "exit" (brutal !)
une action plus adaptee a un fonctionnement en process :
Affichage de la ligne qui a provoque l' erreur,
Preparation d'un eventuel appel suivant (vu qu on ne fait plus exit),
en pour le retour, on s'arrange pour lever une exception
(c-a-d qu on provoque un plantage)
Adaptation pour flex (flex autorise d avoir plusieurs lex dans un meme
executable) : les fonctions et variables sont renommees; et la
continuation a change
*/
static int lastno;
extern int steplineno;
extern void StepFile_Interrupt (char* nomfic); /* rln 13.09.00 port on HP*/
int stepparse(void);
void rec_debfile();
void steprestart(FILE *input_file);
void rec_finfile();
void steperror (char *mess)
{
char newmess[80];
if (steplineno == lastno) return;
lastno = steplineno;
sprintf (newmess,"At line %d, %s",steplineno+1,mess);
/* yysbuf[0] = '\0';
yysptr = yysbuf;
* yylineno = 0; */
StepFile_Interrupt(newmess);
}
/* But de ce mini-programme : appeler yyparse et si besoin preciser un
fichier d'entree
StepFile_Error redefinit yyerror pour ne pas stopper (s'y reporter)
*/
extern FILE* stepin ; /* input de yyparse (executeur de lex-yacc) */
extern int steplineno; /* compteur de ligne lex (pour erreurs) */
/* Designation d'un fichier de lecture
(par defaut, c'est l'entree standard)
Appel : iflag = stepread_setinput ("...") ou (char[] ...) ;
stepread_setinput ("") [longueur nulle] laisse en standard
iflag retourne vaut 0 si c'est OK, 1 sinon
*/
FILE* stepread_setinput (char* nomfic)
{
FILE* newin ;
if (strlen(nomfic) == 0) return stepin ;
newin = OSD_OpenFile(nomfic,"rb");
if (newin == NULL) {
return NULL ;
} else {
stepin = newin ; return newin ;
}
}
void stepread_endinput (FILE* infic, char* nomfic)
{
if (!infic) return;
if (strlen(nomfic) == 0) return;
fclose (infic);
}
/* 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 ()
{
int letat;
lastno = 0;
steplineno = 0;
rec_debfile() ;
steprestart(stepin);
letat = stepparse() ;
rec_finfile() ;
return letat;
}
int stepwrap () { return 1; }

46
src/StepFile/stepread.cxx Normal file
View File

@ -0,0 +1,46 @@
/*
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

@ -16,18 +16,24 @@
// stepread.h
/* lecture du fichier STEP (par appel a lex+yac) */
#include <iostream>
#ifdef __cplusplus
extern "C" {
#endif
extern "C" FILE* stepread_setinput (char* nomfic) ;
extern "C" void stepread_endinput (FILE* infic, char* nomfic);
extern "C" int stepread() ;
extern "C" void recfile_modeprint (int mode) ; /* controle trace recfile */
void recfile_modeprint (int mode) ; /* controle trace recfile */
/* creation du Direc a partir de recfile : entrys connues de c++ */
extern "C" void lir_file_nbr(int* nbh, int* nbr, int* nbp) ;
extern "C" int lir_file_rec(char* *ident , char* *type , int* nbarg) ;
extern "C" void lir_file_finrec() ;
extern "C" int lir_file_arg(int* type , char* *val) ;
extern "C" void lir_file_fin(int mode);
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++ */
extern "C" void StepFile_Interrupt (char* nomfic);
#ifdef __cplusplus
}
#endif
int stepread(std::istream& theStream);
void StepFile_Interrupt (char* theNomfic);

View File

@ -73,8 +73,22 @@ Standard_Integer StepSelect_WorkLibrary::ReadFile
Handle(StepData_StepModel) stepmodel = new StepData_StepModel;
model = stepmodel;
StepFile_ReadTrace (0);
char *pName=(char *)name;
status = StepFile_Read (pName,stepmodel,stepro);
status = StepFile_Read(name, 0, stepmodel, stepro);
return status;
}
Standard_Integer StepSelect_WorkLibrary::ReadStream (const Standard_CString theName,
std::istream& theIStream,
Handle(Interface_InterfaceModel)& model,
const Handle(Interface_Protocol)& protocol) const
{
long status = 1;
DeclareAndCast(StepData_Protocol, stepro, protocol);
if (stepro.IsNull()) return 1;
Handle(StepData_StepModel) stepmodel = new StepData_StepModel;
model = stepmodel;
StepFile_ReadTrace(0);
status = StepFile_Read(theName, &theIStream, stepmodel, stepro);
return status;
}

View File

@ -55,7 +55,15 @@ public:
//! or lets <mod> "Null" in case of Error
//! Returns 0 if OK, 1 if Read Error, -1 if File not opened
Standard_EXPORT Standard_Integer ReadFile (const Standard_CString name, Handle(Interface_InterfaceModel)& model, const Handle(Interface_Protocol)& protocol) const Standard_OVERRIDE;
//! Reads a STEP File from stream and returns a STEP Model (into <mod>),
//! or lets <mod> "Null" in case of Error
//! Returns 0 if OK, 1 if Read Error, -1 if File not opened
Standard_EXPORT Standard_Integer ReadStream(const Standard_CString theName,
std::istream& theIStream,
Handle(Interface_InterfaceModel)& model,
const Handle(Interface_Protocol)& protocol) const Standard_OVERRIDE;
//! Writes a File from a STEP Model
//! Returns False (and writes no file) if <ctx> does not bring a
//! STEP Model

View File

@ -124,14 +124,30 @@ Handle(XSControl_WorkSession) XSControl_Reader::WS () const
//purpose :
//=======================================================================
IFSelect_ReturnStatus XSControl_Reader::ReadFile
(const Standard_CString filename)
IFSelect_ReturnStatus XSControl_Reader::ReadFile (const Standard_CString filename)
{
IFSelect_ReturnStatus stat = thesession->ReadFile(filename);
thesession->InitTransferReader(4);
return stat;
}
//=======================================================================
//function : ReadStream
//purpose :
//=======================================================================
IFSelect_ReturnStatus XSControl_Reader::ReadStream(const Standard_CString theName,
std::istream& theIStream)
{
IFSelect_ReturnStatus stat = thesession->ReadStream(theName, theIStream);
thesession->InitTransferReader(4);
return stat;
}
//=======================================================================
//function : Model
//purpose :
//=======================================================================
Handle(Interface_InterfaceModel) XSControl_Reader::Model () const
{

View File

@ -104,6 +104,9 @@ public:
//! Loads a file and returns the read status
//! Zero for a Model which compies with the Controller
Standard_EXPORT IFSelect_ReturnStatus ReadFile (const Standard_CString filename);
//! Loads a file from stream and returns the read status
Standard_EXPORT IFSelect_ReturnStatus ReadStream(const Standard_CString theName, std::istream& theIStream);
//! Returns the model. It can then be consulted (header, product)
Standard_EXPORT Handle(Interface_InterfaceModel) Model() const;

View File

@ -268,17 +268,30 @@ static Standard_Integer stepread (Draw_Interpretor& di, Standard_Integer argc, c
//function : testreadstep
//purpose :
//=======================================================================
static Standard_Integer testread (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
static Standard_Integer testreadstep (Draw_Interpretor& di, Standard_Integer argc, const char** argv)
{
if (argc != 3)
{
di << "ERROR in " << argv[0] << "Wrong Number of Arguments.\n";
di << " Usage : " << argv[0] <<" file_name shape_name\n";
return 1;
}
if (argc < 3 || argc > 4)
{
di << "ERROR in " << argv[0] << "Wrong Number of Arguments.\n";
di << " Usage : " << argv[0] << " file_name shape_name [-stream]\n";
di << " Option -stream forces usage of API accepting stream\n";
return 1;
}
Standard_Boolean useStream = (argc > 3 && ! strcasecmp (argv[3], "-stream"));
STEPControl_Reader Reader;
Standard_CString filename = argv[1];
IFSelect_ReturnStatus readstat = Reader.ReadFile(filename);
IFSelect_ReturnStatus readstat;
if (useStream)
{
std::ifstream aStream (filename);
readstat = Reader.ReadStream(filename, aStream);
}
else
{
readstat = Reader.ReadFile(filename);
}
di<<"Status from reading STEP file "<<filename<<" : ";
switch(readstat) {
case IFSelect_RetVoid : { di<<"empty file\n"; return 1; }
@ -540,7 +553,7 @@ void XSDRAWSTEP::InitCommands (Draw_Interpretor& theCommands)
theCommands.Add("stepwrite" , "stepwrite mode[0-4 afsmw] shape", __FILE__, stepwrite, g);
theCommands.Add("testwritestep", "testwritestep filename.stp shape", __FILE__, testwrite, g);
theCommands.Add("stepread", "stepread [file] [f or r (type of model full or reduced)]",__FILE__, stepread, g);
theCommands.Add("testreadstep", "testreadstep [file] [name DRAW]", __FILE__, testread, g);
theCommands.Add("testreadstep", "testreadstep file shape [-stream]",__FILE__, testreadstep, g);
theCommands.Add("steptrans", "steptrans shape stepax1 stepax2", __FILE__, steptrans, g);
theCommands.Add("countexpected","TEST", __FILE__, countexpected, g);
theCommands.Add("dumpassembly", "TEST", __FILE__, dumpassembly, g);

10
tests/bugs/step/bug27342 Normal file
View File

@ -0,0 +1,10 @@
puts "=========="
puts "0027342: Data Exchange, STEP - support C++ streams for import / export"
puts "=========="
puts ""
puts "Testing read of STEP file using stream interface"
testreadstep [locate_data_file PRO7071.stp] result -stream
checkshape result
checknbshapes result -solid 4