gfy-cpp
Loading...
Searching...
No Matches
token.hpp
Go to the documentation of this file.
1
#ifndef __TOKEN_HPP__
2
#define __TOKEN_HPP__
3
4
#include <string>
5
#include <tuple>
6
7
using namespace
std;
8
12
enum class
Type
{
13
Module
,
14
Keyword
,
15
Identifier
,
16
Operator
,
17
Parenthesis
,
18
Bracket
,
19
Int
,
20
Float
,
21
String
,
22
Boolean
,
23
List
,
24
Eof
,
25
Unknown
26
};
27
28
class
Token
{
29
public
:
38
Token
(
39
Type
type
,
40
const
string
&
text
,
41
const
string
&
file
,
42
tuple<int, int>
position
43
) :
type
(
type
),
text
(
text
),
file
(
file
),
position
(
position
) {}
44
50
Type
get_type
();
51
57
string
get_text
();
58
64
string
get_file
();
65
71
tuple<int, int>
get_position
();
72
78
int
get_line
();
79
85
int
get_column
();
86
92
string
to_string
()
const
;
93
94
private
:
95
Type
type
;
96
string
text
;
97
string
file
;
98
tuple<int, int>
position
;
99
};
100
106
string
type2str
(
Type
type);
107
108
#endif
// __TOKEN_HPP__
Token
Definition
token.hpp:28
Token::get_column
int get_column()
Get token column number.
Definition
token.cpp:32
Token::get_line
int get_line()
Get token line number.
Definition
token.cpp:28
Token::Token
Token(Type type, const string &text, const string &file, tuple< int, int > position)
Construct a new Token object.
Definition
token.hpp:38
Token::file
string file
Definition
token.hpp:97
Token::type
Type type
Definition
token.hpp:95
Token::get_type
Type get_type()
Type getter.
Definition
token.cpp:12
Token::text
string text
Definition
token.hpp:96
Token::get_position
tuple< int, int > get_position()
Position getter.
Definition
token.cpp:24
Token::get_text
string get_text()
Text getter.
Definition
token.cpp:16
Token::position
tuple< int, int > position
Definition
token.hpp:98
Token::to_string
string to_string() const
Stringify the token.
Definition
token.cpp:5
Token::get_file
string get_file()
File getter.
Definition
token.cpp:20
Type
Type
Token types.
Definition
token.hpp:12
Type::Int
@ Int
Type::Keyword
@ Keyword
Type::Float
@ Float
Type::String
@ String
Type::Boolean
@ Boolean
Type::Identifier
@ Identifier
Type::Parenthesis
@ Parenthesis
Type::Eof
@ Eof
Type::List
@ List
Type::Unknown
@ Unknown
Type::Bracket
@ Bracket
Type::Operator
@ Operator
Type::Module
@ Module
type2str
string type2str(Type type)
Convert a type to a string.
Definition
token.cpp:36
include
token.hpp
Generated by
1.10.0