Integrating the generated BURM into your compiler
jburg.JBurgMain to generate the corresponding 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>
getOperator()
leftChild()
rightChild()
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 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.
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:
For example, suppose the BURM is trying to reduce a + 1
and it has the following rules:
int_value = PLUS(int_value, int_value): 1 { ... }
int_value = INTEGER_LITERAL(void): 1 { ... }
obj_value = IDENTIFIER(void) : 5 { ... }
The solution is to add a rule that allows the BURM to transform an object into an int:
int_value = obj_value: 5
{
// Call Integer.parseInt(obj.toString)), or something similar.
}
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.
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.
JBurg's build is ant-based. The ant targets are:
buildall
Builds or rebuilds JBurg, TL/2, mjava, and runs quick tests.
jarfile
compiles JBurg's Java files and builds jburg.jar
parser rebuilds the parser.
This target is rarely used.
The files that make up JBurg are:
main() method, in grammars/jburg.g.
Java files generated by ANTLR are:
JBurgGenerator.java contains the code that creates the actual BURM.
TODO:Move the static inner classes into separate Java files.