One of our customers recently started using NuGram IDE for the development and maintenance of grammars targeting the IBM speech recognition engine. As is often the case with the IBM engine (and others as well), their ABNF grammars use the “.gram” extension.
NuGram IDE’s default extension for ABNF grammars, however, is “.abnf”, which means that it’s not configured out-of-the-box to work with “.gram” ABNF files. The reason is that the “.gram” extension is often used for binary, compiled grammars.
This can easily be fixed using three simple steps.
Step 1 - Adding a new file association
The NuGram IDE plugin adds to the set of content types already supported by Eclipse, a new content type for ABNF grammars. To associate “.gram” files with the ABNF content type, open the preferences and select the page “General > Content Types”. Then select the “Text > ABNF Grammar File” content type. Finally, click on “Add…” and type “*.gram”. You should see something like:
That’s it! Opening a “.gram” file will now properly launch the ABNF editor.
Step 2 - Setting the extension for newly created grammars
Now, if you want to create a new “.gram” grammar using the New ABNF Grammar wizard, you have to set the default extension in the preferences:
Step 3 - Configuring the project-specific translation rules
To completely support “.gram” grammars, the project translation rules must also be configured appropriately. That’s because all the grammar tools must be also know how to handle references to external grammars whose extensions are “.gram”. By default, references to “.gram” grammars are translated into references to “.grxml” grammars (the reason for this behavior will be explained in a separate post). You thus have to make sure that references to “.gram” grammars are not translated and can be used as is.
To do that, select your grammar project in the Navigator view and open its property page (by pressing Alt-Enter or right-clicking on it and selecting “Properties”). Under the “Grammar Development > External Rule References” category, deselect the rule named “.gram to .grxml” applied at “Runtime”:
Final note
Although I focused exclusively on grammars with the “.gram” extension, the above steps equally apply to any other extension. So go ahead, adapt NuGram IDE to your own needs and habits!


