story.dbcore.grammars
Class SCTools

java.lang.Object
  extended by story.dbcore.grammars.SCTools

public class SCTools
extends java.lang.Object

Back-end functions for the command grammar.


Constructor Summary
SCTools()
           
 
Method Summary
static ReturnValue argument_expression(DBCoreInterface dbci, SymbolTable symbols, ReturnValue subvalue, ArgumentVector args)
          Handle the argument (non) operator, i.e., when an expression is followed by arguments.
static ReturnValue assignment_expression(DBCoreInterface dbci, SymbolTable symbols, ReturnValue lvalue, ReturnValue rvalue)
          Handle an assignment operator when it is followed by an expression
static ReturnValue assignment_new_document(DBCoreInterface dbci, SymbolTable symbols, ReturnValue lvalue, ArgumentVector new_args)
          Handle an assignment operator followed by "new document"
static ReturnValue assignment_new_expression(DBCoreInterface dbci, SymbolTable symbols, ReturnValue lvalue, ReturnValue newrvalue)
          Handle an assignment operator followed by a "new" and then an identifier
static ReturnValue assignment_new_repository(DBCoreInterface dbci, SymbolTable symbols, ReturnValue lvalue, ArgumentVector new_args)
          Handle an assignment operator followed by "new repository" and some arguments
static ReturnValue atomicID(DBCoreInterface dbci, SymbolTable symbols, java.lang.String id)
          Handle an atomic identifier
static ReturnValue colon(DBCoreInterface dbci, ReturnValue lvalue, ReturnValue rvalue)
          Handle the colon operator.
static ReturnValue dot(DBCoreInterface dbci, SymbolTable symbols, ReturnValue lvalue, ReturnValue rvalue, boolean singleDot)
          Handle the dot operator
static ReturnValue equality(DBCoreInterface dbci, SymbolTable symbols, ReturnValue lvalue, ReturnValue rvalue, boolean allow_indirect)
          Handle the equality operator.
static java.lang.StringBuffer examine(DBCoreInterface dbci, SymbolTable symbols, ReturnValue returnVal)
          Examine an identifier in detail (i.e., call its render function) and return the StringBuffer
static ReturnValue expression(DBCoreInterface dbci, SymbolTable symbols, ReturnValue returnValue)
          Handle a completed expression.
static ReturnValue idTuple(DBCoreInterface dbci, SymbolTable symbols, java.lang.String left, java.lang.String right)
          Handle a tuple of atomic identifiers
static ReturnValue link(DBCoreInterface dbci, ReturnValue lvalue, ReturnValue rvalue, boolean overrideInference)
          Handle the link operator, which is used to query for all direct links to or from a node (NOT to assign a link or test for a particular relationship, which are handled by = and ==/=~ respectively).
static void linkLabel(DBCoreInterface dbci, SymbolTable symbols, LinkLabel label, java.lang.String className, java.lang.String attributeName, java.lang.String attributeValue)
          Handle a LinkLabel (inside some pipes ||).
static java.lang.Object parameter_arg_dot_comparison(DBCoreInterface dbci, VariableID outreference, ReturnValue lvalue, ReturnValue mvalue, ReturnValue rvalue, boolean testGreaterThan, boolean singleDot)
          Handles an equality operator within a parameter argument when the lvalue had a dot parameter.
static java.lang.Object parameter_arg_dot(DBCoreInterface dbci, VariableID outreference, ReturnValue lvalue, ReturnValue rvalue)
          Handles a dot operator for a parameter argument, e.g.,
static java.lang.Object parameter_arg_link_equals(DBCoreInterface dbci, VariableID outreference, ReturnValue lvalue, ReturnValue mvalue, ReturnValue rvalue, boolean overrideInference)
          Handle a three-term, two-operator expression within a parameter argument when the two expressions are a link operator and the == equality operator.
static Parameter parameter_arg_link(DBCoreInterface dbci, VariableID outreference, ReturnValue lvalue, ReturnValue mvalue, boolean overrideInference)
          Handle the link operator in a parameter argument.
static NodeAddress parameter_find_node(DBCoreInterface dbci, NodeID nodeID)
          Helper function for parameter() that finds a NodeAddress from a NodeID and throws an exception if it DNE.
static VariableID parameter_parse_reference(DBCoreInterface dbci, java.lang.String reference, SymbolTable symbols)
          Handles a reference specification within a parameter.
static java.lang.Object parameter_term(DBCoreInterface dbci, VariableID outreference, ReturnValue term)
          Handles a lone term within a paramete argument, no operators.
static Parameter parameter(DBCoreInterface dbci, VariableID outreference, ReturnValue paramType, ArgumentVector args)
          Handles a complete parameter, with type and arguments (e.g., node(arg))
static java.lang.Object parseID(java.lang.String id, SymbolTable symbols)
          Given a string identifier, determine what kind of identifier it is, and upgrade it to a more specific object if possible.
static java.lang.StringBuffer renderReturnValue(DBCoreInterface dbci, ReturnValue returnValue, SymbolTable symbols)
          Renders a return value to a StringBuffer, branching on type.
static ArgumentVector stripArgs(ArgumentVector in, SymbolTable symbols)
          Given an arguments vector, which is a Vector of ReturnValues, return a vector of values themselves, suitable for passing to DBCoreInterface (which doesn't know what a ReturnValue object is).
static boolean truth()
          Helper function that gets around peculiar ANTLR behavior by always returning true (but in a way that is not clear at compile time)
static ReturnValue unlink_expression(DBCoreInterface dbci, SymbolTable symbols, ReturnValue lvalue, ReturnValue rvalue)
          Handle the unlink operator when it is followed by an expression
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SCTools

public SCTools()
Method Detail

parseID

public static java.lang.Object parseID(java.lang.String id,
                                       SymbolTable symbols)
                                throws Scheherexception
Given a string identifier, determine what kind of identifier it is, and upgrade it to a more specific object if possible.

Parameters:
id - String identifier.
Returns:
An object that is the most semantically specific object for the identifier. For example, it might be NodeID if the identifier was a properly punctuated node (i.e., [node]), or a CommandType object, if the identifier was one of the reserved command words. If no semantic distinction was found, the identifier is returned as a NonReservedID.
Throws:
Scheherexception

stripArgs

public static ArgumentVector stripArgs(ArgumentVector in,
                                       SymbolTable symbols)
                                throws Scheherexception
Given an arguments vector, which is a Vector of ReturnValues, return a vector of values themselves, suitable for passing to DBCoreInterface (which doesn't know what a ReturnValue object is). In other words, strips away the encapsulation of ReturnVector. However, if there is an associated argument to any value (i.e., an argument in an argument), this will throw an exception. Also dereferences variables from the symbol table. Note: this assumes that a variable NAME will never be a valid argument.

Throws:
Scheherexception

expression

public static ReturnValue expression(DBCoreInterface dbci,
                                     SymbolTable symbols,
                                     ReturnValue returnValue)
                              throws Scheherexception
Handle a completed expression.

Throws:
Scheherexception

assignment_expression

public static ReturnValue assignment_expression(DBCoreInterface dbci,
                                                SymbolTable symbols,
                                                ReturnValue lvalue,
                                                ReturnValue rvalue)
                                         throws Scheherexception
Handle an assignment operator when it is followed by an expression

Throws:
Scheherexception

assignment_new_expression

public static ReturnValue assignment_new_expression(DBCoreInterface dbci,
                                                    SymbolTable symbols,
                                                    ReturnValue lvalue,
                                                    ReturnValue newrvalue)
                                             throws Scheherexception
Handle an assignment operator followed by a "new" and then an identifier

Throws:
Scheherexception

assignment_new_repository

public static ReturnValue assignment_new_repository(DBCoreInterface dbci,
                                                    SymbolTable symbols,
                                                    ReturnValue lvalue,
                                                    ArgumentVector new_args)
                                             throws Scheherexception
Handle an assignment operator followed by "new repository" and some arguments

Throws:
Scheherexception

assignment_new_document

public static ReturnValue assignment_new_document(DBCoreInterface dbci,
                                                  SymbolTable symbols,
                                                  ReturnValue lvalue,
                                                  ArgumentVector new_args)
                                           throws Scheherexception
Handle an assignment operator followed by "new document"

Throws:
Scheherexception

unlink_expression

public static ReturnValue unlink_expression(DBCoreInterface dbci,
                                            SymbolTable symbols,
                                            ReturnValue lvalue,
                                            ReturnValue rvalue)
                                     throws Scheherexception
Handle the unlink operator when it is followed by an expression

Throws:
Scheherexception

dot

public static ReturnValue dot(DBCoreInterface dbci,
                              SymbolTable symbols,
                              ReturnValue lvalue,
                              ReturnValue rvalue,
                              boolean singleDot)
                       throws Scheherexception
Handle the dot operator

Throws:
Scheherexception

argument_expression

public static ReturnValue argument_expression(DBCoreInterface dbci,
                                              SymbolTable symbols,
                                              ReturnValue subvalue,
                                              ArgumentVector args)
                                       throws Scheherexception
Handle the argument (non) operator, i.e., when an expression is followed by arguments.

Throws:
Scheherexception

colon

public static ReturnValue colon(DBCoreInterface dbci,
                                ReturnValue lvalue,
                                ReturnValue rvalue)
                         throws Scheherexception
Handle the colon operator.

Throws:
Scheherexception

link

public static ReturnValue link(DBCoreInterface dbci,
                               ReturnValue lvalue,
                               ReturnValue rvalue,
                               boolean overrideInference)
                        throws Scheherexception
Handle the link operator, which is used to query for all direct links to or from a node (NOT to assign a link or test for a particular relationship, which are handled by = and ==/=~ respectively).

Throws:
Scheherexception

equality

public static ReturnValue equality(DBCoreInterface dbci,
                                   SymbolTable symbols,
                                   ReturnValue lvalue,
                                   ReturnValue rvalue,
                                   boolean allow_indirect)
                            throws Scheherexception
Handle the equality operator.

Throws:
Scheherexception

examine

public static java.lang.StringBuffer examine(DBCoreInterface dbci,
                                             SymbolTable symbols,
                                             ReturnValue returnVal)
                                      throws Scheherexception
Examine an identifier in detail (i.e., call its render function) and return the StringBuffer

Throws:
Scheherexception

idTuple

public static ReturnValue idTuple(DBCoreInterface dbci,
                                  SymbolTable symbols,
                                  java.lang.String left,
                                  java.lang.String right)
                           throws Scheherexception
Handle a tuple of atomic identifiers

Throws:
Scheherexception

atomicID

public static ReturnValue atomicID(DBCoreInterface dbci,
                                   SymbolTable symbols,
                                   java.lang.String id)
                            throws Scheherexception
Handle an atomic identifier

Throws:
Scheherexception

linkLabel

public static void linkLabel(DBCoreInterface dbci,
                             SymbolTable symbols,
                             LinkLabel label,
                             java.lang.String className,
                             java.lang.String attributeName,
                             java.lang.String attributeValue)
                      throws Scheherexception
Handle a LinkLabel (inside some pipes ||).

Throws:
Scheherexception

parameter_parse_reference

public static VariableID parameter_parse_reference(DBCoreInterface dbci,
                                                   java.lang.String reference,
                                                   SymbolTable symbols)
                                            throws Scheherexception
Handles a reference specification within a parameter.

Throws:
Scheherexception

parameter

public static Parameter parameter(DBCoreInterface dbci,
                                  VariableID outreference,
                                  ReturnValue paramType,
                                  ArgumentVector args)
                           throws Scheherexception
Handles a complete parameter, with type and arguments (e.g., node(arg))

Throws:
Scheherexception

parameter_find_node

public static NodeAddress parameter_find_node(DBCoreInterface dbci,
                                              NodeID nodeID)
                                       throws Scheherexception
Helper function for parameter() that finds a NodeAddress from a NodeID and throws an exception if it DNE.

Throws:
Scheherexception

parameter_arg_dot

public static java.lang.Object parameter_arg_dot(DBCoreInterface dbci,
                                                 VariableID outreference,
                                                 ReturnValue lvalue,
                                                 ReturnValue rvalue)
                                          throws Scheherexception
Handles a dot operator for a parameter argument, e.g.,

Throws:
Scheherexception

parameter_arg_dot_comparison

public static java.lang.Object parameter_arg_dot_comparison(DBCoreInterface dbci,
                                                            VariableID outreference,
                                                            ReturnValue lvalue,
                                                            ReturnValue mvalue,
                                                            ReturnValue rvalue,
                                                            boolean testGreaterThan,
                                                            boolean singleDot)
                                                     throws Scheherexception
Handles an equality operator within a parameter argument when the lvalue had a dot parameter. E.g., node.attribute == blah. Returns a Parameter.

Parameters:
testGreaterThan - True if we are parsing a > comparison between the attribute and the constant; false if we are parsing a ==.
singleDot - True if we parsed a single dot, e.g., node.attribute, indicating overriding attribute inheritance. False if we parse the indirect attribute operator .~.
Throws:
Scheherexception

parameter_arg_link_equals

public static java.lang.Object parameter_arg_link_equals(DBCoreInterface dbci,
                                                         VariableID outreference,
                                                         ReturnValue lvalue,
                                                         ReturnValue mvalue,
                                                         ReturnValue rvalue,
                                                         boolean overrideInference)
                                                  throws Scheherexception
Handle a three-term, two-operator expression within a parameter argument when the two expressions are a link operator and the == equality operator. Returns a Parameter.

Throws:
Scheherexception

parameter_arg_link

public static Parameter parameter_arg_link(DBCoreInterface dbci,
                                           VariableID outreference,
                                           ReturnValue lvalue,
                                           ReturnValue mvalue,
                                           boolean overrideInference)
                                    throws Scheherexception
Handle the link operator in a parameter argument. Returns a RelatedNodeParameter.

Throws:
Scheherexception

parameter_term

public static java.lang.Object parameter_term(DBCoreInterface dbci,
                                              VariableID outreference,
                                              ReturnValue term)
                                       throws Scheherexception
Handles a lone term within a paramete argument, no operators.

Throws:
Scheherexception

renderReturnValue

public static java.lang.StringBuffer renderReturnValue(DBCoreInterface dbci,
                                                       ReturnValue returnValue,
                                                       SymbolTable symbols)
                                                throws Scheherexception
Renders a return value to a StringBuffer, branching on type.

Throws:
Scheherexception

truth

public static boolean truth()
Helper function that gets around peculiar ANTLR behavior by always returning true (but in a way that is not clear at compile time)



Copyright © 2011 David K. Elson. All Rights Reserved.