Is there any Grammar editor utility for context-free grammars developed in Java?
The one I know about would be XText.
Might be a bit over-kill:
Xtext is a framework for development of programming languages and domain specific languages (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.
The DSL editor looks like:
alt text http://www.eclipse.org/Xtext/documentation/latest/images/getting-started-grammar.png
Allowing you to play with the language you just defined:
alt text http://www.eclipse.org/Xtext/documentation/latest/images/getting-started-editor.png
ANTLRWorks the GUI development environment for ANTLR is quite nice. I've used it with ease in the past.
http://www.antlr.org/works/index.html
I also found that:
http://ozark.hendrix.edu/~burch/proj/grammar/
If you prefer compiler built into your app without generating any source files, take a look at Parboiled: https://github.com/sirthias/parboiled
Related
In my current project, I write high-level specification ( as indicated below for reference) and am parsing it using grammar written in ANTLR and then using StringTempate to generate equivalent Java programming code. Now, my client finds the writing of this textual high-level specification difficult and want me to provide equivalent visual drag and drop programming constructs and editor to specify this programming constructs. My question is : does eclipse provide any
drag and drop workbench to develop visual programming constructs and editors?
It MAY be easy to integrate with ANTLR.
A Sample example or its link will be useful.
TemperatureSensor
generate tempMeasurement : TempStruct;
TempStruct
tempValue : double;
unitOfMeasurement: String;
You could have a look at Graphiti, it is much lighter than GMF and easier to setup.
https://eclipse.org/graphiti/
In any case to leverage existing tools in eclipse to manipulate models, you absolutely need a metamodel to integrate into the EMF, so you might use Xtext to develop that, based on your existing antlr grammar.
Have a look at Eclipse Graphical Editing Framework (GEF), it's a framework for creating graphical editors in an Eclipse-based product or plug-in. There are even some efforts to integration GEF with XText, for example this one.
Yes, Eclipse has the Sirius project. https://www.eclipse.org/sirius/
I am looking for a parser generator that accepts a Javacc grammar file (.jj) and generates a parser in Javascript (instead of Java). Does such a thing exist? Alternately how difficult would it be to convert the .jj file to something that ANTLR (which can output Javascript) can understand?
I am looking for a parser generator that accepts a Javacc grammar file (.jj) and generates a parser in Javascript (instead of Java). Does such a thing exist?
Apparently, no.
Alternately how difficult would it be to convert the .jj file to something that ANTLR (which can output Javascript) can understand?
It would be non-trivial, and you'd need to do it by hand. But the actual degree of difficulty probably depends on the grammar you are trying to convert.
It is worth noting that there are other parser generators that output parsers in Javascript. (And, no, I'm not going to list them or recommend one!)
Obviously, the input language will be different to Javacc input.
Google's GWT compiles java code to JavaScript, as long as only a specific subset of the JDKis used. I'm also not sure how much GWT-specific cruft it brings along. But that might be a possibility: using javacc to generate java code, and then GWT to translate it to JavaScript.
I recently added support for a GWT compatible parser target to JavaCC (no dependencies on Java IO classes). I recently wrote a pair of blogs on how to use JavaCC so that a JavaScript parser can be generated via GWT. Link below:
Building parsers for the web with JavaCC & GWT (My blog post)
JavaCC 6.1 Development Build
If you don't mind rewriting your grammar,
I have written a parser builder in Kotlin common code, so it will run on a JavaScript platform.
The grammar syntax is fairly simple and EBNF like.
You can see details here, and there is a link to a demo running in the browser if you want to try it out.
https://medium.com/#dr.david.h.akehurst/a-kotlin-multi-platform-parser-usable-from-a-jvm-or-javascript-59e870832a79
Premise:
I started writing an IDE web application a year or so ago. It would be similar to Adobe's Dreamweaver. It would have a WYSIWYG, text editor, and debugging tools. Of course, there are other new features that I'd like to write- otherwise, I wouldn't be writing my own IDE. I wrote a syntax highlighter and parser in JavaScript and started writing the WYSIWYG using the HTML DOM. However, as fast as rendering and JavaScript engines have gotten, they aren't the best choice for writing an IDE. So, yes, I realize how difficult an IDE is to program.
Question: Currently, I plan to write the IDE in Java or C++ (preferably Java). Instead of writing my own interpreter for PHP/HTML/CSS/JavaScript/etc., I'd like to integrate my application with as many existing tools as I can. I know Java has Rhino and Quercus. Gecko and pretty much any JavaScript engine can be integrated with C++. My question is:
What are the best engines available for C++ and Java? For PHP, HTML, CSS, and JavaScript specifically.
Would it be possible to tap into these engines to write a debugger and other tools? Preferably, as unobtrusively as possible, so I can update engine versions without much hassle.
I'm not sure what the best way to approach this. I'd prefer not to have to go back and rewrite the whole thing because my design is flawed. Any suggestions would be deeply appreciated.
I would start with an open source IDE and extend it. Netbeans and Eclipse already support a good number of languages and have debuggers.
IntelliJ CE supports all the languages mentioned, so perhaps you only need to extend it to do what you want. You might not need to write any code at all. ;)
I would like to create an automatic Flowchart-like visualization to simple Java Logic, for this I need to parse Java Source code, I have 2 candidates, ANTLR and javax.lang.model of Java 6. Neither are easy.
I have yet to find a single working example that will be even remotely close to what I want to achieve.
I want to find simple variable declarations, assignments, and flows (if, for, switch, boolean conditions etc)
Is there a simple example or tutorial for either of these?
I found very few ANTLR examples (non of them are working out of the box without significant "homework") and absolutely none for javax.lang.model
Is there a particular reason you want to generate a parser yourself? IMO, it would be easier to let an existing parser create an AST for you which you "simply" traverse in order to collect your data about the source file(s). Using your favorite search engine with the keywords "get ast java source" will result in many relevant hits.
At a first glance, these look like suitable candidates:
Eclipse JDT API
javaparser
You could use ANTLR of course, there are many ANTLR grammars for Java available for you, but there is quite the learning curve when choosing this tool (or some other parser generator, for that matter). If you do choose ANTLR, I'm more than happy to answer any questions regarding it.
Best of luck!
I would try that with Eclipse Xtext, it uses ANTLR under the hood, it is also (relative) easy to use it together with Eclipse GMF for visualization.
I suggest you to go with Java Soot a Java Optimization Framework. Which will help you to parse the java source, can generate the CFG and various options available.
Also you can find eclipse plugin here
I'm building a Java IDE and am trying to implement autocompletion or intellisense. After looking around for something that will do most of the work for me (not reinventing the wheel etc) I've pulled the code for Eclipse JDT core and am trying to figure out how to implement it in my own IDE. I'm obviously working under the assumption that this is possible.
If anyone knows a lot about Eclipse JDT Core, implementing intellisense, or other fun things that would help me accomplish my goal and would like to weigh in, I would appreciate it! Thanks!
Another module that could help when implementing intellisense would be XText
(might be a bit too generic for your specific JDT domain)
Xtext is a framework for development of programming languages and domain specific languages (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.
alt text http://www.eclipse.org/Xtext/documentation/0_7_2/images/getting-started-editor.png