mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-08-19 13:40:49 +03:00
Integration of OCCT 6.5.0 from SVN
This commit is contained in:
54
src/ExprIntrp/ExprIntrp.cdl
Executable file
54
src/ExprIntrp/ExprIntrp.cdl
Executable file
@@ -0,0 +1,54 @@
|
||||
-- File: ExprIntrp.cdl
|
||||
-- Created: Thu Jul 18 18:10:24 1991
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@topsn2>
|
||||
---Copyright: Matra Datavision 1991, 1992
|
||||
|
||||
|
||||
package ExprIntrp
|
||||
|
||||
---Purpose: Describes an interpreter for GeneralExpressions,
|
||||
-- GeneralFunctions, and GeneralRelations defined in
|
||||
-- package Expr.
|
||||
|
||||
uses Expr, MMgt, TCollection, TColStd
|
||||
|
||||
is
|
||||
|
||||
deferred class Generator;
|
||||
|
||||
class GenExp;
|
||||
|
||||
class GenFct;
|
||||
|
||||
class GenRel;
|
||||
|
||||
private class Analysis;
|
||||
|
||||
class SequenceOfNamedFunction instantiates
|
||||
Sequence from TCollection(NamedFunction from Expr);
|
||||
|
||||
class SequenceOfNamedExpression instantiates
|
||||
Sequence from TCollection(NamedExpression from Expr);
|
||||
|
||||
exception SyntaxError inherits Failure from Standard;
|
||||
|
||||
private class StackOfGeneralExpression instantiates
|
||||
Stack from TCollection (GeneralExpression from Expr);
|
||||
|
||||
private class StackOfGeneralRelation instantiates
|
||||
Stack from TCollection (GeneralRelation from Expr);
|
||||
|
||||
private class StackOfGeneralFunction instantiates
|
||||
Stack from TCollection (GeneralFunction from Expr);
|
||||
|
||||
|
||||
private class StackOfNames instantiates
|
||||
Stack from TCollection (AsciiString from TCollection);
|
||||
|
||||
Parse(gen : Generator; str : AsciiString from TCollection)
|
||||
returns Boolean
|
||||
is private;
|
||||
|
||||
end ExprIntrp;
|
||||
|
41
src/ExprIntrp/ExprIntrp.cxx
Executable file
41
src/ExprIntrp/ExprIntrp.cxx
Executable file
@@ -0,0 +1,41 @@
|
||||
//static const char* sccsid = "@(#)ExprIntrp.cxx 3.2 95/01/10"; // Do not delete this line. Used by sccs.
|
||||
// Copyright: Matra-Datavision 1992
|
||||
// File: ExprIntrp.cxx
|
||||
// Created: Mon Aug 17 18:40:44 1992
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
#include <ExprIntrp.ixx>
|
||||
#include <ExprIntrp_yaccintrf.hxx>
|
||||
#include <ExprIntrp_yaccanal.hxx>
|
||||
#include <Standard_ErrorHandler.hxx>
|
||||
#include <ExprIntrp_SyntaxError.hxx>
|
||||
|
||||
TCollection_AsciiString ExprIntrp_thestring;
|
||||
Standard_Integer ExprIntrp_thecurchar=0;
|
||||
|
||||
Standard_Boolean ExprIntrp::Parse(const Handle(ExprIntrp_Generator)& gen, const TCollection_AsciiString& str)
|
||||
{
|
||||
ExprIntrp_Recept.SetMaster(gen);
|
||||
ExprIntrp_thecurchar = 0;
|
||||
if (str.Length() == 0) return Standard_False;
|
||||
ExprIntrp_thestring = str;
|
||||
ExprIntrp_start_string(ExprIntrp_thestring.ToCString());
|
||||
|
||||
int kerror=1;
|
||||
|
||||
{
|
||||
try {
|
||||
OCC_CATCH_SIGNALS
|
||||
while (kerror!=0) {
|
||||
kerror = ExprIntrpparse();
|
||||
}
|
||||
return Standard_True;
|
||||
}
|
||||
catch (Standard_Failure) {
|
||||
return Standard_False;
|
||||
}
|
||||
}
|
||||
return Standard_False;
|
||||
}
|
||||
|
52
src/ExprIntrp/ExprIntrp.lex
Executable file
52
src/ExprIntrp/ExprIntrp.lex
Executable file
@@ -0,0 +1,52 @@
|
||||
%option yywrap
|
||||
%{
|
||||
#include <ExprIntrp.tab.h>
|
||||
#define YY_SKIP_YYWRAP
|
||||
|
||||
static YY_BUFFER_STATE ExprIntrp_bufstring;
|
||||
|
||||
void ExprIntrp_SetResult();
|
||||
void ExprIntrp_SetDegree();
|
||||
|
||||
void ExprIntrp_start_string(char* str)
|
||||
{
|
||||
ExprIntrp_bufstring = ExprIntrp_scan_string(str);
|
||||
}
|
||||
|
||||
void ExprIntrp_stop_string()
|
||||
{
|
||||
ExprIntrp_delete_buffer(ExprIntrp_bufstring);
|
||||
}
|
||||
|
||||
int yywrap()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
%}
|
||||
%%
|
||||
" " {;}
|
||||
"+" {return(SUMOP) ;}
|
||||
"-" {return(MINUSOP) ;}
|
||||
"/" {return(DIVIDEOP) ;}
|
||||
"^" {return(EXPOP) ;}
|
||||
"**" {return(EXPOP) ;}
|
||||
"*" {return(MULTOP) ;}
|
||||
"(" {return(PARENTHESIS);}
|
||||
"[" {return(BRACKET);}
|
||||
")" {return(ENDPARENTHESIS);}
|
||||
"]" {return(ENDBRACKET);}
|
||||
"," {return(COMMA);}
|
||||
"@" {return(DIFFERENTIAL);}
|
||||
"<-" {return(ASSIGNOP);}
|
||||
"=" {return(EQUALOP);}
|
||||
"Deassign" {return(DEASSIGNKEY);}
|
||||
"Deriv" {return(DERIVKEY);}
|
||||
"Const" {return(CONSTKEY);}
|
||||
"Sum" {return(SUMKEY);}
|
||||
"Prod" {return(PRODKEY);}
|
||||
[0-9.]+e[+|-]?[0-9]+ {ExprIntrp_SetResult(); return(VALUE);}
|
||||
[0-9.]+ {ExprIntrp_SetResult(); return(VALUE);}
|
||||
[a-zA-Z][a-zA-Z0-9_]* {ExprIntrp_SetResult(); return(IDENTIFIER);}
|
||||
";" {return(RELSEPARATOR);}
|
||||
"'"+ {ExprIntrp_SetDegree();return(DERIVATE);}
|
1231
src/ExprIntrp/ExprIntrp.tab.c
Executable file
1231
src/ExprIntrp/ExprIntrp.tab.c
Executable file
File diff suppressed because it is too large
Load Diff
149
src/ExprIntrp/ExprIntrp.yacc
Executable file
149
src/ExprIntrp/ExprIntrp.yacc
Executable file
@@ -0,0 +1,149 @@
|
||||
%{
|
||||
extern void ExprIntrp_EndOfFuncDef();
|
||||
extern void ExprIntrp_EndOfRelation();
|
||||
extern void ExprIntrp_AssignVariable();
|
||||
extern void ExprIntrp_EndOfAssign();
|
||||
extern void ExprIntrp_Deassign();
|
||||
extern void ExprIntrp_SumOperator();
|
||||
extern void ExprIntrp_MinusOperator();
|
||||
extern void ExprIntrp_ProductOperator();
|
||||
extern void ExprIntrp_DivideOperator();
|
||||
extern void ExprIntrp_ExpOperator();
|
||||
extern void ExprIntrp_UnaryMinusOperator();
|
||||
extern void ExprIntrp_VariableIdentifier();
|
||||
extern void ExprIntrp_NumValue();
|
||||
extern void ExprIntrp_EndFunction();
|
||||
extern void ExprIntrp_EndDerFunction();
|
||||
extern void ExprIntrp_EndDifferential();
|
||||
extern void ExprIntrp_EndDiffFunction();
|
||||
extern void ExprIntrp_EndFuncArg();
|
||||
extern void ExprIntrp_NextFuncArg();
|
||||
extern void ExprIntrp_StartFunction();
|
||||
extern void ExprIntrp_DefineFunction();
|
||||
extern void ExprIntrp_StartDerivate();
|
||||
extern void ExprIntrp_EndDerivate();
|
||||
extern void ExprIntrp_DiffVar();
|
||||
extern void ExprIntrp_DiffDegree();
|
||||
extern void ExprIntrp_VerDiffDegree();
|
||||
extern void ExprIntrp_DiffDegreeVar();
|
||||
extern void ExprIntrp_StartDifferential();
|
||||
extern void ExprIntrp_StartFunction();
|
||||
extern void ExprIntrp_EndFuncArg();
|
||||
extern void ExprIntrp_NextFuncArg();
|
||||
extern void ExprIntrp_VariableIdentifier();
|
||||
extern void ExprIntrp_Derivation();
|
||||
extern void ExprIntrp_EndDerivation();
|
||||
extern void ExprIntrp_DerivationValue();
|
||||
extern void ExprIntrp_ConstantIdentifier();
|
||||
extern void ExprIntrp_ConstantDefinition();
|
||||
extern void ExprIntrp_VariableIdentifier();
|
||||
extern void ExprIntrp_NumValue();
|
||||
extern void ExprIntrp_Sumator();
|
||||
extern void ExprIntrp_VariableIdentifier();
|
||||
extern void ExprIntrp_Productor();
|
||||
extern void ExprIntrp_EndOfEqual();
|
||||
%}
|
||||
|
||||
%token SUMOP MINUSOP DIVIDEOP EXPOP MULTOP PARENTHESIS BRACKET ENDPARENTHESIS ENDBRACKET VALUE IDENTIFIER COMMA DIFFERENTIAL DERIVATE DERIVKEY ASSIGNOP DEASSIGNKEY EQUALOP RELSEPARATOR CONSTKEY SUMKEY PRODKEY
|
||||
%start exprentry
|
||||
%left SUMOP MINUSOP
|
||||
%left DIVIDEOP MULTOP
|
||||
%left EXPOP
|
||||
%{
|
||||
%}
|
||||
%%
|
||||
|
||||
exprentry : GenExpr
|
||||
| Assignment
|
||||
| Deassignment
|
||||
| FunctionDefinition {ExprIntrp_EndOfFuncDef();}
|
||||
| RelationList {ExprIntrp_EndOfRelation();}
|
||||
;
|
||||
|
||||
Assignment : IDENTIFIER {ExprIntrp_AssignVariable();} ASSIGNOP GenExpr {ExprIntrp_EndOfAssign();}
|
||||
;
|
||||
|
||||
Deassignment : DEASSIGNKEY BRACKET IDENTIFIER {ExprIntrp_Deassign();} ENDBRACKET
|
||||
;
|
||||
|
||||
GenExpr : GenExpr SUMOP GenExpr {ExprIntrp_SumOperator();}
|
||||
| GenExpr MINUSOP GenExpr {ExprIntrp_MinusOperator();}
|
||||
| GenExpr MULTOP GenExpr {ExprIntrp_ProductOperator();}
|
||||
| GenExpr DIVIDEOP GenExpr {ExprIntrp_DivideOperator();}
|
||||
| GenExpr EXPOP GenExpr {ExprIntrp_ExpOperator();}
|
||||
| PARENTHESIS GenExpr ENDPARENTHESIS
|
||||
| BRACKET GenExpr ENDBRACKET
|
||||
| MINUSOP GenExpr {ExprIntrp_UnaryMinusOperator();}
|
||||
| SingleExpr
|
||||
| Derivation
|
||||
| ConstantDefinition
|
||||
| Sumator
|
||||
| Productor
|
||||
;
|
||||
|
||||
SingleExpr : Single
|
||||
| Function
|
||||
;
|
||||
|
||||
|
||||
Single : IDENTIFIER {ExprIntrp_VariableIdentifier();}
|
||||
| VALUE {ExprIntrp_NumValue();}
|
||||
;
|
||||
|
||||
Function : funcident PARENTHESIS ListGenExpr ENDPARENTHESIS {ExprIntrp_EndFunction();}
|
||||
| DerFunctionId PARENTHESIS ListGenExpr ENDPARENTHESIS {ExprIntrp_EndDerFunction();}
|
||||
| DiffFuncId {ExprIntrp_EndDifferential();} PARENTHESIS ListGenExpr ENDPARENTHESIS {ExprIntrp_EndDiffFunction();}
|
||||
;
|
||||
|
||||
ListGenExpr : GenExpr {ExprIntrp_EndFuncArg();}
|
||||
| GenExpr COMMA {ExprIntrp_NextFuncArg();} ListGenExpr
|
||||
;
|
||||
|
||||
funcident : IDENTIFIER {ExprIntrp_StartFunction();}
|
||||
;
|
||||
|
||||
FunctionDefinition : FunctionDef {ExprIntrp_DefineFunction();} ASSIGNOP GenExpr
|
||||
;
|
||||
|
||||
DerFunctionId : IDENTIFIER {ExprIntrp_StartDerivate();} DERIVATE {ExprIntrp_EndDerivate();}
|
||||
;
|
||||
|
||||
DiffFuncId : DIFFERENTIAL DiffId DIVIDEOP DIFFERENTIAL IDENTIFIER {ExprIntrp_DiffVar();}
|
||||
| DIFFERENTIAL VALUE {ExprIntrp_DiffDegree();} DiffId DIVIDEOP DIFFERENTIAL VALUE {ExprIntrp_VerDiffDegree();} IDENTIFIER {ExprIntrp_DiffDegreeVar();}
|
||||
;
|
||||
|
||||
DiffId : IDENTIFIER {ExprIntrp_StartDifferential();}
|
||||
| DiffFuncId
|
||||
;
|
||||
|
||||
FunctionDef : IDENTIFIER {ExprIntrp_StartFunction();} BRACKET ListArg ENDBRACKET
|
||||
;
|
||||
|
||||
ListArg : unarg {ExprIntrp_EndFuncArg();}
|
||||
| unarg COMMA {ExprIntrp_NextFuncArg();} ListArg
|
||||
;
|
||||
|
||||
unarg : IDENTIFIER {ExprIntrp_VariableIdentifier();}
|
||||
;
|
||||
|
||||
Derivation : DERIVKEY BRACKET GenExpr COMMA IDENTIFIER {ExprIntrp_Derivation();} ENDBRACKET {ExprIntrp_EndDerivation();}
|
||||
| DERIVKEY BRACKET GenExpr COMMA IDENTIFIER {ExprIntrp_Derivation();} COMMA VALUE {ExprIntrp_DerivationValue();} ENDBRACKET {ExprIntrp_EndDerivation();}
|
||||
;
|
||||
|
||||
ConstantDefinition : CONSTKEY BRACKET IDENTIFIER {ExprIntrp_ConstantIdentifier();} COMMA VALUE {ExprIntrp_ConstantDefinition();} ENDBRACKET
|
||||
;
|
||||
|
||||
Sumator : SUMKEY BRACKET GenExpr COMMA IDENTIFIER {ExprIntrp_VariableIdentifier();} COMMA GenExpr COMMA GenExpr COMMA VALUE {ExprIntrp_NumValue();} ENDBRACKET {ExprIntrp_Sumator();}
|
||||
;
|
||||
|
||||
Productor : PRODKEY BRACKET GenExpr COMMA IDENTIFIER {ExprIntrp_VariableIdentifier();} COMMA GenExpr COMMA GenExpr COMMA VALUE {ExprIntrp_NumValue();} ENDBRACKET {ExprIntrp_Productor();}
|
||||
;
|
||||
|
||||
RelationList : SingleRelation
|
||||
| SingleRelation RELSEPARATOR RelationList
|
||||
| SingleRelation '\n' RelationList
|
||||
;
|
||||
|
||||
SingleRelation : GenExpr EQUALOP GenExpr {ExprIntrp_EndOfEqual();}
|
||||
;
|
||||
|
107
src/ExprIntrp/ExprIntrp_Analysis.cdl
Executable file
107
src/ExprIntrp/ExprIntrp_Analysis.cdl
Executable file
@@ -0,0 +1,107 @@
|
||||
-- File: Analysis.cdl
|
||||
-- Created: Fri Feb 21 15:48:10 1992
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@topsn2>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
private class Analysis from ExprIntrp
|
||||
|
||||
---Purpose:
|
||||
|
||||
uses Generator from ExprIntrp,
|
||||
GeneralExpression from Expr,
|
||||
GeneralRelation from Expr,
|
||||
GeneralFunction from Expr,
|
||||
StackOfGeneralExpression from ExprIntrp,
|
||||
StackOfGeneralRelation from ExprIntrp,
|
||||
StackOfGeneralFunction from ExprIntrp,
|
||||
StackOfInteger from TColStd,
|
||||
SequenceOfGeneralExpression from Expr,
|
||||
SequenceOfNamedFunction from ExprIntrp,
|
||||
SequenceOfNamedExpression from ExprIntrp,
|
||||
NamedFunction from Expr,
|
||||
NamedExpression from Expr,
|
||||
AsciiString from TCollection,
|
||||
StackOfNames from ExprIntrp
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
returns Analysis;
|
||||
|
||||
SetMaster(me : in out; agen : Generator)
|
||||
is static;
|
||||
|
||||
Push(me : in out; exp : GeneralExpression)
|
||||
is static;
|
||||
|
||||
PushRelation(me : in out; rel : GeneralRelation)
|
||||
is static;
|
||||
|
||||
PushName(me : in out; name : AsciiString)
|
||||
is static;
|
||||
|
||||
PushValue(me : in out; degree : Integer)
|
||||
is static;
|
||||
|
||||
PushFunction(me : in out; func : GeneralFunction)
|
||||
is static;
|
||||
|
||||
Pop(me : in out)
|
||||
returns GeneralExpression
|
||||
is static;
|
||||
|
||||
PopRelation(me : in out)
|
||||
returns GeneralRelation
|
||||
is static;
|
||||
|
||||
PopName(me : in out)
|
||||
returns AsciiString
|
||||
is static;
|
||||
|
||||
PopValue(me: in out)
|
||||
returns Integer
|
||||
is static;
|
||||
|
||||
PopFunction(me: in out)
|
||||
returns GeneralFunction
|
||||
is static;
|
||||
|
||||
IsExpStackEmpty(me)
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
IsRelStackEmpty(me)
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
ResetAll(me : in out)
|
||||
is static;
|
||||
|
||||
Use(me : in out; func : NamedFunction)
|
||||
is static;
|
||||
|
||||
Use(me : in out; named : NamedExpression)
|
||||
is static;
|
||||
|
||||
GetNamed(me : in out; name : AsciiString)
|
||||
returns NamedExpression
|
||||
is static;
|
||||
|
||||
GetFunction(me : in out; name : AsciiString)
|
||||
returns NamedFunction
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
myGEStack : StackOfGeneralExpression;
|
||||
myGRStack : StackOfGeneralRelation;
|
||||
myGFStack : StackOfGeneralFunction;
|
||||
myNameStack : StackOfNames;
|
||||
myValueStack : StackOfInteger;
|
||||
myFunctions : SequenceOfNamedFunction;
|
||||
myNamed : SequenceOfNamedExpression;
|
||||
myMaster : Generator;
|
||||
|
||||
end Analysis;
|
152
src/ExprIntrp/ExprIntrp_Analysis.cxx
Executable file
152
src/ExprIntrp/ExprIntrp_Analysis.cxx
Executable file
@@ -0,0 +1,152 @@
|
||||
//static const char* sccsid = "@(#)ExprIntrp_Analysis.cxx 3.2 95/01/10"; // Do not delete this line. Used by sccs.
|
||||
// Copyright: Matra-Datavision 1992
|
||||
// File: ExprIntrp_Analysis.cxx
|
||||
// Created: Tue Feb 25 17:47:25 1992
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
#define _ExprIntrp_Analysis_SourceFile
|
||||
|
||||
#include <ExprIntrp_Analysis.ixx>
|
||||
#include <Expr_NamedUnknown.hxx>
|
||||
|
||||
ExprIntrp_Analysis::ExprIntrp_Analysis() {}
|
||||
|
||||
|
||||
void ExprIntrp_Analysis::Push(const Handle(Expr_GeneralExpression)& exp)
|
||||
{
|
||||
myGEStack.Push(exp);
|
||||
}
|
||||
|
||||
void ExprIntrp_Analysis::PushRelation(const Handle(Expr_GeneralRelation)& rel)
|
||||
{
|
||||
myGRStack.Push(rel);
|
||||
}
|
||||
|
||||
void ExprIntrp_Analysis::PushFunction(const Handle(Expr_GeneralFunction)& func)
|
||||
{
|
||||
myGFStack.Push(func);
|
||||
}
|
||||
|
||||
void ExprIntrp_Analysis::PushName(const TCollection_AsciiString& name)
|
||||
{
|
||||
myNameStack.Push(name);
|
||||
}
|
||||
|
||||
void ExprIntrp_Analysis::PushValue(const Standard_Integer val)
|
||||
{
|
||||
myValueStack.Push(val);
|
||||
}
|
||||
|
||||
Handle(Expr_GeneralExpression) ExprIntrp_Analysis::Pop()
|
||||
{
|
||||
Handle(Expr_GeneralExpression) res;
|
||||
if (!myGEStack.IsEmpty()) {
|
||||
res = myGEStack.Top();
|
||||
myGEStack.Pop();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Handle(Expr_GeneralRelation) ExprIntrp_Analysis::PopRelation()
|
||||
{
|
||||
Handle(Expr_GeneralRelation) res;
|
||||
if (!myGRStack.IsEmpty()) {
|
||||
res = myGRStack.Top();
|
||||
myGRStack.Pop();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Handle(Expr_GeneralFunction) ExprIntrp_Analysis::PopFunction()
|
||||
{
|
||||
Handle(Expr_GeneralFunction) res;
|
||||
if (!myGFStack.IsEmpty()) {
|
||||
res = myGFStack.Top();
|
||||
myGFStack.Pop();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
TCollection_AsciiString ExprIntrp_Analysis::PopName()
|
||||
{
|
||||
TCollection_AsciiString res;
|
||||
if (!myNameStack.IsEmpty()) {
|
||||
res = myNameStack.Top();
|
||||
myNameStack.Pop();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Standard_Integer ExprIntrp_Analysis::PopValue()
|
||||
{
|
||||
Standard_Integer res =0;
|
||||
if (!myValueStack.IsEmpty()) {
|
||||
res = myValueStack.Top();
|
||||
myValueStack.Pop();
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
Standard_Boolean ExprIntrp_Analysis::IsExpStackEmpty() const
|
||||
{
|
||||
return myGEStack.IsEmpty();
|
||||
}
|
||||
|
||||
Standard_Boolean ExprIntrp_Analysis::IsRelStackEmpty() const
|
||||
{
|
||||
return myGRStack.IsEmpty();
|
||||
}
|
||||
|
||||
void ExprIntrp_Analysis::ResetAll()
|
||||
{
|
||||
myGEStack.Clear();
|
||||
myGRStack.Clear();
|
||||
myGFStack.Clear();
|
||||
myNameStack.Clear();
|
||||
myValueStack.Clear();
|
||||
myFunctions.Clear();
|
||||
myNamed.Clear();
|
||||
}
|
||||
|
||||
void ExprIntrp_Analysis::SetMaster(const Handle(ExprIntrp_Generator)& agen)
|
||||
{
|
||||
ResetAll();
|
||||
myMaster = agen;
|
||||
myFunctions = myMaster->GetFunctions();
|
||||
myNamed = myMaster->GetNamed();
|
||||
}
|
||||
|
||||
void ExprIntrp_Analysis::Use(const Handle(Expr_NamedFunction)& func)
|
||||
{
|
||||
myFunctions.Append(func);
|
||||
myMaster->Use(func);
|
||||
}
|
||||
|
||||
void ExprIntrp_Analysis::Use(const Handle(Expr_NamedExpression)& named)
|
||||
{
|
||||
myNamed.Append(named);
|
||||
myMaster->Use(named);
|
||||
}
|
||||
|
||||
Handle(Expr_NamedExpression) ExprIntrp_Analysis::GetNamed(const TCollection_AsciiString& name)
|
||||
{
|
||||
for (Standard_Integer i=1; i<= myNamed.Length();i++) {
|
||||
if (name == myNamed(i)->GetName()) {
|
||||
return myNamed(i);
|
||||
}
|
||||
}
|
||||
Handle(Expr_NamedExpression) curnamed;
|
||||
return curnamed;
|
||||
}
|
||||
|
||||
Handle(Expr_NamedFunction) ExprIntrp_Analysis::GetFunction(const TCollection_AsciiString& name)
|
||||
{
|
||||
for (Standard_Integer i=1; i<= myFunctions.Length();i++) {
|
||||
if (name == myFunctions(i)->GetName()) {
|
||||
return myFunctions(i);
|
||||
}
|
||||
}
|
||||
Handle(Expr_NamedFunction) curfunc;
|
||||
return curfunc;
|
||||
}
|
13
src/ExprIntrp/ExprIntrp_CMPLRS.edl
Executable file
13
src/ExprIntrp/ExprIntrp_CMPLRS.edl
Executable file
@@ -0,0 +1,13 @@
|
||||
-- File: ExprIntrp_CMPLRS.edl
|
||||
-- Author: Prestataire Pascal BABIN
|
||||
-- History: Wed Jan 15 10:02:48 1997 Prestataire Pascal BABIN Creation
|
||||
-- Copyright: Matra Datavision 1997
|
||||
|
||||
@ifnotdefined ( %ExprIntrp_CMPLRS_EDL) then
|
||||
@set %ExprIntrp_CMPLRS_EDL = "";
|
||||
|
||||
@if ( %Station == "hp" ) then
|
||||
@string %CMPLRS_C_Options = %CMPLRS_C_Options " -Ae";
|
||||
@endif;
|
||||
|
||||
@endif;
|
54
src/ExprIntrp/ExprIntrp_GenExp.cdl
Executable file
54
src/ExprIntrp/ExprIntrp_GenExp.cdl
Executable file
@@ -0,0 +1,54 @@
|
||||
-- File: GenExp.cdl
|
||||
-- Created: Thu Jul 18 18:13:12 1991
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@topsn2>
|
||||
---Copyright: Matra Datavision 1991
|
||||
|
||||
|
||||
class GenExp from ExprIntrp inherits Generator from ExprIntrp
|
||||
|
||||
---Purpose: This class permits, from a string, to create any
|
||||
-- kind of expression of package Expr by using
|
||||
-- built-in functions such as Sin,Cos, etc, and by
|
||||
-- creating variables.
|
||||
|
||||
uses GeneralExpression from Expr,
|
||||
AsciiString from TCollection
|
||||
|
||||
raises NoSuchObject
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
---Purpose: Creates an empty generator
|
||||
---Level: Advanced
|
||||
returns mutable GenExp is private;
|
||||
|
||||
Create( myclass ) returns GenExp;
|
||||
|
||||
Process(me : mutable; str : AsciiString)
|
||||
---Purpose: Processes given string.
|
||||
---Level: Advanced
|
||||
is static;
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns false if any syntax error has occurred during
|
||||
-- process.
|
||||
---Level: Advanced
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
Expression(me)
|
||||
---Purpose: Returns expression generated. Raises an exception if
|
||||
-- IsDone answers false.
|
||||
---Level: Advanced
|
||||
returns any GeneralExpression
|
||||
raises NoSuchObject
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
done : Boolean;
|
||||
myExpression : GeneralExpression;
|
||||
|
||||
end GenExp;
|
54
src/ExprIntrp/ExprIntrp_GenExp.cxx
Executable file
54
src/ExprIntrp/ExprIntrp_GenExp.cxx
Executable file
@@ -0,0 +1,54 @@
|
||||
//static const char* sccsid = "@(#)ExprIntrp_GenExp.cxx 3.2 95/01/10"; // Do not delete this line. Used by sccs.
|
||||
// Copyright: Matra-Datavision 1991
|
||||
// File: ExprIntrp_GenExp.cxx
|
||||
// Created: Thu Aug 8 10:15:28 1991
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
#include <ExprIntrp_GenExp.ixx>
|
||||
#include <ExprIntrp.hxx>
|
||||
#include <ExprIntrp_yaccanal.hxx>
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
|
||||
ExprIntrp_GenExp::ExprIntrp_GenExp ()
|
||||
{
|
||||
done = Standard_False;
|
||||
}
|
||||
|
||||
Handle( ExprIntrp_GenExp ) ExprIntrp_GenExp::Create()
|
||||
{
|
||||
return new ExprIntrp_GenExp();
|
||||
}
|
||||
|
||||
void ExprIntrp_GenExp::Process (const TCollection_AsciiString& str)
|
||||
{
|
||||
Handle(ExprIntrp_GenExp) me = this;
|
||||
done = Standard_False;
|
||||
if (ExprIntrp::Parse(me,str)) {
|
||||
if (!ExprIntrp_Recept.IsExpStackEmpty()) {
|
||||
myExpression = ExprIntrp_Recept.Pop();
|
||||
done = Standard_True;
|
||||
}
|
||||
else {
|
||||
myExpression.Nullify();
|
||||
done = Standard_True;
|
||||
}
|
||||
}
|
||||
else {
|
||||
myExpression.Nullify();
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Boolean ExprIntrp_GenExp::IsDone() const
|
||||
{
|
||||
return done;
|
||||
}
|
||||
|
||||
Handle(Expr_GeneralExpression) ExprIntrp_GenExp::Expression () const
|
||||
{
|
||||
if (!done) {
|
||||
Standard_NoSuchObject::Raise();
|
||||
}
|
||||
return myExpression;
|
||||
}
|
||||
|
40
src/ExprIntrp/ExprIntrp_GenFct.cdl
Executable file
40
src/ExprIntrp/ExprIntrp_GenFct.cdl
Executable file
@@ -0,0 +1,40 @@
|
||||
-- File: GenFct.cdl
|
||||
-- Created: Tue Aug 18 11:06:13 1992
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@bravox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
class GenFct from ExprIntrp inherits Generator from ExprIntrp
|
||||
|
||||
---Purpose: Implements an interpreter for defining functions.
|
||||
-- All its functionnalities can be found in class
|
||||
-- GenExp.
|
||||
|
||||
uses NamedFunction from Expr,
|
||||
SequenceOfNamedFunction from ExprIntrp,
|
||||
AsciiString from TCollection
|
||||
|
||||
raises NoSuchObject
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
---Level: Internal
|
||||
returns mutable GenFct is private;
|
||||
|
||||
Create( myclass ) returns GenFct;
|
||||
|
||||
Process(me : mutable; str : AsciiString)
|
||||
---Level: Internal
|
||||
is static;
|
||||
|
||||
IsDone(me)
|
||||
---Level: Internal
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
done : Boolean;
|
||||
|
||||
end GenFct;
|
32
src/ExprIntrp/ExprIntrp_GenFct.cxx
Executable file
32
src/ExprIntrp/ExprIntrp_GenFct.cxx
Executable file
@@ -0,0 +1,32 @@
|
||||
//static const char* sccsid = "@(#)ExprIntrp_GenFct.cxx 3.2 95/01/10"; // Do not delete this line. Used by sccs.
|
||||
// Copyright: Matra-Datavision 1992
|
||||
// File: ExprIntrp_GenFct.cxx
|
||||
// Created: Tue Aug 18 11:11:32 1992
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
#include <ExprIntrp_GenFct.ixx>
|
||||
#include <ExprIntrp.hxx>
|
||||
#include <ExprIntrp_yaccanal.hxx>
|
||||
|
||||
ExprIntrp_GenFct::ExprIntrp_GenFct ()
|
||||
{
|
||||
done = Standard_False;
|
||||
}
|
||||
|
||||
Handle( ExprIntrp_GenFct ) ExprIntrp_GenFct::Create()
|
||||
{
|
||||
return new ExprIntrp_GenFct();
|
||||
}
|
||||
|
||||
void ExprIntrp_GenFct::Process (const TCollection_AsciiString& str)
|
||||
{
|
||||
Handle(ExprIntrp_GenFct) me = this;
|
||||
done = ExprIntrp::Parse(me,str);
|
||||
}
|
||||
|
||||
Standard_Boolean ExprIntrp_GenFct::IsDone() const
|
||||
{
|
||||
return done;
|
||||
}
|
||||
|
51
src/ExprIntrp/ExprIntrp_GenRel.cdl
Executable file
51
src/ExprIntrp/ExprIntrp_GenRel.cdl
Executable file
@@ -0,0 +1,51 @@
|
||||
-- File: GenRel.cdl
|
||||
-- Created: Tue Aug 18 11:32:35 1992
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@bravox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
class GenRel from ExprIntrp inherits Generator from ExprIntrp
|
||||
|
||||
---Purpose: Implements an interpreter for equations or system
|
||||
-- of equations made of expressions of package Expr.
|
||||
|
||||
uses GeneralRelation from Expr,
|
||||
AsciiString from TCollection
|
||||
|
||||
raises NoSuchObject
|
||||
|
||||
is
|
||||
|
||||
Create
|
||||
---Purpose: Creates an empty generator
|
||||
---Level: Advanced
|
||||
returns mutable GenRel is private;
|
||||
|
||||
Create( myclass ) returns GenRel;
|
||||
|
||||
Process(me : mutable; str : AsciiString)
|
||||
---Purpose: Processes given string.
|
||||
---Level: Advanced
|
||||
is static;
|
||||
|
||||
IsDone(me)
|
||||
---Purpose: Returns false if any syntax error has occurred during
|
||||
-- process.
|
||||
---Level: Advanced
|
||||
returns Boolean
|
||||
is static;
|
||||
|
||||
Relation(me)
|
||||
---Purpose: Returns relation generated. Raises an exception if
|
||||
-- IsDone answers false.
|
||||
---Level: Advanced
|
||||
returns mutable GeneralRelation
|
||||
raises NoSuchObject
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
done : Boolean;
|
||||
myRelation : GeneralRelation;
|
||||
|
||||
end GenRel;
|
53
src/ExprIntrp/ExprIntrp_GenRel.cxx
Executable file
53
src/ExprIntrp/ExprIntrp_GenRel.cxx
Executable file
@@ -0,0 +1,53 @@
|
||||
//static const char* sccsid = "@(#)ExprIntrp_GenRel.cxx 3.2 95/01/10"; // Do not delete this line. Used by sccs.
|
||||
// Copyright: Matra-Datavision 1992
|
||||
// File: ExprIntrp_GenRel.cxx
|
||||
// Created: Tue Aug 18 11:33:52 1992
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
#include <ExprIntrp_GenRel.ixx>
|
||||
#include <ExprIntrp.hxx>
|
||||
#include <ExprIntrp_yaccanal.hxx>
|
||||
#include <Standard_NoSuchObject.hxx>
|
||||
|
||||
ExprIntrp_GenRel::ExprIntrp_GenRel ()
|
||||
{
|
||||
done = Standard_False;
|
||||
}
|
||||
|
||||
Handle( ExprIntrp_GenRel ) ExprIntrp_GenRel::Create()
|
||||
{
|
||||
return new ExprIntrp_GenRel();
|
||||
}
|
||||
|
||||
void ExprIntrp_GenRel::Process (const TCollection_AsciiString& str)
|
||||
{
|
||||
Handle(ExprIntrp_GenRel) me = this;
|
||||
done = Standard_False;
|
||||
if (ExprIntrp::Parse(me,str)) {
|
||||
if (!ExprIntrp_Recept.IsRelStackEmpty()) {
|
||||
myRelation = ExprIntrp_Recept.PopRelation();
|
||||
done = Standard_True;
|
||||
}
|
||||
else {
|
||||
myRelation.Nullify();
|
||||
}
|
||||
}
|
||||
else {
|
||||
myRelation.Nullify();
|
||||
}
|
||||
}
|
||||
|
||||
Standard_Boolean ExprIntrp_GenRel::IsDone() const
|
||||
{
|
||||
return done;
|
||||
}
|
||||
|
||||
Handle(Expr_GeneralRelation) ExprIntrp_GenRel::Relation () const
|
||||
{
|
||||
if (!done) {
|
||||
Standard_NoSuchObject::Raise();
|
||||
}
|
||||
return myRelation;
|
||||
}
|
||||
|
64
src/ExprIntrp/ExprIntrp_Generator.cdl
Executable file
64
src/ExprIntrp/ExprIntrp_Generator.cdl
Executable file
@@ -0,0 +1,64 @@
|
||||
-- File: Generator.cdl
|
||||
-- Created: Mon Jul 20 16:59:17 1992
|
||||
-- Author: Arnaud BOUZY
|
||||
-- <adn@bravox>
|
||||
---Copyright: Matra Datavision 1992
|
||||
|
||||
|
||||
deferred class Generator from ExprIntrp inherits TShared from MMgt
|
||||
|
||||
---Purpose: Implements general services for interpretation of
|
||||
-- expressions.
|
||||
|
||||
uses NamedExpression from Expr,
|
||||
NamedFunction from Expr,
|
||||
SequenceOfNamedFunction from ExprIntrp,
|
||||
SequenceOfNamedExpression from ExprIntrp,
|
||||
AsciiString from TCollection
|
||||
|
||||
is
|
||||
|
||||
Initialize;
|
||||
|
||||
Use(me : mutable; func : NamedFunction)
|
||||
---Level: Internal
|
||||
is static;
|
||||
|
||||
Use(me : mutable; named : NamedExpression)
|
||||
---Level: Internal
|
||||
is static;
|
||||
|
||||
GetNamed(me)
|
||||
returns SequenceOfNamedExpression
|
||||
---C++: return const &
|
||||
---Level: Internal
|
||||
is static;
|
||||
|
||||
GetFunctions(me)
|
||||
returns SequenceOfNamedFunction
|
||||
---C++: return const &
|
||||
---Level: Internal
|
||||
is static;
|
||||
|
||||
GetNamed(me; name : AsciiString)
|
||||
---Purpose: Returns NamedExpression with name <name> already
|
||||
-- interpreted if it exists. Returns a null handle if
|
||||
-- not.
|
||||
---Level: Advanced
|
||||
returns any NamedExpression
|
||||
is static;
|
||||
|
||||
GetFunction(me; name : AsciiString)
|
||||
---Purpose: Returns NamedFunction with name <name> already
|
||||
-- interpreted if it exists. Returns a null handle if
|
||||
-- not.
|
||||
---Level: Advanced
|
||||
returns any NamedFunction
|
||||
is static;
|
||||
|
||||
fields
|
||||
|
||||
myFunctions : SequenceOfNamedFunction;
|
||||
myNamed : SequenceOfNamedExpression;
|
||||
|
||||
end Generator;
|
61
src/ExprIntrp/ExprIntrp_Generator.cxx
Executable file
61
src/ExprIntrp/ExprIntrp_Generator.cxx
Executable file
@@ -0,0 +1,61 @@
|
||||
//static const char* sccsid = "@(#)ExprIntrp_Generator.cxx 3.2 95/01/10"; // Do not delete this line. Used by sccs.
|
||||
// Copyright: Matra-Datavision 1992
|
||||
// File: ExprIntrp_Generator.cxx
|
||||
// Created: Mon Jul 20 17:06:29 1992
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
#include <ExprIntrp_Generator.ixx>
|
||||
//#include <ExprIntrp_yaccanal.hxx>
|
||||
#include <ExprIntrp_Analysis.hxx>
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
Standard_EXPORT ExprIntrp_Analysis ExprIntrp_Recept;
|
||||
|
||||
|
||||
ExprIntrp_Generator::ExprIntrp_Generator()
|
||||
{
|
||||
}
|
||||
|
||||
void ExprIntrp_Generator::Use(const Handle(Expr_NamedFunction)& func)
|
||||
{
|
||||
myFunctions.Append(func);
|
||||
}
|
||||
|
||||
void ExprIntrp_Generator::Use(const Handle(Expr_NamedExpression)& named)
|
||||
{
|
||||
myNamed.Append(named);
|
||||
}
|
||||
|
||||
const ExprIntrp_SequenceOfNamedFunction& ExprIntrp_Generator::GetFunctions() const
|
||||
{
|
||||
return myFunctions;
|
||||
}
|
||||
|
||||
const ExprIntrp_SequenceOfNamedExpression & ExprIntrp_Generator::GetNamed() const
|
||||
{
|
||||
return myNamed;
|
||||
}
|
||||
|
||||
Handle(Expr_NamedFunction) ExprIntrp_Generator::GetFunction (const TCollection_AsciiString& name) const
|
||||
{
|
||||
for (Standard_Integer i=1; i<= myFunctions.Length(); i++) {
|
||||
if (name == myFunctions(i)->GetName()) {
|
||||
return myFunctions(i);
|
||||
}
|
||||
}
|
||||
Handle(Expr_NamedFunction) curfunc;
|
||||
return curfunc;
|
||||
}
|
||||
|
||||
Handle(Expr_NamedExpression) ExprIntrp_Generator::GetNamed (const TCollection_AsciiString& name) const
|
||||
{
|
||||
for (Standard_Integer i=1;i<=myNamed.Length();i++){
|
||||
if (name == myNamed(i)->GetName()) {
|
||||
return myNamed(i);
|
||||
}
|
||||
}
|
||||
Handle(Expr_NamedExpression) curexp;
|
||||
return curexp;
|
||||
}
|
||||
|
60
src/ExprIntrp/ExprIntrp_Replace.tcl
Executable file
60
src/ExprIntrp/ExprIntrp_Replace.tcl
Executable file
@@ -0,0 +1,60 @@
|
||||
proc ExprIntrp_Replace:AdmFileType {} {
|
||||
return "dbadmfile";
|
||||
}
|
||||
|
||||
proc ExprIntrp_Replace:OutputDirTypeName {} {
|
||||
return "dbtmpfile";
|
||||
}
|
||||
|
||||
|
||||
proc ExprIntrp_Replace:HandleInputFile { ID } {
|
||||
|
||||
scan $ID "%\[^:\]:%\[^:\]:%\[^:\]" unit type name
|
||||
|
||||
switch $name {
|
||||
ExprIntrp.tab.c {return 1;}
|
||||
default {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
proc ExprIntrp_Replace:Execute { unit args } {
|
||||
|
||||
msgprint -i -c "ExprIntrp_Replace::Execute" "Copying of ExprIntrp includes $unit $args "
|
||||
|
||||
global tcl_interactive
|
||||
|
||||
set tcl_interactive 1
|
||||
package require Wokutils
|
||||
|
||||
|
||||
if { [wokparam -e %Station $unit] != "wnt" } {
|
||||
set copycmd "cp -p "
|
||||
set replstr "/"
|
||||
} else {
|
||||
set copycmd "cmd /c copy"
|
||||
set replstr "\\\\\\\\"
|
||||
}
|
||||
|
||||
|
||||
set sourcename ExprIntrp.tab.c
|
||||
set name ExprIntrp.tab.c
|
||||
|
||||
set source [woklocate -p ExprIntrp:source:$sourcename [wokinfo -N $unit]]
|
||||
set vistarget [woklocate -p ExprIntrp:privinclude [wokinfo -N $unit]]$name
|
||||
# set target [wokinfo -p ExprIntrp:privinclude:$name [wokinfo -N $unit]]
|
||||
msgprint -i -c "$source "
|
||||
regsub -all "/" " $source $vistarget" $replstr TheArgs
|
||||
|
||||
msgprint -i -c "ExprIntrp_Replace::Execute" "Copy $source to $vistarget"
|
||||
if { [file exist $vistarget] && [wokparam -e %Station ] != "wnt" } {
|
||||
eval exec "chmod u+w $vistarget"
|
||||
}
|
||||
eval exec "$copycmd $TheArgs"
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
15
src/ExprIntrp/ExprIntrp_WOKSteps.edl
Executable file
15
src/ExprIntrp/ExprIntrp_WOKSteps.edl
Executable file
@@ -0,0 +1,15 @@
|
||||
-- File: ExprIntrp_WOKSteps.edl
|
||||
-- Author: Atelier CAS2000
|
||||
-- History: Thu Jun 29 13:18:31 2000 Atelier CAS2000 Creation
|
||||
-- Copyright: Matra Datavision 2000
|
||||
|
||||
@ifnotdefined ( %ExprIntrp_WOKSteps_EDL) then
|
||||
@set %ExprIntrp_WOKSteps_EDL = "";
|
||||
|
||||
--- Insert your stuff Here
|
||||
|
||||
@set %CASCADESamplesJni_WOKSteps_EDL = "";
|
||||
@string %WOKSteps_XcppGroup += "xcpp.repl";
|
||||
@set %WOKSteps_xcpp_repl = "*ExprIntrp_Replace(xcpp.header)";
|
||||
|
||||
@endif;
|
30
src/ExprIntrp/ExprIntrp_yaccanal.hxx
Executable file
30
src/ExprIntrp/ExprIntrp_yaccanal.hxx
Executable file
@@ -0,0 +1,30 @@
|
||||
// Copyright: Matra-Datavision 1992
|
||||
// File: ExprIntrp_yaccanal.hxx
|
||||
// Created: Fri Aug 21 12:21:43 1992
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
|
||||
#ifndef ExprIntrp_yaccanal_HeaderFile
|
||||
#define ExprIntrp_yaccanal_HeaderFile
|
||||
|
||||
#include <ExprIntrp_Analysis.hxx>
|
||||
|
||||
#ifndef _ExprIntrp_API
|
||||
# if !defined(WNT) || defined(__ExprIntrp_DLL) || defined(__Expr_DLL) || defined(__ExprIntrp_DLL) || defined(__math_DLL) || defined(__MathBase_DLL) || defined(__ElCLib_DLL) || defined(__ElSLib_DLL) || defined(__BSplCLib_DLL) || defined(__BSplSLib_DLL) || defined(__Smoothing_DLL) || defined(__SysBase_DLL) || defined(__Data_DLL) || defined(__PLib_DLL) || defined(__GeomAbs_DLL) || defined(__Poly_DLL) || defined(__CSLib_DLL) || defined(__Convert_DLL) || defined(__Bnd_DLL) || defined(__gp_DLL) || defined(__TColgp_DLL)
|
||||
# define __ExprIntrp_API Standard_EXPORT
|
||||
# define __ExprIntrp_APIEXTERN Standard_EXPORTEXTERN
|
||||
# else
|
||||
# define __ExprIntrp_API Standard_IMPORT
|
||||
# define __ExprIntrp_APIEXTERN Standard_IMPORT
|
||||
# endif // __ExprIntrp_DLL
|
||||
#endif // __ExprIntrp_API
|
||||
|
||||
//extern __ExprIntrp_API Standard_EXPORT ExprIntrp_Analysis ExprIntrp_Recept;
|
||||
#ifdef _ExprIntrp_Analysis_SourceFile
|
||||
__ExprIntrp_API ExprIntrp_Analysis ExprIntrp_Recept;
|
||||
#else
|
||||
__ExprIntrp_APIEXTERN ExprIntrp_Analysis ExprIntrp_Recept;
|
||||
#endif
|
||||
|
||||
#endif
|
684
src/ExprIntrp/ExprIntrp_yaccintrf.cxx
Executable file
684
src/ExprIntrp/ExprIntrp_yaccintrf.cxx
Executable file
@@ -0,0 +1,684 @@
|
||||
//static const char* sccsid = "@(#)ExprIntrp_yaccintrf.cxx 3.2 95/01/10"; // Do not delete this line. Used by sccs.
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
#include <ExprIntrp_yaccintrf.hxx>
|
||||
#include <ExprIntrp_yaccanal.hxx>
|
||||
#include <Expr_GeneralExpression.hxx>
|
||||
#include <Expr_NamedExpression.hxx>
|
||||
#include <Expr_NamedUnknown.hxx>
|
||||
#include <Expr_NamedConstant.hxx>
|
||||
#include <Expr_NamedFunction.hxx>
|
||||
#include <Expr_NumericValue.hxx>
|
||||
#include <Expr_UnaryFunction.hxx>
|
||||
#include <Expr_BinaryFunction.hxx>
|
||||
#include <Expr_PolyFunction.hxx>
|
||||
#include <Expr_Exponentiate.hxx>
|
||||
#include <Expr_Absolute.hxx>
|
||||
#include <Expr_ArcCosine.hxx>
|
||||
#include <Expr_ArcSine.hxx>
|
||||
#include <Expr_ArcTangent.hxx>
|
||||
#include <Expr_ArgCosh.hxx>
|
||||
#include <Expr_ArgSinh.hxx>
|
||||
#include <Expr_ArgTanh.hxx>
|
||||
#include <Expr_Cosh.hxx>
|
||||
#include <Expr_Cosine.hxx>
|
||||
#include <Expr_Exponential.hxx>
|
||||
#include <Expr_LogOf10.hxx>
|
||||
#include <Expr_LogOfe.hxx>
|
||||
#include <Expr_Sign.hxx>
|
||||
#include <Expr_Sine.hxx>
|
||||
#include <Expr_Sinh.hxx>
|
||||
#include <Expr_SquareRoot.hxx>
|
||||
#include <Expr_Tangent.hxx>
|
||||
#include <Expr_Tanh.hxx>
|
||||
#include <Expr_Equal.hxx>
|
||||
#include <Expr_SystemRelation.hxx>
|
||||
#include <Expr_UnknownIterator.hxx>
|
||||
#include <Expr_FunctionDerivative.hxx>
|
||||
#include <Expr.hxx> // ATTENTION POUR PROTECTION BUG STACK
|
||||
|
||||
#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 Standard_Integer ExprIntrp_nbargs;
|
||||
static Standard_Integer ExprIntrp_nbdiff;
|
||||
|
||||
|
||||
extern "C" void ExprIntrp_StartFunction()
|
||||
{
|
||||
int nbcar;
|
||||
char funcname[100];
|
||||
nbcar = ExprIntrp_GetResult(funcname);
|
||||
TCollection_AsciiString name(funcname);
|
||||
ExprIntrp_Recept.PushName(name);
|
||||
ExprIntrp_nbargs = 0;
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_StartDerivate()
|
||||
{
|
||||
int nbcar;
|
||||
char funcname[100];
|
||||
nbcar = ExprIntrp_GetResult(funcname);
|
||||
TCollection_AsciiString name(funcname);
|
||||
ExprIntrp_Recept.PushName(name);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_EndDerivate()
|
||||
{
|
||||
int degree;
|
||||
degree = ExprIntrp_GetDegree();
|
||||
ExprIntrp_Recept.PushValue(degree);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_Derivation()
|
||||
{
|
||||
ExprIntrp_Recept.PushValue(1);
|
||||
char name[100];
|
||||
#ifdef DEB
|
||||
Standard_Integer nbcar =
|
||||
#endif
|
||||
ExprIntrp_GetResult(name);
|
||||
TCollection_AsciiString thename(name);
|
||||
Handle(Expr_NamedExpression) namexp = ExprIntrp_Recept.GetNamed(thename);
|
||||
if (namexp.IsNull()) {
|
||||
namexp = new Expr_NamedUnknown(thename);
|
||||
}
|
||||
if (!namexp->IsKind(STANDARD_TYPE(Expr_NamedUnknown))) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
ExprIntrp_Recept.Push(namexp);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_DerivationValue()
|
||||
{
|
||||
char num[30];
|
||||
int nbcar;
|
||||
nbcar = ExprIntrp_GetResult(num);
|
||||
Standard_Integer degree = ExprIntrp_Recept.PopValue();
|
||||
degree = atoi(num);
|
||||
ExprIntrp_Recept.PushValue(degree);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_EndDerivation()
|
||||
{
|
||||
Standard_Integer degree = ExprIntrp_Recept.PopValue();
|
||||
Handle(Expr_NamedUnknown) var = Handle(Expr_NamedUnknown)::DownCast(ExprIntrp_Recept.Pop());
|
||||
Handle(Expr_GeneralExpression) exp = ExprIntrp_Recept.Pop();
|
||||
exp = exp->NDerivative(var,degree);
|
||||
ExprIntrp_Recept.Push(exp);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_StartDifferential()
|
||||
{
|
||||
ExprIntrp_StartDerivate();
|
||||
ExprIntrp_nbdiff = 0;
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_DiffDegreeVar()
|
||||
{
|
||||
char name[100];
|
||||
#ifdef DEB
|
||||
Standard_Integer nbcar =
|
||||
#endif
|
||||
ExprIntrp_GetResult(name);
|
||||
#ifndef WNT
|
||||
if (strncasecmp(name,"X",1)) {
|
||||
#else
|
||||
if ( name[ 0 ] != 'X' && name[ 0 ] != 'x' ) {
|
||||
#endif // WNT
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
char* s = name;
|
||||
s++;
|
||||
Standard_Integer rank = atoi(s);
|
||||
ExprIntrp_Recept.PushValue(rank);
|
||||
ExprIntrp_nbdiff++;
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_DiffVar()
|
||||
{
|
||||
ExprIntrp_Recept.PushValue(1);
|
||||
ExprIntrp_DiffDegreeVar();
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_DiffDegree()
|
||||
{
|
||||
char name[100];
|
||||
#ifdef DEB
|
||||
Standard_Integer nbcar =
|
||||
#endif
|
||||
ExprIntrp_GetResult(name);
|
||||
Standard_Integer deg = atoi(name);
|
||||
ExprIntrp_Recept.PushValue(deg);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_VerDiffDegree()
|
||||
{
|
||||
char name[100];
|
||||
#ifdef DEB
|
||||
Standard_Integer nbcar =
|
||||
#endif
|
||||
ExprIntrp_GetResult(name);
|
||||
Standard_Integer deg = atoi(name);
|
||||
Standard_Integer thedeg = ExprIntrp_Recept.PopValue();
|
||||
if (deg != thedeg) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
ExprIntrp_Recept.PushValue(deg);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_EndDifferential()
|
||||
{
|
||||
TCollection_AsciiString name = ExprIntrp_Recept.PopName();
|
||||
Handle(Expr_GeneralFunction) thefunc = ExprIntrp_Recept.GetFunction(name);
|
||||
if (thefunc.IsNull()) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
Standard_Integer rank,degree;
|
||||
Handle(Expr_NamedUnknown) thediff;
|
||||
Standard_Integer nbvars = thefunc->NbOfVariables();
|
||||
|
||||
for (Standard_Integer i=1; i<= ExprIntrp_nbdiff; i++) {
|
||||
rank = ExprIntrp_Recept.PopValue();
|
||||
degree = ExprIntrp_Recept.PopValue();
|
||||
if ((rank > nbvars) || (rank < 1)) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
thediff = thefunc->Variable(rank);
|
||||
thefunc = new Expr_FunctionDerivative(thefunc,thediff,degree);
|
||||
}
|
||||
ExprIntrp_Recept.PushFunction(thefunc);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_EndDiffFunction()
|
||||
{
|
||||
Handle(Expr_GeneralFunction) thefunc = ExprIntrp_Recept.PopFunction();
|
||||
if (thefunc.IsNull()) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
Standard_Integer nbargs = thefunc->NbOfVariables();
|
||||
if (nbargs == 1) {
|
||||
Handle(Expr_GeneralExpression) op = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_UnaryFunction) res =
|
||||
new Expr_UnaryFunction(thefunc,op);
|
||||
ExprIntrp_Recept.Push(res);
|
||||
}
|
||||
else if (nbargs == 2) {
|
||||
Handle(Expr_GeneralExpression) arg2 = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_GeneralExpression) arg1 = ExprIntrp_Recept.Pop();
|
||||
if (arg1.IsNull()) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
Handle(Expr_BinaryFunction) res =
|
||||
new Expr_BinaryFunction(thefunc,arg1,arg2);
|
||||
ExprIntrp_Recept.Push(res);
|
||||
}
|
||||
else {
|
||||
Expr_Array1OfGeneralExpression tabarg(1,nbargs);
|
||||
Handle(Expr_GeneralExpression) arg;
|
||||
for (Standard_Integer i = 1; i<= nbargs; i++) {
|
||||
arg = ExprIntrp_Recept.Pop();
|
||||
if (arg.IsNull()) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
tabarg(nbargs-i+1) = arg;
|
||||
}
|
||||
Handle(Expr_PolyFunction) res =
|
||||
new Expr_PolyFunction(thefunc,tabarg);
|
||||
ExprIntrp_Recept.Push(res);
|
||||
}
|
||||
}
|
||||
|
||||
static Handle(Expr_GeneralExpression) ExprIntrp_StandardFunction(const TCollection_AsciiString& name, const Handle(Expr_GeneralExpression)& op)
|
||||
{
|
||||
// return standard functions equivalent corresponding to <name>
|
||||
// with given operand <op> if exists. Returns null value if not.
|
||||
// <name> is not case sensitive
|
||||
|
||||
Handle(Expr_GeneralExpression) res;
|
||||
if ((name == "abs") || (name == "Abs")) {
|
||||
res = new Expr_Absolute(op);
|
||||
}
|
||||
else if ((name == "acos") || (name == "ACos")) {
|
||||
res = new Expr_ArcCosine(op);
|
||||
}
|
||||
else if ((name == "asin") || (name == "ASin")) {
|
||||
res = new Expr_ArcSine(op);
|
||||
}
|
||||
else if ((name == "atan") || (name == "ATan")) {
|
||||
res = new Expr_ArcTangent(op);
|
||||
}
|
||||
else if ((name == "acosh") || (name == "ACosh")) {
|
||||
res = new Expr_ArgCosh(op);
|
||||
}
|
||||
else if ((name == "asinh") || (name == "ASinh")) {
|
||||
res = new Expr_ArgSinh(op);
|
||||
}
|
||||
else if ((name == "atanh") || (name == "ATanh")) {
|
||||
res = new Expr_ArgTanh(op);
|
||||
}
|
||||
else if ((name == "cosh") || (name == "Cosh")) {
|
||||
res = new Expr_Cosh(op);
|
||||
}
|
||||
else if ((name == "cos") || (name == "Cos")) {
|
||||
res = new Expr_Cosine(op);
|
||||
}
|
||||
else if ((name == "exp") || (name == "Exp")) {
|
||||
res = new Expr_Exponential(op);
|
||||
}
|
||||
else if (name == "log") {
|
||||
res = new Expr_LogOf10(op);
|
||||
}
|
||||
else if ((name == "Log") || (name == "Ln")) {
|
||||
res = new Expr_LogOfe(op);
|
||||
}
|
||||
else if ((name == "sign") || (name == "Sign")) {
|
||||
res = new Expr_Sign(op);
|
||||
}
|
||||
else if ((name == "sin") || (name == "Sin")) {
|
||||
res = new Expr_Sine(op);
|
||||
}
|
||||
else if ((name == "sinh") || (name == "Sinh")) {
|
||||
res = new Expr_Sinh(op);
|
||||
}
|
||||
else if ((name == "sqrt") || (name == "Sqrt")) {
|
||||
res = new Expr_SquareRoot(op);
|
||||
}
|
||||
else if ((name == "tan") || (name == "Tan")) {
|
||||
res = new Expr_Tangent(op);
|
||||
}
|
||||
else if ((name == "tanh") || (name == "Tanh")) {
|
||||
res = new Expr_Tanh(op);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
extern "C" void ExprIntrp_EndDerFunction()
|
||||
{
|
||||
TCollection_AsciiString name = ExprIntrp_Recept.PopName();
|
||||
Handle(Expr_GeneralExpression) op = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_GeneralExpression) resstand = ExprIntrp_StandardFunction(name,op);
|
||||
|
||||
if (!resstand.IsNull()) {
|
||||
Handle(Expr_NamedUnknown) var;
|
||||
Expr_UnknownIterator rit(resstand);
|
||||
while (rit.More()) {
|
||||
if (!var.IsNull()) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
else {
|
||||
var = rit.Value();
|
||||
if (var->IsAssigned()) {
|
||||
var.Nullify();
|
||||
}
|
||||
}
|
||||
rit.Next();
|
||||
}
|
||||
if (var.IsNull()) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
else {
|
||||
Handle(Expr_GeneralExpression) res = resstand->NDerivative(var,ExprIntrp_Recept.PopValue());
|
||||
ExprIntrp_Recept.Push(res);
|
||||
}
|
||||
}
|
||||
else {
|
||||
Handle(Expr_NamedFunction) thefunc = ExprIntrp_Recept.GetFunction(name);
|
||||
if (thefunc.IsNull()) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
Standard_Integer nbargs = thefunc->NbOfVariables();
|
||||
if (nbargs != 1) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
Handle(Expr_NamedUnknown) var = thefunc->Variable(1);
|
||||
Handle(Expr_FunctionDerivative) thefuncder =
|
||||
new Expr_FunctionDerivative(thefunc,var,ExprIntrp_Recept.PopValue());
|
||||
Handle(Expr_UnaryFunction) res =
|
||||
new Expr_UnaryFunction(thefuncder,op);
|
||||
ExprIntrp_Recept.Push(res);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_EndFunction()
|
||||
{
|
||||
TCollection_AsciiString name = ExprIntrp_Recept.PopName();
|
||||
Handle(Expr_GeneralExpression) op = ExprIntrp_Recept.Pop();
|
||||
|
||||
Handle(Expr_GeneralExpression) resstand = ExprIntrp_StandardFunction(name,op);
|
||||
if (!resstand.IsNull()) {
|
||||
ExprIntrp_Recept.Push(resstand->ShallowSimplified());
|
||||
}
|
||||
else {
|
||||
Handle(Expr_NamedFunction) thefunc = ExprIntrp_Recept.GetFunction(name);
|
||||
if (thefunc.IsNull()) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
Standard_Integer nbargs = thefunc->NbOfVariables();
|
||||
if (nbargs == 1) {
|
||||
Handle(Expr_UnaryFunction) res =
|
||||
new Expr_UnaryFunction(thefunc,op);
|
||||
ExprIntrp_Recept.Push(res);
|
||||
}
|
||||
else if (nbargs == 2) {
|
||||
Handle(Expr_GeneralExpression) arg1 = ExprIntrp_Recept.Pop();
|
||||
if (arg1.IsNull()) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
Handle(Expr_BinaryFunction) res =
|
||||
new Expr_BinaryFunction(thefunc,arg1,op);
|
||||
ExprIntrp_Recept.Push(res);
|
||||
}
|
||||
else {
|
||||
Expr_Array1OfGeneralExpression tabarg(1,nbargs);
|
||||
Handle(Expr_GeneralExpression) arg;
|
||||
tabarg(nbargs) = op;
|
||||
for (Standard_Integer i = 1; i< nbargs; i++) {
|
||||
arg = ExprIntrp_Recept.Pop();
|
||||
if (arg.IsNull()) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
tabarg(nbargs-i) = arg;
|
||||
}
|
||||
Handle(Expr_PolyFunction) res =
|
||||
new Expr_PolyFunction(thefunc,tabarg);
|
||||
ExprIntrp_Recept.Push(res);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_NextFuncArg()
|
||||
{
|
||||
ExprIntrp_nbargs++;
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_EndFuncArg()
|
||||
{
|
||||
ExprIntrp_nbargs++;
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_SumOperator()
|
||||
{
|
||||
Handle(Expr_GeneralExpression) op2 = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_GeneralExpression) op1 = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_Sum) sres = op1 + op2;
|
||||
Handle(Expr_GeneralExpression) res = sres->ShallowSimplified();
|
||||
ExprIntrp_Recept.Push(res);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_MinusOperator()
|
||||
{
|
||||
Handle(Expr_GeneralExpression) op2 = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_GeneralExpression) op1 = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_Difference) res = op1 - op2;
|
||||
ExprIntrp_Recept.Push(res->ShallowSimplified());
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_DivideOperator()
|
||||
{
|
||||
Handle(Expr_GeneralExpression) op2 = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_GeneralExpression) op1 = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_Division) res = op1 / op2;
|
||||
ExprIntrp_Recept.Push(res->ShallowSimplified());
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_ExpOperator()
|
||||
{
|
||||
Handle(Expr_GeneralExpression) op2 = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_GeneralExpression) op1 = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_Exponentiate) res = new Expr_Exponentiate(op1,op2);
|
||||
ExprIntrp_Recept.Push(res->ShallowSimplified());
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_ProductOperator()
|
||||
{
|
||||
Handle(Expr_GeneralExpression) op2 = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_GeneralExpression) op1 = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_Product) res = op1 * op2;
|
||||
ExprIntrp_Recept.Push(res->ShallowSimplified());
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_UnaryMinusOperator()
|
||||
{
|
||||
Handle(Expr_GeneralExpression) op = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_UnaryMinus) res = new Expr_UnaryMinus(op);
|
||||
ExprIntrp_Recept.Push(res->ShallowSimplified());
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_VariableIdentifier()
|
||||
{
|
||||
char name[30];
|
||||
int nbcar;
|
||||
nbcar = ExprIntrp_GetResult(name);
|
||||
TCollection_AsciiString thename(name);
|
||||
Handle(Expr_NamedExpression) nameexp = ExprIntrp_Recept.GetNamed(thename);
|
||||
if (nameexp.IsNull()) {
|
||||
nameexp = new Expr_NamedUnknown(thename);
|
||||
ExprIntrp_Recept.Use(nameexp);
|
||||
}
|
||||
ExprIntrp_Recept.Push(nameexp);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_NumValue()
|
||||
{
|
||||
char num[30];
|
||||
int nbcar;
|
||||
nbcar = ExprIntrp_GetResult(num);
|
||||
Standard_Real value = atof(num);
|
||||
Handle(Expr_NumericValue) nval = new Expr_NumericValue(value);
|
||||
ExprIntrp_Recept.Push(nval);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_AssignVariable()
|
||||
{
|
||||
int nbcar;
|
||||
nbcar = ExprIntrp_GetResult(ExprIntrp_assname);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_Deassign()
|
||||
{
|
||||
int nbcar;
|
||||
char name[100];
|
||||
nbcar = ExprIntrp_GetResult(name);
|
||||
TCollection_AsciiString thename(name);
|
||||
Handle(Expr_NamedExpression) nameexp = ExprIntrp_Recept.GetNamed(thename);
|
||||
if (nameexp.IsNull()) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
if (!nameexp->IsKind(STANDARD_TYPE(Expr_NamedUnknown))) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
Handle(Expr_NamedUnknown) var = Handle(Expr_NamedUnknown)::DownCast(nameexp);
|
||||
var->Deassign();
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_DefineFunction()
|
||||
{
|
||||
ExprIntrp_funcdefname = ExprIntrp_Recept.PopName();
|
||||
ExprIntrp_Recept.PushValue(ExprIntrp_nbargs);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_close()
|
||||
{
|
||||
ExprIntrp_stop_string();
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrperror(char* msg)
|
||||
{
|
||||
ExprIntrp_close();
|
||||
ExprIntrp_SyntaxError::Raise(msg);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void ExprIntrp_EndOfEqual()
|
||||
{
|
||||
Handle(Expr_GeneralExpression) memb2 = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_GeneralExpression) memb1 = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_Equal) res = new Expr_Equal(memb1,memb2);
|
||||
ExprIntrp_Recept.PushRelation(res);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_EndOfRelation()
|
||||
{
|
||||
Handle(Expr_SystemRelation) sys;
|
||||
Handle(Expr_GeneralRelation) currel;
|
||||
Handle(Expr_GeneralRelation) oldrel;
|
||||
while (!ExprIntrp_Recept.IsRelStackEmpty()) {
|
||||
currel = ExprIntrp_Recept.PopRelation();
|
||||
if (!sys.IsNull()) {
|
||||
sys->Add(currel);
|
||||
}
|
||||
else if (!oldrel.IsNull()) {
|
||||
sys = new Expr_SystemRelation(oldrel);
|
||||
sys->Add(currel);
|
||||
}
|
||||
else {
|
||||
oldrel = currel;
|
||||
}
|
||||
}
|
||||
if (sys.IsNull()) {
|
||||
ExprIntrp_Recept.PushRelation(currel);
|
||||
}
|
||||
else {
|
||||
ExprIntrp_Recept.PushRelation(sys);
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_EndOfAssign()
|
||||
{
|
||||
Handle(Expr_NamedExpression) namexp = ExprIntrp_Recept.GetNamed(ExprIntrp_assname);
|
||||
Handle(Expr_NamedUnknown) namu;
|
||||
if (namexp.IsNull()) {
|
||||
namu = new Expr_NamedUnknown(ExprIntrp_assname);
|
||||
ExprIntrp_Recept.Use(namu);
|
||||
}
|
||||
else {
|
||||
if (!namexp->IsKind(STANDARD_TYPE(Expr_NamedUnknown))) {
|
||||
ExprIntrp_SyntaxError::Raise();
|
||||
}
|
||||
namu = Handle(Expr_NamedUnknown)::DownCast(namexp);
|
||||
}
|
||||
namu->Assign(ExprIntrp_Recept.Pop());
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_EndOfFuncDef()
|
||||
{
|
||||
Handle(Expr_GeneralExpression) theexp = ExprIntrp_Recept.Pop();
|
||||
Standard_Integer nbargs = ExprIntrp_Recept.PopValue();
|
||||
Expr_Array1OfNamedUnknown vars(1,nbargs);
|
||||
Expr_Array1OfNamedUnknown internvars(1,nbargs);
|
||||
Standard_Integer i;
|
||||
for (i=nbargs; i > 0; i--) {
|
||||
vars(i) = Handle(Expr_NamedUnknown)::DownCast(ExprIntrp_Recept.Pop());
|
||||
internvars(i) = Handle(Expr_NamedUnknown)::DownCast(vars(i)->Copy());
|
||||
}
|
||||
theexp = Expr::CopyShare(theexp); // ATTENTION, PROTECTION BUG STACK
|
||||
for (i=1; i<= nbargs; i++) {
|
||||
if (theexp->Contains(vars(i))) {
|
||||
theexp->Replace(vars(i),internvars(i));
|
||||
}
|
||||
else {
|
||||
if (theexp == vars(i)) {
|
||||
theexp = internvars(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
Handle(Expr_NamedFunction) thefunc =
|
||||
new Expr_NamedFunction(ExprIntrp_funcdefname,
|
||||
theexp,
|
||||
internvars);
|
||||
ExprIntrp_Recept.Use(thefunc);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_ConstantIdentifier()
|
||||
{
|
||||
char name[100];
|
||||
#ifdef DEB
|
||||
Standard_Integer nbcar =
|
||||
#endif
|
||||
ExprIntrp_GetResult(name);
|
||||
TCollection_AsciiString thename(name);
|
||||
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);
|
||||
Handle(Expr_NamedConstant) theconst = new Expr_NamedConstant(name,val);
|
||||
ExprIntrp_Recept.Use(theconst);
|
||||
ExprIntrp_Recept.Push(theconst);
|
||||
}
|
||||
|
||||
|
||||
extern "C" void ExprIntrp_Sumator()
|
||||
{
|
||||
Handle(Expr_NumericValue) number = Handle(Expr_NumericValue)::DownCast(ExprIntrp_Recept.Pop());
|
||||
Standard_Integer nb = (Standard_Integer) number->GetValue();
|
||||
Handle(Expr_GeneralExpression) inc = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_GeneralExpression) first = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_NamedUnknown) var = Handle(Expr_NamedUnknown)::DownCast(ExprIntrp_Recept.Pop());
|
||||
Handle(Expr_GeneralExpression) theexp = ExprIntrp_Recept.Pop();
|
||||
Standard_Boolean thesame = (theexp == var);
|
||||
Handle(Expr_GeneralExpression) cur = Expr::CopyShare(first);
|
||||
Handle(Expr_GeneralExpression) res;
|
||||
Handle(Expr_GeneralExpression) member;
|
||||
Expr_SequenceOfGeneralExpression seq;
|
||||
for (Standard_Integer i=1; i<= nb; i++) {
|
||||
if (thesame) {
|
||||
member = cur;
|
||||
}
|
||||
else {
|
||||
member = Expr::CopyShare(theexp);
|
||||
member->Replace(var,cur);
|
||||
}
|
||||
seq.Append(member);
|
||||
cur = (cur + inc)->ShallowSimplified();
|
||||
}
|
||||
res = new Expr_Sum(seq);
|
||||
ExprIntrp_Recept.Push(res->ShallowSimplified());
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_Productor()
|
||||
{
|
||||
Handle(Expr_NumericValue) number = Handle(Expr_NumericValue)::DownCast(ExprIntrp_Recept.Pop());
|
||||
Standard_Integer nb = (Standard_Integer) number->GetValue();
|
||||
Handle(Expr_GeneralExpression) inc = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_GeneralExpression) first = ExprIntrp_Recept.Pop();
|
||||
Handle(Expr_NamedUnknown) var = Handle(Expr_NamedUnknown)::DownCast(ExprIntrp_Recept.Pop());
|
||||
Handle(Expr_GeneralExpression) theexp = ExprIntrp_Recept.Pop();
|
||||
Standard_Boolean thesame = (theexp == var);
|
||||
Handle(Expr_GeneralExpression) cur = Expr::CopyShare(first);
|
||||
Handle(Expr_GeneralExpression) res;
|
||||
Handle(Expr_GeneralExpression) member;
|
||||
Expr_SequenceOfGeneralExpression seq;
|
||||
for (Standard_Integer i=1; i<= nb; i++) {
|
||||
if (thesame) {
|
||||
member = cur;
|
||||
}
|
||||
else {
|
||||
member = Expr::CopyShare(theexp);
|
||||
member->Replace(var,cur);
|
||||
}
|
||||
seq.Append(member);
|
||||
cur = (cur + inc)->ShallowSimplified();
|
||||
}
|
||||
res = new Expr_Product(seq);
|
||||
ExprIntrp_Recept.Push(res->ShallowSimplified());
|
||||
}
|
24
src/ExprIntrp/ExprIntrp_yaccintrf.hxx
Executable file
24
src/ExprIntrp/ExprIntrp_yaccintrf.hxx
Executable file
@@ -0,0 +1,24 @@
|
||||
// Copyright: Matra-Datavision 1992
|
||||
// File: ExprIntrp_yaccintrf.hxx
|
||||
// Created: Mon Feb 17 11:14:09 1992
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
|
||||
#ifndef ExprIntrp_yaccintrf_HeaderFile
|
||||
#define ExprIntrp_yaccintrf_HeaderFile
|
||||
|
||||
#include <TCollection_AsciiString.hxx>
|
||||
|
||||
extern "C" int ExprIntrpparse();
|
||||
extern "C" void ExprIntrp_start_string(const char* str);
|
||||
extern "C" void ExprIntrp_stop_string();
|
||||
extern TCollection_AsciiString ExprIntrp_thestring;
|
||||
extern Standard_Integer ExprIntrp_thecurchar;
|
||||
int ExprIntrp_GetDegree();
|
||||
int ExprIntrp_GetResult(char *s);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
40
src/ExprIntrp/ExprIntrp_yacclex.cxx
Executable file
40
src/ExprIntrp/ExprIntrp_yacclex.cxx
Executable file
@@ -0,0 +1,40 @@
|
||||
//static const char* sccsid = "@(#)ExprIntrp_yacclex.cxx 3.2 95/01/10"; // Do not delete this line. Used by sccs.
|
||||
// Copyright: Matra-Datavision 1993
|
||||
// File: ExprIntrp_yacclex.cxx
|
||||
// Created: Tue Dec 14 10:40:17 1993
|
||||
// Author: Arnaud BOUZY
|
||||
// <adn>
|
||||
|
||||
#include <string.h>
|
||||
#include <ExprIntrp_yaccintrf.hxx>
|
||||
|
||||
static char ExprIntrp_curres[255];
|
||||
static int ExprIntrp_degree;
|
||||
|
||||
#ifndef WNT
|
||||
extern char* ExprIntrptext;
|
||||
#else
|
||||
extern "C" char* ExprIntrptext;
|
||||
#endif // WNT
|
||||
|
||||
|
||||
extern "C" void ExprIntrp_SetResult()
|
||||
{
|
||||
strcpy(ExprIntrp_curres,ExprIntrptext);
|
||||
}
|
||||
|
||||
extern "C" void ExprIntrp_SetDegree()
|
||||
{
|
||||
ExprIntrp_degree = strlen(ExprIntrptext);
|
||||
}
|
||||
|
||||
int ExprIntrp_GetDegree()
|
||||
{
|
||||
return ExprIntrp_degree;
|
||||
}
|
||||
|
||||
int ExprIntrp_GetResult(char *s)
|
||||
{
|
||||
strcpy(s,ExprIntrp_curres);
|
||||
return strlen(ExprIntrp_curres);
|
||||
}
|
10
src/ExprIntrp/FILES
Executable file
10
src/ExprIntrp/FILES
Executable file
@@ -0,0 +1,10 @@
|
||||
ExprIntrp_CMPLRS.edl
|
||||
ExprIntrp_WOKSteps.edl
|
||||
ExprIntrp.lex
|
||||
ExprIntrp.yacc
|
||||
ExprIntrp_yaccanal.hxx
|
||||
ExprIntrp_yaccintrf.cxx
|
||||
ExprIntrp_yaccintrf.hxx
|
||||
ExprIntrp_yacclex.cxx
|
||||
ExprIntrp_Replace.tcl
|
||||
ExprIntrp.tab.c
|
Reference in New Issue
Block a user