OSDN Git Service

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