|
tfel
|
class representing a token in a C++-like file More...
#include </home/runner/work/tfel/tfel/include/TFEL/Utilities/Token.hxx>
Public Types | |
| enum | TokenFlag { Standard , Comment , Number , DoxygenComment , DoxygenBackwardComment , String , Char , Preprocessor } |
| possible type of the token | |
| using | size_type = size_t |
| a simple alias | |
Public Member Functions | |
| Token () | |
| default constructor | |
| Token (const std::string &, const size_type, const size_type, const TokenFlag=Standard) | |
| constructor | |
| Token (const Token &) | |
| copy constructor | |
| Token (Token &&) noexcept | |
| move constructor | |
| Token & | operator= (const Token &) |
| assignement | |
| Token & | operator= (Token &&) noexcept |
| move assignement | |
| ~Token () noexcept | |
| destructor | |
Public Attributes | |
| std::string | value |
| string holded by the token | |
| size_type | line = 0u |
| line number | |
| size_type | offset = 0u |
| offset in the line | |
| std::string | comment |
| comment | |
| TokenFlag | flag = Standard |
| type of the token | |
class representing a token in a C++-like file
| tfel::utilities::Token::Token | ( | const std::string & | , |
| const size_type | , | ||
| const size_type | , | ||
| const TokenFlag | = Standard ) |
constructor
| [in] | v | token value |
| [in] | l | line number |
| [in] | o | offset |
| [in] | f | token flag |
| size_type tfel::utilities::Token::offset = 0u |
offset in the line
The offset of a token is the position, in the line the token starts on, of the first character the token stands for, so that it is always strictly smaller than the size of that line. This is the case of a raw string token, whose offset is that of its R delimiter as the offset of a quoted string token is that of its opening quote, see issue #1390. The offset of a token whose value is empty, which is only possible for a comment, is that of the delimiter which opens it, see issue #1391.
A token may span several lines, which is the case of a comment and of a raw string literal: the line and the offset of such a token are those of its first line, whereas its value gathers the lines it spans. The offset of a comment without contents on the line it starts on, as the offset of an empty comment, is that of the delimiter which opens it.
| std::string tfel::utilities::Token::value |
string holded by the token
The value of a token is the spelling of the token in the file, that is the substring of the line taken at the offset of the token, excepted for comments and for numbers: