1
Fork 0

fix error message quoting

This commit is contained in:
Jake Wheat 2024-02-02 17:20:20 +00:00
parent 1f51e630d3
commit 7f4fda7ce7
5 changed files with 16 additions and 17 deletions

View file

@ -898,8 +898,9 @@ instance VisualStream SQLStream where
tokensLength Proxy xs = sum (tokenLength <$> xs) tokensLength Proxy xs = sum (tokenLength <$> xs)
instance TraversableStream SQLStream where instance TraversableStream SQLStream where
reachOffset o M.PosState {..} = -- I have no idea what all this is doing
( Just (prefix ++ restOfLine) reachOffset o _x@(M.PosState {..}) =
( Just $ actualLine
, PosState , PosState
{ pstateInput = SQLStream { pstateInput = SQLStream
{ sqlStreamInput = postStr { sqlStreamInput = postStr
@ -912,6 +913,11 @@ instance TraversableStream SQLStream where
} }
) )
where where
maybeitsthefullsource = sqlStreamInput pstateInput
targetLineNo = M.unPos $ sourceLine newSourcePos
actualLine = case drop (targetLineNo - 1) $ lines maybeitsthefullsource of
(x:_) -> x
[] -> "<empty line>"
prefix = prefix =
if sameLine if sameLine
then pstateLinePrefix ++ preLine then pstateLinePrefix ++ preLine
@ -930,7 +936,6 @@ instance TraversableStream SQLStream where
case NE.nonEmpty pre of case NE.nonEmpty pre of
Nothing -> 0 Nothing -> 0
Just nePre -> tokensLength pxy nePre Just nePre -> tokensLength pxy nePre
restOfLine = takeWhile (/= '\n') postStr
pxy :: Proxy SQLStream pxy :: Proxy SQLStream
pxy = Proxy pxy = Proxy

View file

@ -1,5 +1,5 @@
0.7.0 0.7.1 fix error message source quoting
support autoincrement for sqlite 0.7.0 support autoincrement for sqlite
support table constraints without separating comma for sqlite support table constraints without separating comma for sqlite
switch source from literate to regular haskell switch source from literate to regular haskell
use prettyprinter lib instead of pretty use prettyprinter lib instead of pretty

View file

@ -1,12 +1,10 @@
cabal-version: 2.2 cabal-version: 2.2
name: simple-sql-parser name: simple-sql-parser
version: 0.7.0 version: 0.7.1
synopsis: A parser for SQL. synopsis: A parser for SQL.
description: description: A parser for SQL. Parses most SQL:2011
A parser for SQL. Parses most SQL:2011
queries, non-query DML, DDL, access control and queries, non-query DML, DDL, access control and
transaction management syntax. Please see the transaction management syntax. Please see the
homepage for more information homepage for more information
@ -23,10 +21,6 @@ build-type: Simple
extra-doc-files: README,LICENSE,changelog extra-doc-files: README,LICENSE,changelog
bug-reports: https://github.com/JakeWheat/simple-sql-parser/issues bug-reports: https://github.com/JakeWheat/simple-sql-parser/issues
source-repository head
type: git
location: https://github.com/JakeWheat/simple-sql-parser.git
Flag parserexe Flag parserexe
Description: Build SimpleSQLParserTool exe Description: Build SimpleSQLParserTool exe
Default: False Default: False

View file

@ -212,10 +212,10 @@ make test
When you add support for new syntax: add some tests. If you modify or When you add support for new syntax: add some tests. If you modify or
fix something, and it doesn't have tests, add some. If the syntax fix something, and it doesn't have tests, add some. If the syntax
isn't in ANSI SQL, guard it behind a dialect flag. If you write isn't in ANSI SQL, guard it behind a dialect flag. If you add
support for a dialect that isn't mention, add a new dialect. support for something from a new dialect, add that dialect.
Make sure all the tests still pass, then send a pull request on Github. Check all the tests still pass, then send a pull request on Github.
# Links # Links

View file

@ -1,7 +1,7 @@
cabal-version: 2.2 cabal-version: 2.2
name: simple-sql-parser name: simple-sql-parser
version: 0.7.0 version: 0.7.1
executable RenderTestCases executable RenderTestCases
main-is: RenderTestCases.hs main-is: RenderTestCases.hs