16#include <Interprete_bloc.h>
17#include <Type_Verifie.h>
43 return interprete_courant_.
valeur();
46Interprete_bloc::Interprete_bloc()
50 if (interprete_courant_) pere_ = interprete_courant_;
52 interprete_courant_ = *
this;
55Interprete_bloc::~Interprete_bloc()
58 interprete_courant_ = pere_;
86 Journal(jlevel) <<
"Interprete_bloc::interpreter_bloc bloc_type=" << (int) bloc_type << finl;
97 Journal(jlevel) <<
"Interprete_bloc: end of file => end of bloc" << finl;
102 Cerr <<
"Error in Interprete_bloc: unexpected end of file\n" <<
"check for missig \"}\" or missing FIN keyword" << finl;
107 if (motlu ==
"}" || motlu ==
"FIN|END")
109 if ((motlu ==
"}" && bloc_type ==
ACCOLADE) || (motlu ==
"FIN|END" && bloc_type ==
FIN))
111 Journal(jlevel) <<
"Interprete_bloc: reading " << motlu <<
" => end of bloc" << finl;
117 Cerr <<
"Error in Interprete_bloc: extra \"}\" in data file" << finl;
119 Cerr <<
"Error in Interprete_bloc: unexpected FIN, check for missing \"}\"" << finl;
127 Nom commentaire(
"# ");
135 if ((countleft--) > 0)
137 commentaire += nom_lu;
141 while (nom_lu !=
"#");
144 Cerr <<
"Error in Interprete_bloc: end of file while reading a comment :\n" << commentaire <<
"..." << finl;
149 else if (motlu ==
"{")
151 Journal(jlevel) <<
"Interprete_bloc: reading { => creating new Interprete_bloc" << finl;
159 if (verifie_sans_interpreter)
167 Journal(jlevel) <<
"Interprete_bloc: just checking {} => ignore keyword " << motlu << finl;
174 int export_object = 0;
175 if (motlu ==
"export")
177 Journal(jlevel) <<
"Exporting object, reading object type..." << finl;
182 Journal(jlevel) <<
"Interprete_bloc: reading " << motlu <<
" => trying to instanciate object" << finl;
189 Journal(jlevel) <<
" Calling object.interpreter()" << finl;
196 Journal(jlevel) <<
" Reading object name" << finl;
199 Journal(jlevel) <<
" Storing object " << nom_objet <<
" of type " << motlu << finl;
200 if (!export_object || !pere_)
203 pere_->ajouter(nom_objet, objet);
221 Cerr <<
"Internal error in Interprete::objet_local() : object '" << nom <<
"' does not exist" << finl;
243 Journal(3) <<
"Interprete::ajouter(" << nom <<
") of type " << ob->
que_suis_je() << finl;
246 Cerr <<
"Error in Interprete::ajouter: object " << nom <<
" already exists." << finl;
274 Cerr <<
"Error in Interprete::objet: object " << nom <<
" does not exist." << finl;
Class defining operators and methods for all reading operation in an input flow (file,...
virtual void set_error_action(Error_Action)
Changes the error behaviour of the input; see error_handle_() and get_error_action().
Interprets a block of instructions in the data set.
OBS_PTR(Interprete_bloc) pere_
Objet_U & ajouter(const Nom &nom, DerObjU &object_to_add)
Adds object ob to the interpreter's object list and names it with nom.
Entree & interpreter_bloc(Entree &is, Bloc_Type bloc_type, int verifier_sans_interpreter)
Interprets a block of instructions read from input is.
static int objet_global_existant(const Nom &nom)
Returns a flag indicating whether an object with this name exists in interprete_courant() or one of i...
Objet_U & objet_local(const Nom &nom)
Returns the Objet_U corresponding to nom contained in this interprete_bloc. If the object does not ex...
static Interprete_bloc & interprete_courant()
Returns the Interprete_bloc currently being read from the data set.
int objet_local_existant(const Nom &nom)
Returns a flag indicating whether an object with this name is registered in this interpreter (does no...
static Objet_U & objet_global(const Nom &nom)
Searches for the requested object in the current Interprete_bloc (Interprete_bloc::interprete_courant...
Base class for "interpreter" objects.
virtual Entree & interpreter(Entree &)=0
The Liste_bloc and Liste_bloc_curseur classes represent a list of Deriv<Objet_U> elements and an asso...
Objet_U & operator[](int)
Access operator to the i-th element of the list.
Objet_U & add_deplace(DerObjU &)
Adds an Objet_U to the list. to_add is released on exit.
A character string (Nom) in uppercase.
class Nom: a character string for naming TRUST objects.
Objet_U * typer(const char *nom_type)
Tries to create an instance of type "type".
virtual void nommer(const Nom &)
Assigns a name to the Objet_U. Virtual method to override.
const Nom & que_suis_je() const
Returns the string identifying the class.
virtual Entree & readOn(Entree &)
Reads an Objet_U from an input stream. Virtual method to override.
Objet_U()
Default constructor: assigns a unique identifier to the object (object_id_) and registers the object ...
virtual Sortie & printOn(Sortie &) const
Writes the object to an output stream. Virtual method to override.
static Sortie & Journal(int message_level=0)
Returns a static Sortie object used as an event journal.
static void exit(int exit_code=-1)
Exit routine for TRUST within a Kokkos region.
Base class for output streams.
const Objet_U & valeur() const