AALanguage
The best language for those who have nothing to do
Loading...
Searching...
No Matches
LexicalAnalyzer.h
Go to the documentation of this file.
1
#pragma once
2
3
#include "
Trie.h
"
4
#include <regex>
5
#include <string>
6
#include "
LibParser.h
"
7
8
struct
Token
;
9
11
class
LexicalAnalyzer
{
12
public
:
14
enum
literal_type
{
15
logical
,
integer
,
real
,
symbol
,
string
,
none
16
};
18
enum
token_type
{
19
service
,
identifier
,
literal
,
operation
,
punctuation
,
comma
,
brace
,
comment
,
unknown
20
};
26
Token
get_token
();
32
Token
prev_token
();
38
bool
get_ok
()
const
;
48
literal_type
is_literal
(std::string s);
54
std::vector<Token>
get_tokens
();
55
72
LexicalAnalyzer
(std::string path,
LibParser
& lib_parser);
73
private
:
74
int
line_
= 1;
75
int
curr_
= 0;
76
bool
ok_
=
true
;
77
std::vector<Token>
tokens_
;
78
79
bool
is_service
(
Trie
* service_trie, std::string s);
80
bool
is_identifier
(std::string s);
81
bool
is_operation
(std::string s);
82
bool
is_punctuation
(std::string s);
83
bool
is_comma
(std::string s);
84
bool
is_brace
(std::string s);
85
bool
is_comment
(std::string s);
86
token_type
get_token_type
(
Trie
* service_trie, std::string s);
87
void
print_token
(
Trie
* service_trie, std::string buffer);
88
std::vector<Token>
merge
(std::vector<Token>& f, std::vector<Token>& s,
int
& ind,
int
);
89
};
90
92
struct
Token
{
94
LexicalAnalyzer::token_type
type
;
96
std::string
value
;
98
int
line
;
102
Token
(
LexicalAnalyzer::token_type
type_, std::string value_,
int
line_) {
103
type
= type_;
104
value
= value_;
105
line
= line_;
106
}
113
Token
() {
114
type
=
LexicalAnalyzer::token_type::unknown
;
115
value
=
""
;
116
line
= -1;
117
}
118
};
D:
GitHub
AALanguage2
AALanguage
LexicalAnalyzer.h
Generated by
1.10.0