unsw.cse.framescript
Class Parser

java.lang.Object
  extended by unsw.cse.framescript.Parser

public class Parser
extends java.lang.Object

This is the class that parses FrameScript frames/scripts/expressions.

Author:
mmcgill

Constructor Summary
Parser(Atomiser a)
          Creates a parser that uses a specific atomiser.
 
Method Summary
 Term expression()
          Reads an expression from the input.
 Term factor()
          Reads a factor(function call, list, pattern, number, atom, bracketed expression) from the input.
 Term getDaemon()
          Reads a daemon from the input.
static SyntaxError InvalidName(java.lang.String type, Term value)
          Throws an error with standardised message when the name of an object is invalid.
static boolean isReservedAtom(Term t)
          Check whether an atom is reserved or not.
 Pattern pattern()
          Reads a pattern from the input.
 Term patternElement()
          Reads a pattern element(atom, number, string, sequence, alternatives, ^, #) from the input.
 void skip()
          Skips to the beginning of the next statement.
 Term statement()
          Reads a statement from the input.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Parser

public Parser(Atomiser a)
Creates a parser that uses a specific atomiser.

Parameters:
a - atomiser that tokenises the input to be parsed
Method Detail

statement

public Term statement()
               throws FSException,
                      java.io.IOException
Reads a statement from the input.

Returns:
the statement as a term
Throws:
FSException - if there is a problem parsing the statement
java.io.IOException - if there is an IO problem reading from the input

skip

public void skip()
          throws java.io.IOException
Skips to the beginning of the next statement.

Throws:
java.io.IOException - if there is an IO problem reading from the input

expression

public Term expression()
                throws SyntaxError,
                       java.io.IOException
Reads an expression from the input. May be a list of expressions.

Returns:
the parsed expression
Throws:
SyntaxError - any errors parsing the expression
java.io.IOException - if there is an IO problem reading from the input

isReservedAtom

public static boolean isReservedAtom(Term t)
Check whether an atom is reserved or not.

Parameters:
t - atom being tested
Returns:
true if it is, false otherwise

factor

public Term factor()
            throws SyntaxError,
                   java.io.IOException
Reads a factor(function call, list, pattern, number, atom, bracketed expression) from the input.

Returns:
the parsed factor
Throws:
SyntaxError - any errors parsing the factor
java.io.IOException - if there is an IO problem reading from the input

pattern

public Pattern pattern()
                throws SyntaxError,
                       java.io.IOException
Reads a pattern from the input.

Returns:
the parsed pattern
Throws:
SyntaxError - any errors parsing the pattern
java.io.IOException - if there is an IO problem reading from the input

patternElement

public Term patternElement()
                    throws SyntaxError,
                           java.io.IOException
Reads a pattern element(atom, number, string, sequence, alternatives, ^, #) from the input.

Returns:
the parsed pattern element
Throws:
SyntaxError - any errors parsing the pattern element
java.io.IOException - if there is an IO problem reading from the input

InvalidName

public static SyntaxError InvalidName(java.lang.String type,
                                      Term value)
                               throws SyntaxError
Throws an error with standardised message when the name of an object is invalid.

Parameters:
type - the name of the type
value - the invalid name
Returns:
nothing, always throws
Throws:
SyntaxError - a standardized error

getDaemon

public Term getDaemon()
               throws SyntaxError,
                      java.io.IOException
Reads a daemon from the input.

Returns:
the parsed daemon
Throws:
SyntaxError - any errors parsing the daemon
java.io.IOException - if there is an IO problem reading from the input