1
Fork 0

reorder identifier-like parser code in lex

This commit is contained in:
Jake Wheat 2016-02-18 20:32:32 +02:00
parent ba55859dd7
commit 90e66f4888

View file

@ -208,6 +208,24 @@ this can be moved to the dialect at some point
> isIdentifierChar :: Char -> Bool > isIdentifierChar :: Char -> Bool
> isIdentifierChar c = c == '_' || isAlphaNum c > isIdentifierChar c = c == '_' || isAlphaNum c
use try because : and @ can be part of other things also
> prefixedVariable :: Dialect -> Parser Token
> prefixedVariable d = try $ choice
> [PrefixedVariable <$> char ':' <*> identifierString
> ,guard (diSyntaxFlavour d == SQLServer) >>
> PrefixedVariable <$> char '@' <*> identifierString
> ,guard (diSyntaxFlavour d == Oracle) >>
> PrefixedVariable <$> char '#' <*> identifierString
> ]
> positionalArg :: Dialect -> Parser Token
> positionalArg d =
> guard (diSyntaxFlavour d == Postgres) >>
> -- use try to avoid ambiguities with other syntax which starts with dollar
> PositionalArg <$> try (char '$' *> (read <$> many1 digit))
Parse a SQL string. Examples: Parse a SQL string. Examples:
'basic string' 'basic string'
@ -262,23 +280,7 @@ x'hexidecimal string'
> ++ [string "u&'" > ++ [string "u&'"
> ,string "U&'"] > ,string "U&'"]
use try because : and @ can be part of other things also numbers
> prefixedVariable :: Dialect -> Parser Token
> prefixedVariable d = try $ choice
> [PrefixedVariable <$> char ':' <*> identifierString
> ,guard (diSyntaxFlavour d == SQLServer) >>
> PrefixedVariable <$> char '@' <*> identifierString
> ,guard (diSyntaxFlavour d == Oracle) >>
> PrefixedVariable <$> char '#' <*> identifierString
> ]
> positionalArg :: Dialect -> Parser Token
> positionalArg d =
> guard (diSyntaxFlavour d == Postgres) >>
> -- use try to avoid ambiguities with other syntax which starts with dollar
> PositionalArg <$> try (char '$' *> (read <$> many1 digit))
digits digits
digits.[digits][e[+-]digits] digits.[digits][e[+-]digits]