The first step in setting language information for your language service is to create a project for your language. This step installs a new Babel client, but does not add any functionality. After you complete this step, Visual Studio loads the VSPackage for your language service.
注意
You must provide your own tools that are compatible with lex/yacc; these tools are not included in the Visual Studio SDKand the language service project will not build without them. To build the language service by using the sample grammar and parser for the My C Package Sample, you must use Bison version 1.24 and later versions of Bison and Flex version 2.5.4a and later versions of Flex. Add the Bison and Flex executable files to the Babel Tools folder, for example, <InstallPath>\VisualStudioIntegration\Babel\Tools. These version numbers are specific to the My C sample.
To create a project and add language information
In the VSIP Environment SDK folder, open the Babel folder.
For example, <Visual Studio SDK installation path>\VisualStudioIntegration\Archive\BabelIn the Babel folder, create a new folder that has the name of your language.
For example, \MyC.
Locate the sample MyCLangService folder.
For example, <Visual Studio SDK installation path>\VisualStudioIntegration\Archive\Babel\Samples\MyCLangService
Copy the contents of the sample MyCLangService folder to your new folder.
The template project includes boilerplate code and settings.
Double-click the Bservice.sln file in your new folder to start the Visual Studio integrated development environment (IDE). Doing this may give you a "Can't open the vcproj" file warning. You may have to tweak the bservice.sln file to provide the right path to the \Common\common.vcproj file.
In Solution Explorer, expand the bservice project, expand the Source Files folder, and then double-click the Service.cpp file to open it in the editor.
Replace the following values in the Globals block of this file with the corresponding values for your language:
g_languageName
Specifies a human readable name of the language. For example, "My C".
g_languageFileExtensions
Specifies the extensions of the source files ending with a NULL. For My C, the extension is just {".myc",NULL}.
g_languageCLSID
Specifies the CLSID of this specific language. The guidgen utility, which you can run at a command prompt, can be used to generate a new CLSID.
These values are used during the VSPackage registration.
For example, the definitions for the My C language are as follows:
const char* g_languageName = "My C"; const char* g_languageFileExtensions[] = { ".myc", NULL }; const CLSID g_languageCLSID = {0x54D21404,0x5E7F,0x11D3,{0xB4,0x07,0x00,0x60,0x08,0xD1,0xBF,0x8C}};
You can now build the Babel language service, although no functionality is implemented yet.
After you create the project and add language information, you can set the language properties. The language properties are defined in the g_languageProperties variable, which is an array of LanguageProperty structures (the LanguageProperty structure is defined in the languagedef.h file which is located in the Babel Common folder, for example, [drive]\Program Files\VSIP 8.0\EnvSDK\Babel\Common). Each property in the structure has the following characteristics:
It consists of a name and a numeric value.
It is placed in the registry during registration.
It determines the behavior of certain features in the language service.
For example, automatic brace matching is only enabled if the property MatchBraces is set to a value of one (1).
When no features are implemented, the set of properties is similar to that shown in the following example:
const LanguageProperty g_languageProperties[] =
{
{ "RequestStockColors", 1 },
{ "ShowCompletion", 1 },
{ "CodeSense", 0 },
{ "MaxErrorMessages", 5 },
{ "QuickInfo", 0 },
{ "MatchBraces", 0 },
{ "ShowMatchingBrace", 0 },
{ "MatchBracesAtCaret", 0 },
{ NULL, 0 }
};