aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/testLua/yueliang-0.4.1/orig-5.0.3/test/test_lparser.lua
blob: b9400cc20f502f835f03b3cd6cacc5bc631911da (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
--[[--------------------------------------------------------------------

  test_lparser.lua
  Test for lparser.lua
  This file is part of Yueliang.

  Copyright (c) 2005 Kein-Hong Man <khman@users.sf.net>
  The COPYRIGHT file describes the conditions
  under which this software may be distributed.

  See the ChangeLog for more information.

----------------------------------------------------------------------]]

------------------------------------------------------------------------
-- test the whole kaboodle
------------------------------------------------------------------------

require("../lzio")
require("../llex")
require("../lopcodes")
require("../ldump")
require("../lcode")
require("../lparser")

function lua_assert(test)
  if not test then error("assertion failed!") end
end

luaX:init()

------------------------------------------------------------------------
-- try 1
------------------------------------------------------------------------

local zio = luaZ:init(luaZ:make_getS("local a = 1"), nil, "=string")
local LuaState = {}
local Func = luaY:parser(LuaState, zio, nil)

--[[
for i, v in Func do
  if type(v) == "string" or type(v) == "number" then
    print(i, v)
  elseif type(v) == "table" then
    print(i, "TABLE")
  end
end
--]]

local Writer, Buff = luaU:make_setF("parse1.out")
luaU:dump(LuaState, Func, Writer, Buff)

------------------------------------------------------------------------
-- try 2
------------------------------------------------------------------------

zio = luaZ:init(luaZ:make_getF("sample.lua"), nil, "@sample.lua")
Func = luaY:parser(LuaState, zio, nil)
Writer, Buff = luaU:make_setF("parse2.out")
luaU:dump(LuaState, Func, Writer, Buff)