Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Java Development Tools (JDT) » Extending Eclipse's Java parser(Extending Eclipse's Java parser to support custom syntax)
Extending Eclipse's Java parser [message #1843355] Sun, 25 July 2021 12:53 Go to next message
Tobias de Bruijn is currently offline Tobias de BruijnFriend
Messages: 2
Registered: July 2021
Junior Member
Hi there,

I'm looking to extend Eclipse's Java parser to support custom syntax. Specifically I'm looking at porting Rust's macros to Java.

Supporting it in the compilation process is fairly easy using a preprocessor.
However I'm unsure of how to get Eclipse to play with it nicely.

Currently it's just an idea without much thought put into it yet, but I'm looking at syntax equivalent to something like this:

// Macro declaration
package com.example;

macro MacroExample {
  ($a:expr) => {
    return $a
  }  
}


// Macro usage
import com.example.MacroExample

String return(String a) {
  MacroExample!(a);
}


More on Rust's macros at rustlang.org, I cant link to it directly (yet) unfortunately as this is my first post on the forum here.

The preprocessor here would substitute the macro declaration where it is used, and substitute variables accordingly. Likely it will then also omit the import statement, and remove the declaration in the source to be compiled.

The next step would be to have Eclipse understand this. Is this even achievable? If so, where should I be looking? A couple of Google searches haven't gotten me very far unfortunately.

Thanks!
Re: Extending Eclipse's Java parser [message #1843358 is a reply to message #1843355] Sun, 25 July 2021 17:45 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You might want to study how the Xtext nature/ builder automatically converts *.xtend files to *.java so that at least the compilation process is fairly seamless.

Unfortunately making many other things work smoothly such as source line debugging, refactoring, searching is a fairly substantial and difficult undertaking.

Regards

Ed Willink
Re: Extending Eclipse's Java parser [message #1843360 is a reply to message #1843358] Sun, 25 July 2021 18:25 Go to previous message
Tobias de Bruijn is currently offline Tobias de BruijnFriend
Messages: 2
Registered: July 2021
Junior Member
Hi,

I'll certainly take a good look at that!

Essentially all I want is for Eclipse to not show errors anywhere a macro is involved. Autocomplete, debugging e.d. isn't necessarily a requirment, Though no red squiggly lines all over the place would be appreciated:
index.php/fa/40799/0/

Thanks
  • Attachment: Capture.PNG
    (Size: 10.00KB, Downloaded 150 times)
Previous Topic:2021-09 Release and Java 17
Next Topic:How to disable inline warnings/errors?
Goto Forum:
  


Current Time: Fri Apr 19 11:41:37 GMT 2024

Powered by FUDForum. Page generated in 0.02063 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top