How to: Use the Managed Babel System

This topic describes how you can integrate a new language into Visual Studio using the Managed Babel System.

The Managed Babel System ships with the Visual Studio SDK and does not need to be installed. The executable files for the Managed Babel System are located in \Program Files\Visual Studio 2005 SDK\[build]\VisualStudioIntegration\Tools\Bin\. The executable files are:

  • MPLex.exe

  • mplex.frame

  • MPPG.exe

  • MPPGRuntime.dll

Creating a Language Service

To use the Managed Babel System to integrate a new language into the Visual Studio language services framework, follow the procedures in this section.

To create a VSPackage

  1. On the File menu, point to New and then click Project.

  2. Under Other Project Types, click Extensibility.

  3. Select Visual Studio Integration Package, type a name and location for your project, and then click OK.

    The Visual Studio Integration Package Wizard opens.

  4. On the Select a Programming Language page, select Visual C# and then select Generate a new key file to sign the assembly.

  5. Click Finish to create the VSPackage for your Managed Babel System implementation.

To create the directory structure

  • In your new project, create the following folders in Solution Explorer:

    • Generated

      Holds user-supplied specification files and generated parser and scanner sources.

    • Invariant

      Holds all of the Babel code that applies toall projects.

    • UserSupplied

      Holds the Babel-generated files that require editing by the developer.

To edit the scanner and the parser configuration files

  1. In the Generated directory, create a scanner specification file, such as lexer.lex, and edit it so that it contains the patterns for each token necessary for MPLEX to generate a scanner class for your new language. For more information on how to edit a scanner specification file, refer to the O'Reilly & Associates book,"Lex & Yacc."

  2. In the Generated directory, create a parser specification file, such as parser.y, and edit it so that it contains the grammar necessary for MPPG to generate a parserclass for your new language. For more information on how to edit a parser specification file, refer to the O'Reilly & Associates book, "Lex & Yacc."

To implement functionality for language services

  1. In the Managed Babel System-generated Configuration.cs class in the UserSupplied directory, declare the following information for your new language:

    • The name of the language service and the file extension that loads it.

    • The comment conventions for the language.

    • Color and token trigger information. (Colors must be defined for tokens that will be different from the default colors, or that are associated with trigger actions.)

  2. In the UserSupplied directory, edit the Managed Babel System-generated Resolver.cs class to connect your new language to the Visual Studio IntelliSense functionality. Methods in this class can remain empty until you wish to implement IntelliSense in your new language.

To test the new language service

  1. Build the project. Once built, it will register itself with the experimental hive.

  2. Debug the project. This will invoke another copy of Visual Studio running in the experimental hive.

  3. Open a file that contains code in the new language you wish to edit. This will invoke your new language service.

    注意

    Make sure the file has a file extension that you specified in the first procedure.

See Also

Concepts

Managed Babel System Essentials

Managed Babel System