Adding parser for your language
From Aptana Development
Adding Parser for your language
This page describes how to add parser for new language to Aptana.
Parser is a tool that is capable to build part of AST tree for a given content. It is required for building outline, folding , usually content assist also depends from it. We register a parser for a particular content type (MIME type) by extending extension-point “com.aptana.ide.editors.parser”.
All Aptana editors look up parsers registered via the extension point for the content type they edit. Whenever there are modifications to editor text, the registered parser for that content type is invoked.
Instructions
To add a parser for your language:
1. Add a <parser> entry to “com.aptana.ide.editors.parser” extension point.
<extension
point="com.aptana.ide.editors.parser">
<parser
class="com.aptana.ide.editor.js.parsing.JSParser"
language="text/javascript"/>
</extension>
- class
- Fully qualified Java class name implementing com.aptana.ide.parsing.IParser interface.
- language
- MIME type of content that this parser parses
2. Write Java class specified in step 1 above, implementing the IParser interface.
Instead of implementing the IParser interface directly, it is recommended to extend from the abstract base class
com.aptana.ide.editors.unified.parsing.AbstractUnifiedParser which implements this interface, and then
implement the abstract methods of the base class.
3. Verify that the parser thus registered is detected in Aptana. Build everything and launch the IDE in debug mode. Your parser should be invoked on every change to edited files that contain content of the registered MIME type. Notice that it is possible to use any kind of parser with Aptana. It may be an ANTLR or a JFlex or even hand-made parser.
The IParser interface can be used to integrate existing third-party parsers with Aptana editors e.g. the Aptana PHP parser relies on the PDT (PHP Development Tools) parser to do the actual parsing.
If you are interested, you can take a look at the parsers supplied with Aptana. Some are listed below:
- com.aptana.ide.editor.js.parsing.JSParser
- com.aptana.ide.editor.php.parsing.PHPParser
- com.aptana.ide.editor.html.parsing.HTMLParser
- com.aptana.ide.editor.css.parsing.CSSParser


