Defines datatypes and corresponding constructor functions, combinators and selectors used by the SQLParser
Author: Julia Krone
Version: 0.1
newSPM
:: Pos -> a -> [Token] -> SPM a
constructor function for SPM |
newEmptySPM
:: Pos -> [Token] -> EmptySPM
constructor function for an EmptySPM |
initializeSPM
:: a -> EmptySPM -> SPM a
initializes a SPM - return function of SPMParser Symboltable are passed from the EmptySPM |
concatSPMs
:: (a -> b -> c) -> SPM a -> SPM b -> SPM c
|
hasToken
:: EmptySPM -> Bool
Returns whether the List of Token contained by the given EmptySPM is not empty |
setToken
:: [Token] -> EmptySPM -> EmptySPM
Sets the List of Token. |
token
:: EmptySPM -> [Token]
Returns the list of Token. |
headToken
:: EmptySPM -> Token
Partially defined! Returns first token of the non-empty List of Token. |
continue
:: EmptySPM -> EmptySPM
Cuts the first Token of the List without doing anything else. |
liftSPM
:: (a -> b) -> (EmptySPM -> SPM a) -> EmptySPM -> SPM b
Lift: Applies a given function to the result of the given parser. |
bindSPM
:: (EmptySPM -> SPM a) -> (a -> EmptySPM -> SPM b) -> [Token] -> EmptySPM -> SPM b
Bind-function for SPMParser. |
bindDefSPM
:: (EmptySPM -> SPM a) -> a -> (a -> EmptySPM -> SPM b) -> [Token] -> EmptySPM -> SPM b
Bind-function for SPMParser with superior error menagement. |
(.~>.)
:: (EmptySPM -> Either EmptySPM (SPM a)) -> (EmptySPM -> SPM a) -> EmptySPM -> SPM a
Concats a terminal-Parser to a SPMParser. |
(.<~.)
:: (EmptySPM -> SPM a) -> (EmptySPM -> Either EmptySPM (SPM a)) -> EmptySPM -> SPM a
Concats a SPMParser to a following terminal-Parser. |
combineSPMs
:: (a -> b -> c) -> (EmptySPM -> SPM a) -> (EmptySPM -> SPM b) -> EmptySPM -> SPM c
Combines two SPMParsers in an alternate manner: Both parsers are applied independently , the second one taking the list of token altered by the first one. |
proceedWith
:: Token -> EmptySPM -> EmptySPM
Drop token until given token or Semi is reached. |
proceedWithOneOf
:: [Token] -> EmptySPM -> EmptySPM
Drop Token until one of the token in the list or Semi is reached. |
proceedAfter
:: Token -> EmptySPM -> EmptySPM
Drop Token including the given one. |
terminal
:: Token -> EmptySPM -> Either EmptySPM (SPM a)
Parses a terminal. |
terminalOrProc
:: Token -> [Token] -> EmptySPM -> Either EmptySPM (SPM a)
Alternate terminal-parser: Additionally takes token with which to proceed in case of an error. |
terminalOrConsume
:: Token -> EmptySPM -> Either EmptySPM (SPM a)
alternative terminal parser which in case of error consumes all token including the given one |
parseError
:: String -> EmptySPM -> SPM a
Returns Error with given message. |
emptyTkErr
:: EmptySPM -> SPM a
Returns Standarderror in case the TokenList is empty. |
Datatype for organization of the parsing process used in the monadic structure SPMParser (therefore its name). Note that the SPM itself is not used as a monad here although corresponding functions (satisfying monadic laws) could easily be defined. Consists of the position of integrated Code, a PM which contains the result/errors and warnings that were calculated before and the list of SQLToken which to parse. It is parameterized over a, which represents the result type.
Constructors:
Datatype for an Empty SQLParserMonad. Same as SPM but without a result.
Constructors:
Monadic structure which is the basic type for parsing process. Takes an EmptySPM and passes it down, parsing the Token and generating the result which is finally passed back. Returns the SPM with the result which is constructed bottom-up.
Type synonym: SPMParser a = EmptySPM -> SPM a
constructor function for SPM
|
constructor function for an EmptySPM
|
initializes a SPM - return function of SPMParser Symboltable are passed from the EmptySPM |
|
Returns whether the List of Token contained by the given EmptySPM is not empty
|
Sets the List of Token.
|
Returns the list of Token.
|
Partially defined! Returns first token of the non-empty List of Token.
|
Cuts the first Token of the List without doing anything else. Does Nothing if List of Token is empty.
|
Lift: Applies a given function to the result of the given parser. |
Bind-function for SPMParser. The additional list of Token is for error recovery, normally the follow set of the piece of code that is parsed by the first parser. In case the first parser fails the second one is never invoked, the list of remaining tokes is cut until the first token that is member of the follow set. |
Bind-function for SPMParser with superior error menagement. In case the first parser fails, the second one is invoked with a default value and the tokens set to the next one that is element of the given list (typically the follow-set).
|
Concats a terminal-Parser to a SPMParser. Invokes the second one just if the first one did not fail.
|
Concats a SPMParser to a following terminal-Parser. If the terminal-Parser fails, the errors are concatenated to the former otherwise the result of the SPMParser is returned.
|
Combines two SPMParsers in an alternate manner: Both parsers are applied independently , the second one taking the list of token altered by the first one. The resulting PMs are combined afterwards.
|
Drop token until given token or Semi is reached. |
Drop Token until one of the token in the list or Semi is reached. Tokens are tried in given order. As soon as one token is found, the remaining ones are not tried anymore. |
Drop Token including the given one. |
Parses a terminal.
|
Alternate terminal-parser: Additionally takes token with which to proceed in case of an error. |
alternative terminal parser which in case of error consumes all token including the given one |
Returns Error with given message.
|
Returns Standarderror in case the TokenList is empty. Inserts a single semicolon as Tokenlist to avoid subsequent errors.
|