Class TEDParser

java.lang.Object
  |
  +--TEDParser

public class TEDParser
extends java.lang.Object


Constructor Summary
TEDParser()
           
 
Method Summary
 char consumeChar(java.lang.StringBuffer currentString)
          consumeChar This method returns the first character of the current string.
 java.lang.String getState(java.lang.StringBuffer inputLine)
          getState This method gets a state out of the input line.
static void main(java.lang.String[] args)
           
 boolean parseAlphabet(java.lang.StringBuffer workingAlphabet)
          parseAlphabet Parser for the alphabet Makes sure the alphabet is properly formated (x,x,x,x,x,x,x) If it is not properly formatted an exception is thrown Makes sure there are no doubles and none of TED's special chars On either occurence an exception will be thrown
 void parseError(java.lang.String reason, java.lang.String fault, java.lang.String location, int errorCode)
          parseError This method prints a message to the system console when an error is encountered during the parsing of the input.
 void parseRuleError(java.lang.String reason, java.lang.String fault, int rule, java.lang.String location, int errorCode)
          parseRuleError This method prints a message to the system console when an error is encountered during the parsing of the rules.
 boolean parseRules(java.lang.StringBuffer workingRules)
          parseRules Parser for rule set Makes sure the rule set is properly formated {(a,b,c,d,e),(a,b,c,d,e)} and that the first char of a rule is "(" If it is not properly formatted an exception is thrown.
 boolean parseTapeInput(java.lang.StringBuffer workingTapeInput)
          parseTapeInput Makes sure the tape is properly formatted "@abbba" or "abbba" if it is not properly formatted an exception is thrown Makes sure all the characters being put on the tape are members of the alphabet set.
 boolean validate(java.lang.StringBuffer alphabet, java.lang.StringBuffer tapeInput, java.lang.StringBuffer rules, TEDController controller)
          Constructor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TEDParser

public TEDParser()
Method Detail

validate

public boolean validate(java.lang.StringBuffer alphabet,
                        java.lang.StringBuffer tapeInput,
                        java.lang.StringBuffer rules,
                        TEDController controller)
Constructor
Parameters:
alphabet: - this is the alphabet of the Turing Machine
tapeInput: - this is the tape of the Turing Machine
rules: - this is the rules of the Turing Machine
controller: - this is the controller class of TED

getState

public java.lang.String getState(java.lang.StringBuffer inputLine)
getState This method gets a state out of the input line. It then returns that substring.
Parameters:
inputLine: - the current working string
Returns:
the substring which represents the state taken off of the inputLine.

parseError

public void parseError(java.lang.String reason,
                       java.lang.String fault,
                       java.lang.String location,
                       int errorCode)
parseError This method prints a message to the system console when an error is encountered during the parsing of the input.
Parameters:
reason: - the reason TED experienced an error.
fault: - the character which raised the exception.
location: - the part of the program in which the error was encountered
errorCode: - the constant value in the error message array for the appropriate error message

parseRuleError

public void parseRuleError(java.lang.String reason,
                           java.lang.String fault,
                           int rule,
                           java.lang.String location,
                           int errorCode)
parseRuleError This method prints a message to the system console when an error is encountered during the parsing of the rules.
Parameters:
reason: - the reason TED experienced an error.
fault: - the character which raised the exception.
rule: - number of the rule in which TED encountered the error
location: - the part of the program in which the error was encountered
errorCode: - the constant value in the error message array for the appropriate error message

consumeChar

public char consumeChar(java.lang.StringBuffer currentString)
consumeChar This method returns the first character of the current string.
Parameters:
currentString: - this is the string we want to take a character from.
Returns:
the character consumed by the method

parseAlphabet

public boolean parseAlphabet(java.lang.StringBuffer workingAlphabet)
parseAlphabet Parser for the alphabet Makes sure the alphabet is properly formated (x,x,x,x,x,x,x) If it is not properly formatted an exception is thrown Makes sure there are no doubles and none of TED's special chars On either occurence an exception will be thrown
Parameters:
workingAlphabet: - the current string from which we are parsing the alphabet
Returns:
whether the method completed successfully

parseTapeInput

public boolean parseTapeInput(java.lang.StringBuffer workingTapeInput)
parseTapeInput Makes sure the tape is properly formatted "@abbba" or "abbba" if it is not properly formatted an exception is thrown Makes sure all the characters being put on the tape are members of the alphabet set. If a character is not a member of alphabet an error will be raised.
Parameters:
workingTapeInput: - the input from the textField
Returns:
whether or not we succeeded

parseRules

public boolean parseRules(java.lang.StringBuffer workingRules)
parseRules Parser for rule set Makes sure the rule set is properly formated {(a,b,c,d,e),(a,b,c,d,e)} and that the first char of a rule is "(" If it is not properly formatted an exception is thrown.
Parameters:
rules: - the text input from the textfield.
finalAlphabet: - the read/write characters can only come from the Alphabet so we must check each read/write character.
Returns:
boolean: whether the process completed successfully.

main

public static void main(java.lang.String[] args)