For most languages, the default color classes are sufficient, but some languages have more token categories. For these languages, you can provide custom color classes using the following procedure:
注意
You must provide your own lex/yacc-compatible tools; these tools are not included in the VS SDK and the language service project will not build without them. To build the language service using the sample grammar and parser for the sample My C Package, you must use version 1.24 or later of Bison and version 2.5.4a or later of Flex. Place the Bison and Flex executables in the Babel Tools folder, for example, <InstallPath>\VisualStudioIntegration\Babel\Tools. These version numbers are specific to the My C sample.
To provide custom color classes
Set the RequestStockColors language property to zero to specify that you are going to use custom color classes.
In Solution Explorer, expand the bservice project and then expand the Source Files folder. Double-click the service.cpp file to open it in the editor.
Add an enumeration definition for your language after the language information to define your custom color classes. Start the enumeration with the last default color class (ClassDefaultLast + 1) and use the default color classes where appropriate.
After completing this step, you can use the new custom color classes in the token definition array. Define the tokens to correspond to the color classes defined in the enumeration.
Last, add the method to the class declaration in service.h, as shown in the following example:
class Service : public CommentService { protected: override const ColorInfo* getColorInfo() const; override const TokenInfo* getTokenInfo() const; };
Although it is possible to specify any legal CSS style, the Babel Package recognizes only a subset of properties and values. See the "Supported CSS Styles" section in the IBabelService::GetColorInfo Method.