xc
LexAlgebra.h
1 // -*-c++-*-
2 //----------------------------------------------------------------------------
3 // xc utils library; general purpose classes and functions.
4 //
5 // Copyright (C) Luis C. Pérez Tato
6 //
7 // XC utils is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // This software is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program.
19 // If not, see <http://www.gnu.org/licenses/>.
20 //----------------------------------------------------------------------------
21 //LexAlgebra.h
22 
23 #ifndef LEXALGEBRA_H
24 #define LEXALGEBRA_H
25 
26 #include "Lexico.h"
27 #include "TablaExpresiones.h"
28 
29 class VarExpr;
30 
31 
33 class LexAlgebra : public Lexico
34  {
35  private:
36  friend class ExprAlgebra;
37  TablaExpresiones expresiones;
38  inline ExprAlgebra GetExpresion(const std::string &nmb)
39  { return CalcDirExpr(nmb)->GetExpr(); }
40  public:
41  LexAlgebra(void);
42  inline bool EsExpresion(const std::string &nmb)
43  { return (expresiones.find(nmb)!=expresiones.end()); }
44  virtual VarExpr *CalcDirExpr(const std::string &nmb);
45  inline virtual Variable *CalcDirVar(const std::string &nmb)
46  {
47  Variable *retval= CalcDirExpr(nmb);
48  if(!retval)
49  retval= vars.CalcDir(nmb);
50  return retval;
51  }
52  NamedOperand *NuevaVar(const Variable &v);
53  inline NamedOperand *NuevaVar(const std::string &palabra)
54  { return NuevaVar(Variable(palabra)); }
55  NamedOperand *NuevaExpr(const VarExpr &v);
56  inline NamedOperand *NuevaExpr(const std::string &palabra)
57  { return NuevaExpr(VarExpr(palabra)); }
58  void AsignaExpr(const std::string &palabra,const ExprAlgebra &e);
59  };
60 #endif
Definition: NamedOperand.h:28
static NamedOperand * NuevaVar(const Variable &v)
Creates the variable being passed as parameter.
Definition: ProtoExpr.cc:58
Definition: Variable.h:31
virtual Variable * CalcDirVar(const std::string &nmb)
Return a pointer to the variable which name is being passed as parameter.
Definition: LexAlgebra.h:45
Léxico para expresiones algebraicas.
Definition: LexAlgebra.h:33
Expresión algebraica.
Definition: ExprAlgebra.h:32
Definition: Lexico.h:42
Definition: VarExpr.h:28