Skip to content

Commit

Permalink
Bug fixes and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
pygy committed Jun 7, 2013
1 parent c015f2d commit ad33811
Show file tree
Hide file tree
Showing 24 changed files with 10,084 additions and 471 deletions.
8 changes: 8 additions & 0 deletions ABOUT
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.
45 changes: 45 additions & 0 deletions LICENSE
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.

3 changes: 3 additions & 0 deletions make.sh
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
125 changes: 125 additions & 0 deletions pack.lua
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 ) )

Loading

0 comments on commit ad33811

Please sign in to comment.