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
8struct Token;
9
12public:
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);
73private:
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
92struct Token {
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 }
115 value = "";
116 line = -1;
117 }
118};