java -jar jburg.jar [options] specificationFile
Commonly used options
-g
: generate debugging code-outputdir
: emit the BURM in the specified directory-inputdir
: read the specification from the specified directory-outputfile
: emit the BURM into the specified fileJBurg integrates well into ant
builds via a jburg macrodef.
Optional. Specifies the generated code's implementation language. Default is Java.
@Language Cpp;
Optional, Java-only. Specifies a package for the BURM.
@Package jburg.tutorial.first;
Optional. Specifies a base class for the BURM.
@Extends BaseBURM; // Optional
Optional. Copies the contents of its block into the header of the generated class.
// C++ header @Header { #include "support.h" } // Java header @Header { import java.util.Map; }
Required. Specifies the type of the input tree nodes.
@INodeType CommonTree; // Use ANTLR AST nodes as the i-node type
Optional, may be specified multiple times.
Specifies that nodes matching a particular pattern are of the designated type. The code emitters implement this via a C-style cast.
@NodeType INT = burmTest.LiteralIntNode;
Optional. Use the specified class to emit logic to query the input tree.
See also working with I-nodes in JBurg2.
@INodeAdapter jburg.burg.inode.Antlr3JavaAdapter;
Optional. Use the three logic snippets given to query the input tree.
@GetINodeOperator(x) { return x->getIRElementType(); } @GetINodeCount(x) { return x->getIRElementChildCount(); } @GetINodeChild(x,index) { return x->getIRElementChild(index); }
Optional. By default, the first 'labeling' pass builds an annotation tree that uses a distinct annotation object for each i-node in the input; but if the i-nodes have a way to store and retrieve the annotations, they can in many instances be shared.
@SetAnnotation(p, SemanticAnnotation* anno) { p->setAnnotation(anno); } @GetAnnotation(p) { return (JBurgAnnotation<IRRef>*)p->getAnnotation(); }
Optional, default is 'int' on most targets. Specifies the type of the opcodes, which may be the target platform's enumeration type, e.g., enum.
@OpcodeType ASTNodeID;
Optional. By default, JBurg builds a set of integer constants to code nonterminal types; this directive specifies an enumeration that supplies nonterminal types.
@NonterminalType burmTest.NonterminalTypes;
Optional. By default, a call to reduce() on a tree with no cover for the desired nonterminal state will throw an exception; this directive specifies error handling logic.
Note that it's still usually necessary to throw an exception, since there's no restart logic in the BURM; but if the error handler can in some way modify the tree to allow a subsequent analysis to succeed, the caller could catch the exception and restart the labeling pass.
@DefaultErrorHandler { // p refers to the annotation object at // the root of the unreducible subtree. new UnknownTreeHandler().analyze(p); }
See the debugging section for details.
Optional. Specifies cost functions whose results should not be cached.
@VolatileCostFunctions volatileCost1, volatileCost2;
Optional, may be specified more than once. Defines a manifest constant for the BURG; this helps the BURG do more dynamic programming at compiler-compile time, i.e., free money.
@Constant ERROR_TRAP = 268435456;
Optional, may be specified more than once. The code in the block is copied into the generated BURM.
@Members { // Target and implementation specific code }
@Include "../arithmetic/IntegerArithmetic.jbg"
@include "IntegerArithmetic.jbg" SUBSTITUTE_ADD="ADD" SUBSTITUTE_INT="INT(void)" { "#int#"="intValue()" }
nonterminal = NODE_TYPE(subtreeNonterminal subtreeName, subtreeNonterminalPrime subtreeNamePrime): cost
nonterminal = NODE_TYPE(void): cost
nonterminal = NODE_TYPE(subtreeNonterminal subtreeName*): cost
{reduction action}
or
nonterminal = NODE_TYPE(subtreeNonterminal subtreeName+): cost
{reduction action}
nonterminal = NODE_TYPE(subtreeNonterminal subtreeName subtreeVariadicNonterminal subtreeName*): cost
{reduction action}
nonterminalPrime = originalNonterminal;
nonterminalPrime = originalNonterminal: cost {reduction action};
nonterminalName = NODE_TYPE(subtreeType subtree): cost { return actionForNodeType(#nonterminalName, subtree); }
intExpression = ADD(intExpression lhs, intExpression rhs): cost JBurg.Reduction reducer.emitIntegerAdd(lhs, rhs);
objExpression = FUNCTION(functionHeader header, functionBody body): cost Prologue reducer.setUpFunctionExpression(p) JBurg.Reduction reducer.emitFunctionExpression(__p, header, body);
nonterminal = NODE_TYPE(void): 4 { reduction action; }
nonterminal = NODE_TYPE(void): ManifestConstant { reduction action; }
nonterminal = NODE_TYPE(void): computedCost(getNode()) { reduction action; }
Wiki: CommandLineOptions
Wiki: CostExpressionsGuide
Wiki: Debugging
Wiki: JBurgIncludeGuide
Wiki: PatternRuleGuide
Wiki: ReductionActionsGuide
Wiki: TransformationRuleGuide
Wiki: antbuild