lpeg 1.0.1 → 1.0.2
raw patch · 7 files changed
+37/−29 lines, 7 filesdep ~lua
Dependency ranges changed: lua
Files
- CHANGELOG.md +15/−9
- LICENSE +1/−1
- README.md +1/−1
- lpeg.cabal +4/−3
- src/Lua/LPeg.hs +4/−3
- substitute/Lua/LPeg.hs +1/−1
- test/test-lpeg.hs +11/−11
CHANGELOG.md view
@@ -1,20 +1,26 @@ # Changelog -`lpeg` uses [PVP Versioning][1].+`lpeg` uses [PVP Versioning][]. -## lpeg 1.0.1+## lpeg-1.0.2 +Released 29-01-2022.++- Allow lua-2.1.0.++## lpeg-1.0.1+ Released 2021-11-08. - - The 're' package is a Lua script that's part of LPeg. It is now- included as a byte array in the C sources; a loader function for- this library is provided, and 're' is now handled by the lpeg- searcher.+- The ‘re’ package is a Lua script that’s part of LPeg. It is+ now included as a byte array in the C sources; a loader+ function for this library is provided, and ‘re’ is now handled+ by the lpeg searcher. -## lpeg 1.0.0+## lpeg-1.0.0 Released 2021-10-31. -- A wild package appears.+- A wild package appears. -[1]: https://pvp.haskell.org+ [PVP Versioning]: https://pvp.haskell.org
LICENSE view
@@ -1,5 +1,5 @@ Copyright © 2007-2019 Lua.org, PUC-Rio.-Copyright © 2021 Albert Krewinkel+Copyright © 2021-2022 Albert Krewinkel Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the
README.md view
@@ -6,7 +6,7 @@ [![Stackage Nightly][Stackage Nightly badge]](http://stackage.org/nightly/package/lpeg) [![MIT license][License badge]](LICENSE) -[CI badge]: https://github.com/hslua/hslua/workflows/CI/badge.svg+[CI badge]: https://img.shields.io/github/workflow/status/hslua/hslua/CI.svg?logo=github [Hackage badge]: https://img.shields.io/hackage/v/lpeg.svg?logo=haskell [Stackage Lts badge]: http://stackage.org/package/lpeg/badge/lts [Stackage Nightly badge]: http://stackage.org/package/lpeg/badge/nightly
lpeg.cabal view
@@ -1,6 +1,6 @@ cabal-version: 2.2 name: lpeg-version: 1.0.1+version: 1.0.2 synopsis: LPeg – Parsing Expression Grammars For Lua description: This package contains the C sources of LPeg, as well as some tiny Haskell helper to load the package.@@ -13,7 +13,7 @@ author: Albert Krewinkel maintainer: Albert Krewinkel <albert+hslua@zeitkraut.de> copyright: © 2007-2019 Lua.org, PUC-Rio;- © 2021 Albert Krewinkel+ © 2021-2022 Albert Krewinkel category: Foreign build-type: Simple extra-source-files: cbits/lpeg-1.0.2/*.h@@ -27,6 +27,7 @@ , GHC == 8.8.4 , GHC == 8.10.7 , GHC == 9.0.1+ , GHC == 9.2.1 source-repository head type: git@@ -44,7 +45,7 @@ common common-options default-language: Haskell2010 build-depends: base >= 4.8 && < 5- , lua >= 2.0 && < 2.1+ , lua >= 2.1 && < 2.2 ghc-options: -Wall -Wincomplete-record-updates -Wnoncanonical-monad-instances
src/Lua/LPeg.hs view
@@ -1,6 +1,6 @@ {-| Module : Lua.LPeg-Copyright : © 2021 Albert Krewinkel+Copyright : © 2021-2022 Albert Krewinkel License : MIT Maintainer : Albert Krewinkel <tarleb+hslua@zeitkraut.de> @@ -22,6 +22,7 @@ foreign import ccall unsafe "lptree.c &luaopen_lpeg" luaopen_lpeg_ptr :: CFunction +-- | Pointer to the function which loads the "re" library. foreign import ccall unsafe "&luaopen_re" luaopen_re_ptr :: CFunction @@ -38,6 +39,6 @@ cstrLen <- peek lenPtr pkg <- peekCStringLen (cstr, fromIntegral cstrLen) case pkg of- "lpeg" -> lua_pushcclosure l luaopen_lpeg_ptr 0- "re" -> lua_pushcclosure l luaopen_re_ptr 0+ "lpeg" -> lua_pushcfunction l luaopen_lpeg_ptr+ "re" -> lua_pushcfunction l luaopen_re_ptr _ -> lua_pushnil l
substitute/Lua/LPeg.hs view
@@ -1,6 +1,6 @@ {-| Module : Lua.LPeg-Copyright : © 2021 Albert Krewinkel+Copyright : © 2021-2022 Albert Krewinkel License : MIT Maintainer : Albert Krewinkel <tarleb+hslua@zeitkraut.de>
test/test-lpeg.hs view
@@ -2,7 +2,7 @@ {-# OPTIONS_GHC -Wno-warnings-deprecations #-} {-| Module : Main-Copyright : © 2021 Albert Krewinkel+Copyright : © 2021-2022 Albert Krewinkel License : MIT Maintainer : Albert Krewinkel <albert+hslua@zeitkraut.de> @@ -27,13 +27,13 @@ -- thing don't diverge. [ testCase "can push lpeg loader" $ do l <- hsluaL_newstate- lua_pushcclosure l luaopen_lpeg_ptr 0+ lua_pushcfunction l luaopen_lpeg_ptr assertEqual "loader should be a function" LUA_TFUNCTION =<< lua_type l (-1) lua_close l , testCase "can push re loader" $ do l <- hsluaL_newstate- lua_pushcclosure l luaopen_re_ptr 0+ lua_pushcfunction l luaopen_re_ptr assertEqual "loader should be a function" LUA_TFUNCTION =<< lua_type l (-1) lua_close l@@ -47,13 +47,13 @@ #ifndef RELY_ON_SYSTEM_INSTALL [ testCase "load lpeg library via CFunction" $ do l <- hsluaL_newstate- lua_pushcclosure l luaopen_lpeg_ptr 0+ lua_pushcfunction l luaopen_lpeg_ptr stts <- lua_pcall l 0 1 0 when (stts /= LUA_OK) $ fail =<< peekCString =<< lua_tolstring l (-1) nullPtr _ <- withCString "version" $ lua_pushstring l- lua_rawget l (-2)+ _ <- lua_rawget l (-2) assertEqual "module should have `version` field of type function" LUA_TFUNCTION =<< lua_type l (-1) lua_close l@@ -66,7 +66,7 @@ _ <- withCString "package" $ lua_getglobal l pushstring l "searchers" _ <- lua_gettable l (-2)- forM_ [1..4] $ \i -> lua_pushnil l *> lua_rawseti l (-2) i+ forM_ [1..4] $ \i -> lua_pushnil l <* lua_rawseti l (-2) i lua_pop l 2 -- ensure that lpeg cannot be found@@ -76,11 +76,11 @@ -- get table "_LOADED" from registry _ <- withCString loadedTableRegistryField $ lua_pushstring l- lua_rawget l LUA_REGISTRYINDEX+ _ <- lua_rawget l LUA_REGISTRYINDEX -- load lpeg _ <- withCString "lpeg" $ lua_pushstring l -- key- lua_pushcclosure l luaopen_lpeg_ptr 0+ lua_pushcfunction l luaopen_lpeg_ptr stts <- lua_pcall l 0 1 0 if stts == LUA_OK then lua_rawset l (-3)@@ -88,7 +88,7 @@ -- load re _ <- withCString "re" $ lua_pushstring l -- key- lua_pushcclosure l luaopen_re_ptr 0+ lua_pushcfunction l luaopen_re_ptr stts' <- lua_pcall l 0 1 0 if stts' == LUA_OK then lua_rawset l (-3)@@ -139,7 +139,7 @@ #else [ testCase "loading the lpeg placeholder library causes an error" $ do l <- hsluaL_newstate- lua_pushcclosure l luaopen_lpeg_ptr 0+ lua_pushcfunction l luaopen_lpeg_ptr stts <- lua_pcall l 0 1 0 stts `seq` lua_close l when (stts /= LUA_ERRRUN) $@@ -147,7 +147,7 @@ , testCase "loading the re placeholder library causes an error" $ do l <- hsluaL_newstate- lua_pushcclosure l luaopen_re_ptr 0+ lua_pushcfunction l luaopen_re_ptr stts <- lua_pcall l 0 1 0 stts `seq` lua_close l when (stts /= LUA_ERRRUN) $