com.joanju.cg.util
Class CgAntlrUtil

java.lang.Object
  extended by com.joanju.cg.util.CgAntlrUtil

public class CgAntlrUtil
extends java.lang.Object

Utilities for working with Antlr and ASTs.


Constructor Summary
CgAntlrUtil()
           
 
Method Summary
static java.lang.Object[] match(AST ast, java.lang.Object[] objarray)
          Match an AST to a (possibly nested) array of integer node types.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CgAntlrUtil

public CgAntlrUtil()
Method Detail

match

public static java.lang.Object[] match(AST ast,
                                       java.lang.Object[] objarray)
Match an AST to a (possibly nested) array of integer node types.

Matches AST node types to the integer values in the input Object[]. The first integer value in the Object[] is expected to match the head node of an AST branch. Multiple Object[] may be nested, to describe the shape of the AST to be matched.

The input Object[] may describe just the beginning portion of the AST. The Object[] is not expected to describe the entire AST in order to match.

Parameters:
ast - Parent node of the AST branch to match.
objarray - Possibly nested Object[] of integer node types. Zero may be used like "." in Antlr - match any token/node type.
Returns:
An Object[] matching the shape of the input Object[], but with AST node references rather than integer node types. Null if the AST does not match the input Object[].


Copyright © 2008 Joanju Software. All Rights Reserved.