refactor the join parsing to left factor and remove try
refactor the string token parser to reduce use of try
This commit is contained in:
parent
6720d3e3a3
commit
556f65ee22
|
@ -625,14 +625,19 @@ tref
|
||||||
> from = keyword_ "from" *> commaSep1 tref
|
> from = keyword_ "from" *> commaSep1 tref
|
||||||
> where
|
> where
|
||||||
> tref = nonJoinTref >>= optionSuffix joinTrefSuffix
|
> tref = nonJoinTref >>= optionSuffix joinTrefSuffix
|
||||||
> nonJoinTref = choice [try (TRQueryExpr <$> parens queryExpr)
|
> nonJoinTref = choice
|
||||||
> ,TRParens <$> parens tref
|
> [parens $ choice
|
||||||
> ,TRLateral <$> (try (keyword_ "lateral")
|
> [TRQueryExpr <$> queryExpr
|
||||||
|
> ,TRParens <$> tref]
|
||||||
|
> ,TRLateral <$> (keyword_ "lateral"
|
||||||
> *> nonJoinTref)
|
> *> nonJoinTref)
|
||||||
> ,try (TRFunction <$> name
|
> ,do
|
||||||
> <*> parens (commaSep valueExpr))
|
> n <- name
|
||||||
> ,try (TRQualified <$> name <*> (char '.' >> name))
|
> choice [TRFunction n
|
||||||
> ,TRSimple <$> name]
|
> <$> parens (commaSep valueExpr)
|
||||||
|
> ,do
|
||||||
|
> choice [TRQualified n <$> (symbol "." >> name)
|
||||||
|
> ,return $ TRSimple n]]]
|
||||||
> >>= optionSuffix aliasSuffix
|
> >>= optionSuffix aliasSuffix
|
||||||
> aliasSuffix j = option j (TRAlias j <$> alias)
|
> aliasSuffix j = option j (TRAlias j <$> alias)
|
||||||
> joinTrefSuffix t = (do
|
> joinTrefSuffix t = (do
|
||||||
|
@ -943,7 +948,7 @@ todo: work out the symbol parsing better
|
||||||
> >>= optionSuffix moreString)
|
> >>= optionSuffix moreString)
|
||||||
> <?> "string"
|
> <?> "string"
|
||||||
> where
|
> where
|
||||||
> moreString s0 = try $ choice
|
> moreString s0 = choice
|
||||||
> [-- handle two adjacent quotes
|
> [-- handle two adjacent quotes
|
||||||
> do
|
> do
|
||||||
> void $ char '\''
|
> void $ char '\''
|
||||||
|
@ -952,8 +957,7 @@ todo: work out the symbol parsing better
|
||||||
> ,-- handle string in separate parts
|
> ,-- handle string in separate parts
|
||||||
> -- e.g. 'part 1' 'part 2'
|
> -- e.g. 'part 1' 'part 2'
|
||||||
> do
|
> do
|
||||||
> whitespace
|
> try (whitespace <* char '\'')
|
||||||
> void $ char '\''
|
|
||||||
> s <- manyTill anyChar (char '\'')
|
> s <- manyTill anyChar (char '\'')
|
||||||
> optionSuffix moreString (s0 ++ s)
|
> optionSuffix moreString (s0 ++ s)
|
||||||
> ]
|
> ]
|
||||||
|
|
Loading…
Reference in a new issue