JBurg Users' Guide

Installing JBurg

Generating a BURM with JBurg

Integrating the generated BURM into your compiler

Debugging the BURM

Unable to find a rule to process x(22){-1}

Notes on modifying JBurg

Rebuilding JBurg



Installing JBurg

The compiled distribution of jburg is in the distribution's bin/jburg.jar file. The jarfile is only necessary to generate the BURM.

Generating a BURM with JBurg

First
code a JBurg specification, then invoke jburg.JBurgMain to generate the corresponding BURM.

Required parameters

Optional parameters

Example ANT task that generates a BURM

	<target name="reducer">
		<java classname="jburg.JBurgMain" failonerror="yes" fork="yes" dir="reducer">
			<arg value="tl1.jburg"/>
			<arg value="TL1Reducer.java"/>
			<!-- <arg value="-g"/> -->
			<classpath>
				<pathelement location="${jburgHome}"/>
				<pathelement location="${ANTLRHome}"/>
			</classpath>
		</java>
	</target>

Integrating the generated BURM into your compiler

Required data structures

JBurg's generated BURMs work on a binary tree generated by other passes of the compiler. The object class that represents a tree node (the "INode class") must provide the following methods:

Setting properties in the generated BURM

Use the BURMProperty JBurg specification directive to include a property in your generated BURM. For example, to include a BCEL ClassGen object as the property classGen:

BURMProperty org.apache.bcel.generic.ClassGen classGen;

JBurg will include a field of the specified type and get/set methods.


Debugging your generated BURM

Debugging a BURM is not too different from debugging any other Java code. The theory page will help you understand the structure and control flow of the BURM.

Usual BURM failure modes

Unable to find a rule to process x(22){-1}

The BURM throws this exception if it cannot find any rule to match a particular node. The elements of the diagnostic line are:

The most common causes of this exception are:

BURM debug option output

Your BURM will emit XML-formatted debugging information if you generate it with the JBurg -g command-line switch.

Debugging output is written to the current working directory, into a file named reducerName_jburg.xml.

For example, if your reducer is named MyReducer, debugging output will be written to MyReducer_jburg.xml

Recent versions of InternetExplorer and Netscape render XML files in a convenient tree display.

Debug Information

The debugging information has two main parts: the labelling pass dumps all the nodes' possible states, and the reducer emits a trace as it works.


Notes on modifying JBurg

Rebuilding JBurg

JBurg's build is ant-based. The ant targets are:

The files that make up JBurg are: