Programming Tutorials Browser Tutorials Articles Struts Tutorials Hibernate Tutorials

  Tutorial: From Writing Programs to Creating Compilers

From Writing Programs to Creating Compilers In this article we build a simple compiler that augments Java with tasks (independent blocks of code that execute in parallel), thus creating a new language called AJ that well supports the programming of syste

Tutorial Details:

A Readymade Grammar for Java
VisualLangLab is a freely downloadable (GPL) java.net project. To install it, just unzip the distribution file (VisualLangLab.zip) into a directory. The visual parser generator (see Figure 1) is started by clicking on VisualLangLab.jar. The only other thing to keep in mind is that VisualLangLab.jar must be on the classpath when compiling or executing the generated parser.
The heart of any compiler project is the grammar--a typically cryptic piece of text that serves as a specification for the language. Since we wish to augment the capabilities of an existing language (Java), it is simpler to start with an existing grammar for the base language. The starting point for this exercise will therefore be a Java 1.4 grammar included in the VisualLangLab distribution (the file java14C.lkv). Well-written grammars, like well-written programs, are divided into smaller units called rules. A few sample rules from the Java 1.4 grammar (as displayed by the VisualLangLab GUI) are shown in Figure 2 (IfStatement), Figure 3 (SwitchStatement) and Figure 4 (UnaryExpression).


 

Read Tutorial at: Click here to view the tutorial

Rate Tutorial:
From Writing Programs to Creating Compilers

View Tutorial:
From Writing Programs to Creating Compilers

Related Tutorials:

Accelerate your Java apps! - JavaWorld - September 1998
Accelerate your Java apps! - JavaWorld - September 1998
 
Java Tip 70: Create objects from jar files! - JavaWorld - March 1999
Java Tip 70: Create objects from jar files! - JavaWorld - March 1999
 
Understanding Java Card 2.0 - JavaWorld March 1998
Understanding Java Card 2.0 - JavaWorld March 1998
 
Smart object-management saves the day - JavaWorld November 1999
Smart object-management saves the day - JavaWorld November 1999
 
Java Tip 84: Customize scoping with object keys - JavaWorld
Java Tip 84: Customize scoping with object keys - JavaWorld
 
One, two, three, or n tiers? - JavaWorld January 2000
One, two, three, or n tiers? - JavaWorld January 2000
 
Mapping XML to Java, Part 1 - JavaWorld August 2000
Mapping XML to Java, Part 1 - JavaWorld August 2000
 
Activatable Jini services, Part 2: Patterns of use - JavaWorld October 2000
Activatable Jini services, Part 2: Patterns of use - JavaWorld October 2000
 
Build your own languages with JavaCC - JavaWorld December 2000
Build your own languages with JavaCC - JavaWorld December 2000
 
Double-checked locking: Clever, but broken - JavaWorld February 2001
Double-checked locking: Clever, but broken - JavaWorld February 2001
 
Can double-checked locking be fixed? - JavaWorld May 2001
Can double-checked locking be fixed? - JavaWorld May 2001
 
Achieve strong performance with threads, Part 1
Achieve strong performance with threads, Part 1
 
Test networked code the easy way
Test networked code the easy way
 
Using Java Classes in Windows Batch Files
Using Java Classes in Windows Batch Files - a simple approach for system admin Although Java is an ideal language for implementing rich GUI applications, it is equally well-suited for the development of small console-based programs that, in turn, are p
 
Writing Ant Tasks
Writing Ant Tasks A nice feature of Ant is that it is designed to allow you to add your own tasks and use them in an build. This article shows you the basics of writing an Ant task and how to get a task to work.
 
Software Download Central compatible.
GNU getopt - Java port A while back I found myself in need of a Java command line option parser. Unsatisfied with free versions I was able to find on the net, I volunteered to port the GNU getopt family of functions from C to Java. The current release
 
Creating Varargs in Java 1.5 Tiger
Creating Varargs in Java 1.5 Tiger In this excerpt from Chapter 5 of the book, Brett and David cover how to create and iterate over variable-length argument lists (better known as varargs), which will have you writing better, cleaner, more flexible code
 
From Writing Programs to Creating Compilers
From Writing Programs to Creating Compilers In this article we build a simple compiler that augments Java with tasks (independent blocks of code that execute in parallel), thus creating a new language called AJ that well supports the programming of syste
 
Introduction to the JSP Java Server Pages
Introduction to the JSP Java Server Pages Welcome to JSP Section Introduction To JSP Java Server Pages or JSP for short is Sun's solution for developing dynamic web sites. JSP provide excellent server side scripting support for creating database
 
New Technical Articles: 64-bit Programming on Solaris 10 OS for x86 Platforms
Four technical articles describe the new Sun Studio 10 software's 64-bit programming features on the Solaris 10 OS for x86 and AMD64 platforms. Important issues regarding the AMD64 ABI (Application Binary Interface), debugging, migration to 64-bits, and p
 
Site navigation
 

 

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2006. All rights reserved.