xrel.analyzer
Class BinaryTree

java.lang.Object
  |
  +--xrel.analyzer.BinaryTree
All Implemented Interfaces:
XRelParserTreeConstants

public class BinaryTree
extends java.lang.Object
implements XRelParserTreeConstants

Transformes a generic syntax tree in a binary tree.

To do this it simply processes the lists of children of the tags Comma and Par. For example Comma[a[],b[],c[]] becomes Comma[a[],Comma[b[],c[]]].

N.B.: this is a static class so you will never need to allocate an object for this class.

Author:
Fabrizio Bisi

Fields inherited from interface xrel.parser.XRelParserTreeConstants
JJTAS, JJTCASE, JJTCOMMA, JJTEMPTY, JJTEXPORTTP, JJTIDENTIFIER, JJTIMPORTST, jjtNodeName, JJTOPERATOR, JJTPAR, JJTPROGRAM, JJTSTATEMENTLIST, JJTSTRING, JJTSTRINGLITERAL, JJTSWITCHCASE, JJTTAG, JJTTYPEDECL, JJTVOID
 
Constructor Summary
BinaryTree()
           
 
Method Summary
static void convert(SimpleNode node)
          The entry point of the class.
static void removeGroundTypes(SimpleNode node)
          Replaces ground types (String and literal strings) with pseudo-labels.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BinaryTree

public BinaryTree()
Method Detail

convert

public static void convert(SimpleNode node)

The entry point of the class. It converts from a syntax a-rity tree to a binary tree. See the class description for additional information.

Warning! don't execute it on a null pointer

Parameters:
node - the root node of the subtree

removeGroundTypes

public static void removeGroundTypes(SimpleNode node)

Replaces ground types (String and literal strings) with pseudo-labels.

The name chosen are __String__[] for String and __".."__ for string literals. Note that initial underscore grants that it's impossibile to have name conflicts with normal labels, as labels need to be identifiers.

Parameters:
node - the root node of an expression