[Grace-core] Proposed Input spec
Kim Bruce
kim at cs.pomona.edu
Wed Jun 18 11:27:39 PDT 2014
Here is the spec that Femi is planning on implementing as a way of handling input. There would be a class taking a filepath as a parameter that would construct objects of this type. It is based on a simplified version of the Scanner class of Java and is intended to be very easy to use.
// Handles all types of file input and parsing
type graceInput = {
// Moves to the indicated position in the file
goToPosition(pos:Number)->Done
// Returns true if the current position is at the end of the file
endOfFile->Boolean
//Determines if the next token is of the indicated type
hasNextWord->Boolean
hasNextNumber->Boolean
hasNextBoolean->Boolean
// Returns the next token if it is of the correct type
// Raises an IOException if the token is of the wrong type
// Returns the next number in the file as a number
nextNum(s:String)->Number
// Returns the next line of text excluding the "\n" character
nextLine(s:String)->String
// Returns the next word in the file excluding white spaces
nextWord(s:String)->String
// Returns the next Boolean that is found in the file
nextBoolean(s:String)->Boolean
}
Comments/Questions/Suggestions?
Kim
More information about the Grace-core
mailing list