org.jactr.io.antlr3.misc
Class ASTSupport

java.lang.Object
  extended by org.jactr.io.antlr3.misc.ASTSupport

public class ASTSupport
extends java.lang.Object

create the tree components used to describe various elements of the model Tree modelTree = support.createModelTree(); support.setName(modelTree,"modelName"); support.addParameter(modelTree, parameterName, parameterValueString); Tree chunkType = support.createChunkTypeTree(); support.setName(chunkType,"chunkTypeName"); modelTree.getFirstChildWithType(JACTRBuilder.DECLARATIVE_MEMORY).addChild(chunkType);

Author:
developer

Field Summary
static org.apache.commons.logging.Log LOGGER
          logger definition
 
Constructor Summary
ASTSupport()
           
 
Method Summary
static void addChunkType(org.antlr.runtime.tree.CommonTree modelTree, org.antlr.runtime.tree.CommonTree chunkTypeTree)
           
static void addProduction(org.antlr.runtime.tree.CommonTree modelTree, org.antlr.runtime.tree.CommonTree productionTree)
           
 void addSlot(org.antlr.runtime.tree.CommonTree tree, java.lang.String slotName, org.antlr.runtime.tree.CommonTree content)
           
 void addSlot(org.antlr.runtime.tree.CommonTree tree, java.lang.String slotName, int condition, org.antlr.runtime.tree.CommonTree content)
          create a slot and add it to the slots node
 org.antlr.runtime.tree.CommonTree create(int type)
           
 org.antlr.runtime.tree.CommonTree create(int type, java.lang.String text)
          create a node with type and teext
 org.antlr.runtime.tree.CommonTree createAddTree(java.lang.String bufferName, org.antlr.runtime.tree.CommonTree content)
           
 org.antlr.runtime.tree.CommonTree createBufferTree(java.lang.String bufferName)
          ^(BUFFER NAME CHUNKS PARAMETERS)
 org.antlr.runtime.tree.CommonTree createChunkTree(java.lang.String chunkName, java.lang.String chunkTypeName)
          ^(CHUNK NAME PARENT SLOTS PARAMETERS)
 org.antlr.runtime.tree.CommonTree createChunkTypeTree(java.lang.String chunkTypeName, java.lang.String parentChunkTypeName)
          ^(CHUNK_TYTPE NAME (PARENT)? SLOTS CHUNKS PARAMETERS)
 org.antlr.runtime.tree.CommonTree createExtensionTree(java.lang.String className)
           
 org.antlr.runtime.tree.CommonTree createMatchTree(java.lang.String bufferName, org.antlr.runtime.tree.CommonTree content)
          Creates a tree describing a pattern match condition this tree must have either ientifier or a variable supplied ^(MATCH_CONDITON NAME (IDENTIFIER|VARIBALE) SLOTS)
 org.antlr.runtime.tree.CommonTree createModelTree(java.lang.String modelName)
          construct an empty tree that describes a model ^(MODEL NAME BUFFERS LIBRARY PARAMETERS)
 org.antlr.runtime.tree.CommonTree createModifyTree(java.lang.String bufferName)
          ^(MODIFY_ACTION NAME SLOTS)
 org.antlr.runtime.tree.CommonTree createModuleTree(java.lang.String className)
           
 org.antlr.runtime.tree.CommonTree createOutputAction(java.lang.String output)
           
 org.antlr.runtime.tree.CommonTree createParameter(java.lang.String parameterName, java.lang.String parameterValue)
          add a parameter node to the parameters child of this tree
 org.antlr.runtime.tree.CommonTree createParametersTree()
           
 org.antlr.runtime.tree.CommonTree createProductionTree(java.lang.String productionName)
          ^(PRODUCTION NAME CONDITIONS ACTIONS PARAMETERS)
 org.antlr.runtime.tree.CommonTree createProxyActionTree(java.lang.String className)
           
 org.antlr.runtime.tree.CommonTree createProxyConditionTree(java.lang.String className)
           
 org.antlr.runtime.tree.CommonTree createQueryTree(java.lang.String bufferName)
          ^(QUERY NAME SLOTS)
 org.antlr.runtime.tree.CommonTree createRemoveTree(java.lang.String bufferName, org.antlr.runtime.tree.CommonTree content)
           
 org.antlr.runtime.tree.CommonTree createScriptableActionTree(java.lang.String language, java.lang.String script)
           
 org.antlr.runtime.tree.CommonTree createScriptableConditionTree(java.lang.String language, java.lang.String script)
           
 org.antlr.runtime.tree.CommonTree createSlot(java.lang.String slotName)
           
 org.antlr.runtime.tree.CommonTree createSlot(java.lang.String slotName, org.antlr.runtime.tree.CommonTree content)
           
 org.antlr.runtime.tree.CommonTree createSlot(java.lang.String slotName, org.antlr.runtime.tree.CommonTree condition, org.antlr.runtime.tree.CommonTree content)
           
 org.antlr.runtime.tree.CommonTree createSlotsTree()
           
 org.antlr.runtime.tree.CommonTree createTree(int type, java.lang.String text)
           
static java.util.Collection<org.antlr.runtime.tree.CommonTree> getAllDescendantsWithType(org.antlr.runtime.tree.CommonTree root, int type)
           
static org.antlr.runtime.tree.CommonTree getFirstDescendantWithType(org.antlr.runtime.tree.CommonTree root, int type)
           
static java.util.Map<java.lang.String,org.antlr.runtime.tree.CommonTree> getMapOfTrees(org.antlr.runtime.tree.CommonTree root, int treeType)
           
static java.lang.String getName(org.antlr.runtime.tree.CommonTree node)
           
static java.util.Collection<org.antlr.runtime.tree.CommonTree> getTrees(org.antlr.runtime.tree.CommonTree root, int treeType)
           
 org.antlr.runtime.tree.CommonTree identifier(java.lang.Object obj)
          return an IDENTIFIER wrapping the object
 org.antlr.runtime.tree.CommonTree number(java.lang.Number num)
          return a NUMBER wrapping this one ^(NUMBER)
static java.lang.String outputTree(org.antlr.runtime.tree.Tree tree)
           
static java.lang.String outputTree(org.antlr.runtime.tree.Tree tree, int level)
           
 void setName(org.antlr.runtime.tree.CommonTree tree, java.lang.String name)
          set the name node of this tree element
 void setParameter(org.antlr.runtime.tree.CommonTree tree, java.lang.String parameterName, java.lang.String parameterValue, boolean overwrite)
           
static void setParameters(org.antlr.runtime.tree.CommonTree srcParametersContainer, org.antlr.runtime.tree.CommonTree destParametersContainer)
          copy the parameter nodes from src to dest, overwriting those that already exist
 void setParameters(org.jactr.core.utils.parameter.IParameterized parameterized, org.antlr.runtime.tree.CommonTree parameterizedContainer)
           
static void stealLocation(org.antlr.runtime.tree.CommonTree source, org.antlr.runtime.tree.CommonTree dest)
          steal the location information
 org.antlr.runtime.tree.CommonTree string(java.lang.Object obj)
          return a STRING wrapping the object
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOGGER

public static final org.apache.commons.logging.Log LOGGER
logger definition

Constructor Detail

ASTSupport

public ASTSupport()
Method Detail

createModelTree

public org.antlr.runtime.tree.CommonTree createModelTree(java.lang.String modelName)
construct an empty tree that describes a model ^(MODEL NAME BUFFERS LIBRARY PARAMETERS)

Returns:

createExtensionTree

public org.antlr.runtime.tree.CommonTree createExtensionTree(java.lang.String className)

createModuleTree

public org.antlr.runtime.tree.CommonTree createModuleTree(java.lang.String className)

createBufferTree

public org.antlr.runtime.tree.CommonTree createBufferTree(java.lang.String bufferName)
^(BUFFER NAME CHUNKS PARAMETERS)

Returns:

createChunkTypeTree

public org.antlr.runtime.tree.CommonTree createChunkTypeTree(java.lang.String chunkTypeName,
                                                             java.lang.String parentChunkTypeName)
^(CHUNK_TYTPE NAME (PARENT)? SLOTS CHUNKS PARAMETERS)

Returns:

createChunkTree

public org.antlr.runtime.tree.CommonTree createChunkTree(java.lang.String chunkName,
                                                         java.lang.String chunkTypeName)
^(CHUNK NAME PARENT SLOTS PARAMETERS)

Returns:

createProductionTree

public org.antlr.runtime.tree.CommonTree createProductionTree(java.lang.String productionName)
^(PRODUCTION NAME CONDITIONS ACTIONS PARAMETERS)

Returns:

createMatchTree

public org.antlr.runtime.tree.CommonTree createMatchTree(java.lang.String bufferName,
                                                         org.antlr.runtime.tree.CommonTree content)
Creates a tree describing a pattern match condition this tree must have either ientifier or a variable supplied ^(MATCH_CONDITON NAME (IDENTIFIER|VARIBALE) SLOTS)

Returns:
Throws:
illegal - arugment if content is null or not IDENTIFIER or VARIABLE

createQueryTree

public org.antlr.runtime.tree.CommonTree createQueryTree(java.lang.String bufferName)
^(QUERY NAME SLOTS)

Returns:

createScriptableConditionTree

public org.antlr.runtime.tree.CommonTree createScriptableConditionTree(java.lang.String language,
                                                                       java.lang.String script)

createProxyConditionTree

public org.antlr.runtime.tree.CommonTree createProxyConditionTree(java.lang.String className)

createAddTree

public org.antlr.runtime.tree.CommonTree createAddTree(java.lang.String bufferName,
                                                       org.antlr.runtime.tree.CommonTree content)
Parameters:
bufferName -
content - must not be null
Returns:
Throws:
illegal - argument exception if content is null

createRemoveTree

public org.antlr.runtime.tree.CommonTree createRemoveTree(java.lang.String bufferName,
                                                          org.antlr.runtime.tree.CommonTree content)
Parameters:
bufferName -
content - can be null
Returns:

createModifyTree

public org.antlr.runtime.tree.CommonTree createModifyTree(java.lang.String bufferName)
^(MODIFY_ACTION NAME SLOTS)

Returns:

createScriptableActionTree

public org.antlr.runtime.tree.CommonTree createScriptableActionTree(java.lang.String language,
                                                                    java.lang.String script)

createProxyActionTree

public org.antlr.runtime.tree.CommonTree createProxyActionTree(java.lang.String className)

createOutputAction

public org.antlr.runtime.tree.CommonTree createOutputAction(java.lang.String output)

create

public org.antlr.runtime.tree.CommonTree create(int type,
                                                java.lang.String text)
create a node with type and teext

Parameters:
type -
text -
Returns:

create

public org.antlr.runtime.tree.CommonTree create(int type)

createTree

public org.antlr.runtime.tree.CommonTree createTree(int type,
                                                    java.lang.String text)

identifier

public org.antlr.runtime.tree.CommonTree identifier(java.lang.Object obj)
return an IDENTIFIER wrapping the object

Parameters:
obj -
Returns:

string

public org.antlr.runtime.tree.CommonTree string(java.lang.Object obj)
return a STRING wrapping the object

Parameters:
obj -
Returns:

number

public org.antlr.runtime.tree.CommonTree number(java.lang.Number num)
return a NUMBER wrapping this one ^(NUMBER)

Parameters:
num -
Returns:

createParametersTree

public org.antlr.runtime.tree.CommonTree createParametersTree()

createSlotsTree

public org.antlr.runtime.tree.CommonTree createSlotsTree()

createSlot

public org.antlr.runtime.tree.CommonTree createSlot(java.lang.String slotName,
                                                    org.antlr.runtime.tree.CommonTree condition,
                                                    org.antlr.runtime.tree.CommonTree content)

createSlot

public org.antlr.runtime.tree.CommonTree createSlot(java.lang.String slotName,
                                                    org.antlr.runtime.tree.CommonTree content)

createSlot

public org.antlr.runtime.tree.CommonTree createSlot(java.lang.String slotName)

setName

public void setName(org.antlr.runtime.tree.CommonTree tree,
                    java.lang.String name)
set the name node of this tree element

Parameters:
tree -
name -
Throws:
illegalargumentexception - if tree doesn't have a name node

createParameter

public org.antlr.runtime.tree.CommonTree createParameter(java.lang.String parameterName,
                                                         java.lang.String parameterValue)
add a parameter node to the parameters child of this tree

Parameters:
tree -
parameterName -
parameterValue -
Throws:
illegalarugmentexception - if tree does not have a PARAMETERS node

addSlot

public void addSlot(org.antlr.runtime.tree.CommonTree tree,
                    java.lang.String slotName,
                    int condition,
                    org.antlr.runtime.tree.CommonTree content)
create a slot and add it to the slots node

Parameters:
tree -
slotName -
condition -
content -

addSlot

public void addSlot(org.antlr.runtime.tree.CommonTree tree,
                    java.lang.String slotName,
                    org.antlr.runtime.tree.CommonTree content)

setParameters

public void setParameters(org.jactr.core.utils.parameter.IParameterized parameterized,
                          org.antlr.runtime.tree.CommonTree parameterizedContainer)

setParameters

public static void setParameters(org.antlr.runtime.tree.CommonTree srcParametersContainer,
                                 org.antlr.runtime.tree.CommonTree destParametersContainer)
copy the parameter nodes from src to dest, overwriting those that already exist

Parameters:
srcParametersContainer -
destParametersContainer -

getName

public static java.lang.String getName(org.antlr.runtime.tree.CommonTree node)

getFirstDescendantWithType

public static org.antlr.runtime.tree.CommonTree getFirstDescendantWithType(org.antlr.runtime.tree.CommonTree root,
                                                                           int type)

getAllDescendantsWithType

public static java.util.Collection<org.antlr.runtime.tree.CommonTree> getAllDescendantsWithType(org.antlr.runtime.tree.CommonTree root,
                                                                                                int type)

getMapOfTrees

public static java.util.Map<java.lang.String,org.antlr.runtime.tree.CommonTree> getMapOfTrees(org.antlr.runtime.tree.CommonTree root,
                                                                                              int treeType)

getTrees

public static java.util.Collection<org.antlr.runtime.tree.CommonTree> getTrees(org.antlr.runtime.tree.CommonTree root,
                                                                               int treeType)

setParameter

public void setParameter(org.antlr.runtime.tree.CommonTree tree,
                         java.lang.String parameterName,
                         java.lang.String parameterValue,
                         boolean overwrite)
Parameters:
tree -
parameterName -
parameterValue -
overwrite - should we overwrite parameters if they already exist?

addChunkType

public static void addChunkType(org.antlr.runtime.tree.CommonTree modelTree,
                                org.antlr.runtime.tree.CommonTree chunkTypeTree)

addProduction

public static void addProduction(org.antlr.runtime.tree.CommonTree modelTree,
                                 org.antlr.runtime.tree.CommonTree productionTree)

outputTree

public static java.lang.String outputTree(org.antlr.runtime.tree.Tree tree)

outputTree

public static java.lang.String outputTree(org.antlr.runtime.tree.Tree tree,
                                          int level)

stealLocation

public static void stealLocation(org.antlr.runtime.tree.CommonTree source,
                                 org.antlr.runtime.tree.CommonTree dest)
steal the location information

Parameters:
source -
dest -