Are there any simple languages ​​implemented using ANTLR or similar?

I am trying to create a simple interpreted language for learning. I read countless theory and tutorials on ANTLR and JavaCC, but I can't figure out how to actually get her to do something useful.

I’d best learn how to “take away something separately and combine again”, so are there any working examples of simple languages ​​implemented with tools like ANTLR or the like?

It might seem something like the following:

x = 1 if x == 1 print "true" 
+6
java interpreter antlr
source share
5 answers

[shameless plugin] Why not buy my Language Implementation Templates ? I have everything you need to put together a language, including several translators, etc.

+13
source share

You may find many small languages ​​on Google Code and Github.

Here is the toy language I made at ANTLR as a cool project a few years ago: http://code.google.com/p/bcis/

+4
source share

Scott "JavaDude" The Stanchfield ANTLR3 video series is pretty good.

And of course there's StackOverflow that has tons of ANTLR content. For example:

ANTLR: Is there a simple example?

+3
source share

Note: you can use a different approach and check the XText to generate all the code for you.

In the XText documentation:

Unlike conventional parser generators (like JavaCC or ANTLR), Xtext gets much more than just an analyzer and a lexical analyzer (lexer) from the input grammar. Grammar language is used to describe and generate:

  • ANTLR 3 incremental analyzer and lexer to read your models from text,
  • Ecore models (optional),
  • serializer to return your models to text,
  • linker to cross-reference between model elements,
  • implementation of the EMF resource interface with full support for loading and saving EMF models and
  • Integrating the language into your Eclipse development environment.

After creating all the parts, you can analyze them (and test) as you want.

alt text http://www.eclipse.org/Xtext/documentation/0_7_2/images/getting-started-editor.png

+2
source share

Why don't you define a grammar for a really simple language that matches your example and tries to implement it? Use ANTLR to create a parse tree, and then figure out how to “rate” the tree. To get started, don't worry about declarations or data types (each value is an integer) and support 3 types of operators: assignment, if and print .

0
source share

All Articles