Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grammar editor utility for context-free grammars in Java

Tags:

java

Is there any Grammar editor utility for context-free grammars developed in Java?

like image 441
SamSol Avatar asked May 31 '10 07:05

SamSol


People also ask

Is Java a context-free grammar?

Neither C# nor Java is context-free, because checking of whether a variable is used correctly and consistently throughout a particular scope is known not to be context-free (the proof is complex and relies on Ogden's lemma).

What is context-free grammar with example?

A context free grammar (CFG) is a forma grammar which is used to generate all the possible patterns of strings in a given formal language. G is a grammar, which consists of a set of production rules. It is used to generate the strings of a language. T is the final set of terminal symbols.

Which machine is used for CFG?

State Machines and Automata: Building a RegExp Machine.


2 Answers

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

like image 52
VonC Avatar answered Nov 14 '22 21:11

VonC


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

like image 36
Fergal Avatar answered Nov 14 '22 21:11

Fergal