Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I create a custom Eclipse Syntax Highlighter

I've been developing a compiler for a new language. I thought it would be neat to be able to demonstrate its development in a syntax aware environment. The language has quite a few custom keywords, and its structure is significantly different than common languages such as Java or C/C++.

How can I develop a custom syntax highligher for Eclipse? I've seen some references to a few plugins, but the documentation is not thorough enough for my beginner's needs.

I have a grammar/REs for my language, as well as lists of relevant keywords.

like image 550
Willi Ballenthin Avatar asked Apr 14 '09 01:04

Willi Ballenthin


People also ask

Can you highlight code in Eclipse?

Eclipse plugin for highlighting the background of the source code. While most of plugins highlight the syntax of the source code, EditBox highlights the selected block of the code (method, class, e...


2 Answers

Sounds like you are dealing with a DSL (Domain Specific Language). What you are looking for sounds exactly like XText. Here's an extract from the page:

Xtext is a framework/tool for development of external textual DSLs. Just describe your very own DSL using Xtext's simple EBNF grammar language and the generator will create a parser, an AST-meta model (implemented in EMF) as well as a full-featured Eclipse Text Editor from that.

Also, check out this video which is an interview with one of the people behind it. I'm sure you'll take it from here :-)

You may also want to check out this plugin. Not exactly what you are looking for, but could be a nice start.

like image 122
zvikico Avatar answered Oct 17 '22 07:10

zvikico


The Eclipse framework uses a fairly complex document model to do syntax coloring (they call it coloring, not highlighting), it is not as simple as it is in other editors.

If you really want to try and mess with it, you may want to read the following from the Eclipse plug-in developer guide.

(The above link is now dead. This may be a similar document or this.)

like image 32
Uri Avatar answered Oct 17 '22 07:10

Uri