unsw.cse.framescript
Class Script

java.lang.Object
  extended by unsw.cse.framescript.Term
      extended by unsw.cse.framescript.Frame
          extended by unsw.cse.framescript.Instance
              extended by unsw.cse.framescript.Script

public class Script
extends Instance

This class provides FrameScript with rule based scripts.

Author:
mmcgill

Field Summary
static boolean useFullMatch
          Whether or not to use full matching.
 
Method Summary
 java.lang.String asText()
          Writes the frame as FrameScript.
 boolean fullMatch(unsw.cse.framescript.InputPattern input, Instance current, StackFrame frame)
          Matches the Term to the current position in an input pattern.
 Term getResponse(unsw.cse.framescript.InputPattern input)
          Gets the script's response to an input.
 Term getSlot(Atom slot)
          Gets the value of a slot for the instance.
 void initFrame()
          Initialises the frame.
 boolean match(unsw.cse.framescript.InputPattern input, Instance current, StackFrame frame)
          Matches the Term to the current position in an input pattern.
 Term putSlot(Atom slot, Term value)
          Puts a value into a slot in an instance frame.
 Term removeSlot(Atom slot)
          Removes a slot from the instance frame.
 Term removeSlot(Atom slot, Term value)
          Removes a specific value from a slot in an instance frame.
 Term replaceSlot(Atom slot, Term value)
          Replaces the value of a slot.
 java.lang.String toString()
          Turns the Term into a string.
 
Methods inherited from class unsw.cse.framescript.Instance
addParent
 
Methods inherited from class unsw.cse.framescript.Frame
equals, eval
 
Methods inherited from class unsw.cse.framescript.Term
assign, asString, indents, mapVars
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

useFullMatch

public static boolean useFullMatch
Whether or not to use full matching.

Method Detail

getResponse

public Term getResponse(unsw.cse.framescript.InputPattern input)
                 throws FSException
Gets the script's response to an input.

Parameters:
input - the input the script is to respond to
Returns:
the script's response, null if there is no response
Throws:
FSException - any errors checking the inheritance hierarchy

getSlot

public Term getSlot(Atom slot)
             throws FSException
Description copied from class: Instance
Gets the value of a slot for the instance.

Overrides:
getSlot in class Instance
Parameters:
slot - the name of the slot
Returns:
the value of the slot, null if the slot has no value
Throws:
FSException - if there is an error evaluating the slot's value

putSlot

public Term putSlot(Atom slot,
                    Term value)
             throws FSException
Description copied from class: Instance
Puts a value into a slot in an instance frame.

Overrides:
putSlot in class Instance
Parameters:
slot - the name of the slot
value - the value to be put into the slot
Returns:
the result of the if_added daemon
Throws:
FSException - any errors putting into the slot

replaceSlot

public Term replaceSlot(Atom slot,
                        Term value)
                 throws FSException
Description copied from class: Instance
Replaces the value of a slot.

Overrides:
replaceSlot in class Instance
Parameters:
slot - the name of the slot
value - the new value for the slot
Returns:
the result of running the if_replaced daemon
Throws:
FSException - any errors replacing the slot value

removeSlot

public Term removeSlot(Atom slot)
                throws FSException
Description copied from class: Instance
Removes a slot from the instance frame.

Overrides:
removeSlot in class Instance
Parameters:
slot - the name of the slot
Returns:
the result of running the if_removed daemon
Throws:
FSException - any errors removing the slot

removeSlot

public Term removeSlot(Atom slot,
                       Term value)
                throws FSException
Description copied from class: Instance
Removes a specific value from a slot in an instance frame.

Overrides:
removeSlot in class Instance
Parameters:
slot - the name of the slot
value - the value to be removed from the slot
Returns:
the value removed from the slot
Throws:
FSException

match

public boolean match(unsw.cse.framescript.InputPattern input,
                     Instance current,
                     StackFrame frame)
              throws FSException
Description copied from class: Term
Matches the Term to the current position in an input pattern.

Overrides:
match in class Term
Parameters:
input - the input the Term is being matched against
current - the enclosing instance frame for the code being evaluated
frame - StackFrame that holds the values for any variables
Returns:
true if it matches else false
Throws:
FSException - if any errors occur during the match process

fullMatch

public boolean fullMatch(unsw.cse.framescript.InputPattern input,
                         Instance current,
                         StackFrame frame)
                  throws FSException
Description copied from class: Term
Matches the Term to the current position in an input pattern.

Overrides:
fullMatch in class Term
Parameters:
input - the input the Term is being matched against
current - the enclosing instance frame for the code being evaluated
frame - StackFrame that holds the values for any variables
Returns:
true if it matches else false
Throws:
FSException - if any errors occur during the match process

initFrame

public void initFrame()
Description copied from class: Frame
Initialises the frame.

Overrides:
initFrame in class Instance

toString

public java.lang.String toString()
Description copied from class: Term
Turns the Term into a string.

Overrides:
toString in class Instance

asText

public java.lang.String asText()
Description copied from class: Frame
Writes the frame as FrameScript.

Overrides:
asText in class Instance
Returns:
a string that can hopefully be parsed to recreate the frame