plugbee / dslforge

A generator of domain-specific language (DSL) editors for web applications and cloud IDEs.
78 stars 21 forks source link

Support ANTLR v4.6 grammars #40

Open amlajmi opened 7 years ago

amlajmi commented 7 years ago

Evaluate the JavaScript target of ANTLR v4.6 and provide support for such grammars in the static web app scenario (no Xtext in the backend).

dpatil-gmcs commented 7 years ago

@amlajmi

Could you please let us know ETA for this enhancement? That will be great help.

Thanks. Deepak.

amlajmi commented 7 years ago

Still in progress, the introduction of Node.js in ANTLRv4 JavaScript target is bringing additional headache. Hopefully, it will be made publicly available in v0.9.2 by the end of March.

rimmartin commented 6 years ago

Would this be with the lexer and parser in separate files or combined?

amlajmi commented 6 years ago

Separate files, jut like the current ANTLR v3.3 integration.

rimmartin commented 6 years ago

You need antlr4 in client?

I believe the antlr4 runtime https://github.com/antlr/antlr4/blob/master/doc/javascript-target.md allows running with or without nodejs. To use without nodejs the require needs a replacement. https://github.com/letorbi/smoothie/tree/master/standalone is the updated one. I will try it with one of my small experimental apps. Also curious if http://requirejs.org/ would work as well.

Since ace has it's own require some coding to have both is needed

...
importScripts("http://roger-g74sx:9080/worker-base.js");
// load nodejs compatible require
var ace_require = require;
require = undefined;
var Honey = { 'requirePath': ['/'] }; // walk up to js folder, see Honey docs
importScripts("http://roger-g74sx:9080/lib/require.js");
var antlr4_require = require;
require = ace_require;
...

I never tried their webpack suggestion but did stand up an antlr4 grammar with ace with require.js

amlajmi commented 6 years ago

I agree, the problem v4.6 has a strong depenency to Node.js, and the Honey stuff looks like a hack to make it work with ACE's require.js.

I think doing a clean integration with ACE requires to slightly modify the parser/lexer generator templates, which is possible with ANTLR, but as it needs a non negligible ammount of work, we don't want to do it just because it's cool (we've contributed a lot of stuff based on this philosophy so far :), and we'd like to get more feedback from developers before going further.

That said, if you make it work the clean way, it would be nice to integrate it to DSL Forge. Please feel free to open a pull request if you are interested.

rimmartin commented 6 years ago

Well it ain't happenin' fast via me lol. I get 2807 errors after getting the plugins projects into Eclipse. The pde dependencies are there. Eclipse EE thingy. And I'm not asking for anyone to help me with this. I have great intestinal fortitude for most tasks but for some reason Eclipse is a complete pita to me.

One question; how vital is Java and Eclipse to the dsl forge's purposes? Could it be a webapp itself?

amlajmi commented 6 years ago

Of course yes, we experimented something like this before, the idea was to setup an ANTLR Web IDE, based on DSL Forge and other open-source projects. We were able to migrate parts of the tooling (Eclipse) to the runtime (the webapp), but the backend was still in Java.

rimmartin commented 6 years ago

Ah very interesting. In a branch or other project?

amlajmi commented 6 years ago

For now, it's an internal prototype, we did not publish the code as it needs additional care to make it compatible with EPL. We would love to take this direction, but unfortunately, this is not our top priority now, unless there are good reasons. Alternatively, you could get in touch with the professional support if you want to share your usecase/motivations and discuss how to dispatch the efforts.

Anyone else interested in this enhancement is more than welcome!

rimmartin commented 6 years ago

Hi @amlajmi, I've learned more about what you were referring to ace needing modification.

As you know ace is a one line-at-a-time lexer/highlighter and currently isn't built for grammars. I'm looking around to see if anyone is forking and attempting to redo the core of ace and looking at other possibilities of going from antlr v4 to a rich text editor in javascript

amlajmi commented 6 years ago

Hi @rimmartin ,

if anyone is forking and attempting to redo the core of ace

I think it's a good practice to keep the runtime based on a standard Ace distribution, even with the issue of multiline parsing, which is another known problem. Maybe the effort should be done on the Antlr side; changing the template headers to use Ace require instead of Node require would be enough.

rimmartin commented 6 years ago

Oh I wasn't proposing forking forever but to put a pull request eventually to them. (Or see if anyone is already forking for this but their fork list is so huge ace's github won't display them)

I may try a pull request for using the same ace require to the antlr team as well. As you stated it is two issues.

Ace's mode getLineTokens is a limitation that my project can't live with since I'm even employing the multi lexer mode(https://github.com/antlr/antlr4/blob/master/doc/lexer-rules.md, a different concept than ace's language mode concept) capability with antlr v4

amlajmi commented 6 years ago

OK, I see. If you are using multiple lexers, I understand why you may need to process several lines at once, I guess something needs to be done here to make it work with your project. Anyway, let us know if you succeed in rebuilding Antlr v4, this would be awesome :)