grammar simple; // Antlr3 foo: number+; number: NUMBER; NUMBER: '0'..'9'+;
and its Xtext counterpart
grammar Simple; // Xtext import "http://www.eclipse.org/emf/2002/Ecore" as ecore generate Simple "http://www.example.org/Simple" Foo: dummy=Number+; Number: NUMBER_TOKEN; terminal NUMBER_TOKEN: '0'..'9'+;
Xtext uses Antlr behind the scenes, but the two format are not exactly the same. There are quite a few annoying (and partly understandable) things I have to modify, including:
- Prefix terminals with the
import "http://www.eclipse.org/emf/2002/Ecore" as ecoreto make terminals work
- Add a feature to the top-level rule, e.g.
- Keep in mind that rule and terminal names have to be unique even case-insensitive.
- Optionally, capitalize the first letter of rule names to follow Java convention.
Is there a tool to make this conversion automatically at least for simple cases? If not, is there a more complete checklist of such required modifications?