I want to use the runtime configuration for running an xText parser. In an example xText project I get the standalone and the runtime configuration for using the parser.
Please can somebody indicate the steps needed to use the parser during runtime in another Eclipse plug-in project. I have no experience with the plugin.xml file and I know I need to create there some extension points.
The xText sample project contain also an ui project which uses the obtained parser during runtime. Still I was not able to understand what things I need from that configuration an what not.
Help is highly appreciated.
Related
I have two Eclipse plugin Xtext(2.11) projects.(Called Project A and B) Project B grammar file is dependent on Project A grammar file. Project A's grammar file extension is a and Project B is b.
I am able to generate the language server for Project B. I want to generate the single language server for both projects.(Currently, in project B it includes project A.)
Depend on extension type it needs invoke respective Xtext grammar functionality.
In above scenario, I have below questions:
Does Xtext can handle this kind of scenario seamlessly? Do I need to generate the language server for Project A also and need to add in Project B? What is the best way to do this?
What kind of Xtext changes required?
What kind of changes required at client side also? like in Visual code/ Che?
Xtext LS can be used with multiple Xtext languages. It uses java service loading to look up language setups: https://github.com/eclipse/xtext-core/blob/master/org.eclipse.xtext/src/org/eclipse/xtext/resource/ResourceServiceProviderServiceLoader.xtend#L25. In ide project of your language you should be able to find META-INF/services/org.ecalipse.xtext.ISetup file that says java what implementations should be used for ISetup interface.
Having jars for ide projects on the classpath should be enough. No changes are required.
VS code and Che does not care about implementation details of Xtext LS, but both languages should be registered for them
When using a third-party JavaScript library in my Dart project, I manually go through the library's documentation and iterate through its properties and methods to build the Dart code through a series of tedious context and callMethod calls. Has anyone figured out a way to automate this?
I tried to first find a command-line interface that introspects the JavaScript library so that I can auto-generate the Dart source code. I've been unsuccessful in my search.
I've tried to make my implementation of .d.ts -> dart2js annotations converter.
This is possible way to automate the process.
Please, see https://github.com/denis-aes/DefinitelyTyped.dart
Introspecting JS lib can be really hard due to the dynamic face of the JS language.
In the Typescript world there are *.d.ts files used to provide types to existing libraries. As far as I can tell most of those files are manually writen.
For now such a tool isn't yet available.
I'm thinking it might be easiest if I modify the Java syntax used in Rascal to better fit our Java-like language.
Is there a way I can build Rascal from the source? I've cloned the repo from Github and imported it as a project into Eclipse but there are some compilation errors regarding org.eclipse.imp. Before I head down the rabbit-hole of trying to get this all to work in Eclipse I thought I would post here to see if there is an easy way to handle this.
Thanks!
Sure you could build Rascal from scratch; following the developer instructions at https://github.com/cwi-swat/rascal/wiki/Rascal-Developers-Setup---Step-by-Step
On the other hand, if you wish to simply adapt the Java syntax definition it would be better to clone it into your own files. Grammars may look modular, but in reality there are complex interactions between different parts of the grammar. Better to clone and manage the whole thing as your own than depend on two co-evolving definitions.
If you clone the Java grammar Rascal will generate new parsers for you on-the-fly. If this generation becomes cumbersome, a "cached parser" can help you to optimize the deployment of your tools. Please contact us if you need help with that.
I'm trying to analyze Java source files with Clojure but I couldn't find a way to do that.
First, I thought using Eclipse AST plugin(by copying necessary JAR's to my Clojure project) but I gave up after seeing Eclipse AST's API(visitor based walker).
Then I've tried creating a Java parser with ANTLR. I can only find one Java 1.6 grammar for ANTLR( http://openjdk.java.net/projects/compiler-grammar/antlrworks/Java.g ) and it doesn't compile with latest ANTLR(here's the errors I'm getting ).
Now I have no idea how can I do that. At worst I'll try to go with Eclipse AST.
Does anyone know a better way to parse Java files with Clojure?
Thanks.
Edit: To clarify my point:
I need to find some specific method calls in Java projects and inspect it's parameters(we have multiple definitions of the method, with different type of parameters). Right now I have a simple solution written in Java(Eclipse AST) but I want to use Clojure in this project as much as possible.
... and it doesn't compile with latest ANTLR ...
I could not reproduce that.
Using ANTLR v3.2, I got some warnings, but no errors. Using both ANTLR v3.3 and v3.4 (latest version), I have no problems generating a parser.
You didn't mention how you're (trying) to generate a lexer/parser, but here's how it works for me:
java -cp antlr-3.4.jar org.antlr.Tool Java.g
EDIT 1
Here's my output when running the commands:
ls
wget http://www.antlr.org/download/antlr-3.4-complete.jar
wget http://openjdk.java.net/projects/compiler-grammar/antlrworks/Java.g
java -cp antlr-3.4-complete.jar org.antlr.Tool Java.g
ls
As you can see, the .java files of the lexer and parser are properly created.
EDIT 2
Instead of generating a parser yourself (from a grammar), you could use an existing parser like this one (Java 1.5 only AFAIK) and call it from your Clojure code.
It depends a bit on what you want to do - what are you hoping to get from the analysis?
If you want to actually compile Java or at least build an AST, then you probably need to go the ANTLR or Eclipse AST route. Java isn't that bad of a language to parse, but you still probably don't want to be reinventing too many wheels..... so you might as well build on the Eclipse and OpenJDK work.
If however you are just interesting in parsing the basic syntax and analysing certain features, it might be easier to use a simpler general purpose parser combinator library. Options to explore:
fnparse (Clojure, not sure how well maintained)
jparsec (Java, but can probably be used quite easily from Clojure)
Is it possible to use ant's antlr task to do code generation with the stringtemplate library?
If not, is it better to just execute a java class from command line to code gen w/ stringtemplate?
I've found this link which is close to what I want, but I am having a hard time setting this up properly. That library is not able to see antlr for some reason. link text
It depends of the complexity of the code that you want to generate. In case of our company, we extended org.apache.tools.ant.Task with the generation logic for java code. After that, both ant task and template files were packaged in a jar file.