~kiwec/ke

ke/src/Syntax.h -rw-r--r-- 953 bytes
1cc8481d — Wolf Clément Fix compilation 3 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#pragma once
#include <stdint.h>
#include <string>
#include <vector>

using syntax_t = uint8_t;
class Line;
class Text;
struct Section;

enum TextColor {
	CHAR_COLOR = 1,
	COMMENT_COLOR = 2,
	STRING_COLOR = 6,
  OPERATOR_COLOR = 11,
	DEFAULT_COLOR = 15,
};

class Syntax {
private:
	static void prepare(Line);

	static void markPreprocessor(Line);
	static void markComments(Line line);
	static void markNumbers(Line line);
	static void markChars(Line line);
	static void markStrings(Line line);
	static void markOperators(Line line);
	static void markSpecial(Line line);

public:
	// Marks the line's start_commented bool based on
	// previous's line start_commented and text
  static void mark_start_commented(Line line);

  static std::vector<Section> get_inline_matches(Line line, std::wstring match);
	static std::vector<Section> get_inline_strings(Line line, wchar_t delimiter);

	static void update(Text& text);
	static void update(Line line);
};