diff options
author | Calvin Morrison <mutantturkey@gmail.com> | 2013-11-13 13:07:23 -0500 |
---|---|---|
committer | Calvin Morrison <mutantturkey@gmail.com> | 2013-11-13 13:07:23 -0500 |
commit | 9066ea884129957fe899d6d10cba1e17547214b9 (patch) | |
tree | aaa3ba9e0e507d9d13d8258def7585675e86f221 /src/nbc/parse-state.sml | |
parent | ba07cda9cbf54d33b657d9ee30bc03c0b67f0b5f (diff) |
remove nbc:
Diffstat (limited to 'src/nbc/parse-state.sml')
-rw-r--r-- | src/nbc/parse-state.sml | 89 |
1 files changed, 0 insertions, 89 deletions
diff --git a/src/nbc/parse-state.sml b/src/nbc/parse-state.sml deleted file mode 100644 index 8b30a67..0000000 --- a/src/nbc/parse-state.sml +++ /dev/null @@ -1,89 +0,0 @@ -signature PARSE_STATE = sig - type ('argument, 'result) state - val create: unit -> ('argument, 'result) state - type ('argument, 'result) handler = - TextIO.instream * 'argument -> 'result - datatype whichCharacters = These of char list | Any - val build: { - state: ('argument, 'result) state - , characters: - (whichCharacters * ('argument, 'result) handler) list - , endOfFile: ('argument, 'result) handler - } -> unit - val enter: - ('argument, 'result) state - * TextIO.instream - * 'argument - -> 'result -end - -structure ParseState :> PARSE_STATE = struct - type ('argument, 'result) handler = - TextIO.instream * 'argument -> 'result - datatype whichCharacters = These of char list | Any - type ('argument, 'result) state = { - byCharacter: Int8.int vector ref - , byIndex: ('argument, 'result) handler vector ref - , endOfFile: ('argument, 'result) handler option ref - } - fun create () = { - byCharacter = ref (Vector.fromList nil) - , byIndex = ref (Vector.fromList nil) - , endOfFile = ref NONE - } - fun build { - state = {byCharacter, byIndex, endOfFile} - , characters - , endOfFile = newEndOfFile - } = - let - val characters = vector characters - fun equal (one: char) (two: char) = - one = two - fun shallHandle ((whichToHandle, _), char) = - case whichToHandle of - Any => true - | These charactersToHandle => - List.exists (equal char) - charactersToHandle - fun charToIndex char = - case - Vector.findi (fn (_, handler) => - shallHandle (handler, char) - ) characters - of - NONE => raise Fail ( - "ParseState.build: " - ^ Char.toString char - ^ " not found" - ) | SOME (index, _) => - Int8.fromInt index - fun handlerToFunction (_, function) = function - fun indexToFunction index = handlerToFunction ( - Vector.sub (characters, index) - ) - in - byCharacter := Vector.tabulate ( - Char.maxOrd + 1 - , charToIndex o chr - ); byIndex := - Vector.map (fn (_, function) => - function - ) characters - ; endOfFile := SOME newEndOfFile - end - fun enter ( - { - byCharacter = ref byCharacter - , byIndex = ref byIndex - , endOfFile = ref endOfFile - } - , instream - , argument - ) = case TextIO.input1 instream of - NONE => (valOf endOfFile) (instream, argument) - | SOME char => Vector.sub ( - byIndex - , Int8.toInt (Vector.sub (byCharacter, ord char)) - ) (instream, argument) -end |