OSDN Git Service

05b6b7ef67f9893c30bb0936e6f61dbe2d2f8fd6
[winmerge-jp/winmerge-jp.git] / Externals / crystaledit / editlib / parsers / crystallineparser.h
1 #pragma once\r
2 \r
3 #define ISXKEYWORD(keywordlist, key, keylen) CrystalLineParser::IsXKeyword(key, keylen, keywordlist, sizeof(keywordlist)/sizeof(keywordlist[0]), _tcsncmp)\r
4 #define ISXKEYWORDI(keywordlist, key, keylen) CrystalLineParser::IsXKeyword(key, keylen, keywordlist, sizeof(keywordlist)/sizeof(keywordlist[0]), _tcsnicmp)\r
5 \r
6 #define DEFINE_BLOCK(pos, colorindex)   \\r
7 ASSERT((pos) >= 0 && (pos) <= nLength);\\r
8 if (pBuf != nullptr)\\r
9   {\\r
10     if (nActualItems == 0 || pBuf[nActualItems - 1].m_nCharPos <= (pos)){\\r
11         if (nActualItems > 0 && pBuf[nActualItems - 1].m_nCharPos == (pos)) nActualItems--;\\r
12         if (nActualItems == 0 || pBuf[nActualItems - 1].m_nColorIndex != (colorindex)){\\r
13             pBuf[nActualItems].m_nCharPos = (pos);\\r
14             pBuf[nActualItems].m_nColorIndex = (colorindex);\\r
15             pBuf[nActualItems].m_nBgColorIndex = COLORINDEX_BKGND;\\r
16             nActualItems ++;}}\\r
17   }\r
18 \r
19 #define COOKIE_COMMENT          0x0001\r
20 #define COOKIE_PREPROCESSOR     0x0002\r
21 #define COOKIE_ELEMENT          0x0002\r
22 #define COOKIE_EXT_COMMENT      0x0004\r
23 #define COOKIE_STRING           0x0008\r
24 #define COOKIE_CHAR             0x0010\r
25 #define COOKIE_USER1            0x0020\r
26 #define COOKIE_EXT_USER1        0x0040\r
27 #define COOKIE_BLOCK_STYLE      0x0080\r
28 #define COOKIE_BLOCK_SCRIPT     0x0100\r
29 #define COOKIE_SECTION          0x0080\r
30 #define COOKIE_KEY              0x0100\r
31 #define COOKIE_EXT_COMMENT2     0x0200\r
32 #define COOKIE_USER2            0x0400\r
33 #define COOKIE_VARIABLE         0x0800\r
34 #define COOKIE_RAWSTRING        0x1000\r
35 #define COOKIE_EXT_DEFINITION   0x2000\r
36 #define COOKIE_EXT_VALUE        0x4000\r
37 \r
38 #define COOKIE_GET_EXT_COMMENT_DEPTH(cookie) (((cookie) & 0x0F000000) >> 24)\r
39 #define COOKIE_SET_EXT_COMMENT_DEPTH(cookie, depth) (cookie) = (((cookie) & 0xF0FFFFFF) | ((depth) << 24))\r
40 #define COOKIE_GET_RAWSTRING_NUMBER_COUNT(cookie) (((cookie) & 0xF0000000) >> 28)\r
41 #define COOKIE_SET_RAWSTRING_NUMBER_COUNT(cookie, count) (cookie) = (((cookie) & 0x0FFFFFFF) | ((count) << 28))\r
42 #define COOKIE_GET_LUA_EQUALS_SIGN_COUNT(cookie) (((cookie) & 0xF0000000) >> 28)\r
43 #define COOKIE_SET_LUA_EQUALS_SIGN_COUNT(cookie, count) (cookie) = (((cookie) & 0x0FFFFFFF) | ((count) << 28))\r
44 \r
45 #define SRCOPT_INSERTTABS 1\r
46 #define SRCOPT_SHOWTABS 2\r
47 #define SRCOPT_BSATBOL 4\r
48 #define SRCOPT_SELMARGIN 8\r
49 #define SRCOPT_AUTOINDENT 16\r
50 #define SRCOPT_BRACEANSI 32\r
51 #define SRCOPT_BRACEGNU 64\r
52 #define SRCOPT_EOLNDOS 128\r
53 #define SRCOPT_EOLNUNIX 256\r
54 #define SRCOPT_EOLNMAC 512\r
55 #define SRCOPT_FNBRACE 1024\r
56 #define SRCOPT_WORDWRAP 2048\r
57 #define SRCOPT_TOPMARGIN 4096\r
58 \r
59 namespace CrystalLineParser\r
60 {\r
61 //  Syntax coloring overrides\r
62 struct TEXTBLOCK\r
63 {\r
64         int m_nCharPos;\r
65         int m_nColorIndex;\r
66         int m_nBgColorIndex;\r
67 };\r
68 \r
69 typedef enum\r
70 {\r
71         SRC_PLAIN,\r
72         SRC_ASP,\r
73         SRC_AUTOIT,\r
74         SRC_BASIC,\r
75         SRC_BATCH,\r
76         SRC_C,\r
77         SRC_CSHARP,\r
78         SRC_CSS,\r
79         SRC_DCL,\r
80         SRC_FORTRAN,\r
81         SRC_GO,\r
82         SRC_HTML,\r
83         SRC_INI,\r
84         SRC_INNOSETUP,\r
85         SRC_INSTALLSHIELD,\r
86         SRC_JAVA,\r
87         SRC_JAVASCRIPT,\r
88         SRC_JSON,\r
89         SRC_LISP,\r
90         SRC_LUA,\r
91         SRC_NSIS,\r
92         SRC_PASCAL,\r
93         SRC_PERL,\r
94         SRC_PHP,\r
95         SRC_PO,\r
96         SRC_POWERSHELL,\r
97         SRC_PYTHON,\r
98         SRC_REXX,\r
99         SRC_RSRC,\r
100         SRC_RUBY,\r
101         SRC_RUST,\r
102         SRC_SGML,\r
103         SRC_SH,\r
104         SRC_SIOD,\r
105         SRC_SMARTY,\r
106         SRC_SQL,\r
107         SRC_TCL,\r
108         SRC_TEX,\r
109         SRC_VERILOG,\r
110         SRC_VHDL,\r
111         SRC_XML\r
112 }\r
113 TextType;\r
114 \r
115 // Tabsize is commented out since we have only GUI setting for it now.\r
116 // Not removed because we may later want to have per-filetype settings again.\r
117 // See ccrystaltextview.cpp for per filetype table initialization.\r
118 struct TextDefinition\r
119 {\r
120         TextType type;\r
121         TCHAR name[256];\r
122         TCHAR exts[256];\r
123         unsigned (* ParseLineX) (unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
124         unsigned flags;\r
125 //        unsigned tabsize;\r
126         TCHAR opencomment[8];\r
127         TCHAR closecomment[8];\r
128         TCHAR commentline[8];\r
129         unsigned encoding;\r
130 };\r
131 \r
132 extern TextDefinition m_SourceDefs[41];\r
133 \r
134 bool IsXKeyword(const TCHAR *pszKey, size_t nKeyLen, const TCHAR *pszKeywordList[], size_t nKeywordListCount, int(*compare)(const TCHAR *, const TCHAR *, size_t));\r
135 bool IsXNumber(const TCHAR* pszChars, int nLength);\r
136 bool IsHtmlKeyword(const TCHAR *pszChars, int nLength);\r
137 bool IsHtmlUser1Keyword(const TCHAR *pszChars, int nLength);\r
138 bool IsHtmlUser2Keyword(const TCHAR *pszChars, int nLength);\r
139 \r
140 TextDefinition *GetTextType(const TCHAR *pszExt);\r
141 TextDefinition* GetTextType(int index);\r
142 void SetExtension(int index, const TCHAR *pszExts);\r
143 \r
144 unsigned ParseLinePlain(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
145 unsigned ParseLineAsp(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
146 unsigned ParseLineAutoIt(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
147 unsigned ParseLineBasic(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
148 unsigned ParseLineBatch(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
149 unsigned ParseLineC(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
150 unsigned ParseLineCJava(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems, bool (*IsKeyword)(const TCHAR *pszChars, int nLength), bool (*IsUser1Keyword)(const TCHAR *pszChars, int nLength));\r
151 unsigned ParseLineCSharp(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
152 unsigned ParseLineCss(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
153 unsigned ParseLineDcl(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
154 unsigned ParseLineFortran(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
155 unsigned ParseLineGo(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
156 unsigned ParseLineHtml(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
157 unsigned ParseLineHtmlEx(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems, int nEmbeddedLanguage);\r
158 unsigned ParseLineIni(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
159 unsigned ParseLineInnoSetup(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
160 unsigned ParseLineIS(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
161 unsigned ParseLineJava(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
162 unsigned ParseLineJavaScript(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
163 unsigned ParseLineLisp(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
164 unsigned ParseLineLua(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
165 unsigned ParseLineNsis(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
166 unsigned ParseLinePascal(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
167 unsigned ParseLinePerl(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
168 unsigned ParseLinePhp(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
169 unsigned ParseLinePhpLanguage(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
170 unsigned ParseLinePo(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
171 unsigned ParseLinePowerShell(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
172 unsigned ParseLinePython(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
173 unsigned ParseLineRexx(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
174 unsigned ParseLineRsrc(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
175 unsigned ParseLineRuby(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
176 unsigned ParseLineRust(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
177 unsigned ParseLineSgml(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
178 unsigned ParseLineSh(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
179 unsigned ParseLineSiod(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
180 unsigned ParseLineSmarty(unsigned dwCookie, const TCHAR* pszChars, int nLength, TEXTBLOCK* pBuf, int& nActualItems);\r
181 unsigned ParseLineSmartyLanguage(unsigned dwCookie, const TCHAR* pszChars, int nLength, TEXTBLOCK* pBuf, int& nActualItems);\r
182 unsigned ParseLineSql(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
183 unsigned ParseLineTcl(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
184 unsigned ParseLineTex(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
185 unsigned ParseLineVerilog(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
186 unsigned ParseLineVhdl(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
187 unsigned ParseLineXml(unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems);\r
188 \r
189 }\r