OSDN Git Service

crystaledit: Separate JavaScript and Java parsers. osdn.net #41083
[winmerge-jp/winmerge-jp.git] / Externals / crystaledit / editlib / parsers / csharp.cpp
1 ///////////////////////////////////////////////////////////////////////////
2 //  File:       cplusplus.cpp
3 //  Version:    1.2.0.5
4 //  Created:    29-Dec-1998
5 //
6 //  Copyright:  Stcherbatchenko Andrei
7 //  E-mail:     windfall@gmx.de
8 //
9 //  Implementation of the CCrystalEditView class, a part of the Crystal Edit -
10 //  syntax coloring text editor.
11 //
12 //  You are free to use or modify this code to the following restrictions:
13 //  - Acknowledge me somewhere in your about box, simple "Parts of code by.."
14 //  will be enough. If you can't (or don't want to), contact me personally.
15 //  - LEAVE THIS HEADER INTACT
16 ////////////////////////////////////////////////////////////////////////////
17
18 ////////////////////////////////////////////////////////////////////////////
19 //  16-Aug-99
20 //      Ferdinand Prantl:
21 //  +   FEATURE: corrected bug in syntax highlighting C comments
22 //  +   FEATURE: extended levels 1- 4 of keywords in some languages
23 //
24 //  ... it's being edited very rapidly so sorry for non-commented
25 //        and maybe "ugly" code ...
26 ////////////////////////////////////////////////////////////////////////////
27
28 #include "StdAfx.h"
29 #include "crystallineparser.h"
30 #include "../SyntaxColors.h"
31 #include "../utils/string_util.h"
32
33 #ifdef _DEBUG
34 #define new DEBUG_NEW
35 #endif
36
37 //  C# keywords
38 static const TCHAR * s_apszCppKeywordList[] =
39   {
40     _T ("abstract"),
41     _T ("base"),
42     _T ("bool"),
43     _T ("break"),
44     _T ("byte"),
45     _T ("case"),
46     _T ("catch"),
47     _T ("char"),
48     _T ("checked"),
49     _T ("class"),
50     _T ("const"),
51     _T ("continue"),
52     _T ("decimal"),
53     _T ("default"),
54     _T ("delegate"),
55     _T ("do"),
56     _T ("double"),
57     _T ("else"),
58     _T ("enum"),
59     _T ("event"),
60     _T ("exdouble"),
61     _T ("exfloat"),
62     _T ("explicit"),
63     _T ("extern"),
64     _T ("false"),
65     _T ("finally"),
66     _T ("fixed"),
67     _T ("float"),
68     _T ("for"),
69     _T ("foreach"),
70     _T ("get"),
71     _T ("goto"),
72     _T ("if"),
73     _T ("implicit"),
74     _T ("in"),
75     _T ("int"),
76     _T ("interface"),
77     _T ("internal"),
78     _T ("is"),
79     _T ("lock"),
80     _T ("long"),
81     _T ("namespace"),
82     _T ("new"),
83     _T ("null"),
84     _T ("object"),
85     _T ("operator"),
86     _T ("out"),
87     _T ("override"),
88     _T ("private"),
89     _T ("protected"),
90     _T ("public"),
91     _T ("readonly"),
92     _T ("ref"),
93     _T ("return"),
94     _T ("sbyte"),
95     _T ("sealed"),
96     _T ("set"),
97     _T ("short"),
98     _T ("sizeof"),
99     _T ("static"),
100     _T ("string"),
101     _T ("struct"),
102     _T ("switch"),
103     _T ("this"),
104     _T ("throw"),
105     _T ("true"),
106     _T ("try"),
107     _T ("typeof"),
108     _T ("uint"),
109     _T ("ulong"),
110     _T ("unchecked"),
111     _T ("unsafe"),
112     _T ("ushort"),
113     _T ("using"),
114     _T ("virtual"),
115     _T ("void"),
116   };
117
118
119 static bool
120 IsCppKeyword (const TCHAR *pszChars, int nLength)
121 {
122   return ISXKEYWORD (s_apszCppKeywordList, pszChars, nLength);
123 }
124
125 unsigned
126 CrystalLineParser::ParseLineCSharp (unsigned dwCookie, const TCHAR *pszChars, int nLength, TEXTBLOCK * pBuf, int &nActualItems)
127 {
128   return ParseLineCJava (dwCookie, pszChars, nLength, pBuf, nActualItems, IsCppKeyword, nullptr);
129 }