%{
#include <ExprIntrp.tab.h>
+#include <ExprIntrp_yaccintrf.hxx>
+
#define YY_SKIP_YYWRAP
static YY_BUFFER_STATE ExprIntrp_bufstring;
-void ExprIntrp_SetResult();
-void ExprIntrp_SetDegree();
-
-int ExprIntrlex (void);
-
-void ExprIntrp_start_string(char* str)
+void ExprIntrp_start_string(const char* str)
{
- ExprIntrp_bufstring = ExprIntrp_scan_string(str);
+ // depending on configuration and generator, yyconst may be defined as const or empty
+ ExprIntrp_bufstring = ExprIntrp_scan_string((yyconst char*)str);
}
void ExprIntrp_stop_string()
ExprIntrp_bufstring = (YY_BUFFER_STATE) 0;
}
-int yywrap()
+static int yywrap()
{
return 1;
}
+// provide safe error handler (exception instead of exit())
+#define YY_FATAL_ERROR(msg) ExprIntrperror(msg)
+
#ifdef _MSC_VER
// add includes for flex 2.91 (Linux version)
#include <stdlib.h>
// Avoid includion of unistd.h if parser is generated on Linux (flex 2.5.35)
#define YY_NO_UNISTD_H
-// disable MSVC warnings in flex 2.89 code
-#pragma warning(disable:4131 4244 4273 4127)
+// disable MSVC warnings in flex 2.89 and 2.5.35 code
+// Note that Intel compiler also defines _MSC_VER but has different warning ids
+#if defined(__INTEL_COMPILER)
+#pragma warning(disable:177 1786 1736)
+#else
+#pragma warning(disable:4131 4244 4273 4127 4267)
+#endif
+
#endif
#ifdef __GNUC__
// Alternatively, this file may be used under the terms of Open CASCADE
// commercial license or contractual agreement.
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
#include <ExprIntrp_yaccintrf.hxx>
#include <ExprIntrp_yaccanal.hxx>
#include <Expr_GeneralExpression.hxx>
#include <Expr_SystemRelation.hxx>
#include <Expr_UnknownIterator.hxx>
#include <Expr_FunctionDerivative.hxx>
-#include <Expr.hxx> // ATTENTION POUR PROTECTION BUG STACK
-
+#include <Expr.hxx>
#include <Expr_SequenceOfGeneralExpression.hxx>
#include <Expr_Operators.hxx>
#include <ExprIntrp_SyntaxError.hxx>
#include <Expr_Array1OfNamedUnknown.hxx>
#include <Expr_Array1OfGeneralExpression.hxx>
-#ifdef HAVE_STRINGS_H
-# include <strings.h>
-#endif
-
-extern char yysbuf[];
-extern char *yysptr;
-static char ExprIntrp_assname[30];
-TCollection_AsciiString ExprIntrp_funcdefname;
+
+static TCollection_AsciiString ExprIntrp_assname;
+static TCollection_AsciiString ExprIntrp_funcdefname;
static Standard_Integer ExprIntrp_nbargs;
static Standard_Integer ExprIntrp_nbdiff;
-
extern "C" void ExprIntrp_StartFunction()
{
- char funcname[100];
- ExprIntrp_GetResult(funcname);
- TCollection_AsciiString name(funcname);
+ const TCollection_AsciiString& name = ExprIntrp_GetResult();
ExprIntrp_Recept.PushName(name);
ExprIntrp_nbargs = 0;
}
extern "C" void ExprIntrp_StartDerivate()
{
- char funcname[100];
- ExprIntrp_GetResult(funcname);
- TCollection_AsciiString name(funcname);
+ const TCollection_AsciiString& name = ExprIntrp_GetResult();
ExprIntrp_Recept.PushName(name);
}
extern "C" void ExprIntrp_Derivation()
{
ExprIntrp_Recept.PushValue(1);
- char name[100];
- ExprIntrp_GetResult(name);
- TCollection_AsciiString thename(name);
+ const TCollection_AsciiString& thename = ExprIntrp_GetResult();
Handle(Expr_NamedExpression) namexp = ExprIntrp_Recept.GetNamed(thename);
if (namexp.IsNull()) {
namexp = new Expr_NamedUnknown(thename);
extern "C" void ExprIntrp_DerivationValue()
{
- char num[30];
- ExprIntrp_GetResult(num);
- Standard_Integer degree = ExprIntrp_Recept.PopValue();
- degree = atoi(num);
- ExprIntrp_Recept.PushValue(degree);
+ const TCollection_AsciiString& aStr = ExprIntrp_GetResult();
+ ExprIntrp_Recept.PopValue();
+ ExprIntrp_Recept.PushValue(aStr.IntegerValue());
}
extern "C" void ExprIntrp_EndDerivation()
extern "C" void ExprIntrp_DiffDegreeVar()
{
- char name[100];
- ExprIntrp_GetResult(name);
-#ifndef WNT
- if (strncasecmp(name,"X",1)) {
-#else
- if ( name[ 0 ] != 'X' && name[ 0 ] != 'x' ) {
-#endif // WNT
+ const TCollection_AsciiString& aStr = ExprIntrp_GetResult();
+ const char* s = aStr.ToCString();
+ if ( *s != 'X' && *s != 'x' ) {
ExprIntrp_SyntaxError::Raise();
}
- char* s = name;
s++;
Standard_Integer rank = atoi(s);
ExprIntrp_Recept.PushValue(rank);
extern "C" void ExprIntrp_DiffDegree()
{
- char name[100];
- ExprIntrp_GetResult(name);
- Standard_Integer deg = atoi(name);
+ const TCollection_AsciiString& aStr = ExprIntrp_GetResult();
+ Standard_Integer deg = aStr.IntegerValue();
ExprIntrp_Recept.PushValue(deg);
}
extern "C" void ExprIntrp_VerDiffDegree()
{
- char name[100];
- ExprIntrp_GetResult(name);
- Standard_Integer deg = atoi(name);
+ const TCollection_AsciiString& aStr = ExprIntrp_GetResult();
+ Standard_Integer deg = aStr.IntegerValue();
Standard_Integer thedeg = ExprIntrp_Recept.PopValue();
if (deg != thedeg) {
ExprIntrp_SyntaxError::Raise();
extern "C" void ExprIntrp_VariableIdentifier()
{
- char name[30];
- ExprIntrp_GetResult(name);
- TCollection_AsciiString thename(name);
+ const TCollection_AsciiString& thename = ExprIntrp_GetResult();
Handle(Expr_NamedExpression) nameexp = ExprIntrp_Recept.GetNamed(thename);
if (nameexp.IsNull()) {
nameexp = new Expr_NamedUnknown(thename);
extern "C" void ExprIntrp_NumValue()
{
- char num[30];
- int nbcar;
- nbcar = ExprIntrp_GetResult(num);
- Standard_Real value = Atof(num);
+ const TCollection_AsciiString& aStr = ExprIntrp_GetResult();
+ Standard_Real value = aStr.RealValue();
Handle(Expr_NumericValue) nval = new Expr_NumericValue(value);
ExprIntrp_Recept.Push(nval);
}
extern "C" void ExprIntrp_AssignVariable()
{
- ExprIntrp_GetResult(ExprIntrp_assname);
+ ExprIntrp_assname = ExprIntrp_GetResult();
}
extern "C" void ExprIntrp_Deassign()
{
- char name[100];
- ExprIntrp_GetResult(name);
- TCollection_AsciiString thename(name);
+ const TCollection_AsciiString& thename = ExprIntrp_GetResult();
Handle(Expr_NamedExpression) nameexp = ExprIntrp_Recept.GetNamed(thename);
if (nameexp.IsNull()) {
ExprIntrp_SyntaxError::Raise();
extern "C" void ExprIntrp_ConstantIdentifier()
{
- char name[100];
- ExprIntrp_GetResult(name);
- TCollection_AsciiString thename(name);
+ const TCollection_AsciiString& thename = ExprIntrp_GetResult();
ExprIntrp_Recept.PushName(thename);
}
extern "C" void ExprIntrp_ConstantDefinition()
{
TCollection_AsciiString name = ExprIntrp_Recept.PopName();
- char num[30];
- int nbcar;
- nbcar = ExprIntrp_GetResult(num);
- Standard_Real val = Atof(num);
+ const TCollection_AsciiString& aStr = ExprIntrp_GetResult();
+ Standard_Real val = aStr.RealValue();
Handle(Expr_NamedConstant) theconst = new Expr_NamedConstant(name,val);
ExprIntrp_Recept.Use(theconst);
ExprIntrp_Recept.Push(theconst);