c00b856cce6b4d2d2e78a9629308a3195aab91e6
[occt.git] / src / ExprIntrp / ExprIntrp.cxx
1 // Created on: 1992-08-17
2 // Created by: Arnaud BOUZY
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <ExprIntrp.ixx>
18 #include <ExprIntrp_yaccintrf.hxx>
19 #include <ExprIntrp_yaccanal.hxx>
20 #include <Standard_ErrorHandler.hxx>
21 #include <ExprIntrp_SyntaxError.hxx>
22
23 TCollection_AsciiString ExprIntrp_thestring;
24 Standard_Integer ExprIntrp_thecurchar=0;
25
26 Standard_Boolean ExprIntrp::Parse(const Handle(ExprIntrp_Generator)& gen, const TCollection_AsciiString& str)
27 {
28   ExprIntrp_Recept.SetMaster(gen);
29   ExprIntrp_thecurchar = 0;
30   if (str.Length() == 0) return Standard_False;
31   ExprIntrp_thestring = str;
32   ExprIntrp_start_string(ExprIntrp_thestring.ToCString());
33
34   int kerror=1;
35
36   {
37     try {
38       OCC_CATCH_SIGNALS
39       while (kerror!=0) {
40         kerror = ExprIntrpparse();
41       }
42       ExprIntrp_stop_string();
43       return Standard_True;
44     }
45     catch (Standard_Failure) {}
46   }
47   ExprIntrp_stop_string();
48   return Standard_False;
49 }
50