-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
10,084 additions
and
471 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
PureLPeg, a pure Lua port of LPeg, Roberto Ierusalimschy's | ||
Parsing Expression Grammars library. | ||
|
||
Copyright (C) Pierre-Yves Gerardy. | ||
Released under the Romantif WTF Public License (cf. the LICENSE | ||
file or the end of this file, whichever is present). | ||
|
||
See http://www.inf.puc-rio.br/~roberto/lpeg/ for the original. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
The Romantic WTF public license. | ||
-------------------------------- | ||
a.k.a. version "<3" or simply v3 | ||
|
||
|
||
Dear user, | ||
|
||
The PureLPeg library | ||
|
||
\ | ||
'.,__ | ||
\ / | ||
'/,__ | ||
/ | ||
/ | ||
/ | ||
has been / released | ||
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | ||
under the Romantic WTF Public License. | ||
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~`,´ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | ||
I hereby grant you an irrevocable license to | ||
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | ||
do what the gentle caress you want to | ||
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ | ||
with this lovely | ||
~ ~ ~ ~ ~ ~ ~ ~ | ||
/ library... | ||
/ ~ ~ ~ ~ | ||
/ Love, | ||
# / ',' | ||
####### · | ||
##### | ||
### | ||
# | ||
|
||
-- Pierre-Yves | ||
|
||
|
||
|
||
P.S.: Even though I poured my heart into this work, | ||
I _cannot_ provide any warranty regarding | ||
its fitness for _any_ purpose. You | ||
acknowledge that I will not be held liable | ||
for any damage its use could incur. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#! /usr/bin/env bash | ||
|
||
lua -e'os.execute"cd src; lua ../pack.lua"' > purelpeg.lua |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
-- A Lua source file packer. | ||
-- released under the Romantic WTF Public License | ||
-- setmetatable( _G or _ENV, {__index = require"init" } ) | ||
|
||
args = {...} | ||
--[[]] pcall( require,"luarocks.loader" ) | ||
--[[]] fs = pcall( require,"lfs" ) | ||
files = {} | ||
|
||
fs = fs or { | ||
dir = function (path) | ||
local listing = io.popen ( "ls "..path ):read"*all" | ||
local files = {} | ||
for file in listing:gmatch( "[^\n]+" ) do | ||
files[file] = true | ||
end | ||
return next, files | ||
end, | ||
attributes = function() return{} end | ||
} | ||
|
||
root = "./" | ||
|
||
function pront(...) print("PRONT ", ...) return ... end | ||
|
||
function scandir (root) | ||
-- adapted from http://keplerproject.github.com/luafilesystem/examples.html | ||
path = path or "" | ||
for f in fs.dir( root ) do | ||
if f:find"%.lua$" then | ||
hndl = f:gsub( "%.lua$", "" ):gsub("^[/\\]","") | ||
:gsub( "/", "." ) | ||
:gsub( "\\", "." ) | ||
files[hndl] = io.open( root..f ):read"*a" | ||
end | ||
end | ||
end | ||
|
||
scandir( root ) | ||
|
||
acc={(io.open("../ABOUT"):read("*all").."\n"):gsub( "([^\n]-\n)","-- %1" ),[[ | ||
local module_name = ... | ||
local _ENV, error, loaded, packages, release, require_ | ||
= _ENV or _G, error or print, {}, {}, true, require | ||
local t_concat = require"table".concat | ||
local function require(...) | ||
local lib = ... | ||
-- is it a private file? | ||
if loaded[lib] then | ||
return loaded[lib] | ||
elseif packages[lib] then | ||
loaded[lib] = packages[lib](lib) | ||
return loaded[lib] | ||
else | ||
-- standard require. | ||
local success, lib = pcall(require_, lib) | ||
if success then return lib end | ||
-- -- error handling. | ||
-- local name, line, trace | ||
-- local success, d = pcall(require, "debug") | ||
-- if success then success, d = pcall (debug.getinfo, 2) end | ||
-- if success then | ||
-- line = d.currentline or "-1" | ||
-- name = ( d.name ~= "" ) and name | ||
-- or ( d.shortsrc ~= "" ) and d.shortsrc | ||
-- or "?" | ||
-- success, trace = pcall(d.traceback(1)) | ||
-- if not success then trace = "" end | ||
-- else | ||
-- line, name, trace = -1, "?", "" | ||
-- end | ||
-- print(t_concat( name, ":", line, ": module '", lib, "' not found:")) | ||
-- print(t_concat("\tno private field ", module_name,".packages['", | ||
-- lib,"']\n", trace)) | ||
-- error() | ||
end | ||
end | ||
]] | ||
} local wrapper = { [[ | ||
--============================================================================= | ||
do local _ENV = _ENV | ||
packages[']], nil, [['] = function (...) | ||
]], nil, [[ | ||
end | ||
end | ||
]] } | ||
-- local eol = "\n" + P(-1) | ||
-- local blank = P" "^0 * eol / "" | ||
-- local fullcomment = P" "^0 * "--" * (P(1)-eol)^0 * eol / "" | ||
-- local trailingspace = P" "^0 | ||
-- local trailingcomment = P" "^0 * "--" * (P(1)-eol)^0 | ||
-- local lineWspace = (1 - trailingspace * eol) ^ 1 * (trailingspace / "") * eol | ||
-- local lineWcomment = (1 - trailingcomment * eol) ^ 1 * (trailingcomment / "") * eol | ||
-- local strip = Cs((blank + fullcomment | ||
-- -- + lineWspace + lineWcomment | ||
-- )^0) | ||
|
||
for k,v in pairs( files ) do | ||
wrapper[2], wrapper[4] | ||
= k, v | ||
--:gsub("\n *\n","\n") -- strip blank lines and comments. | ||
-- :gsub("( *\-\-.-\n)","\n") -- and stray debug commands. | ||
-- :gsub("^( -\n)","") | ||
-- :gsub("^ *\-\-.*\n","") | ||
-- :gsub("\n *$","") | ||
-- :gsub("\n *\-\-.*$","") | ||
|
||
acc[#acc+1]= table.concat(wrapper) | ||
end | ||
|
||
acc[#acc + 1] = [[ | ||
return require"init" | ||
]] | ||
|
||
acc[#acc+1] = io.open("../LICENSE"):read("*all".."\n"):gsub("([^\n]-\n)","-- %1") | ||
|
||
print( table.concat( acc ) ) | ||
|
Oops, something went wrong.