From 7f4fda7ce7f61e42bbdf168bd8fc3383d09906e8 Mon Sep 17 00:00:00 2001 From: Jake Wheat Date: Fri, 2 Feb 2024 17:20:20 +0000 Subject: [PATCH] fix error message quoting --- Language/SQL/SimpleSQL/Lex.hs | 11 ++++++++--- changelog | 4 ++-- simple-sql-parser.cabal | 10 ++-------- website/index.md | 6 +++--- website/render-test-cases.cabal | 2 +- 5 files changed, 16 insertions(+), 17 deletions(-) diff --git a/Language/SQL/SimpleSQL/Lex.hs b/Language/SQL/SimpleSQL/Lex.hs index e238f78..6af2a35 100644 --- a/Language/SQL/SimpleSQL/Lex.hs +++ b/Language/SQL/SimpleSQL/Lex.hs @@ -898,8 +898,9 @@ instance VisualStream SQLStream where tokensLength Proxy xs = sum (tokenLength <$> xs) instance TraversableStream SQLStream where - reachOffset o M.PosState {..} = - ( Just (prefix ++ restOfLine) + -- I have no idea what all this is doing + reachOffset o _x@(M.PosState {..}) = + ( Just $ actualLine , PosState { pstateInput = SQLStream { sqlStreamInput = postStr @@ -912,6 +913,11 @@ instance TraversableStream SQLStream where } ) where + maybeitsthefullsource = sqlStreamInput pstateInput + targetLineNo = M.unPos $ sourceLine newSourcePos + actualLine = case drop (targetLineNo - 1) $ lines maybeitsthefullsource of + (x:_) -> x + [] -> "" prefix = if sameLine then pstateLinePrefix ++ preLine @@ -930,7 +936,6 @@ instance TraversableStream SQLStream where case NE.nonEmpty pre of Nothing -> 0 Just nePre -> tokensLength pxy nePre - restOfLine = takeWhile (/= '\n') postStr pxy :: Proxy SQLStream pxy = Proxy diff --git a/changelog b/changelog index f58dfc8..5847169 100644 --- a/changelog +++ b/changelog @@ -1,5 +1,5 @@ -0.7.0 - support autoincrement for sqlite +0.7.1 fix error message source quoting +0.7.0 support autoincrement for sqlite support table constraints without separating comma for sqlite switch source from literate to regular haskell use prettyprinter lib instead of pretty diff --git a/simple-sql-parser.cabal b/simple-sql-parser.cabal index ce32c08..888235e 100644 --- a/simple-sql-parser.cabal +++ b/simple-sql-parser.cabal @@ -1,12 +1,10 @@ cabal-version: 2.2 name: simple-sql-parser -version: 0.7.0 +version: 0.7.1 synopsis: A parser for SQL. -description: - - A parser for SQL. Parses most SQL:2011 +description: A parser for SQL. Parses most SQL:2011 queries, non-query DML, DDL, access control and transaction management syntax. Please see the homepage for more information @@ -23,10 +21,6 @@ build-type: Simple extra-doc-files: README,LICENSE,changelog 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 Description: Build SimpleSQLParserTool exe Default: False diff --git a/website/index.md b/website/index.md index af37adc..a2705c1 100644 --- a/website/index.md +++ b/website/index.md @@ -212,10 +212,10 @@ make test 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 -isn't in ANSI SQL, guard it behind a dialect flag. If you write -support for a dialect that isn't mention, add a new dialect. +isn't in ANSI SQL, guard it behind a dialect flag. If you add +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 diff --git a/website/render-test-cases.cabal b/website/render-test-cases.cabal index 79d9a54..a8b7289 100644 --- a/website/render-test-cases.cabal +++ b/website/render-test-cases.cabal @@ -1,7 +1,7 @@ cabal-version: 2.2 name: simple-sql-parser -version: 0.7.0 +version: 0.7.1 executable RenderTestCases main-is: RenderTestCases.hs