mirror of
https://github.com/Reuh/candran.git
synced 2025-10-28 18:29:30 +00:00
Complete overhaul
- Changed name to Candran
- Do a real code parsing
* Removed lexer.lua
* Added LuaMinify
- Removed -- and ++ operators (see issue #2)
- Added decorators
- Preprocessor : renamed include to import and rawInclude to include
- Updated test.lua
- Updated table.lua
- Updated README.md
- Fixed tons of things
This commit is contained in:
parent
18d3acf648
commit
1875ea31de
36 changed files with 11601 additions and 1582 deletions
60
lib/LuaMinify/tests/test_beautifier.lua
Normal file
60
lib/LuaMinify/tests/test_beautifier.lua
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
-- Adapted from Yueliang
|
||||
|
||||
package.path = "../?.lua;" .. package.path
|
||||
local util = require'Util'
|
||||
local Parser = require'ParseLua'
|
||||
local Format = require'FormatBeautiful'
|
||||
|
||||
for w in io.lines("test_lines.txt") do
|
||||
--print(w)
|
||||
local success, ast = Parser.ParseLua(w)
|
||||
if w:find("FAIL") then
|
||||
--[[if success then
|
||||
print("ERROR PARSING LINE:")
|
||||
print("Should fail: true. Did fail: " .. tostring(not success))
|
||||
print("Line: " .. w)
|
||||
else
|
||||
--print("Suceeded!")
|
||||
end]]
|
||||
else
|
||||
if not success then
|
||||
print("ERROR PARSING LINE:")
|
||||
print("Should fail: false. Did fail: " .. tostring(not success))
|
||||
print("Line: " .. w)
|
||||
else
|
||||
success, ast = Format(ast)
|
||||
--print(success, ast)
|
||||
if not success then
|
||||
print("ERROR BEAUTIFYING LINE:")
|
||||
print("Message: " .. ast)
|
||||
print("Line: " .. w)
|
||||
end
|
||||
local success_ = success
|
||||
success, ast = loadstring(success)
|
||||
if not success then
|
||||
print("ERROR PARSING BEAUTIFIED LINE:")
|
||||
print("Message: " .. ast)
|
||||
print("Line: " .. success_)
|
||||
end
|
||||
--print("Suceeded!")
|
||||
end
|
||||
end
|
||||
end
|
||||
print"Done!"
|
||||
os.remove("tmp")
|
||||
|
||||
|
||||
--[[
|
||||
function readAll(file)
|
||||
local f = io.open(file, "rb")
|
||||
local content = f:read("*all")
|
||||
f:close()
|
||||
return content
|
||||
end
|
||||
|
||||
local text = readAll('../ParseLua.lua')
|
||||
local success, ast = Parser.ParseLua(text)
|
||||
local nice
|
||||
nice = Format(ast)
|
||||
print(nice)
|
||||
--]]
|
||||
Loading…
Add table
Add a link
Reference in a new issue