1 class CSyntax : public EditorSyntax { // Curly braces languages (C++, Java, C#, Javascript...) common support
2 public:
3 	virtual void            Clear();
4 	virtual void            ScanSyntax(const wchar *ln, const wchar *e, int line, int tab_size);
5 	virtual void            Serialize(Stream& s);
6 	virtual void            IndentInsert(CodeEditor& editor, int chr, int count);
7 	virtual bool            CheckBrackets(CodeEditor& e, int64& bpos0, int64& bpos);
8 	virtual bool            CanAssist() const;
9 	virtual void            Highlight(const wchar *s, const wchar *end, HighlightOutput& hls,
10 	                                  CodeEditor *editor, int line, int64 pos);
11 	virtual void            CheckSyntaxRefresh(CodeEditor& e, int64 pos, const WString& text);
12 	virtual Vector<IfState> PickIfStack(); // TODO: Refactor?
13 	virtual void            ReformatComment(CodeEditor& e);
14 
15 protected:
16 	bool        comment;       // we are in /* */ block comment
17 	bool        linecomment;   // we are in // line comment (because it can be continued by '\')
18 	bool        string;        // we are in string (becase it can be continued by '\')
19 	bool        linecont;      // line ended with '\'
20 	bool        was_namespace; // true if there was 'namespace', until '{' or ';' (not in ( [ brackets)
21 	WString     raw_string;    // we are in C++11 raw string literal, this is end delimiter, e.g. )"
22 	char        macro;         // can be one of:
23 	enum        {
24 		MACRO_OFF = 0,  // last line was not #define
25 	    MACRO_CONT, // last line was #define and ended with '\'
26 	    MACRO_END   // last line was a macro, but ended
27 	};
28 
29 	int         cl, bl, pl; // levels of { [ (
30 
31 	Vector<int>     brk; // { ( [ stack (contains '{', ')', ']')
32 	Vector<int>     blk; // { line stack //TODO:SYNTAX: Join blk and bid
33 	Vector<int>     bid; // { indentation stack
34 	Vector<Isx>     par; // ( [ position stack
35 	Vector<IfState> ifstack;
36 
37 	int         stmtline;     // line of latest "if", "else", "while", "do", "for" or -1
38 	int         endstmtline;  // line of latest ';' (not in ( [ brackets)
39 	int         seline;       // stmtline stored here on ';' (not in ( [ brackets)
40 	int         spar;         // ( [ level, reset on "if", "else", "while", "do", "for"
41 
42 	int         highlight;    // subtype (temporary) TODO
43 
44 	static int  InitUpp(const char **q);
45 	static void InitKeywords();
46 	const wchar *DoComment(HighlightOutput& hls, const wchar *p, const wchar *e);
47 
48 	static Vector< Index<String> > keyword;
49 	static Vector< Index<String> > name;
50 	static Index<String> kw_upp;
51 	static int kw_macros, kw_logs, kw_sql_base, kw_sql_func;
52 
53 
54 	static Color BlockColor(int level);
55 
56 	int     GetCommentPos(CodeEditor& e, int l, WString& ch) const;
GetCommentHdr(CodeEditor & e,int l)57 	WString GetCommentHdr(CodeEditor& e, int l) const { WString h; GetCommentPos(e, l, h); return h; }
58 	void    IndentInsert0(CodeEditor& e, int chr, int count, bool reformat);
59 
60 	void Bracket(int64 pos, HighlightOutput& hls, CodeEditor *editor);
61 
62 	void  ClearBraces();
63 
64 	void  Grounding(const wchar *ln, const wchar *e);
65 
66 	bool CheckBracket(CodeEditor& e, int li, int64 pos, int64 ppos, int64 pos0, WString ln, int d, int limit, int64& bpos0, int64& bpos);
67 	bool CheckLeftBracket(CodeEditor& e, int64 pos, int64& bpos0, int64& bpos);
68 	bool CheckRightBracket(CodeEditor& e, int64 pos, int64& bpos0, int64& bpos);
69 
70 	bool RawString(const wchar *p, int& n);
71 
72 public:
73 	static int  LoadSyntax(const char *keywords[], const char *names[]);
74 
75 	enum HighlightType {
76 		HIGHLIGHT_NONE = -1, HIGHLIGHT_CPP = 0, HIGHLIGHT_USC, HIGHLIGHT_JAVA, HIGHLIGHT_T,
77 		HIGHLIGHT_CALC, HIGHLIGHT_LAY, HIGHLIGHT_SCH, HIGHLIGHT_SQL, HIGHLIGHT_CS,
78 		HIGHLIGHT_JAVASCRIPT, HIGHLIGHT_CSS, HIGHLIGHT_JSON, HIGHLIGHT_PHP,
79 		HIGHLIGHT_COUNT
80 	};
81 
SetHighlight(int h)82 	void    SetHighlight(int h)           { highlight = h; }
83 
CSyntax()84 	CSyntax()                             { Clear(); }
85 };
86 
87 const wchar *HighlightNumber(HighlightOutput& hls, const wchar *p, bool ts, bool octal, bool css);
88 const wchar *HighlightHexBin(HighlightOutput& hls, const wchar *p, int plen, bool thousands_separator);
89