1
Fork 0

move the megaparsec stream stuff to the lexer, restore the old lex return without source positions, add a new lex function that does return source positions

This commit is contained in:
Jake Wheat 2024-01-10 11:57:13 +00:00
parent e76aa2818b
commit de121d1fd6
4 changed files with 132 additions and 117 deletions
tools/Language/SQL/SimpleSQL

View file

@ -82,7 +82,7 @@ bootstrapTests = Group "bootstrap tests" $
] ++ map (\a -> (a, [Symbol a])) (
["!=", "<>", ">=", "<=", "||"]
++ map T.singleton ("(),-+*/<>=." :: String)))
++ map T.singleton ("(),-+*/<>=." :: [Char])))
ansiLexerTable :: [(Text,[Token])]

View file

@ -110,8 +110,7 @@ itemToTest (LexFails d s) = makeLexingFailsTest d s
makeLexerTest :: Dialect -> Text -> [Lex.Token] -> T.TestTree
makeLexerTest d s ts = H.testCase (T.unpack s) $ do
let lx = either (error . T.unpack . Lex.prettyError) id $ Lex.lexSQL d "" Nothing s
ts1 = map Lex.tokenVal lx
let ts1 = either (error . T.unpack . Lex.prettyError) id $ Lex.lexSQL d "" Nothing s
H.assertEqual "" ts ts1
let s' = Lex.prettyTokens d $ ts1
H.assertEqual "pretty print" s s'