c1cd33dc680eb18daeb599c1371c91b773cd85dc
[occt.git] / src / ExprIntrp / ExprIntrp.cxx
1 //static const char* sccsid = "@(#)ExprIntrp.cxx        3.2 95/01/10"; // Do not delete this line. Used by sccs.
2 // Copyright:   Matra-Datavision 1992
3 // File:        ExprIntrp.cxx
4 // Created:     Mon Aug 17 18:40:44 1992
5 // Author:      Arnaud BOUZY
6 //              <adn>
7
8 #include <ExprIntrp.ixx>
9 #include <ExprIntrp_yaccintrf.hxx>
10 #include <ExprIntrp_yaccanal.hxx>
11 #include <Standard_ErrorHandler.hxx>
12 #include <ExprIntrp_SyntaxError.hxx>
13
14 TCollection_AsciiString ExprIntrp_thestring;
15 Standard_Integer ExprIntrp_thecurchar=0;
16
17 Standard_Boolean ExprIntrp::Parse(const Handle(ExprIntrp_Generator)& gen, const TCollection_AsciiString& str)
18 {
19   ExprIntrp_Recept.SetMaster(gen);
20   ExprIntrp_thecurchar = 0;
21   if (str.Length() == 0) return Standard_False;
22   ExprIntrp_thestring = str;
23   ExprIntrp_start_string(ExprIntrp_thestring.ToCString());
24
25   int kerror=1;
26
27   {
28     try {
29       OCC_CATCH_SIGNALS
30       while (kerror!=0) {
31         kerror = ExprIntrpparse();
32       }
33       ExprIntrp_stop_string();
34       return Standard_True;
35     }
36     catch (Standard_Failure) {}
37   }
38   ExprIntrp_stop_string();
39   return Standard_False;
40 }
41