| eRPC Generator (erpcgen) Rev. 1.8.1 NXP Semiconductors

- Main Page
- Classes
- Files

- File List

Token.h
1 /*
2 * Copyright (c) 2014, Freescale Semiconductor, Inc.
3 * Copyright 2016 NXP
4 * All rights reserved.
5 *
6 *
7 * SPDX-License-Identifier: BSD-3-Clause
8 */
9
10 #ifndef _EMBEDDED_RPC__TOKEN_H_
11 #define _EMBEDDED_RPC__TOKEN_H_
12
13 #include "Value.h"
14 #include "smart_ptr.h"
15
17 // Classes
19
20 namespace erpcgen {
21
25 struct token_loc_t
26 {
27 int m_firstLine;
28 int m_firstChar;
29 int m_lastLine;
30 int m_lastChar;
32 token_loc_t()
33 : m_firstLine(0)
34 , m_firstChar(0)
35 , m_lastLine(0)
36 , m_lastChar(0)
37 {
38 }
39
45 token_loc_t(const token_loc_t &other) = default;
46
54 token_loc_t &operator=(const token_loc_t &other) = default;
55 };
56
60 class Token
61 {
62 public:
74 Token(int token)
75 : m_token(token)
76 , m_value()
77 , m_location()
78 {
79 }
80
94 Token(int token, Value *value)
95 : m_token(token)
96 , m_value(value)
97 , m_location()
98 {
99 }
100
115 Token(int token, Value *value, const token_loc_t &loc)
116 : m_token(token)
117 , m_value(value)
118 , m_location(loc)
119 {
120 }
121
134 Token(const Token &other);
135
147 Token &operator=(const Token &other);
148
152 ~Token() {}
153
155
156
163 int getToken() const { return m_token; }
164
172 void setToken(int tok) { m_token = tok; }
173
181 const char *getTokenName() const;
182
188 bool isNumberTok() const;
189
195 bool isIdentifierTok() const;
197
199
200
210 bool hasValue() const { return m_value.get() != nullptr; }
211
221 Value *getValue() { return m_value; }
222
232 const Value *getValue() const { return m_value; }
233
245 void setValue(Value *val) { m_value = val; }
246
258 const std::string &getStringValue() const;
259
271 uint64_t getIntValue() const;
273
275
276
283 const token_loc_t &getLocation() const { return m_location; }
284
292 void setLocation(const token_loc_t &loc) { m_location = loc; }
293
300 void setLocation(const token_loc_t &first, const token_loc_t &last);
301
310 int getFirstLine() const { return m_location.m_firstLine; }
311
320 int getLastLine() const { return m_location.m_lastLine; }
321
329 bool isBinaryOp() const;
331
332 private:
333 int m_token;
334 smart_ptr<Value> m_value;
335 token_loc_t m_location;
336 };
337
338 } // namespace erpcgen
339
340 #endif // _EMBEDDED_RPC__TOKEN_H_
erpcgen::Token::~Token
~Token()
Destructor.
Definition: Token.h:152
erpcgen::Token::Token
Token(int token, Value *value, const token_loc_t &loc)
Constructor.
Definition: Token.h:115
erpcgen::Token::setValue
void setValue(Value *val)
This function set token value.
Definition: Token.h:245
erpcgen::token_loc_t::m_lastLine
int m_lastLine
Definition: Token.h:29
erpcgen::Token::Token
Token(int token, Value *value)
Constructor.
Definition: Token.h:94
erpcgen::Token::getValue
Value * getValue()
This function returns token value.
Definition: Token.h:221
erpcgen::Token::getLastLine
int getLastLine() const
This function returns last line of token from token location (location from analyzed file)...
Definition: Token.h:320
erpcgen::token_loc_t::m_firstLine
int m_firstLine
Definition: Token.h:27
erpcgen::Token::setToken
void setToken(int tok)
This function set token number.
Definition: Token.h:172
erpcgen::Token::setLocation
void setLocation(const token_loc_t &loc)
This function set token location (location from analyzed file).
Definition: Token.h:292
Value
Abstract base class for values of arbitrary types.
Definition: Value.h:27
erpcgen::Token::Token
Token(int token)
Constructor.
Definition: Token.h:74
erpcgen::Token::getLocation
const token_loc_t & getLocation() const
This function returns token location (location from analyzed file).
Definition: Token.h:283
erpcgen::token_loc_t::operator=
token_loc_t & operator=(const token_loc_t &other)=default
Default assign operator.
erpcgen::Token::hasValue
bool hasValue() const
This function return true/false, when token has/hasn&#39;t value.
Definition: Token.h:210
erpcgen::token_loc_t::m_lastChar
int m_lastChar
Definition: Token.h:30
erpcgen::Token
Encapsulates all information about a token.
Definition: Token.h:60
erpcgen::Token::getValue
const Value * getValue() const
This function returns const token value.
Definition: Token.h:232
erpcgen::Token::getToken
int getToken() const
This function returns token number.
Definition: Token.h:163
erpcgen::token_loc_t::m_firstChar
int m_firstChar
Definition: Token.h:28
erpcgen::token_loc_t
Token location in the source file.
Definition: Token.h:25
erpcgen
Definition: AstNode.h:26
erpcgen::Token::getFirstLine
int getFirstLine() const
This function returns first line of token from token location (location from analyzed file)...
Definition: Token.h:310