OpcUaCanOpen
CANopen OPC-UA server
muParserTokenReader.h
Go to the documentation of this file.
1 /*
2  __________
3  _____ __ __\______ \_____ _______ ______ ____ _______
4  / \ | | \| ___/\__ \ \_ __ \/ ___/_/ __ \\_ __ \
5  | Y Y \| | /| | / __ \_| | \/\___ \ \ ___/ | | \/
6  |__|_| /|____/ |____| (____ /|__| /____ > \___ >|__|
7  \/ \/ \/ \/
8  Copyright (C) 2004-2013 Ingo Berg
9 
10  Permission is hereby granted, free of charge, to any person obtaining a copy of this
11  software and associated documentation files (the "Software"), to deal in the Software
12  without restriction, including without limitation the rights to use, copy, modify,
13  merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
14  permit persons to whom the Software is furnished to do so, subject to the following conditions:
15 
16  The above copyright notice and this permission notice shall be included in all copies or
17  substantial portions of the Software.
18 
19  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
20  NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21  NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
22  DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25 
26 #ifndef MU_PARSER_TOKEN_READER_H
27 #define MU_PARSER_TOKEN_READER_H
28 
29 #include <cassert>
30 #include <cstdio>
31 #include <cstring>
32 #include <list>
33 #include <map>
34 #include <memory>
35 #include <stack>
36 #include <string>
37 
38 #include "muParserDef.h"
39 #include "muParserToken.h"
40 
46 namespace mu
47 {
48  // Forward declaration
49  class ParserBase;
50 
55  {
56  private:
57 
59 
60  public:
61 
62  ParserTokenReader(ParserBase *a_pParent);
63  ParserTokenReader* Clone(ParserBase *a_pParent) const;
64 
65  void AddValIdent(identfun_type a_pCallback);
67  void SetFormula(const string_type &a_strFormula);
69 
70  int GetPos() const;
71  const string_type& GetExpr() const;
73  char_type GetArgSep() const;
74 
75  void IgnoreUndefVar(bool bIgnore);
76  void ReInit();
78 
79  private:
80 
87  enum ESynCodes
88  {
89  noBO = 1 << 0,
90  noBC = 1 << 1,
91  noVAL = 1 << 2,
92  noVAR = 1 << 3,
93  noARG_SEP = 1 << 4,
94  noFUN = 1 << 5,
95  noOPT = 1 << 6,
96  noPOSTOP = 1 << 7,
97  noINFIXOP = 1 << 8,
98  noEND = 1 << 9,
99  noSTR = 1 << 10,
100  noASSIGN = 1 << 11,
101  noIF = 1 << 12,
102  noELSE = 1 << 13,
104  noANY = ~0
105  };
106 
107  ParserTokenReader(const ParserTokenReader &a_Reader);
109  void Assign(const ParserTokenReader &a_Reader);
110 
111  void SetParent(ParserBase *a_pParent);
112  int ExtractToken(const char_type *a_szCharSet,
113  string_type &a_strTok,
114  int a_iPos) const;
115  int ExtractOperatorToken(string_type &a_sTok, int a_iPos) const;
116 
117  bool IsBuiltIn(token_type &a_Tok);
118  bool IsArgSep(token_type &a_Tok);
119  bool IsEOF(token_type &a_Tok);
120  bool IsInfixOpTok(token_type &a_Tok);
121  bool IsFunTok(token_type &a_Tok);
122  bool IsPostOpTok(token_type &a_Tok);
123  bool IsOprt(token_type &a_Tok);
124  bool IsValTok(token_type &a_Tok);
125  bool IsVarTok(token_type &a_Tok);
126  bool IsStrVarTok(token_type &a_Tok);
127  bool IsUndefVarTok(token_type &a_Tok);
128  bool IsString(token_type &a_Tok);
129  void Error(EErrorCodes a_iErrc,
130  int a_iPos = -1,
131  const string_type &a_sTok = string_type() ) const;
132 
134 
137  int m_iPos;
140 
150  std::list<identfun_type> m_vIdentFun;
156  };
157 } // namespace mu
158 
159 #endif
160 
161