Safe Haskell | Safe |
---|---|
Language | Haskell2010 |
- data Token
- = Symbol Text
- | Identifier (Maybe (Char, Char)) Text
- | SqlString Text Text
- | SqlNumber Text
- | Whitespace Text
- | PositionalArg Int
- | LineComment Text
- | BlockComment Text
- | Splice Char Text
- | CopyPayload Text
- prettyToken :: SQLSyntaxDialect -> Token -> Text
- sqlToken :: SQLSyntaxDialect -> Parser ((FilePath, Int, Int), Token)
- sqlTokens :: SQLSyntaxDialect -> FilePath -> Maybe (Int, Int) -> Text -> Either ParseError [((FilePath, Int, Int), Token)]
- data SQLSyntaxDialect
Documentation
data Token
Represents a lexed token
Symbol Text | a symbol in postgresql dialect is one of the following:
things that are not lexed as symbols:
|
Identifier (Maybe (Char, Char)) Text | This is an identifier or keyword. The 'Maybe (Char,Char)' selects the quoted style - '"' is used to quote identifiers in standard sql, sql server also uses [brackets] to quote identifiers. The identifier also includes the 'variable marker prefix' used in sql server (e.g. @identifier, #identifier), and oracle (e.g. :identifier) |
SqlString Text Text | This is a string literal. The first field is the quotes used: single quote (') for normal strings, E' for escape supporting strings, and $$ delimiter for postgresql dollar quoted strings. The lexer doesn't process the escapes in strings, but passes on the literal source e.g. E'\n' parses to SqlString "E'" "\n" with the literal characters '\' and 'n' in the string, not a newline character. quotes within a string ('') or escaped string ('' or \') are passed through unchanged |
SqlNumber Text | a number literal (integral or otherwise), stored in original format unchanged |
Whitespace Text | non-significant whitespace (space, tab, newline) (strictly speaking, it is up to the client to decide whether the whitespace is significant or not) |
PositionalArg Int | a postgresql positional arg, e.g. $1 |
LineComment Text | a commented line using --, contains every character starting with the '--' and including the terminating newline character if there is one - this will be missing if the last line in the source is a line comment with no trailing newline |
BlockComment Text | a block comment, /* stuff */, includes the comment delimiters |
Splice Char Text | an antiquotation splice, e.g. $x(stuff) |
CopyPayload Text | the copy data in a copy from stdin |
prettyToken :: SQLSyntaxDialect -> Token -> Text
Accurate pretty printing, if you lex a bunch of tokens, then pretty print them, should should get back exactly the same string
sqlTokens :: SQLSyntaxDialect -> FilePath -> Maybe (Int, Int) -> Text -> Either ParseError [((FilePath, Int, Int), Token)]
data SQLSyntaxDialect
The dialect of SQL to use.