unsw.cse.framescript
Class Atom

java.lang.Object
  extended by unsw.cse.framescript.Term
      extended by unsw.cse.framescript.Atom

public class Atom
extends Term

Atoms are the most common term used in FrameScript. The are strings of characters which can be used as the names of frames/terms or as values them selves.

Author:
mmcgill

Field Summary
static Atom _default
          Reserved atoms used in the parser.
static Atom _else
          Reserved atoms used in the parser.
static Atom _false
          Reserved atoms used in the parser.
static Atom _if
          Reserved atoms used in the parser.
static Atom _instanceof
          Reserved atoms used in the parser.
static Atom _new
          Reserved atoms used in the parser.
static Atom _null
          Reserved atoms used in the parser.
static Atom _terminator
          Reserved atoms used in the parser.
static Atom _then
          Reserved atoms used in the parser.
static Atom _true
          Reserved atoms used in the parser.
static Atom ako
          Reserved atoms used in the parser.
static Atom and
          Reserved atoms used in the parser.
static Atom aposS
          Reserved atoms used in the parser.
static Atom arrow
          Reserved atoms used in the parser.
static Atom assign
          Reserved atoms used in the parser.
static Atom bang
          Reserved atoms used in the parser.
static Atom bar
          Reserved atoms used in the parser.
static Atom because
          Reserved atoms used in the parser.
static Atom cache
          Reserved atoms used in the parser.
static Atom colon
          Reserved atoms used in the parser.
static Atom comma
          Reserved atoms used in the parser.
static Atom current_object
          Reserved atoms used in the parser.
static Atom current_slot
          Reserved atoms used in the parser.
static Atom division
          Reserved atoms used in the parser.
static Atom domain
          Reserved atoms used in the parser.
static Atom dot
          Reserved atoms used in the parser.
static Atom double_arrow
          Reserved atoms used in the parser.
static Atom double_colon
          Reserved atoms used in the parser.
static Atom double_semi
          Reserved atoms used in the parser.
static Atom eq
          Reserved atoms used in the parser.
static Atom except
          Reserved atoms used in the parser.
static Atom failsafe
          Reserved atoms used in the parser.
static Atom forall
          Reserved atoms used in the parser.
static Atom ge
          Reserved atoms used in the parser.
static Atom gt
          Reserved atoms used in the parser.
static Atom hash
          Reserved atoms used in the parser.
static Atom hat
          Reserved atoms used in the parser.
static Atom help
          Reserved atoms used in the parser.
static Atom if_added
          Reserved atoms used in the parser.
static Atom if_destroyed
          Reserved atoms used in the parser.
static Atom if_needed
          Reserved atoms used in the parser.
static Atom if_new
          Reserved atoms used in the parser.
static Atom if_removed
          Reserved atoms used in the parser.
static Atom if_replaced
          Reserved atoms used in the parser.
static Atom in
          Reserved atoms used in the parser.
static Atom inherits
          Reserved atoms used in the parser.
static Atom isa
          Reserved atoms used in the parser.
static Atom lbrace
          Reserved atoms used in the parser.
static Atom lbracket
          Reserved atoms used in the parser.
static Atom le
          Reserved atoms used in the parser.
static Atom lpren
          Reserved atoms used in the parser.
static Atom lquote
          Reserved atoms used in the parser.
static Atom lt
          Reserved atoms used in the parser.
static Atom match
          Reserved atoms used in the parser.
static Atom minus
          Reserved atoms used in the parser.
static Atom mod
          Reserved atoms used in the parser.
static Atom multiplication
          Reserved atoms used in the parser.
static Atom multivalued
          Reserved atoms used in the parser.
static Atom ne
          Reserved atoms used in the parser.
static Atom new_value
          Reserved atoms used in the parser.
static Atom non_terminal
          Reserved atoms used in the parser.
static Atom not
          Reserved atoms used in the parser.
static Atom object
          Reserved atoms used in the parser.
static Atom of
          Reserved atoms used in the parser.
static Atom old_value
          Reserved atoms used in the parser.
static Atom on_entry
          Reserved atoms used in the parser.
static Atom on_exit
          Reserved atoms used in the parser.
static Atom or
          Reserved atoms used in the parser.
static Atom plus
          Reserved atoms used in the parser.
static Atom question
          Reserved atoms used in the parser.
static Atom range
          Reserved atoms used in the parser.
static Atom rbrace
          Reserved atoms used in the parser.
static Atom rbracket
          Reserved atoms used in the parser.
static Atom respond
          Reserved atoms used in the parser.
static Atom rpren
          Reserved atoms used in the parser.
static Atom rquote
          Reserved atoms used in the parser.
static Atom semi_colon
          Reserved atoms used in the parser.
static Atom separator
          Reserved atoms used in the parser.
static Atom star
          Reserved atoms used in the parser.
static Atom tilde
          Reserved atoms used in the parser.
static Atom to
          Reserved atoms used in the parser.
static Atom topic
          Reserved atoms used in the parser.
static Atom trigger
          Reserved atoms used in the parser.
static Atom underscore
          Reserved atoms used in the parser.
static Atom var
          Reserved atoms used in the parser.
static Atom with
          Reserved atoms used in the parser.
 
Method Summary
 Term apply(Instance currentObject, Term[] args, StackFrame frame)
          Used to lookup the subroutine/function defined with the name.
 Term assign(Instance currentObject, Term arg, StackFrame stackframe)
          Assigns a value to a Term.
 boolean equals(Term t)
          Compares two Terms for equality.
 Term eval(Instance currentObject, StackFrame stackframe)
          Gets an atom's value.
 boolean fullMatch(unsw.cse.framescript.InputPattern input, Instance current, StackFrame frame)
          Matches the Term to the current position in an input pattern.
static Atom intern(java.lang.String str)
          Gets the atom identified by a string.
static Atom intern(java.lang.String str, int pre, int in, int post)
          Gets the atom identified by a string and sets its operator precedences.
static Atom intern(java.lang.String str, int pre, int in, int post, boolean r)
          Gets the atom identified by a string and sets its operator precedences.
 Term mapVars(FSList vars)
          Maps atoms to variables from the list of variables.
 boolean match(unsw.cse.framescript.InputPattern input, Instance current, StackFrame frame)
          Matches the Term to the current position in an input pattern.
 java.lang.String toString()
          Turns the Term into a string.
 
Methods inherited from class unsw.cse.framescript.Term
asString, indents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

_null

public static Atom _null
Reserved atoms used in the parser.


_true

public static Atom _true
Reserved atoms used in the parser.


_false

public static Atom _false
Reserved atoms used in the parser.


assign

public static Atom assign
Reserved atoms used in the parser.


lt

public static Atom lt
Reserved atoms used in the parser.


le

public static Atom le
Reserved atoms used in the parser.


eq

public static Atom eq
Reserved atoms used in the parser.


ne

public static Atom ne
Reserved atoms used in the parser.


gt

public static Atom gt
Reserved atoms used in the parser.


ge

public static Atom ge
Reserved atoms used in the parser.


bang

public static Atom bang
Reserved atoms used in the parser.


question

public static Atom question
Reserved atoms used in the parser.


var

public static Atom var
Reserved atoms used in the parser.


plus

public static Atom plus
Reserved atoms used in the parser.


minus

public static Atom minus
Reserved atoms used in the parser.


multiplication

public static Atom multiplication
Reserved atoms used in the parser.


division

public static Atom division
Reserved atoms used in the parser.


mod

public static Atom mod
Reserved atoms used in the parser.


and

public static Atom and
Reserved atoms used in the parser.


or

public static Atom or
Reserved atoms used in the parser.


not

public static Atom not
Reserved atoms used in the parser.


lpren

public static Atom lpren
Reserved atoms used in the parser.


rpren

public static Atom rpren
Reserved atoms used in the parser.


lbrace

public static Atom lbrace
Reserved atoms used in the parser.


rbrace

public static Atom rbrace
Reserved atoms used in the parser.


lbracket

public static Atom lbracket
Reserved atoms used in the parser.


rbracket

public static Atom rbracket
Reserved atoms used in the parser.


lquote

public static Atom lquote
Reserved atoms used in the parser.


rquote

public static Atom rquote
Reserved atoms used in the parser.


isa

public static Atom isa
Reserved atoms used in the parser.


ako

public static Atom ako
Reserved atoms used in the parser.


with

public static Atom with
Reserved atoms used in the parser.


of

public static Atom of
Reserved atoms used in the parser.


object

public static Atom object
Reserved atoms used in the parser.


_new

public static Atom _new
Reserved atoms used in the parser.


dot

public static Atom dot
Reserved atoms used in the parser.


comma

public static Atom comma
Reserved atoms used in the parser.


semi_colon

public static Atom semi_colon
Reserved atoms used in the parser.


colon

public static Atom colon
Reserved atoms used in the parser.


double_colon

public static Atom double_colon
Reserved atoms used in the parser.


double_semi

public static Atom double_semi
Reserved atoms used in the parser.


_default

public static Atom _default
Reserved atoms used in the parser.


range

public static Atom range
Reserved atoms used in the parser.


help

public static Atom help
Reserved atoms used in the parser.


cache

public static Atom cache
Reserved atoms used in the parser.


multivalued

public static Atom multivalued
Reserved atoms used in the parser.


if_new

public static Atom if_new
Reserved atoms used in the parser.


if_added

public static Atom if_added
Reserved atoms used in the parser.


if_needed

public static Atom if_needed
Reserved atoms used in the parser.


if_removed

public static Atom if_removed
Reserved atoms used in the parser.


if_replaced

public static Atom if_replaced
Reserved atoms used in the parser.


if_destroyed

public static Atom if_destroyed
Reserved atoms used in the parser.


current_object

public static Atom current_object
Reserved atoms used in the parser.


current_slot

public static Atom current_slot
Reserved atoms used in the parser.


new_value

public static Atom new_value
Reserved atoms used in the parser.


old_value

public static Atom old_value
Reserved atoms used in the parser.


to

public static Atom to
Reserved atoms used in the parser.


_if

public static Atom _if
Reserved atoms used in the parser.


_then

public static Atom _then
Reserved atoms used in the parser.


_else

public static Atom _else
Reserved atoms used in the parser.


except

public static Atom except
Reserved atoms used in the parser.


because

public static Atom because
Reserved atoms used in the parser.


forall

public static Atom forall
Reserved atoms used in the parser.


in

public static Atom in
Reserved atoms used in the parser.


star

public static Atom star
Reserved atoms used in the parser.


bar

public static Atom bar
Reserved atoms used in the parser.


hat

public static Atom hat
Reserved atoms used in the parser.


hash

public static Atom hash
Reserved atoms used in the parser.


underscore

public static Atom underscore
Reserved atoms used in the parser.


arrow

public static Atom arrow
Reserved atoms used in the parser.


double_arrow

public static Atom double_arrow
Reserved atoms used in the parser.


non_terminal

public static Atom non_terminal
Reserved atoms used in the parser.


match

public static Atom match
Reserved atoms used in the parser.


respond

public static Atom respond
Reserved atoms used in the parser.


topic

public static Atom topic
Reserved atoms used in the parser.


domain

public static Atom domain
Reserved atoms used in the parser.


trigger

public static Atom trigger
Reserved atoms used in the parser.


failsafe

public static Atom failsafe
Reserved atoms used in the parser.


on_entry

public static Atom on_entry
Reserved atoms used in the parser.


on_exit

public static Atom on_exit
Reserved atoms used in the parser.


_instanceof

public static Atom _instanceof
Reserved atoms used in the parser.


inherits

public static Atom inherits
Reserved atoms used in the parser.


separator

public static Atom separator
Reserved atoms used in the parser.


_terminator

public static Atom _terminator
Reserved atoms used in the parser.


tilde

public static Atom tilde
Reserved atoms used in the parser.


aposS

public static Atom aposS
Reserved atoms used in the parser.

Method Detail

intern

public static Atom intern(java.lang.String str)
Gets the atom identified by a string.

Parameters:
str - the name of the atom
Returns:
the atom with the name str

intern

public static Atom intern(java.lang.String str,
                          int pre,
                          int in,
                          int post)
Gets the atom identified by a string and sets its operator precedences.

Parameters:
str - name of the atom
pre - the precedence of the atom as a prefix operator
in - the precedence of the atom as an infix operator
post - the precedence of the atom as a postfix operator
Returns:
the atom with the name str

intern

public static Atom intern(java.lang.String str,
                          int pre,
                          int in,
                          int post,
                          boolean r)
Gets the atom identified by a string and sets its operator precedences.

Parameters:
str - name of the atom
pre - the precedence of the atom as a prefix operator
in - the precedence of the atom as an infix operator
post - the precedence of the atom as a postfix operator
r - whether or not the infix operator is right branching
Returns:
the atom with the name str

apply

public Term apply(Instance currentObject,
                  Term[] args,
                  StackFrame frame)
           throws FSException
Used to lookup the subroutine/function defined with the name.

Parameters:
currentObject - the enclosing instance frame
args - the arguments for the function call
frame - the values of any defined variables
Returns:
the result of the function call
Throws:
FSException - if no function is defined for the atom or the number of arguments is incorrect

assign

public Term assign(Instance currentObject,
                   Term arg,
                   StackFrame stackframe)
            throws FSException
Description copied from class: Term
Assigns a value to a Term. Most Terms cannot be assigned values so the default is to throw an error.

Overrides:
assign in class Term
Parameters:
currentObject - the enclosing instance frame for the code being evaluated that is performing the assignment
arg - the unevaluated value to be assigned to the Term
stackframe - StackFrame that holds the values for any variables
Returns:
the valuse assigned to the Term
Throws:
FSException - if assignment cannot be performed

mapVars

public Term mapVars(FSList vars)
Description copied from class: Term
Maps atoms to variables from the list of variables.

Overrides:
mapVars in class Term
Parameters:
vars - a list of variables to be mapped
Returns:
a clone of the Term where all the variables have been mapped

eval

public Term eval(Instance currentObject,
                 StackFrame stackframe)
          throws FSException
Gets an atom's value. First it checks if the atom is a slot in the current object if so it returns the value of the slot. Second it checks if there is a global value for the atom if so the global value is returned. If the atom is not the name of a slot in the current object and has no global value it returns itself.

Specified by:
eval in class Term
Parameters:
currentObject - the enclosing instance frame for the code being evaluated
stackframe - StackFrame that holds the values for any variables
Returns:
the result of the evaluation
Throws:
FSException - if any errors occur in performing the evaluation

equals

public boolean equals(Term t)
Description copied from class: Term
Compares two Terms for equality.

Specified by:
equals in class Term
Parameters:
t - Term to be compared to
Returns:
true if the Terms are equal, false otherwise

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)
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

toString

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

Specified by:
toString in class Term