aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/README122
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/llex_mk2.lua309
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/llex_mk3.lua266
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/llex_mk4.lua285
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lparser_mk3.lua1027
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lparser_mk3b.lua1121
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lzio_mk2.lua106
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lzio_mk4.lua82
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk2.lua94
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk3.lua92
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk4.lua94
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_01.lua9
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_02.lua10
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_03.lua21
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_04.lua31
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_05.lua129
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_06.lua132
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_07.lua147
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_08.lua66
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_09.lua97
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_10.lua106
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_11.lua175
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_12.lua46
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_13.lua99
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_14.lua107
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_15.lua135
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_16.lua87
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_17.lua110
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_01.lua26
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_02.lua35
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_03.lua64
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_04.lua77
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_05.lua43
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_06.lua70
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_07.lua84
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_08.lua159
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_09.lua53
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_10.lua49
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_11.lua79
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_12.lua94
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_13.lua117
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_14.lua125
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/sample.lua3
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_llex_mk2.lua499
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_llex_mk3.lua500
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_llex_mk4.lua499
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3.lua218
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3_2.lua158
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3b.lua188
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3b_2.lua158
-rw-r--r--LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lzio_mk2.lua53
51 files changed, 0 insertions, 8456 deletions
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/README b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/README
deleted file mode 100644
index b6a65d2..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/README
+++ /dev/null
@@ -1,122 +0,0 @@
1nat-5.0.3
2
3This directory contains versions of front end files that are rewritten
4to be more "native" to Lua. These files should be considered as
5exercises in exploring ways to write the front end, for example, to
6write a front end that is optimized for size, etc. See also file size
7data further below.
8
9The following are the different versions available (mk2 == "mark 2",
10this is commonly used in the UK, e.g. for aeroplanes during WWII):
11
12Lexers
13------
14
15WARNING: Theses lexer may or may not exhibit exact behaviour when lexing
16strings or long strings with embedded CRLF newlines. The CRLF sequence
17may be translated into LF (the reference manual is unclear on this.) The
18user is advised to stick to LF line endings exclusively.
19
20llex_mk2 Rewritten from original ported code to become more
21 Lua-like. Still uses a stream-based input interface.
22 MK2 still scans using a per-character function that
23 is pretty inefficient.
24
25 Status: TESTED
26
27llex_mk3 A rewritten version of MK2 that needs input to be
28 entered as a single string. Unless an application's
29 need is very unusual, this should not be a problem.
30 It will not work for per-line interaction, though.
31 MK3 no longer needs stream input functions. This
32 version is also heavily optimized for size. MK3 scans
33 using find functions and doesn't create many strings.
34
35 Status: TESTED
36
37llex_mk4 A rewritten version of MK3 that is line-oriented.
38 This allows a command-line version that works in the
39 usual way to be written.
40
41 Status: TESTED
42
43The following is a comparison of file sizes (as of 20061111):
44
45 lzio llex TOTAL Speed (2)
46 (bytes) (bytes) (bytes) (KB/s)
47----------------------------------------------
48Binary (Mingw) 416 5312 5728 N/A
49----------------------------------------------
50(in orig-5.0.3:)
51----------------------------------------------
52normal 2219 12639 14585 404.9
53stripped 1292 7618 8910
54----------------------------------------------
55(in nat-5.0.3:)
56----------------------------------------------
57mk2 1995 7628 9623 469.5
58mk2-stripped 1195 4003 5298
59----------------------------------------------
60mk3 (1) - 6552 6552 1870.8
61mk3-stripped - 3286 3286
62----------------------------------------------
63mk4 1337 6956 8293 802.9
64mk4-stripped 798 3457 4225
65----------------------------------------------
66
67(1) mk3 does not have a file input streaming function
68
69(2) Speed was benchmarked using a Sempron 3000+. Benchmark scripts are
70in the test directories. Best of first three figures quoted. This is a
71measurement of raw lexer speed, i.e. tokens are read but no processing
72is done. All files are read in entirely before running the lexer.
73
74The performance of the orig-5.0.3 parser is probably a whole magnitude
75less than the orig-5.0.3 lexer performance.
76
77Parsers
78-------
79
80lparser_mk3 Written for the simplified lexer interface of llex_mk3+.
81 (Should be compatible with llex_mk4 too, but untested.)
82 This is a lexer skeleton, stripped of codegen code. See
83 the comments in the source code for more information.
84 Without logging messages and comments, it's under 600 LOC.
85
86 Sample output of the parser message logger can be found
87 in the test/parser_log subdirectory.
88
89 Tested with test_parser-5.0.lua, the Lua 5.0.x parser test
90 cases in the test_lua/ directory, appears to be fine.
91
92 Status: SNIPPETS APPEAR TO WORK
93
94lparser_mk3b As above, with variable management code added. In order
95 to use the parser usefully, variable management code is
96 a big step forward, allowing the parser to differentiate
97 locals, upvalues and globals. The number of added lines
98 is around 100 LOC. A binary chunk of lparser_mk3b
99 (stripped) is 18076 bytes.
100
101 Sample output of the parser message logger can be found
102 in the test/parser_log subdirectory.
103
104 Tested with test_parser-5.0.lua, the Lua 5.0.x parser test
105 cases in the test_lua/ directory, appears to be fine.
106
107 Status: SNIPPETS APPEAR TO WORK
108
109There will be no further development beyond lparser_mk3b. Further work
110will focus on a 5.1.x equivalent, for which both a parser skeleton and a
111parser with full code generation using nicely commented code is planned.
112
113Other notes:
114------------
115
116For Lua 5.0.2, see Yueliang 0.1.3, which was the last release of Lua
1175.0.2 material.
118
119Test scripts for the lexer should probably be consolidated, but it's a
120little difficult because not all lexers give the same error messages or
121use the same token names or format.
122
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/llex_mk2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/llex_mk2.lua
deleted file mode 100644
index 955f229..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/llex_mk2.lua
+++ /dev/null
@@ -1,309 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 llex.lua
4 Lua 5 lexical analyzer in Lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2005-2006 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15--[[--------------------------------------------------------------------
16-- Notes:
17-- * parser to implement luaX_syntaxerror, call errorline with 2 parms
18----------------------------------------------------------------------]]
19
20--[[--------------------------------------------------------------------
21-- local lex_init = require("llex.lua")
22-- local llex = lex_init(z, source)
23-- llex:chunkid()
24-- * returns formatted name of chunk id
25-- llex:errorline(s, token, line)
26-- * throws an error with a formatted message
27-- llex:lex()
28-- * returns next lexical element (token, seminfo)
29----------------------------------------------------------------------]]
30
31return
32function(z, source)
33--[[--------------------------------------------------------------------
34-- lexer initialization
35----------------------------------------------------------------------]]
36 --------------------------------------------------------------------
37 -- initialize variables
38 --------------------------------------------------------------------
39 local string = string
40 local EOF = "<eof>"
41 local z = z
42 local luaX = {source = source, lineno = 1,}
43 local curr, buff
44 --------------------------------------------------------------------
45 -- initialize keyword list
46 --------------------------------------------------------------------
47 local kw = {}
48 for v in string.gfind([[
49and break do else elseif end false for function if in
50local nil not or repeat return then true until while]], "%S+") do
51 kw[v] = true
52 end
53--[[--------------------------------------------------------------------
54-- support functions
55----------------------------------------------------------------------]]
56 --------------------------------------------------------------------
57 -- returns a chunk name or id
58 --------------------------------------------------------------------
59 function luaX:chunkid()
60 local sub = string.sub
61 local first = sub(source, 1, 1)
62 if first == "=" or first == "@" then
63 return sub(source, 2) -- remove first char
64 end
65 return "[string]"
66 end
67 --------------------------------------------------------------------
68 -- formats error message and throws error
69 --------------------------------------------------------------------
70 function luaX:errorline(s, token, line)
71 if not line then line = self.lineno end
72 error(string.format("%s:%d: %s near '%s'", self:chunkid(), line, s, token))
73 end
74 --------------------------------------------------------------------
75 -- throws a lexer error
76 --------------------------------------------------------------------
77 local function lexerror(s, token)
78 if not token then token = buff end
79 luaX:errorline(s, token)
80 end
81 --------------------------------------------------------------------
82 -- gets the next character and returns it
83 --------------------------------------------------------------------
84 local function nextc()
85 local c = z:getc()
86 curr = c
87 return c
88 end
89 --------------------------------------------------------------------
90 -- save current character into token buffer, grabs next character
91 -- * save(c) merged into this and elsewhere to save space
92 --------------------------------------------------------------------
93 local function save_next()
94 buff = buff..curr
95 return nextc()
96 end
97 --------------------------------------------------------------------
98 -- move on to next line
99 --------------------------------------------------------------------
100 local function nextline()
101 local luaX = luaX
102 nextc() -- skip '\n'
103 luaX.lineno = luaX.lineno + 1
104 end
105--[[--------------------------------------------------------------------
106-- reads a number (LUA_NUMBER)
107----------------------------------------------------------------------]]
108 local function read_numeral(comma)
109 buff = ""
110 local find = string.find
111 if comma then buff = "." end
112 ------------------------------------------------------------------
113 while find(curr, "%d") do save_next() end
114 if curr == "." then
115 if save_next() == "." then
116 save_next()
117 lexerror("ambiguous syntax (dots follows digits)")
118 end
119 end
120 ------------------------------------------------------------------
121 while find(curr, "%d") do save_next() end
122 if find(curr, "^[eE]$") then
123 save_next() -- read 'E' and optional exponent sign
124 if find(curr, "^[+-]$") then save_next() end
125 while find(curr, "%d") do save_next() end
126 end
127 c = tonumber(buff)
128 if c then return c end
129 lexerror("malformed number")
130 end
131--[[--------------------------------------------------------------------
132-- reads a long string or long comment
133----------------------------------------------------------------------]]
134 local function read_long(is_str)
135 local cont = 0
136 buff = ""
137 nextc() -- pass the '[['
138 if curr == "\n" then -- string starts with a newline?
139 nextline() -- skip it
140 end
141 while true do
142 local c = curr
143 ----------------------------------------------------------------
144 if c == "EOZ" then
145 lexerror(is_str and "unfinished long string" or
146 "unfinished long comment", EOF)
147 ----------------------------------------------------------------
148 elseif c == "[" then
149 if save_next() == "[" then
150 cont = cont + 1; save_next()
151 end
152 ----------------------------------------------------------------
153 elseif c == "]" then
154 if save_next() == "]" then
155 if cont == 0 then break end
156 cont = cont - 1; save_next()
157 end
158 ----------------------------------------------------------------
159 elseif c == "\n" then
160 buff = buff.."\n"; nextline()
161 if not is_str then buff = "" end -- avoid wasting space
162 ----------------------------------------------------------------
163 else
164 save_next()
165 ----------------------------------------------------------------
166 end--if c
167 end--while
168 nextc() -- skip second ']'
169 return string.sub(buff, 1, -2)
170 end
171--[[--------------------------------------------------------------------
172-- reads a string
173----------------------------------------------------------------------]]
174 local function read_string(del)
175 local find = string.find
176 buff = ""
177 save_next() -- save delimiter
178 while curr ~= del do
179 local c = curr
180 ----------------------------------------------------------------
181 -- end-of-file, newline
182 ----------------------------------------------------------------
183 if c == "EOZ" then
184 lexerror("unfinished string", EOF)
185 elseif c == "\n" then
186 lexerror("unfinished string")
187 ----------------------------------------------------------------
188 -- escapes
189 ----------------------------------------------------------------
190 elseif c == "\\" then
191 c = nextc() -- do not save the '\'
192 if c ~= "EOZ" then -- will raise an error next loop iteration
193 local d = find("\nabfnrtv", c, 1, 1)
194 if d then
195 buff = buff..string.sub("\n\a\b\f\n\r\t\v", d, d)
196 if d == 1 then nextline() else nextc() end
197 elseif find(c, "%D") then
198 save_next() -- handles \\, \", \', and \?
199 else -- \xxx
200 c, d = 0, 0
201 repeat
202 c = 10 * c + curr; d = d + 1; nextc()
203 until d >= 3 or find(curr, "%D")
204 if c > 255 then -- UCHAR_MAX
205 lexerror("escape sequence too large")
206 end
207 buff = buff..string.char(c)
208 end
209 end
210 ----------------------------------------------------------------
211 -- a regular character
212 ----------------------------------------------------------------
213 else
214 save_next()
215 ----------------------------------------------------------------
216 end--if c
217 end--while
218 nextc() -- skip delimiter
219 return string.sub(buff, 2)
220 end
221--[[--------------------------------------------------------------------
222-- main lexer function
223----------------------------------------------------------------------]]
224 function luaX:lex()
225 local find = string.find
226 while true do
227 local c = curr
228 ----------------------------------------------------------------
229 -- operators, numbers
230 ----------------------------------------------------------------
231 local d = find("=<>~\"'-[.\n", c, 1, 1)
232 if d then
233 ------------------------------------------------------------
234 if d <= 4 then -- "=<>~" (relational operators)
235 if nextc() ~= "=" then return c end
236 nextc(); return c.."="
237 ------------------------------------------------------------
238 elseif d <= 6 then -- "\"" or "'" (string)
239 return "<string>", read_string(c)
240 ------------------------------------------------------------
241 elseif c == "-" then -- "-" ("-", comment, or long comment)
242 if nextc() ~= "-" then return "-" end
243 c = nextc() -- otherwise it is a comment
244 if c == "[" and nextc() == "[" then
245 read_long() -- long comment
246 else -- short comment
247 while c ~= "\n" and c ~= "EOZ" do c = nextc() end
248 end
249 ------------------------------------------------------------
250 elseif c == "[" then -- "[" ("[" or long string)
251 if nextc() ~= "[" then return c end
252 return "<string>", read_long(true)
253 ------------------------------------------------------------
254 elseif c == "." then -- "." (".", concatenation, or dots)
255 buff = ""
256 c = save_next()
257 if c == "." then -- interpret 2 or 3 dots
258 if save_next() == "." then save_next() end
259 return buff
260 end
261 if find(c, "%d") then
262 return "<number>", read_numeral(true)
263 end
264 return "."
265 ------------------------------------------------------------
266 else-- c == "\n" then -- "\n" (newline)
267 nextline()
268 ------------------------------------------------------------
269 end--if d/c
270 ----------------------------------------------------------------
271 -- number, end-of-file, identifier or reserved word
272 ----------------------------------------------------------------
273 elseif find(c, "%d") then -- number
274 return "<number>", read_numeral(false)
275 ----------------------------------------------------------------
276 elseif find(c, "[_%a]") then -- reads a name
277 if c == "EOZ" then return EOF end -- end-of-file
278 buff = ""
279 repeat
280 c = save_next()
281 until c == "EOZ" or find(c, "[^_%w]")
282 c = buff
283 if kw[c] then return c end -- reserved word
284 return "<name>", c
285 ----------------------------------------------------------------
286 -- whitespace, other characters, control characters
287 ----------------------------------------------------------------
288 elseif find(c, "%s") then -- whitespace
289 nextc()
290 ----------------------------------------------------------------
291 elseif find(c, "%c") then -- control characters
292 lexerror("invalid control char", "char("..string.byte(c)..")")
293 ----------------------------------------------------------------
294 else -- single-char tokens (+ - / etc.)
295 nextc(); return c
296 ----------------------------------------------------------------
297 end--if d/c
298 end--while
299 end
300--[[--------------------------------------------------------------------
301-- initial processing (shbang handling)
302----------------------------------------------------------------------]]
303 nextc() -- read first char
304 if cur == "#" then -- skip first line
305 repeat nextc() until curr == "\n" or curr == "EOZ"
306 end
307 return luaX
308--[[------------------------------------------------------------------]]
309end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/llex_mk3.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/llex_mk3.lua
deleted file mode 100644
index 1cd22b5..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/llex_mk3.lua
+++ /dev/null
@@ -1,266 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 llex.lua
4 Lua 5 lexical analyzer in Lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15--[[--------------------------------------------------------------------
16-- Notes:
17-- * takes in the entire source at once
18-- * code is heavily optimized for size
19--
20-- local lex_init = require("llex.lua")
21-- local llex = lex_init(z, source)
22-- llex:chunkid()
23-- * returns formatted name of chunk id
24-- llex:errorline(s, line)
25-- * throws an error with a formatted message
26-- llex:lex()
27-- * returns next lexical element (token, seminfo)
28-- llex.ln
29-- * line number
30----------------------------------------------------------------------]]
31
32return
33function(z, source)
34 --------------------------------------------------------------------
35 -- initialize variables
36 -- * I is the upvalue, i is the local version for space/efficiency
37 --------------------------------------------------------------------
38 local string = string
39 local find, sub = string.find, string.sub
40 local EOF = "<eof>"
41 local luaX = { ln = 1 }
42 local I = 1
43 --------------------------------------------------------------------
44 -- initialize keyword list
45 --------------------------------------------------------------------
46 local kw = {}
47 for v in string.gfind([[
48and break do else elseif end false for function if in
49local nil not or repeat return then true until while]], "%S+") do
50 kw[v] = true
51 end
52 --------------------------------------------------------------------
53 -- returns a chunk name or id
54 --------------------------------------------------------------------
55 function luaX:chunkid()
56 if find(source, "^[=@]") then
57 return sub(source, 2) -- remove first char
58 end
59 return "[string]"
60 end
61 --------------------------------------------------------------------
62 -- formats error message and throws error
63 -- * a simplified version, does not report what token was responsible
64 --------------------------------------------------------------------
65 function luaX:errorline(s, line)
66 error(string.format("%s:%d: %s", self:chunkid(), line or self.ln, s))
67 end
68 ----------------------------------------------------------------------
69 -- reads a long string or long comment
70 ----------------------------------------------------------------------
71 local function read_long(i, is_str)
72 local luaX = luaX
73 local string = string
74 local cont = 1
75 if sub(z, i, i) == "\n" then
76 i = i + 1
77 luaX.ln = luaX.ln + 1
78 end
79 local j = i
80 while true do
81 local p, q, r = find(z, "([\n%[%]])", i) -- (long range)
82 if not p then
83 luaX:errorline(is_str and "unfinished long string" or
84 "unfinished long comment")
85 end
86 i = p + 1
87 if r == "\n" then
88 luaX.ln = luaX.ln + 1
89 elseif sub(z, i, i) == r then -- only [[ or ]]
90 i = i + 1
91 if r == "[" then
92 cont = cont + 1
93 else-- r == "]" then
94 if cont == 1 then break end -- last ]] found
95 cont = cont - 1
96 end
97 end
98 end--while
99 I = i
100 return sub(z, j, i - 3)
101 end
102 ----------------------------------------------------------------------
103 -- reads a string
104 ----------------------------------------------------------------------
105 local function read_string(i, del)
106 local luaX = luaX
107 local string = string
108 local buff = ""
109 while true do
110 local p, q, r = find(z, "([\n\\\"\'])", i) -- (long range)
111 if p then
112 if r == "\n" then
113 luaX:errorline("unfinished string")
114 end
115 buff = buff..sub(z, i, p - 1) -- normal portions
116 i = p
117 if r == "\\" then -- handle escapes
118 i = i + 1
119 r = sub(z, i, i)
120 if r == "" then break end -- (error)
121 p = find("\nabfnrtv", r, 1, 1)
122 ------------------------------------------------------
123 if p then -- special escapes
124 r = sub("\n\a\b\f\n\r\t\v", p, p)
125 if p == 1 then luaX.ln = luaX.ln + 1 end
126 i = i + 1
127 ------------------------------------------------------
128 elseif find(r, "%D") then -- other non-digits
129 i = i + 1
130 ------------------------------------------------------
131 else -- \xxx sequence
132 local p, q, s = find(z, "^(%d%d?%d?)", i)
133 i = q + 1
134 if s + 1 > 256 then -- UCHAR_MAX
135 luaX:errorline("escape sequence too large")
136 end
137 r = string.char(s)
138 ------------------------------------------------------
139 end--if p
140 else
141 i = i + 1
142 if r == del then
143 I = i
144 return buff -- ending delimiter
145 end
146 end--if r
147 buff = buff..r
148 else
149 break -- (error)
150 end--if p
151 end--while
152 luaX:errorline("unfinished string")
153 end
154 ----------------------------------------------------------------------
155 -- main lexer function
156 ----------------------------------------------------------------------
157 function luaX:lex()
158 local string = string
159 local find, len = find, string.len
160 while true do--outer
161 local i = I
162 -- inner loop allows break to be used to nicely section tests
163 while true do--inner
164 ----------------------------------------------------------------
165 local p, _, r = find(z, "^([_%a][_%w]*)", i)
166 if p then
167 I = i + len(r)
168 if kw[r] then return r end -- keyword
169 return "<name>", r -- identifier
170 end
171 ----------------------------------------------------------------
172 local p, q, r = find(z, "^(%.?)%d", i)
173 if p then -- numeral
174 if r == "." then i = i + 1 end
175 local _, n, r, s = find(z, "^%d*(%.?%.?)%d*([eE]?)", i)
176 q = n
177 i = q + 1
178 if len(r) == 2 then
179 self:errorline("ambiguous syntax (dots follows digits)")
180 end
181 if len(s) == 1 then -- optional exponent
182 local _, n = find(z, "^[%+%-]?%d*", i) -- optional sign
183 q = n
184 i = q + 1
185 end
186 r = tonumber(sub(z, p, q))
187 I = i
188 if not r then self:errorline("malformed number") end
189 return "<number>", r
190 end
191 ----------------------------------------------------------------
192 local p, q, r = find(z, "^(%s)[ \t]*", i)
193 if p then
194 if r == "\n" then -- newline
195 self.ln = self.ln + 1
196 I = i + 1
197 else
198 I = q + 1 -- whitespace
199 end
200 break -- (continue)
201 end
202 ----------------------------------------------------------------
203 local p, _, r = find(z, "^(%p)", i) -- symbols/punctuation
204 if p then
205 local q = find("-[\"\'.=<>~", r, 1, 1)
206 if q then -- further processing for more complex symbols
207 ----------------------------------------------------
208 if q <= 2 then
209 if q == 1 then -- minus
210 if find(z, "^%-%-", i) then
211 i = i + 2
212 if find(z, "^%[%[", i) then -- long comment
213 read_long(i + 2)
214 else -- short comment
215 I = find(z, "\n", i) or (len(z) + 1)
216 end
217 break -- (continue)
218 end
219 -- (fall through for "-")
220 elseif q == 2 then -- [ or long string
221 if find(z, "^%[%[", i) then
222 return "<string>", read_long(i + 2, true)
223 end
224 -- (fall through for "[")
225 end
226 ----------------------------------------------------
227 elseif q <= 5 then
228 if q < 5 then -- strings
229 return "<string>", read_string(i + 1, r)
230 end
231 local _, _, s = find(z, "^(%.%.?%.?)", i) -- dots
232 r = s
233 -- (fall through)
234 ----------------------------------------------------
235 else -- relational/logic
236 local _, _, s = find(z, "^(%p=?)", i)
237 r = s
238 -- (fall through)
239 end
240 end
241 I = i + len(r); return r -- for other symbols, fall through
242 end
243 ----------------------------------------------------------------
244 local r = sub(z, i, i)
245 if r ~= "" then
246 if find(r, "%c") then -- invalid control char
247 self:errorline("invalid control char("..string.byte(r)..")")
248 end
249 I = i + 1; return r -- other single-char tokens
250 end
251 return EOF -- end of stream
252 ----------------------------------------------------------------
253 end--while inner
254 end--while outer
255 end
256 --------------------------------------------------------------------
257 -- initial processing (shbang handling)
258 --------------------------------------------------------------------
259 local p, q, r = find(z, "^#[^\n]*(\n?)")
260 if p then -- skip first line
261 I = q + 1
262 if r == "\n" then luaX.ln = luaX.ln + 1 end
263 end
264 return luaX
265 --------------------------------------------------------------------
266end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/llex_mk4.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/llex_mk4.lua
deleted file mode 100644
index 42559a3..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/llex_mk4.lua
+++ /dev/null
@@ -1,285 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 llex.lua
4 Lua 5 lexical analyzer in Lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15--[[--------------------------------------------------------------------
16-- Notes:
17-- * a line-oriented version of mk3
18--
19-- local lex_init = require("llex.lua")
20-- local llex = lex_init(z, source)
21-- llex:chunkid()
22-- * returns formatted name of chunk id
23-- llex:errorline(s, line)
24-- * throws an error with a formatted message
25-- llex:lex()
26-- * returns next lexical element (token, seminfo)
27-- llex.ln
28-- * line number
29----------------------------------------------------------------------]]
30
31return
32function(zio, source)
33 --------------------------------------------------------------------
34 -- initialize variables
35 -- * I is the upvalue, i is the local version for space/efficiency
36 --------------------------------------------------------------------
37 local string = string
38 local find, sub = string.find, string.sub
39 local EOF = "<eof>"
40 local luaX = { ln = 0 }
41 local I, z
42 --------------------------------------------------------------------
43 -- initialize keyword list
44 --------------------------------------------------------------------
45 local kw = {}
46 for v in string.gfind([[
47and break do else elseif end false for function if in
48local nil not or repeat return then true until while]], "%S+") do
49 kw[v] = true
50 end
51 --------------------------------------------------------------------
52 -- returns a chunk name or id
53 --------------------------------------------------------------------
54 function luaX:chunkid()
55 if find(source, "^[=@]") then
56 return sub(source, 2) -- remove first char
57 end
58 return "[string]"
59 end
60 --------------------------------------------------------------------
61 -- formats error message and throws error
62 -- * a simplified version, does not report what token was responsible
63 --------------------------------------------------------------------
64 function luaX:errorline(s, line)
65 error(string.format("%s:%d: %s", self:chunkid(), line or self.ln, s))
66 end
67 --------------------------------------------------------------------
68 -- move on to next line
69 --------------------------------------------------------------------
70 local function nextln()
71 local luaX = luaX
72 luaX.ln = luaX.ln + 1
73 z = zio:getln()
74 I = 1
75 end
76 ----------------------------------------------------------------------
77 -- reads a long string or long comment
78 ----------------------------------------------------------------------
79 local function read_long(i, is_str)
80 local luaX = luaX
81 local string = string
82 local buff = ""
83 local cont = 1
84 if sub(z, i, i) == "\n" then
85 nextln(); i = 1
86 end
87 while true do
88 local p, q, r = find(z, "([\n%[%]])", i) -- (long range)
89 if not p then
90 luaX:errorline(is_str and "unfinished long string" or
91 "unfinished long comment")
92 end
93 buff = buff..string.sub(z, i, p - 1) -- add a portion
94 i = p + 1
95 if sub(z, i, i) == r then -- only [[ or ]]
96 i = i + 1
97 if r == "[" then
98 cont = cont + 1
99 else-- r == "]" then
100 if cont == 1 then break end -- last ]] found
101 cont = cont - 1
102 end
103 buff = buff..r..r
104 else -- [ or ] or \n
105 buff = buff..r
106 if r == "\n" then
107 nextln(); i = 1
108 end
109 end
110 end--while
111 I = i
112 return buff
113 end
114 ----------------------------------------------------------------------
115 -- reads a string
116 ----------------------------------------------------------------------
117 local function read_string(i, del)
118 local luaX = luaX
119 local string = string
120 local buff = ""
121 while true do
122 local p, q, r = find(z, "([\n\\\"\'])", i) -- (long range)
123 if p then
124 if r == "\n" then
125 luaX:errorline("unfinished string")
126 end
127 buff = buff..sub(z, i, p - 1) -- normal portions
128 i = p
129 if r == "\\" then -- handle escapes
130 i = i + 1
131 r = sub(z, i, i)
132 if r == "" then break end -- (error)
133 p = find("\nabfnrtv", r, 1, 1)
134 ------------------------------------------------------
135 if p then -- special escapes
136 r = sub("\n\a\b\f\n\r\t\v", p, p)
137 if p == 1 then
138 nextln(); i = 1
139 else
140 i = i + 1
141 end
142 ------------------------------------------------------
143 elseif find(r, "%D") then -- other non-digits
144 i = i + 1
145 ------------------------------------------------------
146 else -- \xxx sequence
147 local p, q, s = find(z, "^(%d%d?%d?)", i)
148 i = q + 1
149 if s + 1 > 256 then -- UCHAR_MAX
150 luaX:errorline("escape sequence too large")
151 end
152 r = string.char(s)
153 ------------------------------------------------------
154 end--if p
155 else
156 i = i + 1
157 if r == del then
158 I = i
159 return buff -- ending delimiter
160 end
161 end--if r
162 buff = buff..r
163 else
164 break -- (error)
165 end--if p
166 end--while
167 luaX:errorline("unfinished string")
168 end
169 ----------------------------------------------------------------------
170 -- main lexer function
171 ----------------------------------------------------------------------
172 function luaX:lex()
173 local string = string
174 local find, len = find, string.len
175 while true do--outer
176 local i = I
177 -- inner loop allows break to be used to nicely section tests
178 while true do--inner
179 ----------------------------------------------------------------
180 local p, _, r = find(z, "^([_%a][_%w]*)", i)
181 if p then
182 I = i + len(r)
183 if kw[r] then return r end -- keyword
184 return "<name>", r -- identifier
185 end
186 ----------------------------------------------------------------
187 local p, q, r = find(z, "^(%.?)%d", i)
188 if p then -- numeral
189 if r == "." then i = i + 1 end
190 local _, n, r, s = find(z, "^%d*(%.?%.?)%d*([eE]?)", i)
191 q = n
192 i = q + 1
193 if len(r) == 2 then
194 self:errorline("ambiguous syntax (dots follows digits)")
195 end
196 if len(s) == 1 then -- optional exponent
197 local _, n = find(z, "^[%+%-]?%d*", i) -- optional sign
198 q = n
199 i = q + 1
200 end
201 r = tonumber(sub(z, p, q))
202 I = i
203 if not r then self:errorline("malformed number") end
204 return "<number>", r
205 end
206 ----------------------------------------------------------------
207 local p, q, r = find(z, "^(%s)[ \t]*", i)
208 if p then
209 if r == "\n" then -- newline
210 nextln()
211 else
212 I = q + 1 -- whitespace
213 end
214 break -- (continue)
215 end
216 ----------------------------------------------------------------
217 local p, _, r = find(z, "^(%p)", i) -- symbols/punctuation
218 if p then
219 local q = find("-[\"\'.=<>~", r, 1, 1)
220 if q then -- further processing for more complex symbols
221 ----------------------------------------------------
222 if q <= 2 then
223 if q == 1 then -- minus
224 if find(z, "^%-%-", i) then
225 i = i + 2
226 if find(z, "^%[%[", i) then -- long comment
227 read_long(i + 2)
228 else -- short comment
229 if find(z, "\n", i) then
230 nextln()
231 else
232 I = len(z) + 1
233 end
234 end
235 break -- (continue)
236 end
237 -- (fall through for "-")
238 elseif q == 2 then -- [ or long string
239 if find(z, "^%[%[", i) then
240 return "<string>", read_long(i + 2, true)
241 end
242 -- (fall through for "[")
243 end
244 ----------------------------------------------------
245 elseif q <= 5 then
246 if q < 5 then -- strings
247 return "<string>", read_string(i + 1, r)
248 end
249 local _, _, s = find(z, "^(%.%.?%.?)", i) -- dots
250 r = s
251 -- (fall through)
252 ----------------------------------------------------
253 else -- relational/logic
254 local _, _, s = find(z, "^(%p=?)", i)
255 r = s
256 -- (fall through)
257 end
258 end
259 I = i + len(r); return r -- for other symbols, fall through
260 end
261 ----------------------------------------------------------------
262 local r = sub(z, i, i)
263 if r ~= "" then
264 if find(r, "%c") then -- invalid control char
265 self:errorline("invalid control char("..string.byte(r)..")")
266 end
267 I = i + 1; return r -- other single-char tokens
268 end
269 return EOF -- end of stream
270 ----------------------------------------------------------------
271 end--while inner
272 end--while outer
273 end
274 --------------------------------------------------------------------
275 -- initial processing (shbang handling)
276 --------------------------------------------------------------------
277 nextln()
278 local p, q, r = find(z, "^#[^\n]*(\n?)")
279 if p then -- skip first line
280 I = q + 1
281 if r == "\n" then nextln() end
282 end
283 return luaX
284 --------------------------------------------------------------------
285end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lparser_mk3.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lparser_mk3.lua
deleted file mode 100644
index 17d6f64..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lparser_mk3.lua
+++ /dev/null
@@ -1,1027 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 lparser.lua
4 Lua 5 parser in Lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2008 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15--[[--------------------------------------------------------------------
16-- Notes:
17-- * this is a Lua 5.0.x parser skeleton, for llex_mk3.lua lexer
18-- * written as a module factory with recognizable lparser.c roots
19-- * builds some data, performs logging for educational purposes
20-- * target is to have relatively efficient and clear code
21-- * needs one parameter, a lexer module that implements:
22-- luaX:lex() - returns appropriate [token, semantic info] pairs
23-- luaX.ln - current line number
24-- luaX:errorline(s, [line]) - dies with error message
25--
26-- Usage example:
27-- lex_init = require("llex_mk3.lua")
28-- parser_init = require("lparser_mk3.lua")
29-- local luaX = lex_init(chunk, "=string")
30-- local luaY = parser_init(luaX)
31-- local fs = luaY:parser()
32--
33-- Development notes:
34-- * see test_parser-5.0.lua for grammar elements based on lparser.c
35-- * lparser has a few extra items to help parsing/syntax checking
36-- (a) line number (error reporting), lookahead token storage
37-- (b) per-prototype states needs a storage list
38-- (c) 'break' needs a per-block flag in a stack
39-- (d) 'kind' (v.k) testing needed in expr_stat() and assignment()
40-- for disambiguation, thus v.k manipulation is retained
41-- (e) one line # var (lastln) for ambiguous (split line) function
42-- call checking
43-- (f) most line number function call args retained for future use
44-- (g) Lua 4 compatibility code completely removed
45-- (h) no variable management code! singlevar() always returns VLOCAL
46-- * parsing starts from the end of this file in luaY:parser()
47--
48----------------------------------------------------------------------]]
49
50return
51function(luaX)
52--[[--------------------------------------------------------------------
53-- structures and data initialization
54----------------------------------------------------------------------]]
55
56 local line -- start line # for error messages
57 local lastln -- last line # for ambiguous syntax chk
58 local tok, seminfo -- token, semantic info pair
59 local peek_tok, peek_sem -- ditto, for lookahead
60 local fs -- function state
61 local top_fs = {} -- top-level function state
62 local luaY = {}
63 --------------------------------------------------------------------
64 local block_follow = {} -- lookahead check in chunk(), returnstat()
65 for v in string.gfind("else elseif end until <eof>", "%S+") do
66 block_follow[v] = true
67 end
68 --------------------------------------------------------------------
69 local stat_call = {} -- lookup for calls in stat()
70 for v in string.gfind("if while do for repeat function local return break", "%S+") do
71 stat_call[v] = v.."_stat"
72 end
73 --------------------------------------------------------------------
74 local binopr_left = {} -- binary operators, left priority
75 local binopr_right = {} -- binary operators, right priority
76 for op, lt, rt in string.gfind([[
77{+ 6 6}{- 6 6}{* 7 7}{/ 7 7}{^ 10 9}{.. 5 4}
78{~= 3 3}{== 3 3}{< 3 3}{<= 3 3}{> 3 3}{>= 3 3}
79{and 2 2}{or 1 1}
80]], "{(%S+)%s(%d+)%s(%d+)}") do
81 binopr_left[op] = lt + 0
82 binopr_right[op] = rt + 0
83 end
84 local unopr = { ["not"] = true, ["-"] = true, } -- unary operators
85
86--[[--------------------------------------------------------------------
87-- logging: this logging function is for educational purposes
88-- * logged data can be retrieved from the returned data structure
89-- * or, replace self:log() instances with your custom code...
90----------------------------------------------------------------------]]
91
92 function luaY:log(msg)
93 local log = top_fs.log
94 if not log then log = {}; top_fs.log = log end
95 table.insert(top_fs.log, msg)
96 end
97
98--[[--------------------------------------------------------------------
99-- support functions
100----------------------------------------------------------------------]]
101
102 --------------------------------------------------------------------
103 -- reads in next token
104 --------------------------------------------------------------------
105 function luaY:next()
106 lastln = luaX.ln
107 if peek_tok then -- is there a look-ahead token? if yes, use it
108 tok, seminfo = peek_tok, peek_sem
109 peek_tok = nil
110 else
111 tok, seminfo = luaX:lex() -- read next token
112 end
113 end
114 --------------------------------------------------------------------
115 -- peek at next token (single lookahead for table constructor)
116 --------------------------------------------------------------------
117 function luaY:lookahead()
118 peek_tok, peek_sem = luaX:lex()
119 return peek_tok
120 end
121
122 ------------------------------------------------------------------------
123 -- throws a syntax error
124 ------------------------------------------------------------------------
125 function luaY:syntaxerror(msg)
126 local tok = tok
127 if tok ~= "<number>" and tok ~= "<string>" then
128 if tok == "<name>" then tok = seminfo end
129 tok = "'"..tok.."'"
130 end
131 luaX:errorline(msg.." near "..tok)
132 end
133 --------------------------------------------------------------------
134 -- throws a syntax error if token expected is not there
135 --------------------------------------------------------------------
136 function luaY:error_expected(token)
137 self:syntaxerror("'"..token.."' expected")
138 end
139
140 --------------------------------------------------------------------
141 -- verifies token conditions are met or else throw error
142 --------------------------------------------------------------------
143 function luaY:check_match(what, who, where)
144 if not self:testnext(what) then
145 if where == luaX.ln then
146 self:error_expected(what)
147 else
148 self:syntaxerror("'"..what.."' expected (to close '"..who.."' at line "..where..")")
149 end
150 end
151 end
152 --------------------------------------------------------------------
153 -- tests for a token, returns outcome
154 -- * return value changed to boolean
155 --------------------------------------------------------------------
156 function luaY:testnext(c)
157 if tok == c then self:next(); return true end
158 end
159 --------------------------------------------------------------------
160 -- throws error if condition not matched
161 --------------------------------------------------------------------
162 function luaY:check_condition(c, msg)
163 if not c then self:syntaxerror(msg) end
164 end
165 --------------------------------------------------------------------
166 -- check for existence of a token, throws error if not found
167 --------------------------------------------------------------------
168 function luaY:check(c)
169 if not self:testnext(c) then self:error_expected(c) end
170 end
171
172 --------------------------------------------------------------------
173 -- expect that token is a name, return the name
174 --------------------------------------------------------------------
175 function luaY:str_checkname()
176 self:check_condition(tok == "<name>", "<name> expected")
177 local ts = seminfo
178 self:next()
179 self:log(" str_checkname: '"..ts.."'")
180 return ts
181 end
182 --------------------------------------------------------------------
183 -- adds given string s in string pool, sets e as VK
184 --------------------------------------------------------------------
185 function luaY:codestring(e, s)
186 e.k = "VK"
187 self:log(" codestring: "..string.format("%q", s))
188 end
189 --------------------------------------------------------------------
190 -- consume a name token, adds it to string pool
191 --------------------------------------------------------------------
192 function luaY:checkname(e)
193 self:log(" checkname:")
194 self:codestring(e, self:str_checkname())
195 end
196
197--[[--------------------------------------------------------------------
198-- state management functions with open/close pairs
199----------------------------------------------------------------------]]
200
201 --------------------------------------------------------------------
202 -- enters a code unit, initializes elements
203 --------------------------------------------------------------------
204 function luaY:enterblock(isbreakable)
205 local bl = {} -- per-block state
206 bl.isbreakable = isbreakable
207 bl.prev = fs.bl
208 fs.bl = bl
209 self:log(">> enterblock(isbreakable="..tostring(isbreakable)..")")
210 end
211 --------------------------------------------------------------------
212 -- leaves a code unit, close any upvalues
213 --------------------------------------------------------------------
214 function luaY:leaveblock()
215 local bl = fs.bl
216 fs.bl = bl.prev
217 self:log("<< leaveblock")
218 end
219 --------------------------------------------------------------------
220 -- opening of a function
221 --------------------------------------------------------------------
222 function luaY:open_func()
223 local new_fs -- per-function state
224 if not fs then -- top_fs is created early
225 new_fs = top_fs
226 else
227 new_fs = {}
228 end
229 new_fs.prev = fs -- linked list of function states
230 new_fs.bl = nil
231 fs = new_fs
232 self:log(">> open_func")
233 end
234 --------------------------------------------------------------------
235 -- closing of a function
236 --------------------------------------------------------------------
237 function luaY:close_func()
238 fs = fs.prev
239 self:log("<< close_func")
240 end
241
242--[[--------------------------------------------------------------------
243-- variable (global|local|upvalue) handling
244-- * does nothing for now, always returns "VLOCAL"
245----------------------------------------------------------------------]]
246
247 --------------------------------------------------------------------
248 -- consume a name token, creates a variable (global|local|upvalue)
249 -- * used in prefixexp(), funcname()
250 --------------------------------------------------------------------
251 function luaY:singlevar(v)
252 local varname = self:str_checkname()
253 v.k = "VLOCAL"
254 self:log(" singlevar: name='"..varname.."'")
255 end
256
257--[[--------------------------------------------------------------------
258-- other parsing functions
259-- * for table constructor, parameter list, argument list
260----------------------------------------------------------------------]]
261
262 --------------------------------------------------------------------
263 -- parse a function name suffix, for function call specifications
264 -- * used in primaryexp(), funcname()
265 --------------------------------------------------------------------
266 function luaY:field(v)
267 -- field -> ['.' | ':'] NAME
268 local key = {}
269 self:log(" field: operator="..tok)
270 self:next() -- skip the dot or colon
271 self:checkname(key)
272 v.k = "VINDEXED"
273 end
274 --------------------------------------------------------------------
275 -- parse a table indexing suffix, for constructors, expressions
276 -- * used in recfield(), primaryexp()
277 --------------------------------------------------------------------
278 function luaY:index(v)
279 -- index -> '[' expr ']'
280 self:log(">> index: begin '['")
281 self:next() -- skip the '['
282 self:expr(v)
283 self:check("]")
284 self:log("<< index: end ']'")
285 end
286 --------------------------------------------------------------------
287 -- parse a table record (hash) field
288 -- * used in constructor()
289 --------------------------------------------------------------------
290 function luaY:recfield(cc)
291 -- recfield -> (NAME | '['exp1']') = exp1
292 local key, val = {}, {}
293 if tok == "<name>" then
294 self:log("recfield: name")
295 self:checkname(key)
296 else-- tok == '['
297 self:log("recfield: [ exp1 ]")
298 self:index(key)
299 end
300 self:check("=")
301 self:expr(val)
302 end
303 --------------------------------------------------------------------
304 -- emit a set list instruction if enough elements (LFIELDS_PER_FLUSH)
305 -- * note: retained in this skeleton because it modifies cc.v.k
306 -- * used in constructor()
307 --------------------------------------------------------------------
308 function luaY:closelistfield(cc)
309 if cc.v.k == "VVOID" then return end -- there is no list item
310 cc.v.k = "VVOID"
311 end
312 --------------------------------------------------------------------
313 -- parse a table list (array) field
314 -- * used in constructor()
315 --------------------------------------------------------------------
316 function luaY:listfield(cc)
317 self:log("listfield: expr")
318 self:expr(cc.v)
319 end
320 --------------------------------------------------------------------
321 -- parse a table constructor
322 -- * used in funcargs(), simpleexp()
323 --------------------------------------------------------------------
324 function luaY:constructor(t)
325 -- constructor -> '{' [ field { fieldsep field } [ fieldsep ] ] '}'
326 -- field -> recfield | listfield
327 -- fieldsep -> ',' | ';'
328 self:log(">> constructor: begin")
329 local line = luaX.ln
330 local cc = {}
331 cc.v = {}
332 cc.t = t
333 t.k = "VRELOCABLE"
334 cc.v.k = "VVOID"
335 self:check("{")
336 repeat
337 self:testnext(";") -- compatibility only
338 if tok == "}" then break end
339 -- closelistfield(cc) here
340 local c = tok
341 if c == "<name>" then -- may be listfields or recfields
342 if self:lookahead() ~= "=" then -- look ahead: expression?
343 self:listfield(cc)
344 else
345 self:recfield(cc)
346 end
347 elseif c == "[" then -- constructor_item -> recfield
348 self:recfield(cc)
349 else -- constructor_part -> listfield
350 self:listfield(cc)
351 end
352 until not self:testnext(",") and not self:testnext(";")
353 self:check_match("}", "{", line)
354 -- lastlistfield(cc) here
355 self:log("<< constructor: end")
356 end
357 --------------------------------------------------------------------
358 -- parse the arguments (parameters) of a function declaration
359 -- * used in body()
360 --------------------------------------------------------------------
361 function luaY:parlist()
362 -- parlist -> [ param { ',' param } ]
363 self:log(">> parlist: begin")
364 local dots = false
365 if tok ~= ")" then -- is 'parlist' not empty?
366 repeat
367 local c = tok
368 if c == "..." then
369 self:log("parlist: ... (dots)")
370 dots = true
371 self:next()
372 elseif c == "<name>" then
373 local str = self:str_checkname()
374 else
375 self:syntaxerror("<name> or '...' expected")
376 end
377 until dots or not self:testnext(",")
378 end
379 self:log("<< parlist: end")
380 end
381 --------------------------------------------------------------------
382 -- parse the parameters of a function call
383 -- * contrast with parlist(), used in function declarations
384 -- * used in primaryexp()
385 --------------------------------------------------------------------
386 function luaY:funcargs(f)
387 local args = {}
388 local line = luaX.ln
389 local c = tok
390 if c == "(" then -- funcargs -> '(' [ explist1 ] ')'
391 self:log(">> funcargs: begin '('")
392 if line ~= lastln then
393 self:syntaxerror("ambiguous syntax (function call x new statement)")
394 end
395 self:next()
396 if tok == ")" then -- arg list is empty?
397 args.k = "VVOID"
398 else
399 self:explist1(args)
400 end
401 self:check_match(")", "(", line)
402 elseif c == "{" then -- funcargs -> constructor
403 self:log(">> funcargs: begin '{'")
404 self:constructor(args)
405 elseif c == "<string>" then -- funcargs -> STRING
406 self:log(">> funcargs: begin <string>")
407 self:codestring(args, seminfo)
408 self:next() -- must use 'seminfo' before 'next'
409 else
410 self:syntaxerror("function arguments expected")
411 return
412 end--if c
413 f.k = "VCALL"
414 self:log("<< funcargs: end -- expr is a VCALL")
415 end
416
417--[[--------------------------------------------------------------------
418-- mostly expression functions
419----------------------------------------------------------------------]]
420
421 --------------------------------------------------------------------
422 -- parses an expression in parentheses or a single variable
423 -- * used in primaryexp()
424 --------------------------------------------------------------------
425 function luaY:prefixexp(v)
426 -- prefixexp -> NAME | '(' expr ')'
427 local c = tok
428 if c == "(" then
429 self:log(">> prefixexp: begin ( expr ) ")
430 local line = self.ln
431 self:next()
432 self:expr(v)
433 self:check_match(")", "(", line)
434 self:log("<< prefixexp: end ( expr ) ")
435 elseif c == "<name>" then
436 self:log("prefixexp: <name>")
437 self:singlevar(v)
438 else
439 self:syntaxerror("unexpected symbol")
440 end--if c
441 end
442 --------------------------------------------------------------------
443 -- parses a prefixexp (an expression in parentheses or a single
444 -- variable) or a function call specification
445 -- * used in simpleexp(), assignment(), expr_stat()
446 --------------------------------------------------------------------
447 function luaY:primaryexp(v)
448 -- primaryexp ->
449 -- prefixexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs }
450 self:prefixexp(v)
451 while true do
452 local c = tok
453 if c == "." then -- field
454 self:log("primaryexp: '.' field")
455 self:field(v)
456 elseif c == "[" then -- '[' exp1 ']'
457 self:log("primaryexp: [ exp1 ]")
458 local key = {}
459 self:index(key)
460 elseif c == ":" then -- ':' NAME funcargs
461 self:log("primaryexp: :<name> funcargs")
462 local key = {}
463 self:next()
464 self:checkname(key)
465 self:funcargs(v)
466 elseif c == "(" or c == "<string>" or c == "{" then -- funcargs
467 self:log("primaryexp: "..c.." funcargs")
468 self:funcargs(v)
469 else
470 return
471 end--if c
472 end--while
473 end
474 --------------------------------------------------------------------
475 -- parses general expression types, constants handled here
476 -- * used in subexpr()
477 --------------------------------------------------------------------
478 function luaY:simpleexp(v)
479 -- simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE | constructor
480 -- | FUNCTION body | primaryexp
481 local c = tok
482 if c == "<number>" then
483 self:log("simpleexp: <number>="..seminfo)
484 v.k = "VK"
485 self:next() -- must use 'seminfo' before 'next'
486 elseif c == "<string>" then
487 self:log("simpleexp: <string>="..seminfo)
488 self:codestring(v, seminfo)
489 self:next() -- must use 'seminfo' before 'next'
490 elseif c == "nil" then
491 self:log("simpleexp: nil")
492 v.k = "VNIL"
493 self:next()
494 elseif c == "true" then
495 self:log("simpleexp: true")
496 v.k = "VTRUE"
497 self:next()
498 elseif c == "false" then
499 self:log("simpleexp: false")
500 v.k = "VFALSE"
501 self:next()
502 elseif c == "{" then -- constructor
503 self:log("simpleexp: constructor")
504 self:constructor(v)
505 elseif c == "function" then
506 self:log("simpleexp: function")
507 self:next()
508 self:body(v, false, luaX.ln)
509 else
510 self:primaryexp(v)
511 end--if c
512 end
513 ------------------------------------------------------------------------
514 -- Parse subexpressions. Includes handling of unary operators and binary
515 -- operators. A subexpr is given the rhs priority level of the operator
516 -- immediately left of it, if any (limit is -1 if none,) and if a binop
517 -- is found, limit is compared with the lhs priority level of the binop
518 -- in order to determine which executes first.
519 -- * recursively called
520 -- * used in expr()
521 ------------------------------------------------------------------------
522 function luaY:subexpr(v, limit)
523 -- subexpr -> (simpleexp | unop subexpr) { binop subexpr }
524 -- * where 'binop' is any binary operator with a priority
525 -- higher than 'limit'
526 local op = tok
527 local uop = unopr[op]
528 if uop then
529 self:log(" subexpr: uop='"..op.."'")
530 self:next()
531 self:subexpr(v, 8) -- UNARY_PRIORITY
532 else
533 self:simpleexp(v)
534 end
535 -- expand while operators have priorities higher than 'limit'
536 op = tok
537 local binop = binopr_left[op]
538 while binop and binop > limit do
539 local v2 = {}
540 self:log(">> subexpr: binop='"..op.."'")
541 self:next()
542 -- read sub-expression with higher priority
543 local nextop = self:subexpr(v2, binopr_right[op])
544 self:log("<< subexpr: -- evaluate")
545 op = nextop
546 binop = binopr_left[op]
547 end
548 return op -- return first untreated operator
549 end
550 --------------------------------------------------------------------
551 -- Expression parsing starts here. Function subexpr is entered with the
552 -- left operator (which is non-existent) priority of -1, which is lower
553 -- than all actual operators. Expr information is returned in parm v.
554 -- * used in cond(), explist1(), index(), recfield(), listfield(),
555 -- prefixexp(), while_stat(), exp1()
556 --------------------------------------------------------------------
557 function luaY:expr(v)
558 -- expr -> subexpr
559 self:log("expr:")
560 self:subexpr(v, -1)
561 end
562
563--[[--------------------------------------------------------------------
564-- third level parsing functions
565----------------------------------------------------------------------]]
566
567 --------------------------------------------------------------------
568 -- parse a variable assignment sequence
569 -- * recursively called
570 -- * used in expr_stat()
571 --------------------------------------------------------------------
572 function luaY:assignment(v)
573 local e = {}
574 local c = v.v.k
575 self:check_condition(c == "VLOCAL" or c == "VUPVAL" or c == "VGLOBAL"
576 or c == "VINDEXED", "syntax error")
577 if self:testnext(",") then -- assignment -> ',' primaryexp assignment
578 local nv = {} -- expdesc
579 nv.v = {}
580 self:log("assignment: ',' -- next LHS element")
581 self:primaryexp(nv.v)
582 -- lparser.c deals with some register usage conflict here
583 self:assignment(nv)
584 else -- assignment -> '=' explist1
585 self:check("=")
586 self:log("assignment: '=' -- RHS elements follows")
587 self:explist1(e)
588 return -- avoid default
589 end
590 e.k = "VNONRELOC"
591 end
592 --------------------------------------------------------------------
593 -- parse a for loop body for both versions of the for loop
594 -- * used in fornum(), forlist()
595 --------------------------------------------------------------------
596 function luaY:forbody(line, isnum)
597 self:check("do")
598 self:enterblock(true) -- loop block
599 self:block()
600 self:leaveblock()
601 end
602 --------------------------------------------------------------------
603 -- parse a numerical for loop, calls forbody()
604 -- * used in for_stat()
605 --------------------------------------------------------------------
606 function luaY:fornum(line)
607 -- fornum -> NAME = exp1, exp1 [, exp1] DO body
608 self:log(">> fornum: begin")
609 self:check("=")
610 self:log("fornum: index start")
611 self:exp1() -- initial value
612 self:check(",")
613 self:log("fornum: index stop")
614 self:exp1() -- limit
615 if self:testnext(",") then
616 self:log("fornum: index step")
617 self:exp1() -- optional step
618 else
619 -- default step = 1
620 end
621 self:log("fornum: body")
622 self:forbody(line, true)
623 self:log("<< fornum: end")
624 end
625 --------------------------------------------------------------------
626 -- parse a generic for loop, calls forbody()
627 -- * used in for_stat()
628 --------------------------------------------------------------------
629 function luaY:forlist()
630 -- forlist -> NAME {, NAME} IN explist1 DO body
631 self:log(">> forlist: begin")
632 local e = {}
633 while self:testnext(",") do
634 self:str_checkname()
635 end
636 self:check("in")
637 local line = line
638 self:log("forlist: explist1")
639 self:explist1(e)
640 self:log("forlist: body")
641 self:forbody(line, false)
642 self:log("<< forlist: end")
643 end
644 --------------------------------------------------------------------
645 -- parse a function name specification
646 -- * used in func_stat()
647 --------------------------------------------------------------------
648 function luaY:funcname(v)
649 -- funcname -> NAME {field} [':' NAME]
650 self:log(">> funcname: begin")
651 local needself = false
652 self:singlevar(v)
653 while tok == "." do
654 self:log("funcname: -- '.' field")
655 self:field(v)
656 end
657 if tok == ":" then
658 self:log("funcname: -- ':' field")
659 needself = true
660 self:field(v)
661 end
662 self:log("<< funcname: end")
663 return needself
664 end
665 --------------------------------------------------------------------
666 -- parse the single expressions needed in numerical for loops
667 -- * used in fornum()
668 --------------------------------------------------------------------
669 function luaY:exp1()
670 -- exp1 -> expr
671 local e = {}
672 self:log(">> exp1: begin")
673 self:expr(e)
674 self:log("<< exp1: end")
675 end
676 --------------------------------------------------------------------
677 -- parse condition in a repeat statement or an if control structure
678 -- * used in repeat_stat(), test_then_block()
679 --------------------------------------------------------------------
680 function luaY:cond(v)
681 -- cond -> expr
682 self:log(">> cond: begin")
683 self:expr(v) -- read condition
684 self:log("<< cond: end")
685 end
686 --------------------------------------------------------------------
687 -- parse part of an if control structure, including the condition
688 -- * used in if_stat()
689 --------------------------------------------------------------------
690 function luaY:test_then_block(v)
691 -- test_then_block -> [IF | ELSEIF] cond THEN block
692 self:next() -- skip IF or ELSEIF
693 self:log("test_then_block: test condition")
694 self:cond(v)
695 self:check("then")
696 self:log("test_then_block: then block")
697 self:block() -- 'then' part
698 end
699 --------------------------------------------------------------------
700 -- parse a local function statement
701 -- * used in local_stat()
702 --------------------------------------------------------------------
703 function luaY:localfunc()
704 -- localfunc -> NAME body
705 local v, b = {}
706 self:log("localfunc: begin")
707 local str = self:str_checkname()
708 v.k = "VLOCAL"
709 self:log("localfunc: body")
710 self:body(b, false, luaX.ln)
711 self:log("localfunc: end")
712 end
713 --------------------------------------------------------------------
714 -- parse a local variable declaration statement
715 -- * used in local_stat()
716 --------------------------------------------------------------------
717 function luaY:localstat()
718 -- localstat -> NAME {',' NAME} ['=' explist1]
719 self:log(">> localstat: begin")
720 local e = {}
721 repeat
722 local str = self:str_checkname()
723 until not self:testnext(",")
724 if self:testnext("=") then
725 self:log("localstat: -- assignment")
726 self:explist1(e)
727 else
728 e.k = "VVOID"
729 end
730 self:log("<< localstat: end")
731 end
732 --------------------------------------------------------------------
733 -- parse a list of comma-separated expressions
734 -- * used in return_stat(), localstat(), funcargs(), assignment(),
735 -- forlist()
736 --------------------------------------------------------------------
737 function luaY:explist1(e)
738 -- explist1 -> expr { ',' expr }
739 self:log(">> explist1: begin")
740 self:expr(e)
741 while self:testnext(",") do
742 self:log("explist1: ',' -- continuation")
743 self:expr(e)
744 end
745 self:log("<< explist1: end")
746 end
747 --------------------------------------------------------------------
748 -- parse function declaration body
749 -- * used in simpleexp(), localfunc(), func_stat()
750 --------------------------------------------------------------------
751 function luaY:body(e, needself, line)
752 -- body -> '(' parlist ')' chunk END
753 self:open_func()
754 self:log("body: begin")
755 self:check("(")
756 if needself then
757 -- handle 'self' processing here
758 end
759 self:log("body: parlist")
760 self:parlist()
761 self:check(")")
762 self:log("body: chunk")
763 self:chunk()
764 self:check_match("end", "function", line)
765 self:log("body: end")
766 self:close_func()
767 end
768 --------------------------------------------------------------------
769 -- parse a code block or unit
770 -- * used in do_stat(), while_stat(), repeat_stat(), forbody(),
771 -- test_then_block(), if_stat()
772 --------------------------------------------------------------------
773 function luaY:block()
774 -- block -> chunk
775 self:log("block: begin")
776 self:enterblock(false)
777 self:chunk()
778 self:leaveblock()
779 self:log("block: end")
780 end
781
782--[[--------------------------------------------------------------------
783-- second level parsing functions, all with '_stat' suffix
784-- * stat() -> *_stat()
785----------------------------------------------------------------------]]
786
787 --------------------------------------------------------------------
788 -- initial parsing for a for loop, calls fornum() or forlist()
789 -- * used in stat()
790 --------------------------------------------------------------------
791 function luaY:for_stat()
792 -- stat -> for_stat -> fornum | forlist
793 local line = line
794 self:log("for_stat: begin")
795 self:enterblock(false) -- block to control variable scope
796 self:next() -- skip 'for'
797 local str = self:str_checkname() -- first variable name
798 local c = tok
799 if c == "=" then
800 self:log("for_stat: numerical loop")
801 self:fornum(line)
802 elseif c == "," or c == "in" then
803 self:log("for_stat: list-based loop")
804 self:forlist()
805 else
806 self:syntaxerror("'=' or 'in' expected")
807 end
808 self:check_match("end", "for", line)
809 self:leaveblock()
810 self:log("for_stat: end")
811 end
812 --------------------------------------------------------------------
813 -- parse a while-do control structure, body processed by block()
814 -- * used in stat()
815 --------------------------------------------------------------------
816 function luaY:while_stat()
817 -- stat -> while_stat -> WHILE cond DO block END
818 local line = line
819 local v = {}
820 self:next() -- skip WHILE
821 self:log("while_stat: begin/condition")
822 self:expr(v) -- parse condition
823 self:enterblock(true)
824 self:check("do")
825 self:log("while_stat: block")
826 self:block()
827 self:check_match("end", "while", line)
828 self:leaveblock()
829 self:log("while_stat: end")
830 end
831 --------------------------------------------------------------------
832 -- parse a repeat-until control structure, body parsed by block()
833 -- * used in stat()
834 --------------------------------------------------------------------
835 function luaY:repeat_stat()
836 -- stat -> repeat_stat -> REPEAT block UNTIL cond
837 local line = line
838 local v = {}
839 self:log("repeat_stat: begin")
840 self:enterblock(true)
841 self:next()
842 self:block()
843 self:check_match("until", "repeat", line)
844 self:log("repeat_stat: condition")
845 self:cond(v)
846 self:leaveblock()
847 self:log("repeat_stat: end")
848 end
849 --------------------------------------------------------------------
850 -- parse an if control structure
851 -- * used in stat()
852 --------------------------------------------------------------------
853 function luaY:if_stat()
854 -- stat -> if_stat -> IF cond THEN block
855 -- {ELSEIF cond THEN block} [ELSE block] END
856 local line = line
857 local v = {}
858 self:log("if_stat: if...then")
859 self:test_then_block(v) -- IF cond THEN block
860 while tok == "elseif" do
861 self:log("if_stat: elseif...then")
862 self:test_then_block(v) -- ELSEIF cond THEN block
863 end
864 if tok == "else" then
865 self:log("if_stat: else...")
866 self:next() -- skip ELSE
867 self:block() -- 'else' part
868 end
869 self:check_match("end", "if", line)
870 self:log("if_stat: end")
871 end
872 --------------------------------------------------------------------
873 -- parse a return statement
874 -- * used in stat()
875 --------------------------------------------------------------------
876 function luaY:return_stat()
877 -- stat -> return_stat -> RETURN explist
878 local e = {}
879 self:next() -- skip RETURN
880 local c = tok
881 if block_follow[c] or c == ";" then
882 -- return no values
883 self:log("return_stat: no return values")
884 else
885 self:log("return_stat: begin")
886 self:explist1(e) -- optional return values
887 self:log("return_stat: end")
888 end
889 end
890 --------------------------------------------------------------------
891 -- parse a break statement
892 -- * used in stat()
893 --------------------------------------------------------------------
894 function luaY:break_stat()
895 -- stat -> break_stat -> BREAK
896 local bl = fs.bl
897 self:next() -- skip BREAK
898 while bl and not bl.isbreakable do -- find a breakable block
899 bl = bl.prev
900 end
901 if not bl then
902 self:syntaxerror("no loop to break")
903 end
904 self:log("break_stat: -- break out of loop")
905 end
906 --------------------------------------------------------------------
907 -- parse a function call with no returns or an assignment statement
908 -- * the struct with .prev is used for name searching in lparse.c,
909 -- so it is retained for now; present in assignment() also
910 -- * used in stat()
911 --------------------------------------------------------------------
912 function luaY:expr_stat()
913 -- stat -> expr_stat -> func | assignment
914 local v = {}
915 v.v = {}
916 self:primaryexp(v.v)
917 if v.v.k == "VCALL" then -- stat -> func
918 -- call statement uses no results
919 self:log("expr_stat: function call k='"..v.v.k.."'")
920 else -- stat -> assignment
921 self:log("expr_stat: assignment k='"..v.v.k.."'")
922 v.prev = nil
923 self:assignment(v)
924 end
925 end
926 --------------------------------------------------------------------
927 -- parse a function statement
928 -- * used in stat()
929 --------------------------------------------------------------------
930 function luaY:function_stat()
931 -- stat -> function_stat -> FUNCTION funcname body
932 local line = line
933 local v, b = {}, {}
934 self:log("function_stat: begin")
935 self:next() -- skip FUNCTION
936 local needself = self:funcname(v)
937 self:log("function_stat: body needself='"..tostring(needself).."'")
938 self:body(b, needself, line)
939 self:log("function_stat: end")
940 end
941 --------------------------------------------------------------------
942 -- parse a simple block enclosed by a DO..END pair
943 -- * used in stat()
944 --------------------------------------------------------------------
945 function luaY:do_stat()
946 -- stat -> do_stat -> DO block END
947 self:next() -- skip DO
948 self:log("do_stat: begin")
949 self:block()
950 self:log("do_stat: end")
951 self:check_match("end", "do", line)
952 end
953 --------------------------------------------------------------------
954 -- parse a statement starting with LOCAL
955 -- * used in stat()
956 --------------------------------------------------------------------
957 function luaY:local_stat()
958 -- stat -> local_stat -> LOCAL FUNCTION localfunc
959 -- -> LOCAL localstat
960 self:next() -- skip LOCAL
961 if self:testnext("function") then -- local function?
962 self:log("local_stat: local function")
963 self:localfunc()
964 else
965 self:log("local_stat: local statement")
966 self:localstat()
967 end
968 end
969
970--[[--------------------------------------------------------------------
971-- main function, top level parsing functions
972-- * [entry] -> parser() -> chunk() -> stat()
973----------------------------------------------------------------------]]
974
975 --------------------------------------------------------------------
976 -- initial parsing for statements, calls '_stat' suffixed functions
977 -- * used in chunk()
978 --------------------------------------------------------------------
979 function luaY:stat()
980 line = luaX.ln
981 local c = tok
982 local fn = stat_call[c]
983 -- handles: if while do for repeat function local return break
984 if fn then
985 self:log("-- STATEMENT: begin '"..c.."' line="..line)
986 self[fn](self)
987 self:log("-- STATEMENT: end '"..c.."'")
988 -- return or break must be last statement
989 if c == "return" or c == "break" then return true end
990 else
991 self:log("-- STATEMENT: begin 'expr' line="..line)
992 self:expr_stat()
993 self:log("-- STATEMENT: end 'expr'")
994 end
995 self:log("")
996 return false
997 end
998 --------------------------------------------------------------------
999 -- parse a chunk, which consists of a bunch of statements
1000 -- * used in parser(), body(), block()
1001 --------------------------------------------------------------------
1002 function luaY:chunk()
1003 -- chunk -> { stat [';'] }
1004 self:log("chunk:")
1005 local islast = false
1006 while not islast and not block_follow[tok] do
1007 islast = self:stat()
1008 self:testnext(";")
1009 end
1010 end
1011 --------------------------------------------------------------------
1012 -- performs parsing, returns parsed data structure
1013 --------------------------------------------------------------------
1014 function luaY:parser()
1015 self:log("-- TOP: begin")
1016 self:open_func()
1017 self:log("")
1018 self:next() -- read first token
1019 self:chunk()
1020 self:check_condition(tok == "<eof>", "<eof> expected")
1021 self:close_func()
1022 self:log("-- TOP: end")
1023 return top_fs
1024 end
1025 --------------------------------------------------------------------
1026 return luaY -- return actual module to user, done
1027end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lparser_mk3b.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lparser_mk3b.lua
deleted file mode 100644
index a46edc6..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lparser_mk3b.lua
+++ /dev/null
@@ -1,1121 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 lparser.lua
4 Lua 5 parser in Lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2008 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15--[[--------------------------------------------------------------------
16-- Notes:
17-- * this is a Lua 5.0.x parser skeleton, for llex_mk3.lua lexer
18-- * written as a module factory with recognizable lparser.c roots
19-- * builds some data, performs logging for educational purposes
20-- * target is to have relatively efficient and clear code
21-- * needs one parameter, a lexer module that implements:
22-- luaX:lex() - returns appropriate [token, semantic info] pairs
23-- luaX.ln - current line number
24-- luaX:errorline(s, [line]) - dies with error message
25--
26-- Usage example:
27-- lex_init = require("llex_mk3.lua")
28-- parser_init = require("lparser_mk3.lua")
29-- local luaX = lex_init(chunk, "=string")
30-- local luaY = parser_init(luaX)
31-- local fs = luaY:parser()
32--
33-- Development notes:
34-- * see test_parser-5.0.lua for grammar elements based on lparser.c
35-- * lparser has a few extra items to help parsing/syntax checking
36-- (a) line number (error reporting), lookahead token storage
37-- (b) per-prototype states needs a storage list
38-- (c) 'break' needs a per-block flag in a stack
39-- (d) 'kind' (v.k) testing needed in expr_stat() and assignment()
40-- for disambiguation, thus v.k manipulation is retained
41-- (e) one line # var (lastln) for ambiguous (split line) function
42-- call checking
43-- (f) most line number function call args retained for future use
44-- (g) Lua 4 compatibility code completely removed
45-- (h) minimal variable management code to differentiate each type
46-- * parsing starts from the end of this file in luaY:parser()
47--
48----------------------------------------------------------------------]]
49
50return
51function(luaX)
52--[[--------------------------------------------------------------------
53-- structures and data initialization
54----------------------------------------------------------------------]]
55
56 local line -- start line # for error messages
57 local lastln -- last line # for ambiguous syntax chk
58 local tok, seminfo -- token, semantic info pair
59 local peek_tok, peek_sem -- ditto, for lookahead
60 local fs -- function state
61 local top_fs = {} -- top-level function state
62 local luaY = {}
63 --------------------------------------------------------------------
64 local block_follow = {} -- lookahead check in chunk(), returnstat()
65 for v in string.gfind("else elseif end until <eof>", "%S+") do
66 block_follow[v] = true
67 end
68 --------------------------------------------------------------------
69 local stat_call = {} -- lookup for calls in stat()
70 for v in string.gfind("if while do for repeat function local return break", "%S+") do
71 stat_call[v] = v.."_stat"
72 end
73 --------------------------------------------------------------------
74 local binopr_left = {} -- binary operators, left priority
75 local binopr_right = {} -- binary operators, right priority
76 for op, lt, rt in string.gfind([[
77{+ 6 6}{- 6 6}{* 7 7}{/ 7 7}{^ 10 9}{.. 5 4}
78{~= 3 3}{== 3 3}{< 3 3}{<= 3 3}{> 3 3}{>= 3 3}
79{and 2 2}{or 1 1}
80]], "{(%S+)%s(%d+)%s(%d+)}") do
81 binopr_left[op] = lt + 0
82 binopr_right[op] = rt + 0
83 end
84 local unopr = { ["not"] = true, ["-"] = true, } -- unary operators
85
86--[[--------------------------------------------------------------------
87-- logging: this logging function is for educational purposes
88-- * logged data can be retrieved from the returned data structure
89-- * or, replace self:log() instances with your custom code...
90----------------------------------------------------------------------]]
91
92 function luaY:log(msg)
93 local log = top_fs.log
94 if not log then log = {}; top_fs.log = log end
95 table.insert(top_fs.log, msg)
96 end
97
98--[[--------------------------------------------------------------------
99-- support functions
100----------------------------------------------------------------------]]
101
102 --------------------------------------------------------------------
103 -- reads in next token
104 --------------------------------------------------------------------
105 function luaY:next()
106 lastln = luaX.ln
107 if peek_tok then -- is there a look-ahead token? if yes, use it
108 tok, seminfo = peek_tok, peek_sem
109 peek_tok = nil
110 else
111 tok, seminfo = luaX:lex() -- read next token
112 end
113 end
114 --------------------------------------------------------------------
115 -- peek at next token (single lookahead for table constructor)
116 --------------------------------------------------------------------
117 function luaY:lookahead()
118 peek_tok, peek_sem = luaX:lex()
119 return peek_tok
120 end
121
122 ------------------------------------------------------------------------
123 -- throws a syntax error
124 ------------------------------------------------------------------------
125 function luaY:syntaxerror(msg)
126 local tok = tok
127 if tok ~= "<number>" and tok ~= "<string>" then
128 if tok == "<name>" then tok = seminfo end
129 tok = "'"..tok.."'"
130 end
131 luaX:errorline(msg.." near "..tok)
132 end
133 --------------------------------------------------------------------
134 -- throws a syntax error if token expected is not there
135 --------------------------------------------------------------------
136 function luaY:error_expected(token)
137 self:syntaxerror("'"..token.."' expected")
138 end
139
140 --------------------------------------------------------------------
141 -- verifies token conditions are met or else throw error
142 --------------------------------------------------------------------
143 function luaY:check_match(what, who, where)
144 if not self:testnext(what) then
145 if where == luaX.ln then
146 self:error_expected(what)
147 else
148 self:syntaxerror("'"..what.."' expected (to close '"..who.."' at line "..where..")")
149 end
150 end
151 end
152 --------------------------------------------------------------------
153 -- tests for a token, returns outcome
154 -- * return value changed to boolean
155 --------------------------------------------------------------------
156 function luaY:testnext(c)
157 if tok == c then self:next(); return true end
158 end
159 --------------------------------------------------------------------
160 -- throws error if condition not matched
161 --------------------------------------------------------------------
162 function luaY:check_condition(c, msg)
163 if not c then self:syntaxerror(msg) end
164 end
165 --------------------------------------------------------------------
166 -- check for existence of a token, throws error if not found
167 --------------------------------------------------------------------
168 function luaY:check(c)
169 if not self:testnext(c) then self:error_expected(c) end
170 end
171
172 --------------------------------------------------------------------
173 -- expect that token is a name, return the name
174 --------------------------------------------------------------------
175 function luaY:str_checkname()
176 self:check_condition(tok == "<name>", "<name> expected")
177 local ts = seminfo
178 self:next()
179 self:log(" str_checkname: '"..ts.."'")
180 return ts
181 end
182 --------------------------------------------------------------------
183 -- adds given string s in string pool, sets e as VK
184 --------------------------------------------------------------------
185 function luaY:codestring(e, s)
186 e.k = "VK"
187 self:log(" codestring: "..string.format("%q", s))
188 end
189 --------------------------------------------------------------------
190 -- consume a name token, adds it to string pool
191 --------------------------------------------------------------------
192 function luaY:checkname(e)
193 self:log(" checkname:")
194 self:codestring(e, self:str_checkname())
195 end
196
197--[[--------------------------------------------------------------------
198-- state management functions with open/close pairs
199----------------------------------------------------------------------]]
200
201 --------------------------------------------------------------------
202 -- enters a code unit, initializes elements
203 --------------------------------------------------------------------
204 function luaY:enterblock(isbreakable)
205 local bl = {} -- per-block state
206 bl.isbreakable = isbreakable
207 bl.prev = fs.bl
208 bl.locallist = {}
209 fs.bl = bl
210 self:log(">> enterblock(isbreakable="..tostring(isbreakable)..")")
211 end
212 --------------------------------------------------------------------
213 -- leaves a code unit, close any upvalues
214 --------------------------------------------------------------------
215 function luaY:leaveblock()
216 local bl = fs.bl
217 fs.bl = bl.prev
218 self:log("<< leaveblock")
219 end
220 --------------------------------------------------------------------
221 -- opening of a function
222 --------------------------------------------------------------------
223 function luaY:open_func()
224 local new_fs -- per-function state
225 if not fs then -- top_fs is created early
226 new_fs = top_fs
227 else
228 new_fs = {}
229 end
230 new_fs.prev = fs -- linked list of function states
231 new_fs.bl = nil
232 new_fs.locallist = {}
233 fs = new_fs
234 self:log(">> open_func")
235 end
236 --------------------------------------------------------------------
237 -- closing of a function
238 --------------------------------------------------------------------
239 function luaY:close_func()
240 fs = fs.prev
241 self:log("<< close_func")
242 end
243
244--[[--------------------------------------------------------------------
245-- variable (global|local|upvalue) handling
246-- * a pure parser does not really need this, but if we want to produce
247-- useful output, might as well write minimal code to manage this...
248-- * entry point is singlevar() for variable lookups
249-- * three entry points for local variable creation, in order to keep
250-- to original C calls, but the extra arguments such as positioning
251-- are removed as we are not allocating registers -- we are only
252-- doing simple classification
253-- * lookup tables (bl.locallist) are maintained awkwardly in the basic
254-- block data structures, PLUS the function data structure (this is
255-- an inelegant hack, since bl is nil for the top level of a function)
256----------------------------------------------------------------------]]
257
258 --------------------------------------------------------------------
259 -- register a local variable, set in active variable list
260 -- * used in new_localvarstr(), parlist(), fornum(), forlist(),
261 -- localfunc(), localstat()
262 --------------------------------------------------------------------
263 function luaY:new_localvar(name)
264 local bl = fs.bl
265 local locallist
266 if bl then
267 locallist = bl.locallist
268 else
269 locallist = fs.locallist
270 end
271 locallist[name] = true
272 self:log(" new_localvar: '"..name.."'")
273 end
274 --------------------------------------------------------------------
275 -- creates a new local variable given a name
276 -- * used in fornum(), forlist() for loop variables; in create_local()
277 --------------------------------------------------------------------
278 function luaY:new_localvarstr(name)
279 self:new_localvar(name)
280 end
281 --------------------------------------------------------------------
282 -- creates a single local variable and activates it
283 -- * used only in code_params() for "arg", body() for "self"
284 --------------------------------------------------------------------
285 function luaY:create_local(name)
286 self:new_localvarstr(name)
287 end
288
289 --------------------------------------------------------------------
290 -- search the local variable namespace of the given fs for a match
291 -- * a simple lookup only, no active variable list kept, so no useful
292 -- index value can be returned by this function
293 -- * used only in singlevaraux()
294 --------------------------------------------------------------------
295 function luaY:searchvar(fs, n)
296 local bl = fs.bl
297 if bl then
298 locallist = bl.locallist
299 while locallist do
300 if locallist[n] then return 1 end -- found
301 bl = bl.prev
302 locallist = bl and bl.locallist
303 end
304 end
305 locallist = fs.locallist
306 if locallist[n] then return 1 end -- found
307 return -1 -- not found
308 end
309 --------------------------------------------------------------------
310 -- handle locals, globals and upvalues and related processing
311 -- * search mechanism is recursive, calls itself to search parents
312 -- * used only in singlevar()
313 --------------------------------------------------------------------
314 function luaY:singlevaraux(fs, n, var, base)
315 if fs == nil then -- no more levels?
316 var.k = "VGLOBAL" -- default is global variable
317 else
318 local v = self:searchvar(fs, n) -- look up at current level
319 if v >= 0 then
320 var.k = "VLOCAL"
321 else -- not found at current level; try upper one
322 self:singlevaraux(fs.prev, n, var, 0)
323 if var.k == "VGLOBAL" then
324 -- handle global var processing here
325 else -- LOCAL or UPVAL
326 var.k = "VUPVAL"
327 end
328 end--if v
329 end--if fs
330 end
331 --------------------------------------------------------------------
332 -- consume a name token, creates a variable (global|local|upvalue)
333 -- * used in prefixexp(), funcname()
334 --------------------------------------------------------------------
335 function luaY:singlevar(v)
336 local varname = self:str_checkname()
337 self:singlevaraux(fs, varname, v, 1)
338 self:log(" singlevar(kind): '"..v.k.."'")
339 end
340
341--[[--------------------------------------------------------------------
342-- other parsing functions
343-- * for table constructor, parameter list, argument list
344----------------------------------------------------------------------]]
345
346 --------------------------------------------------------------------
347 -- parse a function name suffix, for function call specifications
348 -- * used in primaryexp(), funcname()
349 --------------------------------------------------------------------
350 function luaY:field(v)
351 -- field -> ['.' | ':'] NAME
352 local key = {}
353 self:log(" field: operator="..tok)
354 self:next() -- skip the dot or colon
355 self:checkname(key)
356 v.k = "VINDEXED"
357 end
358 --------------------------------------------------------------------
359 -- parse a table indexing suffix, for constructors, expressions
360 -- * used in recfield(), primaryexp()
361 --------------------------------------------------------------------
362 function luaY:index(v)
363 -- index -> '[' expr ']'
364 self:log(">> index: begin '['")
365 self:next() -- skip the '['
366 self:expr(v)
367 self:check("]")
368 self:log("<< index: end ']'")
369 end
370 --------------------------------------------------------------------
371 -- parse a table record (hash) field
372 -- * used in constructor()
373 --------------------------------------------------------------------
374 function luaY:recfield(cc)
375 -- recfield -> (NAME | '['exp1']') = exp1
376 local key, val = {}, {}
377 if tok == "<name>" then
378 self:log("recfield: name")
379 self:checkname(key)
380 else-- tok == '['
381 self:log("recfield: [ exp1 ]")
382 self:index(key)
383 end
384 self:check("=")
385 self:expr(val)
386 end
387 --------------------------------------------------------------------
388 -- emit a set list instruction if enough elements (LFIELDS_PER_FLUSH)
389 -- * note: retained in this skeleton because it modifies cc.v.k
390 -- * used in constructor()
391 --------------------------------------------------------------------
392 function luaY:closelistfield(cc)
393 if cc.v.k == "VVOID" then return end -- there is no list item
394 cc.v.k = "VVOID"
395 end
396 --------------------------------------------------------------------
397 -- parse a table list (array) field
398 -- * used in constructor()
399 --------------------------------------------------------------------
400 function luaY:listfield(cc)
401 self:log("listfield: expr")
402 self:expr(cc.v)
403 end
404 --------------------------------------------------------------------
405 -- parse a table constructor
406 -- * used in funcargs(), simpleexp()
407 --------------------------------------------------------------------
408 function luaY:constructor(t)
409 -- constructor -> '{' [ field { fieldsep field } [ fieldsep ] ] '}'
410 -- field -> recfield | listfield
411 -- fieldsep -> ',' | ';'
412 self:log(">> constructor: begin")
413 local line = luaX.ln
414 local cc = {}
415 cc.v = {}
416 cc.t = t
417 t.k = "VRELOCABLE"
418 cc.v.k = "VVOID"
419 self:check("{")
420 repeat
421 self:testnext(";") -- compatibility only
422 if tok == "}" then break end
423 -- closelistfield(cc) here
424 local c = tok
425 if c == "<name>" then -- may be listfields or recfields
426 if self:lookahead() ~= "=" then -- look ahead: expression?
427 self:listfield(cc)
428 else
429 self:recfield(cc)
430 end
431 elseif c == "[" then -- constructor_item -> recfield
432 self:recfield(cc)
433 else -- constructor_part -> listfield
434 self:listfield(cc)
435 end
436 until not self:testnext(",") and not self:testnext(";")
437 self:check_match("}", "{", line)
438 -- lastlistfield(cc) here
439 self:log("<< constructor: end")
440 end
441 --------------------------------------------------------------------
442 -- parse the arguments (parameters) of a function declaration
443 -- * used in body()
444 --------------------------------------------------------------------
445 function luaY:parlist()
446 -- parlist -> [ param { ',' param } ]
447 self:log(">> parlist: begin")
448 local dots = false
449 if tok ~= ")" then -- is 'parlist' not empty?
450 repeat
451 local c = tok
452 if c == "..." then
453 self:log("parlist: ... (dots)")
454 dots = true
455 self:next()
456 elseif c == "<name>" then
457 self:new_localvar(self:str_checkname())
458 else
459 self:syntaxerror("<name> or '...' expected")
460 end
461 until dots or not self:testnext(",")
462 end
463 -- was code_params()
464 if dots then
465 self:create_local("arg")
466 end
467 self:log("<< parlist: end")
468 end
469 --------------------------------------------------------------------
470 -- parse the parameters of a function call
471 -- * contrast with parlist(), used in function declarations
472 -- * used in primaryexp()
473 --------------------------------------------------------------------
474 function luaY:funcargs(f)
475 local args = {}
476 local line = luaX.ln
477 local c = tok
478 if c == "(" then -- funcargs -> '(' [ explist1 ] ')'
479 self:log(">> funcargs: begin '('")
480 if line ~= lastln then
481 self:syntaxerror("ambiguous syntax (function call x new statement)")
482 end
483 self:next()
484 if tok == ")" then -- arg list is empty?
485 args.k = "VVOID"
486 else
487 self:explist1(args)
488 end
489 self:check_match(")", "(", line)
490 elseif c == "{" then -- funcargs -> constructor
491 self:log(">> funcargs: begin '{'")
492 self:constructor(args)
493 elseif c == "<string>" then -- funcargs -> STRING
494 self:log(">> funcargs: begin <string>")
495 self:codestring(args, seminfo)
496 self:next() -- must use 'seminfo' before 'next'
497 else
498 self:syntaxerror("function arguments expected")
499 return
500 end--if c
501 f.k = "VCALL"
502 self:log("<< funcargs: end -- expr is a VCALL")
503 end
504
505--[[--------------------------------------------------------------------
506-- mostly expression functions
507----------------------------------------------------------------------]]
508
509 --------------------------------------------------------------------
510 -- parses an expression in parentheses or a single variable
511 -- * used in primaryexp()
512 --------------------------------------------------------------------
513 function luaY:prefixexp(v)
514 -- prefixexp -> NAME | '(' expr ')'
515 local c = tok
516 if c == "(" then
517 self:log(">> prefixexp: begin ( expr ) ")
518 local line = self.ln
519 self:next()
520 self:expr(v)
521 self:check_match(")", "(", line)
522 self:log("<< prefixexp: end ( expr ) ")
523 elseif c == "<name>" then
524 self:log("prefixexp: <name>")
525 self:singlevar(v)
526 else
527 self:syntaxerror("unexpected symbol")
528 end--if c
529 end
530 --------------------------------------------------------------------
531 -- parses a prefixexp (an expression in parentheses or a single
532 -- variable) or a function call specification
533 -- * used in simpleexp(), assignment(), expr_stat()
534 --------------------------------------------------------------------
535 function luaY:primaryexp(v)
536 -- primaryexp ->
537 -- prefixexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs }
538 self:prefixexp(v)
539 while true do
540 local c = tok
541 if c == "." then -- field
542 self:log("primaryexp: '.' field")
543 self:field(v)
544 elseif c == "[" then -- '[' exp1 ']'
545 self:log("primaryexp: [ exp1 ]")
546 local key = {}
547 self:index(key)
548 elseif c == ":" then -- ':' NAME funcargs
549 self:log("primaryexp: :<name> funcargs")
550 local key = {}
551 self:next()
552 self:checkname(key)
553 self:funcargs(v)
554 elseif c == "(" or c == "<string>" or c == "{" then -- funcargs
555 self:log("primaryexp: "..c.." funcargs")
556 self:funcargs(v)
557 else
558 return
559 end--if c
560 end--while
561 end
562 --------------------------------------------------------------------
563 -- parses general expression types, constants handled here
564 -- * used in subexpr()
565 --------------------------------------------------------------------
566 function luaY:simpleexp(v)
567 -- simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE | constructor
568 -- | FUNCTION body | primaryexp
569 local c = tok
570 if c == "<number>" then
571 self:log("simpleexp: <number>="..seminfo)
572 v.k = "VK"
573 self:next() -- must use 'seminfo' before 'next'
574 elseif c == "<string>" then
575 self:log("simpleexp: <string>="..seminfo)
576 self:codestring(v, seminfo)
577 self:next() -- must use 'seminfo' before 'next'
578 elseif c == "nil" then
579 self:log("simpleexp: nil")
580 v.k = "VNIL"
581 self:next()
582 elseif c == "true" then
583 self:log("simpleexp: true")
584 v.k = "VTRUE"
585 self:next()
586 elseif c == "false" then
587 self:log("simpleexp: false")
588 v.k = "VFALSE"
589 self:next()
590 elseif c == "{" then -- constructor
591 self:log("simpleexp: constructor")
592 self:constructor(v)
593 elseif c == "function" then
594 self:log("simpleexp: function")
595 self:next()
596 self:body(v, false, luaX.ln)
597 else
598 self:primaryexp(v)
599 end--if c
600 end
601 ------------------------------------------------------------------------
602 -- Parse subexpressions. Includes handling of unary operators and binary
603 -- operators. A subexpr is given the rhs priority level of the operator
604 -- immediately left of it, if any (limit is -1 if none,) and if a binop
605 -- is found, limit is compared with the lhs priority level of the binop
606 -- in order to determine which executes first.
607 -- * recursively called
608 -- * used in expr()
609 ------------------------------------------------------------------------
610 function luaY:subexpr(v, limit)
611 -- subexpr -> (simpleexp | unop subexpr) { binop subexpr }
612 -- * where 'binop' is any binary operator with a priority
613 -- higher than 'limit'
614 local op = tok
615 local uop = unopr[op]
616 if uop then
617 self:log(" subexpr: uop='"..op.."'")
618 self:next()
619 self:subexpr(v, 8) -- UNARY_PRIORITY
620 else
621 self:simpleexp(v)
622 end
623 -- expand while operators have priorities higher than 'limit'
624 op = tok
625 local binop = binopr_left[op]
626 while binop and binop > limit do
627 local v2 = {}
628 self:log(">> subexpr: binop='"..op.."'")
629 self:next()
630 -- read sub-expression with higher priority
631 local nextop = self:subexpr(v2, binopr_right[op])
632 self:log("<< subexpr: -- evaluate")
633 op = nextop
634 binop = binopr_left[op]
635 end
636 return op -- return first untreated operator
637 end
638 --------------------------------------------------------------------
639 -- Expression parsing starts here. Function subexpr is entered with the
640 -- left operator (which is non-existent) priority of -1, which is lower
641 -- than all actual operators. Expr information is returned in parm v.
642 -- * used in cond(), explist1(), index(), recfield(), listfield(),
643 -- prefixexp(), while_stat(), exp1()
644 --------------------------------------------------------------------
645 function luaY:expr(v)
646 -- expr -> subexpr
647 self:log("expr:")
648 self:subexpr(v, -1)
649 end
650
651--[[--------------------------------------------------------------------
652-- third level parsing functions
653----------------------------------------------------------------------]]
654
655 --------------------------------------------------------------------
656 -- parse a variable assignment sequence
657 -- * recursively called
658 -- * used in expr_stat()
659 --------------------------------------------------------------------
660 function luaY:assignment(v)
661 local e = {}
662 local c = v.v.k
663 self:check_condition(c == "VLOCAL" or c == "VUPVAL" or c == "VGLOBAL"
664 or c == "VINDEXED", "syntax error")
665 if self:testnext(",") then -- assignment -> ',' primaryexp assignment
666 local nv = {} -- expdesc
667 nv.v = {}
668 self:log("assignment: ',' -- next LHS element")
669 self:primaryexp(nv.v)
670 -- lparser.c deals with some register usage conflict here
671 self:assignment(nv)
672 else -- assignment -> '=' explist1
673 self:check("=")
674 self:log("assignment: '=' -- RHS elements follows")
675 self:explist1(e)
676 return -- avoid default
677 end
678 e.k = "VNONRELOC"
679 end
680 --------------------------------------------------------------------
681 -- parse a for loop body for both versions of the for loop
682 -- * used in fornum(), forlist()
683 --------------------------------------------------------------------
684 function luaY:forbody(line, isnum)
685 self:check("do")
686 self:enterblock(true) -- loop block
687 self:block()
688 self:leaveblock()
689 end
690 --------------------------------------------------------------------
691 -- parse a numerical for loop, calls forbody()
692 -- * used in for_stat()
693 --------------------------------------------------------------------
694 function luaY:fornum(varname, line)
695 -- fornum -> NAME = exp1, exp1 [, exp1] DO body
696 self:new_localvar(varname)
697 self:new_localvarstr("(for limit)")
698 self:new_localvarstr("(for step)")
699 self:log(">> fornum: begin")
700 self:check("=")
701 self:log("fornum: index start")
702 self:exp1() -- initial value
703 self:check(",")
704 self:log("fornum: index stop")
705 self:exp1() -- limit
706 if self:testnext(",") then
707 self:log("fornum: index step")
708 self:exp1() -- optional step
709 else
710 -- default step = 1
711 end
712 self:log("fornum: body")
713 self:forbody(line, true)
714 self:log("<< fornum: end")
715 end
716 --------------------------------------------------------------------
717 -- parse a generic for loop, calls forbody()
718 -- * used in for_stat()
719 --------------------------------------------------------------------
720 function luaY:forlist(indexname)
721 -- forlist -> NAME {, NAME} IN explist1 DO body
722 self:log(">> forlist: begin")
723 local e = {}
724 self:new_localvarstr("(for generator)")
725 self:new_localvarstr("(for state)")
726 self:new_localvar(indexname)
727 while self:testnext(",") do
728 self:new_localvar(self:str_checkname())
729 end
730 self:check("in")
731 local line = line
732 self:log("forlist: explist1")
733 self:explist1(e)
734 self:log("forlist: body")
735 self:forbody(line, false)
736 self:log("<< forlist: end")
737 end
738 --------------------------------------------------------------------
739 -- parse a function name specification
740 -- * used in func_stat()
741 --------------------------------------------------------------------
742 function luaY:funcname(v)
743 -- funcname -> NAME {field} [':' NAME]
744 self:log(">> funcname: begin")
745 local needself = false
746 self:singlevar(v)
747 while tok == "." do
748 self:log("funcname: -- '.' field")
749 self:field(v)
750 end
751 if tok == ":" then
752 self:log("funcname: -- ':' field")
753 needself = true
754 self:field(v)
755 end
756 self:log("<< funcname: end")
757 return needself
758 end
759 --------------------------------------------------------------------
760 -- parse the single expressions needed in numerical for loops
761 -- * used in fornum()
762 --------------------------------------------------------------------
763 function luaY:exp1()
764 -- exp1 -> expr
765 local e = {}
766 self:log(">> exp1: begin")
767 self:expr(e)
768 self:log("<< exp1: end")
769 end
770 --------------------------------------------------------------------
771 -- parse condition in a repeat statement or an if control structure
772 -- * used in repeat_stat(), test_then_block()
773 --------------------------------------------------------------------
774 function luaY:cond(v)
775 -- cond -> expr
776 self:log(">> cond: begin")
777 self:expr(v) -- read condition
778 self:log("<< cond: end")
779 end
780 --------------------------------------------------------------------
781 -- parse part of an if control structure, including the condition
782 -- * used in if_stat()
783 --------------------------------------------------------------------
784 function luaY:test_then_block(v)
785 -- test_then_block -> [IF | ELSEIF] cond THEN block
786 self:next() -- skip IF or ELSEIF
787 self:log("test_then_block: test condition")
788 self:cond(v)
789 self:check("then")
790 self:log("test_then_block: then block")
791 self:block() -- 'then' part
792 end
793 --------------------------------------------------------------------
794 -- parse a local function statement
795 -- * used in local_stat()
796 --------------------------------------------------------------------
797 function luaY:localfunc()
798 -- localfunc -> NAME body
799 local v, b = {}
800 self:log("localfunc: begin")
801 self:new_localvar(self:str_checkname())
802 v.k = "VLOCAL"
803 self:log("localfunc: body")
804 self:body(b, false, luaX.ln)
805 self:log("localfunc: end")
806 end
807 --------------------------------------------------------------------
808 -- parse a local variable declaration statement
809 -- * used in local_stat()
810 --------------------------------------------------------------------
811 function luaY:localstat()
812 -- localstat -> NAME {',' NAME} ['=' explist1]
813 self:log(">> localstat: begin")
814 local e = {}
815 repeat
816 self:new_localvar(self:str_checkname())
817 until not self:testnext(",")
818 if self:testnext("=") then
819 self:log("localstat: -- assignment")
820 self:explist1(e)
821 else
822 e.k = "VVOID"
823 end
824 self:log("<< localstat: end")
825 end
826 --------------------------------------------------------------------
827 -- parse a list of comma-separated expressions
828 -- * used in return_stat(), localstat(), funcargs(), assignment(),
829 -- forlist()
830 --------------------------------------------------------------------
831 function luaY:explist1(e)
832 -- explist1 -> expr { ',' expr }
833 self:log(">> explist1: begin")
834 self:expr(e)
835 while self:testnext(",") do
836 self:log("explist1: ',' -- continuation")
837 self:expr(e)
838 end
839 self:log("<< explist1: end")
840 end
841 --------------------------------------------------------------------
842 -- parse function declaration body
843 -- * used in simpleexp(), localfunc(), func_stat()
844 --------------------------------------------------------------------
845 function luaY:body(e, needself, line)
846 -- body -> '(' parlist ')' chunk END
847 self:open_func()
848 self:log("body: begin")
849 self:check("(")
850 if needself then
851 self:create_local("self")
852 end
853 self:log("body: parlist")
854 self:parlist()
855 self:check(")")
856 self:log("body: chunk")
857 self:chunk()
858 self:check_match("end", "function", line)
859 self:log("body: end")
860 self:close_func()
861 end
862 --------------------------------------------------------------------
863 -- parse a code block or unit
864 -- * used in do_stat(), while_stat(), repeat_stat(), forbody(),
865 -- test_then_block(), if_stat()
866 --------------------------------------------------------------------
867 function luaY:block()
868 -- block -> chunk
869 self:log("block: begin")
870 self:enterblock(false)
871 self:chunk()
872 self:leaveblock()
873 self:log("block: end")
874 end
875
876--[[--------------------------------------------------------------------
877-- second level parsing functions, all with '_stat' suffix
878-- * stat() -> *_stat()
879----------------------------------------------------------------------]]
880
881 --------------------------------------------------------------------
882 -- initial parsing for a for loop, calls fornum() or forlist()
883 -- * used in stat()
884 --------------------------------------------------------------------
885 function luaY:for_stat()
886 -- stat -> for_stat -> fornum | forlist
887 local line = line
888 self:log("for_stat: begin")
889 self:enterblock(false) -- block to control variable scope
890 self:next() -- skip 'for'
891 local varname = self:str_checkname() -- first variable name
892 local c = tok
893 if c == "=" then
894 self:log("for_stat: numerical loop")
895 self:fornum(varname, line)
896 elseif c == "," or c == "in" then
897 self:log("for_stat: list-based loop")
898 self:forlist(varname)
899 else
900 self:syntaxerror("'=' or 'in' expected")
901 end
902 self:check_match("end", "for", line)
903 self:leaveblock()
904 self:log("for_stat: end")
905 end
906 --------------------------------------------------------------------
907 -- parse a while-do control structure, body processed by block()
908 -- * used in stat()
909 --------------------------------------------------------------------
910 function luaY:while_stat()
911 -- stat -> while_stat -> WHILE cond DO block END
912 local line = line
913 local v = {}
914 self:next() -- skip WHILE
915 self:log("while_stat: begin/condition")
916 self:expr(v) -- parse condition
917 self:enterblock(true)
918 self:check("do")
919 self:log("while_stat: block")
920 self:block()
921 self:check_match("end", "while", line)
922 self:leaveblock()
923 self:log("while_stat: end")
924 end
925 --------------------------------------------------------------------
926 -- parse a repeat-until control structure, body parsed by block()
927 -- * used in stat()
928 --------------------------------------------------------------------
929 function luaY:repeat_stat()
930 -- stat -> repeat_stat -> REPEAT block UNTIL cond
931 local line = line
932 local v = {}
933 self:log("repeat_stat: begin")
934 self:enterblock(true)
935 self:next()
936 self:block()
937 self:check_match("until", "repeat", line)
938 self:log("repeat_stat: condition")
939 self:cond(v)
940 self:leaveblock()
941 self:log("repeat_stat: end")
942 end
943 --------------------------------------------------------------------
944 -- parse an if control structure
945 -- * used in stat()
946 --------------------------------------------------------------------
947 function luaY:if_stat()
948 -- stat -> if_stat -> IF cond THEN block
949 -- {ELSEIF cond THEN block} [ELSE block] END
950 local line = line
951 local v = {}
952 self:log("if_stat: if...then")
953 self:test_then_block(v) -- IF cond THEN block
954 while tok == "elseif" do
955 self:log("if_stat: elseif...then")
956 self:test_then_block(v) -- ELSEIF cond THEN block
957 end
958 if tok == "else" then
959 self:log("if_stat: else...")
960 self:next() -- skip ELSE
961 self:block() -- 'else' part
962 end
963 self:check_match("end", "if", line)
964 self:log("if_stat: end")
965 end
966 --------------------------------------------------------------------
967 -- parse a return statement
968 -- * used in stat()
969 --------------------------------------------------------------------
970 function luaY:return_stat()
971 -- stat -> return_stat -> RETURN explist
972 local e = {}
973 self:next() -- skip RETURN
974 local c = tok
975 if block_follow[c] or c == ";" then
976 -- return no values
977 self:log("return_stat: no return values")
978 else
979 self:log("return_stat: begin")
980 self:explist1(e) -- optional return values
981 self:log("return_stat: end")
982 end
983 end
984 --------------------------------------------------------------------
985 -- parse a break statement
986 -- * used in stat()
987 --------------------------------------------------------------------
988 function luaY:break_stat()
989 -- stat -> break_stat -> BREAK
990 local bl = fs.bl
991 self:next() -- skip BREAK
992 while bl and not bl.isbreakable do -- find a breakable block
993 bl = bl.prev
994 end
995 if not bl then
996 self:syntaxerror("no loop to break")
997 end
998 self:log("break_stat: -- break out of loop")
999 end
1000 --------------------------------------------------------------------
1001 -- parse a function call with no returns or an assignment statement
1002 -- * the struct with .prev is used for name searching in lparse.c,
1003 -- so it is retained for now; present in assignment() also
1004 -- * used in stat()
1005 --------------------------------------------------------------------
1006 function luaY:expr_stat()
1007 -- stat -> expr_stat -> func | assignment
1008 local v = {}
1009 v.v = {}
1010 self:primaryexp(v.v)
1011 if v.v.k == "VCALL" then -- stat -> func
1012 -- call statement uses no results
1013 self:log("expr_stat: function call k='"..v.v.k.."'")
1014 else -- stat -> assignment
1015 self:log("expr_stat: assignment k='"..v.v.k.."'")
1016 v.prev = nil
1017 self:assignment(v)
1018 end
1019 end
1020 --------------------------------------------------------------------
1021 -- parse a function statement
1022 -- * used in stat()
1023 --------------------------------------------------------------------
1024 function luaY:function_stat()
1025 -- stat -> function_stat -> FUNCTION funcname body
1026 local line = line
1027 local v, b = {}, {}
1028 self:log("function_stat: begin")
1029 self:next() -- skip FUNCTION
1030 local needself = self:funcname(v)
1031 self:log("function_stat: body needself='"..tostring(needself).."'")
1032 self:body(b, needself, line)
1033 self:log("function_stat: end")
1034 end
1035 --------------------------------------------------------------------
1036 -- parse a simple block enclosed by a DO..END pair
1037 -- * used in stat()
1038 --------------------------------------------------------------------
1039 function luaY:do_stat()
1040 -- stat -> do_stat -> DO block END
1041 self:next() -- skip DO
1042 self:log("do_stat: begin")
1043 self:block()
1044 self:log("do_stat: end")
1045 self:check_match("end", "do", line)
1046 end
1047 --------------------------------------------------------------------
1048 -- parse a statement starting with LOCAL
1049 -- * used in stat()
1050 --------------------------------------------------------------------
1051 function luaY:local_stat()
1052 -- stat -> local_stat -> LOCAL FUNCTION localfunc
1053 -- -> LOCAL localstat
1054 self:next() -- skip LOCAL
1055 if self:testnext("function") then -- local function?
1056 self:log("local_stat: local function")
1057 self:localfunc()
1058 else
1059 self:log("local_stat: local statement")
1060 self:localstat()
1061 end
1062 end
1063
1064--[[--------------------------------------------------------------------
1065-- main function, top level parsing functions
1066-- * [entry] -> parser() -> chunk() -> stat()
1067----------------------------------------------------------------------]]
1068
1069 --------------------------------------------------------------------
1070 -- initial parsing for statements, calls '_stat' suffixed functions
1071 -- * used in chunk()
1072 --------------------------------------------------------------------
1073 function luaY:stat()
1074 line = luaX.ln
1075 local c = tok
1076 local fn = stat_call[c]
1077 -- handles: if while do for repeat function local return break
1078 if fn then
1079 self:log("-- STATEMENT: begin '"..c.."' line="..line)
1080 self[fn](self)
1081 self:log("-- STATEMENT: end '"..c.."'")
1082 -- return or break must be last statement
1083 if c == "return" or c == "break" then return true end
1084 else
1085 self:log("-- STATEMENT: begin 'expr' line="..line)
1086 self:expr_stat()
1087 self:log("-- STATEMENT: end 'expr'")
1088 end
1089 self:log("")
1090 return false
1091 end
1092 --------------------------------------------------------------------
1093 -- parse a chunk, which consists of a bunch of statements
1094 -- * used in parser(), body(), block()
1095 --------------------------------------------------------------------
1096 function luaY:chunk()
1097 -- chunk -> { stat [';'] }
1098 self:log("chunk:")
1099 local islast = false
1100 while not islast and not block_follow[tok] do
1101 islast = self:stat()
1102 self:testnext(";")
1103 end
1104 end
1105 --------------------------------------------------------------------
1106 -- performs parsing, returns parsed data structure
1107 --------------------------------------------------------------------
1108 function luaY:parser()
1109 self:log("-- TOP: begin")
1110 self:open_func()
1111 self:log("")
1112 self:next() -- read first token
1113 self:chunk()
1114 self:check_condition(tok == "<eof>", "<eof> expected")
1115 self:close_func()
1116 self:log("-- TOP: end")
1117 return top_fs
1118 end
1119 --------------------------------------------------------------------
1120 return luaY -- return actual module to user, done
1121end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lzio_mk2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lzio_mk2.lua
deleted file mode 100644
index 6378366..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lzio_mk2.lua
+++ /dev/null
@@ -1,106 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 lzio.lua
4 Lua 5 buffered streams in Lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2005-2006 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15--[[--------------------------------------------------------------------
16-- Notes:
17-- *
18----------------------------------------------------------------------]]
19
20--[[--------------------------------------------------------------------
21-- local zio_init = require("lzio.lua")
22-- local z = zio_init("@<filename>")
23-- local z = zio_init("<string>")
24-- z:getc()
25-- * get next character from input stream
26-- z:fill()
27-- * fills an empty stream buffer
28-- z.name
29-- * name of the chunk, "@<filename>" or "=string"
30----------------------------------------------------------------------]]
31
32--[[--------------------------------------------------------------------
33-- Format of z structure (ZIO)
34-- z.n -- bytes still unread
35-- z.p -- last read position in buffer
36-- z.reader -- chunk reader function
37-- z.data -- data buffer
38-- z.name -- name of stream
39----------------------------------------------------------------------]]
40
41return
42function(buff)
43--[[--------------------------------------------------------------------
44-- initialize reader
45-- * reader should return a string, or nil if nothing else to parse
46----------------------------------------------------------------------]]
47 local reader
48 local z = {}
49 if string.sub(buff, 1, 1) == "@" then
50 ----------------------------------------------------------------
51 -- create a chunk reader function from a source file
52 ----------------------------------------------------------------
53 z.name = buff
54 local BUFFERSIZE = 512
55 local h = io.open(string.sub(buff, 2), "r")
56 if not h then return nil end
57 reader = function()
58 if not h or io.type(h) == "closed file" then return nil end
59 local buff = h:read(BUFFERSIZE)
60 if not buff then h:close(); h = nil end
61 return buff
62 end
63 else
64 ----------------------------------------------------------------
65 -- create a chunk reader function from a source string
66 ----------------------------------------------------------------
67 z.name = "=string"
68 reader = function()
69 if not buff then return nil end
70 local data = buff
71 buff = nil
72 return data
73 end
74 end
75--[[--------------------------------------------------------------------
76-- fills an empty stream buffer, returns first character
77----------------------------------------------------------------------]]
78 function z:fill()
79 local data = z.reader()
80 z.data = data
81 if not data or data == "" then return "EOZ" end
82 z.n, z.p = string.len(data) - 1, 1
83 return string.sub(data, 1, 1)
84 end
85--[[--------------------------------------------------------------------
86-- get next character, fills buffer if characters needed
87----------------------------------------------------------------------]]
88 function z:getc()
89 local n, p = z.n, z.p + 1
90 if n > 0 then
91 z.n, z.p = n - 1, p
92 return string.sub(z.data, p, p)
93 else
94 return self:fill()
95 end
96 end
97--[[--------------------------------------------------------------------
98-- initialize input stream object
99----------------------------------------------------------------------]]
100 if not reader then return end
101 z.reader = reader
102 z.data = ""
103 z.n, z.p = 0, 0
104 return z
105--[[------------------------------------------------------------------]]
106end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lzio_mk4.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lzio_mk4.lua
deleted file mode 100644
index d97c795..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/lzio_mk4.lua
+++ /dev/null
@@ -1,82 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 lzio.lua
4 Lua 5 buffered streams in Lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15--[[--------------------------------------------------------------------
16-- Notes:
17-- * this is a line-based input streamer for the MK4 lexer
18-- * all EOL (end-of-line) characters are translated to "\n"
19-- * if last line in a file does not have an EOL character, this
20-- streamer adds one, the ambiguity is due to "*l" stripping
21-- * EOF uses an empty string to simplify testing in lexer
22----------------------------------------------------------------------]]
23
24--[[--------------------------------------------------------------------
25-- local zio_init = require("lzio.lua")
26-- local z = zio_init("@<filename>")
27-- local z = zio_init("<string>")
28-- z:getln()
29-- * get next line from input stream
30-- z.name
31-- * name of the chunk, "@<filename>" or "=string"
32----------------------------------------------------------------------]]
33
34--[[--------------------------------------------------------------------
35-- Format of z structure (ZIO)
36-- z.getln -- chunk reader function, reads line-by-line
37-- z.name -- name of stream
38----------------------------------------------------------------------]]
39
40return
41function(buff)
42--[[--------------------------------------------------------------------
43-- initialize reader
44-- * reader should return a string with an EOL character, or an empty
45-- string if there is nothing else to parse
46----------------------------------------------------------------------]]
47 local reader
48 local z = {}
49 if string.sub(buff, 1, 1) == "@" then
50 ----------------------------------------------------------------
51 -- create a chunk reader function from a source file
52 ----------------------------------------------------------------
53 z.name = buff
54 local h = io.open(string.sub(buff, 2), "r")
55 if not h then return nil end
56 reader = function()
57 if not h or io.type(h) == "closed file" then return nil end
58 local data = h:read("*l")
59 if not data then h:close(); return "" end
60 return data.."\n"
61 end
62 else
63 ----------------------------------------------------------------
64 -- create a chunk reader function from a source string
65 ----------------------------------------------------------------
66 z.name = "=string"
67 reader = function()
68 if not buff then return nil end
69 local p, q, data, eol = string.find(buff, "([^\r\n]*)(\r?\n?)")
70 buff = string.sub(buff, q + 1)
71 if data == "" and eol == "" then return "" end
72 return data..eol
73 end
74 end
75--[[--------------------------------------------------------------------
76-- initialize input stream object
77----------------------------------------------------------------------]]
78 if not reader then return end
79 z.getln = reader
80 return z
81--[[------------------------------------------------------------------]]
82end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk2.lua
deleted file mode 100644
index 873afd1..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk2.lua
+++ /dev/null
@@ -1,94 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 bench_llex.lua
4 Benchmark test for llex.lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15local zio_init = require("../lzio_mk2")
16local lex_init = require("../llex_mk2")
17
18------------------------------------------------------------------------
19-- load in a standard set of sample files
20-- * file set is 5.0.3 front end set sans luac.lua
21------------------------------------------------------------------------
22
23local fileset, totalsize = {}, 0
24for fn in string.gfind([[
25../../orig-5.0.3/lcode.lua
26../../orig-5.0.3/ldump.lua
27../../orig-5.0.3/llex.lua
28../../orig-5.0.3/lopcodes.lua
29../../orig-5.0.3/lparser.lua
30../../orig-5.0.3/lzio.lua
31]], "%S+") do
32 table.insert(fileset, fn)
33end
34
35for i = 1, table.getn(fileset) do
36 local fn = fileset[i]
37 local inf = io.open(fn, "rb")
38 if not inf then
39 error("failed to open "..fn.." for reading")
40 end
41 local data = inf:read("*a")
42 local data_sz = string.len(data)
43 inf:close()
44 if not data or data_sz == 0 then
45 error("failed to read data from "..fn.." or file is zero-length")
46 end
47 totalsize = totalsize + data_sz
48 fileset[i] = data
49end
50
51------------------------------------------------------------------------
52-- benchmark tester
53------------------------------------------------------------------------
54
55local DURATION = 5 -- how long the benchmark should run
56
57local time = os.time
58local lexedsize = 0
59local tnow, elapsed = time(), 0
60
61while time() == tnow do end -- wait for second to click over
62tnow = time()
63
64while true do
65 for i = 1, table.getn(fileset) do
66 ------------------------------------------------------------
67 local chunk = fileset[i]
68 local z = zio_init(chunk)
69 local luaX = lex_init(z, "=string")
70 while true do
71 local tok, seminfo = luaX:lex()
72 if tok == "<eof>" then break end
73 end
74 ------------------------------------------------------------
75 lexedsize = lexedsize + string.len(chunk)
76 if time() > tnow then
77 tnow = time()
78 elapsed = elapsed + 1
79 if elapsed >= DURATION then
80 -- report performance of lexer
81 lexedsize = lexedsize / 1024
82 local speed = lexedsize / DURATION
83 print("Lexer performance:")
84 print("Size of data lexed (KB): "..string.format("%.1f", lexedsize))
85 print("Speed of lexer (KB/s): "..string.format("%.1f", speed))
86 -- repeat until user breaks program
87 elapsed = 0
88 end
89 end
90 ------------------------------------------------------------
91 end--for
92end--while
93
94-- end of script
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk3.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk3.lua
deleted file mode 100644
index 6b2a4a6..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk3.lua
+++ /dev/null
@@ -1,92 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 bench_llex.lua
4 Benchmark test for llex.lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15local lex_init = require("../llex_mk3")
16
17------------------------------------------------------------------------
18-- load in a standard set of sample files
19-- * file set is 5.0.3 front end set sans luac.lua
20------------------------------------------------------------------------
21
22local fileset, totalsize = {}, 0
23for fn in string.gfind([[
24../../orig-5.0.3/lcode.lua
25../../orig-5.0.3/ldump.lua
26../../orig-5.0.3/llex.lua
27../../orig-5.0.3/lopcodes.lua
28../../orig-5.0.3/lparser.lua
29../../orig-5.0.3/lzio.lua
30]], "%S+") do
31 table.insert(fileset, fn)
32end
33
34for i = 1, table.getn(fileset) do
35 local fn = fileset[i]
36 local inf = io.open(fn, "rb")
37 if not inf then
38 error("failed to open "..fn.." for reading")
39 end
40 local data = inf:read("*a")
41 local data_sz = string.len(data)
42 inf:close()
43 if not data or data_sz == 0 then
44 error("failed to read data from "..fn.." or file is zero-length")
45 end
46 totalsize = totalsize + data_sz
47 fileset[i] = data
48end
49
50------------------------------------------------------------------------
51-- benchmark tester
52------------------------------------------------------------------------
53
54local DURATION = 5 -- how long the benchmark should run
55
56local time = os.time
57local lexedsize = 0
58local tnow, elapsed = time(), 0
59
60while time() == tnow do end -- wait for second to click over
61tnow = time()
62
63while true do
64 for i = 1, table.getn(fileset) do
65 ------------------------------------------------------------
66 local chunk = fileset[i]
67 local luaX = lex_init(chunk, "=string")
68 while true do
69 local tok, seminfo = luaX:lex()
70 if tok == "<eof>" then break end
71 end
72 ------------------------------------------------------------
73 lexedsize = lexedsize + string.len(chunk)
74 if time() > tnow then
75 tnow = time()
76 elapsed = elapsed + 1
77 if elapsed >= DURATION then
78 -- report performance of lexer
79 lexedsize = lexedsize / 1024
80 local speed = lexedsize / DURATION
81 print("Lexer performance:")
82 print("Size of data lexed (KB): "..string.format("%.1f", lexedsize))
83 print("Speed of lexer (KB/s): "..string.format("%.1f", speed))
84 -- repeat until user breaks program
85 elapsed = 0
86 end
87 end
88 ------------------------------------------------------------
89 end--for
90end--while
91
92-- end of script
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk4.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk4.lua
deleted file mode 100644
index b94386b..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/bench_llex_mk4.lua
+++ /dev/null
@@ -1,94 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 bench_llex.lua
4 Benchmark test for llex.lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15local zio_init = require("../lzio_mk4")
16local lex_init = require("../llex_mk4")
17
18------------------------------------------------------------------------
19-- load in a standard set of sample files
20-- * file set is 5.0.3 front end set sans luac.lua
21------------------------------------------------------------------------
22
23local fileset, totalsize = {}, 0
24for fn in string.gfind([[
25../../orig-5.0.3/lcode.lua
26../../orig-5.0.3/ldump.lua
27../../orig-5.0.3/llex.lua
28../../orig-5.0.3/lopcodes.lua
29../../orig-5.0.3/lparser.lua
30../../orig-5.0.3/lzio.lua
31]], "%S+") do
32 table.insert(fileset, fn)
33end
34
35for i = 1, table.getn(fileset) do
36 local fn = fileset[i]
37 local inf = io.open(fn, "rb")
38 if not inf then
39 error("failed to open "..fn.." for reading")
40 end
41 local data = inf:read("*a")
42 local data_sz = string.len(data)
43 inf:close()
44 if not data or data_sz == 0 then
45 error("failed to read data from "..fn.." or file is zero-length")
46 end
47 totalsize = totalsize + data_sz
48 fileset[i] = data
49end
50
51------------------------------------------------------------------------
52-- benchmark tester
53------------------------------------------------------------------------
54
55local DURATION = 5 -- how long the benchmark should run
56
57local time = os.time
58local lexedsize = 0
59local tnow, elapsed = time(), 0
60
61while time() == tnow do end -- wait for second to click over
62tnow = time()
63
64while true do
65 for i = 1, table.getn(fileset) do
66 ------------------------------------------------------------
67 local chunk = fileset[i]
68 local z = zio_init(chunk)
69 local luaX = lex_init(z, "=string")
70 while true do
71 local tok, seminfo = luaX:lex()
72 if tok == "<eof>" then break end
73 end
74 ------------------------------------------------------------
75 lexedsize = lexedsize + string.len(chunk)
76 if time() > tnow then
77 tnow = time()
78 elapsed = elapsed + 1
79 if elapsed >= DURATION then
80 -- report performance of lexer
81 lexedsize = lexedsize / 1024
82 local speed = lexedsize / DURATION
83 print("Lexer performance:")
84 print("Size of data lexed (KB): "..string.format("%.1f", lexedsize))
85 print("Speed of lexer (KB/s): "..string.format("%.1f", speed))
86 -- repeat until user breaks program
87 elapsed = 0
88 end
89 end
90 ------------------------------------------------------------
91 end--for
92end--while
93
94-- end of script
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_01.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_01.lua
deleted file mode 100644
index 379cc9d..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_01.lua
+++ /dev/null
@@ -1,9 +0,0 @@
1-- START OF SOURCE --
2-- END OF SOURCE --
3
4-- TOP: begin
5 open_func
6
7 chunk:
8 close_func
9-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_02.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_02.lua
deleted file mode 100644
index 13eb2e6..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_02.lua
+++ /dev/null
@@ -1,10 +0,0 @@
1-- START OF SOURCE --
2-- foobar
3-- END OF SOURCE --
4
5-- TOP: begin
6 open_func
7
8 chunk:
9 close_func
10-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_03.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_03.lua
deleted file mode 100644
index 33df29c..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_03.lua
+++ /dev/null
@@ -1,21 +0,0 @@
1-- START OF SOURCE --
2do
3end
4-- END OF SOURCE --
5
6-- TOP: begin
7 open_func
8
9 chunk:
10 -- STATEMENT: begin 'do' line=1
11 do_stat: begin
12 block: begin
13 enterblock(isbreakable=false)
14 chunk:
15 leaveblock
16 block: end
17 do_stat: end
18 -- STATEMENT: end 'do'
19
20 close_func
21-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_04.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_04.lua
deleted file mode 100644
index d0fefbc..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_04.lua
+++ /dev/null
@@ -1,31 +0,0 @@
1-- START OF SOURCE --
2do end
3do end
4-- END OF SOURCE --
5
6-- TOP: begin
7 open_func
8
9 chunk:
10 -- STATEMENT: begin 'do' line=1
11 do_stat: begin
12 block: begin
13 enterblock(isbreakable=false)
14 chunk:
15 leaveblock
16 block: end
17 do_stat: end
18 -- STATEMENT: end 'do'
19
20 -- STATEMENT: begin 'do' line=2
21 do_stat: begin
22 block: begin
23 enterblock(isbreakable=false)
24 chunk:
25 leaveblock
26 block: end
27 do_stat: end
28 -- STATEMENT: end 'do'
29
30 close_func
31-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_05.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_05.lua
deleted file mode 100644
index 8d6f962..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_05.lua
+++ /dev/null
@@ -1,129 +0,0 @@
1-- START OF SOURCE --
2foo()
3foo{}
4foo""
5foo:bar()
6foo=false
7foo.bar=true
8foo[true]=nil
9foo,bar=1,"a"
10-- END OF SOURCE --
11
12-- TOP: begin
13 open_func
14
15 chunk:
16 -- STATEMENT: begin 'expr' line=1
17 prefixexp: <name>
18 str_checkname: 'foo'
19 singlevar: name='foo'
20 primaryexp: ( funcargs
21 funcargs: begin '('
22 funcargs: end -- expr is a VCALL
23 expr_stat: function call k='VCALL'
24 -- STATEMENT: end 'expr'
25
26 -- STATEMENT: begin 'expr' line=2
27 prefixexp: <name>
28 str_checkname: 'foo'
29 singlevar: name='foo'
30 primaryexp: { funcargs
31 funcargs: begin '{'
32 constructor: begin
33 constructor: end
34 funcargs: end -- expr is a VCALL
35 expr_stat: function call k='VCALL'
36 -- STATEMENT: end 'expr'
37
38 -- STATEMENT: begin 'expr' line=3
39 prefixexp: <name>
40 str_checkname: 'foo'
41 singlevar: name='foo'
42 primaryexp: <string> funcargs
43 funcargs: begin <string>
44 codestring: ""
45 funcargs: end -- expr is a VCALL
46 expr_stat: function call k='VCALL'
47 -- STATEMENT: end 'expr'
48
49 -- STATEMENT: begin 'expr' line=4
50 prefixexp: <name>
51 str_checkname: 'foo'
52 singlevar: name='foo'
53 primaryexp: :<name> funcargs
54 checkname:
55 str_checkname: 'bar'
56 codestring: "bar"
57 funcargs: begin '('
58 funcargs: end -- expr is a VCALL
59 expr_stat: function call k='VCALL'
60 -- STATEMENT: end 'expr'
61
62 -- STATEMENT: begin 'expr' line=5
63 prefixexp: <name>
64 str_checkname: 'foo'
65 singlevar: name='foo'
66 expr_stat: assignment k='VLOCAL'
67 assignment: '=' -- RHS elements follows
68 explist1: begin
69 expr:
70 simpleexp: false
71 explist1: end
72 -- STATEMENT: end 'expr'
73
74 -- STATEMENT: begin 'expr' line=6
75 prefixexp: <name>
76 str_checkname: 'foo'
77 singlevar: name='foo'
78 primaryexp: '.' field
79 field: operator=.
80 checkname:
81 str_checkname: 'bar'
82 codestring: "bar"
83 expr_stat: assignment k='VINDEXED'
84 assignment: '=' -- RHS elements follows
85 explist1: begin
86 expr:
87 simpleexp: true
88 explist1: end
89 -- STATEMENT: end 'expr'
90
91 -- STATEMENT: begin 'expr' line=7
92 prefixexp: <name>
93 str_checkname: 'foo'
94 singlevar: name='foo'
95 primaryexp: [ exp1 ]
96 index: begin '['
97 expr:
98 simpleexp: true
99 index: end ']'
100 expr_stat: assignment k='VLOCAL'
101 assignment: '=' -- RHS elements follows
102 explist1: begin
103 expr:
104 simpleexp: nil
105 explist1: end
106 -- STATEMENT: end 'expr'
107
108 -- STATEMENT: begin 'expr' line=8
109 prefixexp: <name>
110 str_checkname: 'foo'
111 singlevar: name='foo'
112 expr_stat: assignment k='VLOCAL'
113 assignment: ',' -- next LHS element
114 prefixexp: <name>
115 str_checkname: 'bar'
116 singlevar: name='bar'
117 assignment: '=' -- RHS elements follows
118 explist1: begin
119 expr:
120 simpleexp: <number>=1
121 explist1: ',' -- continuation
122 expr:
123 simpleexp: <string>=a
124 codestring: "a"
125 explist1: end
126 -- STATEMENT: end 'expr'
127
128 close_func
129-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_06.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_06.lua
deleted file mode 100644
index ca7776e..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_06.lua
+++ /dev/null
@@ -1,132 +0,0 @@
1-- START OF SOURCE --
2foo=true
3foo=false
4foo=nil
5foo=1.23e45
6foo=-1
7foo=(0)
8foo=1+2
9foo=1+2*3-4/5
10-- END OF SOURCE --
11
12-- TOP: begin
13 open_func
14
15 chunk:
16 -- STATEMENT: begin 'expr' line=1
17 prefixexp: <name>
18 str_checkname: 'foo'
19 singlevar: name='foo'
20 expr_stat: assignment k='VLOCAL'
21 assignment: '=' -- RHS elements follows
22 explist1: begin
23 expr:
24 simpleexp: true
25 explist1: end
26 -- STATEMENT: end 'expr'
27
28 -- STATEMENT: begin 'expr' line=2
29 prefixexp: <name>
30 str_checkname: 'foo'
31 singlevar: name='foo'
32 expr_stat: assignment k='VLOCAL'
33 assignment: '=' -- RHS elements follows
34 explist1: begin
35 expr:
36 simpleexp: false
37 explist1: end
38 -- STATEMENT: end 'expr'
39
40 -- STATEMENT: begin 'expr' line=3
41 prefixexp: <name>
42 str_checkname: 'foo'
43 singlevar: name='foo'
44 expr_stat: assignment k='VLOCAL'
45 assignment: '=' -- RHS elements follows
46 explist1: begin
47 expr:
48 simpleexp: nil
49 explist1: end
50 -- STATEMENT: end 'expr'
51
52 -- STATEMENT: begin 'expr' line=4
53 prefixexp: <name>
54 str_checkname: 'foo'
55 singlevar: name='foo'
56 expr_stat: assignment k='VLOCAL'
57 assignment: '=' -- RHS elements follows
58 explist1: begin
59 expr:
60 simpleexp: <number>=1.23e+45
61 explist1: end
62 -- STATEMENT: end 'expr'
63
64 -- STATEMENT: begin 'expr' line=5
65 prefixexp: <name>
66 str_checkname: 'foo'
67 singlevar: name='foo'
68 expr_stat: assignment k='VLOCAL'
69 assignment: '=' -- RHS elements follows
70 explist1: begin
71 expr:
72 subexpr: uop='-'
73 simpleexp: <number>=1
74 explist1: end
75 -- STATEMENT: end 'expr'
76
77 -- STATEMENT: begin 'expr' line=6
78 prefixexp: <name>
79 str_checkname: 'foo'
80 singlevar: name='foo'
81 expr_stat: assignment k='VLOCAL'
82 assignment: '=' -- RHS elements follows
83 explist1: begin
84 expr:
85 prefixexp: begin ( expr )
86 expr:
87 simpleexp: <number>=0
88 prefixexp: end ( expr )
89 explist1: end
90 -- STATEMENT: end 'expr'
91
92 -- STATEMENT: begin 'expr' line=7
93 prefixexp: <name>
94 str_checkname: 'foo'
95 singlevar: name='foo'
96 expr_stat: assignment k='VLOCAL'
97 assignment: '=' -- RHS elements follows
98 explist1: begin
99 expr:
100 simpleexp: <number>=1
101 subexpr: binop='+'
102 simpleexp: <number>=2
103 subexpr: -- evaluate
104 explist1: end
105 -- STATEMENT: end 'expr'
106
107 -- STATEMENT: begin 'expr' line=8
108 prefixexp: <name>
109 str_checkname: 'foo'
110 singlevar: name='foo'
111 expr_stat: assignment k='VLOCAL'
112 assignment: '=' -- RHS elements follows
113 explist1: begin
114 expr:
115 simpleexp: <number>=1
116 subexpr: binop='+'
117 simpleexp: <number>=2
118 subexpr: binop='*'
119 simpleexp: <number>=3
120 subexpr: -- evaluate
121 subexpr: -- evaluate
122 subexpr: binop='-'
123 simpleexp: <number>=4
124 subexpr: binop='/'
125 simpleexp: <number>=5
126 subexpr: -- evaluate
127 subexpr: -- evaluate
128 explist1: end
129 -- STATEMENT: end 'expr'
130
131 close_func
132-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_07.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_07.lua
deleted file mode 100644
index 8c0a738..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_07.lua
+++ /dev/null
@@ -1,147 +0,0 @@
1-- START OF SOURCE --
2if foo then foo=1 end
3if foo then foo=1 else foo=0 end
4if foo then foo=1 elseif not foo then foo=0 end
5-- END OF SOURCE --
6
7-- TOP: begin
8 open_func
9
10 chunk:
11 -- STATEMENT: begin 'if' line=1
12 if_stat: if...then
13 test_then_block: test condition
14 cond: begin
15 expr:
16 prefixexp: <name>
17 str_checkname: 'foo'
18 singlevar: name='foo'
19 cond: end
20 test_then_block: then block
21 block: begin
22 enterblock(isbreakable=false)
23 chunk:
24 -- STATEMENT: begin 'expr' line=1
25 prefixexp: <name>
26 str_checkname: 'foo'
27 singlevar: name='foo'
28 expr_stat: assignment k='VLOCAL'
29 assignment: '=' -- RHS elements follows
30 explist1: begin
31 expr:
32 simpleexp: <number>=1
33 explist1: end
34 -- STATEMENT: end 'expr'
35
36 leaveblock
37 block: end
38 if_stat: end
39 -- STATEMENT: end 'if'
40
41 -- STATEMENT: begin 'if' line=2
42 if_stat: if...then
43 test_then_block: test condition
44 cond: begin
45 expr:
46 prefixexp: <name>
47 str_checkname: 'foo'
48 singlevar: name='foo'
49 cond: end
50 test_then_block: then block
51 block: begin
52 enterblock(isbreakable=false)
53 chunk:
54 -- STATEMENT: begin 'expr' line=2
55 prefixexp: <name>
56 str_checkname: 'foo'
57 singlevar: name='foo'
58 expr_stat: assignment k='VLOCAL'
59 assignment: '=' -- RHS elements follows
60 explist1: begin
61 expr:
62 simpleexp: <number>=1
63 explist1: end
64 -- STATEMENT: end 'expr'
65
66 leaveblock
67 block: end
68 if_stat: else...
69 block: begin
70 enterblock(isbreakable=false)
71 chunk:
72 -- STATEMENT: begin 'expr' line=2
73 prefixexp: <name>
74 str_checkname: 'foo'
75 singlevar: name='foo'
76 expr_stat: assignment k='VLOCAL'
77 assignment: '=' -- RHS elements follows
78 explist1: begin
79 expr:
80 simpleexp: <number>=0
81 explist1: end
82 -- STATEMENT: end 'expr'
83
84 leaveblock
85 block: end
86 if_stat: end
87 -- STATEMENT: end 'if'
88
89 -- STATEMENT: begin 'if' line=3
90 if_stat: if...then
91 test_then_block: test condition
92 cond: begin
93 expr:
94 prefixexp: <name>
95 str_checkname: 'foo'
96 singlevar: name='foo'
97 cond: end
98 test_then_block: then block
99 block: begin
100 enterblock(isbreakable=false)
101 chunk:
102 -- STATEMENT: begin 'expr' line=3
103 prefixexp: <name>
104 str_checkname: 'foo'
105 singlevar: name='foo'
106 expr_stat: assignment k='VLOCAL'
107 assignment: '=' -- RHS elements follows
108 explist1: begin
109 expr:
110 simpleexp: <number>=1
111 explist1: end
112 -- STATEMENT: end 'expr'
113
114 leaveblock
115 block: end
116 if_stat: elseif...then
117 test_then_block: test condition
118 cond: begin
119 expr:
120 subexpr: uop='not'
121 prefixexp: <name>
122 str_checkname: 'foo'
123 singlevar: name='foo'
124 cond: end
125 test_then_block: then block
126 block: begin
127 enterblock(isbreakable=false)
128 chunk:
129 -- STATEMENT: begin 'expr' line=3
130 prefixexp: <name>
131 str_checkname: 'foo'
132 singlevar: name='foo'
133 expr_stat: assignment k='VLOCAL'
134 assignment: '=' -- RHS elements follows
135 explist1: begin
136 expr:
137 simpleexp: <number>=0
138 explist1: end
139 -- STATEMENT: end 'expr'
140
141 leaveblock
142 block: end
143 if_stat: end
144 -- STATEMENT: end 'if'
145
146 close_func
147-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_08.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_08.lua
deleted file mode 100644
index d086c98..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_08.lua
+++ /dev/null
@@ -1,66 +0,0 @@
1-- START OF SOURCE --
2do return end
3do return 123 end
4do return "foo","bar" end
5-- END OF SOURCE --
6
7-- TOP: begin
8 open_func
9
10 chunk:
11 -- STATEMENT: begin 'do' line=1
12 do_stat: begin
13 block: begin
14 enterblock(isbreakable=false)
15 chunk:
16 -- STATEMENT: begin 'return' line=1
17 return_stat: no return values
18 -- STATEMENT: end 'return'
19 leaveblock
20 block: end
21 do_stat: end
22 -- STATEMENT: end 'do'
23
24 -- STATEMENT: begin 'do' line=2
25 do_stat: begin
26 block: begin
27 enterblock(isbreakable=false)
28 chunk:
29 -- STATEMENT: begin 'return' line=2
30 return_stat: begin
31 explist1: begin
32 expr:
33 simpleexp: <number>=123
34 explist1: end
35 return_stat: end
36 -- STATEMENT: end 'return'
37 leaveblock
38 block: end
39 do_stat: end
40 -- STATEMENT: end 'do'
41
42 -- STATEMENT: begin 'do' line=3
43 do_stat: begin
44 block: begin
45 enterblock(isbreakable=false)
46 chunk:
47 -- STATEMENT: begin 'return' line=3
48 return_stat: begin
49 explist1: begin
50 expr:
51 simpleexp: <string>=foo
52 codestring: "foo"
53 explist1: ',' -- continuation
54 expr:
55 simpleexp: <string>=bar
56 codestring: "bar"
57 explist1: end
58 return_stat: end
59 -- STATEMENT: end 'return'
60 leaveblock
61 block: end
62 do_stat: end
63 -- STATEMENT: end 'do'
64
65 close_func
66-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_09.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_09.lua
deleted file mode 100644
index 2236388..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_09.lua
+++ /dev/null
@@ -1,97 +0,0 @@
1-- START OF SOURCE --
2while true do foo=not foo end
3while foo~=42 do foo=foo-1 end
4while true do break end
5-- END OF SOURCE --
6
7-- TOP: begin
8 open_func
9
10 chunk:
11 -- STATEMENT: begin 'while' line=1
12 while_stat: begin/condition
13 expr:
14 simpleexp: true
15 enterblock(isbreakable=true)
16 while_stat: block
17 block: begin
18 enterblock(isbreakable=false)
19 chunk:
20 -- STATEMENT: begin 'expr' line=1
21 prefixexp: <name>
22 str_checkname: 'foo'
23 singlevar: name='foo'
24 expr_stat: assignment k='VLOCAL'
25 assignment: '=' -- RHS elements follows
26 explist1: begin
27 expr:
28 subexpr: uop='not'
29 prefixexp: <name>
30 str_checkname: 'foo'
31 singlevar: name='foo'
32 explist1: end
33 -- STATEMENT: end 'expr'
34
35 leaveblock
36 block: end
37 leaveblock
38 while_stat: end
39 -- STATEMENT: end 'while'
40
41 -- STATEMENT: begin 'while' line=2
42 while_stat: begin/condition
43 expr:
44 prefixexp: <name>
45 str_checkname: 'foo'
46 singlevar: name='foo'
47 subexpr: binop='~='
48 simpleexp: <number>=42
49 subexpr: -- evaluate
50 enterblock(isbreakable=true)
51 while_stat: block
52 block: begin
53 enterblock(isbreakable=false)
54 chunk:
55 -- STATEMENT: begin 'expr' line=2
56 prefixexp: <name>
57 str_checkname: 'foo'
58 singlevar: name='foo'
59 expr_stat: assignment k='VLOCAL'
60 assignment: '=' -- RHS elements follows
61 explist1: begin
62 expr:
63 prefixexp: <name>
64 str_checkname: 'foo'
65 singlevar: name='foo'
66 subexpr: binop='-'
67 simpleexp: <number>=1
68 subexpr: -- evaluate
69 explist1: end
70 -- STATEMENT: end 'expr'
71
72 leaveblock
73 block: end
74 leaveblock
75 while_stat: end
76 -- STATEMENT: end 'while'
77
78 -- STATEMENT: begin 'while' line=3
79 while_stat: begin/condition
80 expr:
81 simpleexp: true
82 enterblock(isbreakable=true)
83 while_stat: block
84 block: begin
85 enterblock(isbreakable=false)
86 chunk:
87 -- STATEMENT: begin 'break' line=3
88 break_stat: -- break out of loop
89 -- STATEMENT: end 'break'
90 leaveblock
91 block: end
92 leaveblock
93 while_stat: end
94 -- STATEMENT: end 'while'
95
96 close_func
97-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_10.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_10.lua
deleted file mode 100644
index 72f7ae3..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_10.lua
+++ /dev/null
@@ -1,106 +0,0 @@
1-- START OF SOURCE --
2repeat foo=foo.."bar" until false
3repeat foo=foo/2 until foo<1
4repeat break until false
5-- END OF SOURCE --
6
7-- TOP: begin
8 open_func
9
10 chunk:
11 -- STATEMENT: begin 'repeat' line=1
12 repeat_stat: begin
13 enterblock(isbreakable=true)
14 block: begin
15 enterblock(isbreakable=false)
16 chunk:
17 -- STATEMENT: begin 'expr' line=1
18 prefixexp: <name>
19 str_checkname: 'foo'
20 singlevar: name='foo'
21 expr_stat: assignment k='VLOCAL'
22 assignment: '=' -- RHS elements follows
23 explist1: begin
24 expr:
25 prefixexp: <name>
26 str_checkname: 'foo'
27 singlevar: name='foo'
28 subexpr: binop='..'
29 simpleexp: <string>=bar
30 codestring: "bar"
31 subexpr: -- evaluate
32 explist1: end
33 -- STATEMENT: end 'expr'
34
35 leaveblock
36 block: end
37 repeat_stat: condition
38 cond: begin
39 expr:
40 simpleexp: false
41 cond: end
42 leaveblock
43 repeat_stat: end
44 -- STATEMENT: end 'repeat'
45
46 -- STATEMENT: begin 'repeat' line=2
47 repeat_stat: begin
48 enterblock(isbreakable=true)
49 block: begin
50 enterblock(isbreakable=false)
51 chunk:
52 -- STATEMENT: begin 'expr' line=2
53 prefixexp: <name>
54 str_checkname: 'foo'
55 singlevar: name='foo'
56 expr_stat: assignment k='VLOCAL'
57 assignment: '=' -- RHS elements follows
58 explist1: begin
59 expr:
60 prefixexp: <name>
61 str_checkname: 'foo'
62 singlevar: name='foo'
63 subexpr: binop='/'
64 simpleexp: <number>=2
65 subexpr: -- evaluate
66 explist1: end
67 -- STATEMENT: end 'expr'
68
69 leaveblock
70 block: end
71 repeat_stat: condition
72 cond: begin
73 expr:
74 prefixexp: <name>
75 str_checkname: 'foo'
76 singlevar: name='foo'
77 subexpr: binop='<'
78 simpleexp: <number>=1
79 subexpr: -- evaluate
80 cond: end
81 leaveblock
82 repeat_stat: end
83 -- STATEMENT: end 'repeat'
84
85 -- STATEMENT: begin 'repeat' line=3
86 repeat_stat: begin
87 enterblock(isbreakable=true)
88 block: begin
89 enterblock(isbreakable=false)
90 chunk:
91 -- STATEMENT: begin 'break' line=3
92 break_stat: -- break out of loop
93 -- STATEMENT: end 'break'
94 leaveblock
95 block: end
96 repeat_stat: condition
97 cond: begin
98 expr:
99 simpleexp: false
100 cond: end
101 leaveblock
102 repeat_stat: end
103 -- STATEMENT: end 'repeat'
104
105 close_func
106-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_11.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_11.lua
deleted file mode 100644
index 8af611b..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_11.lua
+++ /dev/null
@@ -1,175 +0,0 @@
1-- START OF SOURCE --
2for i=1,10 do foo=i end
3for i=1,10,2 do break end
4for i in foo do bar=0 end
5for i,j in foo,bar do baz=0 end
6-- END OF SOURCE --
7
8-- TOP: begin
9 open_func
10
11 chunk:
12 -- STATEMENT: begin 'for' line=1
13 for_stat: begin
14 enterblock(isbreakable=false)
15 str_checkname: 'i'
16 for_stat: numerical loop
17 fornum: begin
18 fornum: index start
19 exp1: begin
20 expr:
21 simpleexp: <number>=1
22 exp1: end
23 fornum: index stop
24 exp1: begin
25 expr:
26 simpleexp: <number>=10
27 exp1: end
28 fornum: body
29 enterblock(isbreakable=true)
30 block: begin
31 enterblock(isbreakable=false)
32 chunk:
33 -- STATEMENT: begin 'expr' line=1
34 prefixexp: <name>
35 str_checkname: 'foo'
36 singlevar: name='foo'
37 expr_stat: assignment k='VLOCAL'
38 assignment: '=' -- RHS elements follows
39 explist1: begin
40 expr:
41 prefixexp: <name>
42 str_checkname: 'i'
43 singlevar: name='i'
44 explist1: end
45 -- STATEMENT: end 'expr'
46
47 leaveblock
48 block: end
49 leaveblock
50 fornum: end
51 leaveblock
52 for_stat: end
53 -- STATEMENT: end 'for'
54
55 -- STATEMENT: begin 'for' line=2
56 for_stat: begin
57 enterblock(isbreakable=false)
58 str_checkname: 'i'
59 for_stat: numerical loop
60 fornum: begin
61 fornum: index start
62 exp1: begin
63 expr:
64 simpleexp: <number>=1
65 exp1: end
66 fornum: index stop
67 exp1: begin
68 expr:
69 simpleexp: <number>=10
70 exp1: end
71 fornum: index step
72 exp1: begin
73 expr:
74 simpleexp: <number>=2
75 exp1: end
76 fornum: body
77 enterblock(isbreakable=true)
78 block: begin
79 enterblock(isbreakable=false)
80 chunk:
81 -- STATEMENT: begin 'break' line=2
82 break_stat: -- break out of loop
83 -- STATEMENT: end 'break'
84 leaveblock
85 block: end
86 leaveblock
87 fornum: end
88 leaveblock
89 for_stat: end
90 -- STATEMENT: end 'for'
91
92 -- STATEMENT: begin 'for' line=3
93 for_stat: begin
94 enterblock(isbreakable=false)
95 str_checkname: 'i'
96 for_stat: list-based loop
97 forlist: begin
98 forlist: explist1
99 explist1: begin
100 expr:
101 prefixexp: <name>
102 str_checkname: 'foo'
103 singlevar: name='foo'
104 explist1: end
105 forlist: body
106 enterblock(isbreakable=true)
107 block: begin
108 enterblock(isbreakable=false)
109 chunk:
110 -- STATEMENT: begin 'expr' line=3
111 prefixexp: <name>
112 str_checkname: 'bar'
113 singlevar: name='bar'
114 expr_stat: assignment k='VLOCAL'
115 assignment: '=' -- RHS elements follows
116 explist1: begin
117 expr:
118 simpleexp: <number>=0
119 explist1: end
120 -- STATEMENT: end 'expr'
121
122 leaveblock
123 block: end
124 leaveblock
125 forlist: end
126 leaveblock
127 for_stat: end
128 -- STATEMENT: end 'for'
129
130 -- STATEMENT: begin 'for' line=4
131 for_stat: begin
132 enterblock(isbreakable=false)
133 str_checkname: 'i'
134 for_stat: list-based loop
135 forlist: begin
136 str_checkname: 'j'
137 forlist: explist1
138 explist1: begin
139 expr:
140 prefixexp: <name>
141 str_checkname: 'foo'
142 singlevar: name='foo'
143 explist1: ',' -- continuation
144 expr:
145 prefixexp: <name>
146 str_checkname: 'bar'
147 singlevar: name='bar'
148 explist1: end
149 forlist: body
150 enterblock(isbreakable=true)
151 block: begin
152 enterblock(isbreakable=false)
153 chunk:
154 -- STATEMENT: begin 'expr' line=4
155 prefixexp: <name>
156 str_checkname: 'baz'
157 singlevar: name='baz'
158 expr_stat: assignment k='VLOCAL'
159 assignment: '=' -- RHS elements follows
160 explist1: begin
161 expr:
162 simpleexp: <number>=0
163 explist1: end
164 -- STATEMENT: end 'expr'
165
166 leaveblock
167 block: end
168 leaveblock
169 forlist: end
170 leaveblock
171 for_stat: end
172 -- STATEMENT: end 'for'
173
174 close_func
175-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_12.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_12.lua
deleted file mode 100644
index 916fc7f..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_12.lua
+++ /dev/null
@@ -1,46 +0,0 @@
1-- START OF SOURCE --
2local foo
3local foo,bar,baz
4local foo,bar="foo","bar"
5-- END OF SOURCE --
6
7-- TOP: begin
8 open_func
9
10 chunk:
11 -- STATEMENT: begin 'local' line=1
12 local_stat: local statement
13 localstat: begin
14 str_checkname: 'foo'
15 localstat: end
16 -- STATEMENT: end 'local'
17
18 -- STATEMENT: begin 'local' line=2
19 local_stat: local statement
20 localstat: begin
21 str_checkname: 'foo'
22 str_checkname: 'bar'
23 str_checkname: 'baz'
24 localstat: end
25 -- STATEMENT: end 'local'
26
27 -- STATEMENT: begin 'local' line=3
28 local_stat: local statement
29 localstat: begin
30 str_checkname: 'foo'
31 str_checkname: 'bar'
32 localstat: -- assignment
33 explist1: begin
34 expr:
35 simpleexp: <string>=foo
36 codestring: "foo"
37 explist1: ',' -- continuation
38 expr:
39 simpleexp: <string>=bar
40 codestring: "bar"
41 explist1: end
42 localstat: end
43 -- STATEMENT: end 'local'
44
45 close_func
46-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_13.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_13.lua
deleted file mode 100644
index 8ddd3ea..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_13.lua
+++ /dev/null
@@ -1,99 +0,0 @@
1-- START OF SOURCE --
2local function foo() return end
3local function foo(a) return end
4local function foo(x,y,z) return end
5local function foo(x,...) return end
6-- END OF SOURCE --
7
8-- TOP: begin
9 open_func
10
11 chunk:
12 -- STATEMENT: begin 'local' line=1
13 local_stat: local function
14 localfunc: begin
15 str_checkname: 'foo'
16 localfunc: body
17 open_func
18 body: begin
19 body: parlist
20 parlist: begin
21 parlist: end
22 body: chunk
23 chunk:
24 -- STATEMENT: begin 'return' line=1
25 return_stat: no return values
26 -- STATEMENT: end 'return'
27 body: end
28 close_func
29 localfunc: end
30 -- STATEMENT: end 'local'
31
32 -- STATEMENT: begin 'local' line=2
33 local_stat: local function
34 localfunc: begin
35 str_checkname: 'foo'
36 localfunc: body
37 open_func
38 body: begin
39 body: parlist
40 parlist: begin
41 str_checkname: 'a'
42 parlist: end
43 body: chunk
44 chunk:
45 -- STATEMENT: begin 'return' line=2
46 return_stat: no return values
47 -- STATEMENT: end 'return'
48 body: end
49 close_func
50 localfunc: end
51 -- STATEMENT: end 'local'
52
53 -- STATEMENT: begin 'local' line=3
54 local_stat: local function
55 localfunc: begin
56 str_checkname: 'foo'
57 localfunc: body
58 open_func
59 body: begin
60 body: parlist
61 parlist: begin
62 str_checkname: 'x'
63 str_checkname: 'y'
64 str_checkname: 'z'
65 parlist: end
66 body: chunk
67 chunk:
68 -- STATEMENT: begin 'return' line=3
69 return_stat: no return values
70 -- STATEMENT: end 'return'
71 body: end
72 close_func
73 localfunc: end
74 -- STATEMENT: end 'local'
75
76 -- STATEMENT: begin 'local' line=4
77 local_stat: local function
78 localfunc: begin
79 str_checkname: 'foo'
80 localfunc: body
81 open_func
82 body: begin
83 body: parlist
84 parlist: begin
85 str_checkname: 'x'
86 parlist: ... (dots)
87 parlist: end
88 body: chunk
89 chunk:
90 -- STATEMENT: begin 'return' line=4
91 return_stat: no return values
92 -- STATEMENT: end 'return'
93 body: end
94 close_func
95 localfunc: end
96 -- STATEMENT: end 'local'
97
98 close_func
99-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_14.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_14.lua
deleted file mode 100644
index aa0069a..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_14.lua
+++ /dev/null
@@ -1,107 +0,0 @@
1-- START OF SOURCE --
2function foo() return end
3function foo(a) return end
4function foo(x,y,z) return end
5function foo(x,...) return end
6-- END OF SOURCE --
7
8-- TOP: begin
9 open_func
10
11 chunk:
12 -- STATEMENT: begin 'function' line=1
13 function_stat: begin
14 funcname: begin
15 str_checkname: 'foo'
16 singlevar: name='foo'
17 funcname: end
18 function_stat: body needself='false'
19 open_func
20 body: begin
21 body: parlist
22 parlist: begin
23 parlist: end
24 body: chunk
25 chunk:
26 -- STATEMENT: begin 'return' line=1
27 return_stat: no return values
28 -- STATEMENT: end 'return'
29 body: end
30 close_func
31 function_stat: end
32 -- STATEMENT: end 'function'
33
34 -- STATEMENT: begin 'function' line=2
35 function_stat: begin
36 funcname: begin
37 str_checkname: 'foo'
38 singlevar: name='foo'
39 funcname: end
40 function_stat: body needself='false'
41 open_func
42 body: begin
43 body: parlist
44 parlist: begin
45 str_checkname: 'a'
46 parlist: end
47 body: chunk
48 chunk:
49 -- STATEMENT: begin 'return' line=2
50 return_stat: no return values
51 -- STATEMENT: end 'return'
52 body: end
53 close_func
54 function_stat: end
55 -- STATEMENT: end 'function'
56
57 -- STATEMENT: begin 'function' line=3
58 function_stat: begin
59 funcname: begin
60 str_checkname: 'foo'
61 singlevar: name='foo'
62 funcname: end
63 function_stat: body needself='false'
64 open_func
65 body: begin
66 body: parlist
67 parlist: begin
68 str_checkname: 'x'
69 str_checkname: 'y'
70 str_checkname: 'z'
71 parlist: end
72 body: chunk
73 chunk:
74 -- STATEMENT: begin 'return' line=3
75 return_stat: no return values
76 -- STATEMENT: end 'return'
77 body: end
78 close_func
79 function_stat: end
80 -- STATEMENT: end 'function'
81
82 -- STATEMENT: begin 'function' line=4
83 function_stat: begin
84 funcname: begin
85 str_checkname: 'foo'
86 singlevar: name='foo'
87 funcname: end
88 function_stat: body needself='false'
89 open_func
90 body: begin
91 body: parlist
92 parlist: begin
93 str_checkname: 'x'
94 parlist: ... (dots)
95 parlist: end
96 body: chunk
97 chunk:
98 -- STATEMENT: begin 'return' line=4
99 return_stat: no return values
100 -- STATEMENT: end 'return'
101 body: end
102 close_func
103 function_stat: end
104 -- STATEMENT: end 'function'
105
106 close_func
107-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_15.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_15.lua
deleted file mode 100644
index 73cdac3..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_15.lua
+++ /dev/null
@@ -1,135 +0,0 @@
1-- START OF SOURCE --
2function foo.bar(p) return end
3function foo.bar.baz(p) return end
4function foo:bar(p) return end
5function foo.bar.baz(p) return end
6-- END OF SOURCE --
7
8-- TOP: begin
9 open_func
10
11 chunk:
12 -- STATEMENT: begin 'function' line=1
13 function_stat: begin
14 funcname: begin
15 str_checkname: 'foo'
16 singlevar: name='foo'
17 funcname: -- '.' field
18 field: operator=.
19 checkname:
20 str_checkname: 'bar'
21 codestring: "bar"
22 funcname: end
23 function_stat: body needself='false'
24 open_func
25 body: begin
26 body: parlist
27 parlist: begin
28 str_checkname: 'p'
29 parlist: end
30 body: chunk
31 chunk:
32 -- STATEMENT: begin 'return' line=1
33 return_stat: no return values
34 -- STATEMENT: end 'return'
35 body: end
36 close_func
37 function_stat: end
38 -- STATEMENT: end 'function'
39
40 -- STATEMENT: begin 'function' line=2
41 function_stat: begin
42 funcname: begin
43 str_checkname: 'foo'
44 singlevar: name='foo'
45 funcname: -- '.' field
46 field: operator=.
47 checkname:
48 str_checkname: 'bar'
49 codestring: "bar"
50 funcname: -- '.' field
51 field: operator=.
52 checkname:
53 str_checkname: 'baz'
54 codestring: "baz"
55 funcname: end
56 function_stat: body needself='false'
57 open_func
58 body: begin
59 body: parlist
60 parlist: begin
61 str_checkname: 'p'
62 parlist: end
63 body: chunk
64 chunk:
65 -- STATEMENT: begin 'return' line=2
66 return_stat: no return values
67 -- STATEMENT: end 'return'
68 body: end
69 close_func
70 function_stat: end
71 -- STATEMENT: end 'function'
72
73 -- STATEMENT: begin 'function' line=3
74 function_stat: begin
75 funcname: begin
76 str_checkname: 'foo'
77 singlevar: name='foo'
78 funcname: -- ':' field
79 field: operator=:
80 checkname:
81 str_checkname: 'bar'
82 codestring: "bar"
83 funcname: end
84 function_stat: body needself='true'
85 open_func
86 body: begin
87 body: parlist
88 parlist: begin
89 str_checkname: 'p'
90 parlist: end
91 body: chunk
92 chunk:
93 -- STATEMENT: begin 'return' line=3
94 return_stat: no return values
95 -- STATEMENT: end 'return'
96 body: end
97 close_func
98 function_stat: end
99 -- STATEMENT: end 'function'
100
101 -- STATEMENT: begin 'function' line=4
102 function_stat: begin
103 funcname: begin
104 str_checkname: 'foo'
105 singlevar: name='foo'
106 funcname: -- '.' field
107 field: operator=.
108 checkname:
109 str_checkname: 'bar'
110 codestring: "bar"
111 funcname: -- '.' field
112 field: operator=.
113 checkname:
114 str_checkname: 'baz'
115 codestring: "baz"
116 funcname: end
117 function_stat: body needself='false'
118 open_func
119 body: begin
120 body: parlist
121 parlist: begin
122 str_checkname: 'p'
123 parlist: end
124 body: chunk
125 chunk:
126 -- STATEMENT: begin 'return' line=4
127 return_stat: no return values
128 -- STATEMENT: end 'return'
129 body: end
130 close_func
131 function_stat: end
132 -- STATEMENT: end 'function'
133
134 close_func
135-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_16.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_16.lua
deleted file mode 100644
index b53b2fb..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_16.lua
+++ /dev/null
@@ -1,87 +0,0 @@
1-- START OF SOURCE --
2foo = function() return end
3foo = function(x,y) return end
4foo = function(...) return end
5-- END OF SOURCE --
6
7-- TOP: begin
8 open_func
9
10 chunk:
11 -- STATEMENT: begin 'expr' line=1
12 prefixexp: <name>
13 str_checkname: 'foo'
14 singlevar: name='foo'
15 expr_stat: assignment k='VLOCAL'
16 assignment: '=' -- RHS elements follows
17 explist1: begin
18 expr:
19 simpleexp: function
20 open_func
21 body: begin
22 body: parlist
23 parlist: begin
24 parlist: end
25 body: chunk
26 chunk:
27 -- STATEMENT: begin 'return' line=1
28 return_stat: no return values
29 -- STATEMENT: end 'return'
30 body: end
31 close_func
32 explist1: end
33 -- STATEMENT: end 'expr'
34
35 -- STATEMENT: begin 'expr' line=2
36 prefixexp: <name>
37 str_checkname: 'foo'
38 singlevar: name='foo'
39 expr_stat: assignment k='VLOCAL'
40 assignment: '=' -- RHS elements follows
41 explist1: begin
42 expr:
43 simpleexp: function
44 open_func
45 body: begin
46 body: parlist
47 parlist: begin
48 str_checkname: 'x'
49 str_checkname: 'y'
50 parlist: end
51 body: chunk
52 chunk:
53 -- STATEMENT: begin 'return' line=2
54 return_stat: no return values
55 -- STATEMENT: end 'return'
56 body: end
57 close_func
58 explist1: end
59 -- STATEMENT: end 'expr'
60
61 -- STATEMENT: begin 'expr' line=3
62 prefixexp: <name>
63 str_checkname: 'foo'
64 singlevar: name='foo'
65 expr_stat: assignment k='VLOCAL'
66 assignment: '=' -- RHS elements follows
67 explist1: begin
68 expr:
69 simpleexp: function
70 open_func
71 body: begin
72 body: parlist
73 parlist: begin
74 parlist: ... (dots)
75 parlist: end
76 body: chunk
77 chunk:
78 -- STATEMENT: begin 'return' line=3
79 return_stat: no return values
80 -- STATEMENT: end 'return'
81 body: end
82 close_func
83 explist1: end
84 -- STATEMENT: end 'expr'
85
86 close_func
87-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_17.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_17.lua
deleted file mode 100644
index 87634d3..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_17.lua
+++ /dev/null
@@ -1,110 +0,0 @@
1-- START OF SOURCE --
2foo = {}
3foo = { 1,2,3; "foo"; }
4foo = { bar=77, baz=88, }
5foo = { ["bar"]=77, ["baz"]=88, }
6-- END OF SOURCE --
7
8-- TOP: begin
9 open_func
10
11 chunk:
12 -- STATEMENT: begin 'expr' line=1
13 prefixexp: <name>
14 str_checkname: 'foo'
15 singlevar: name='foo'
16 expr_stat: assignment k='VLOCAL'
17 assignment: '=' -- RHS elements follows
18 explist1: begin
19 expr:
20 simpleexp: constructor
21 constructor: begin
22 constructor: end
23 explist1: end
24 -- STATEMENT: end 'expr'
25
26 -- STATEMENT: begin 'expr' line=2
27 prefixexp: <name>
28 str_checkname: 'foo'
29 singlevar: name='foo'
30 expr_stat: assignment k='VLOCAL'
31 assignment: '=' -- RHS elements follows
32 explist1: begin
33 expr:
34 simpleexp: constructor
35 constructor: begin
36 listfield: expr
37 expr:
38 simpleexp: <number>=1
39 listfield: expr
40 expr:
41 simpleexp: <number>=2
42 listfield: expr
43 expr:
44 simpleexp: <number>=3
45 listfield: expr
46 expr:
47 simpleexp: <string>=foo
48 codestring: "foo"
49 constructor: end
50 explist1: end
51 -- STATEMENT: end 'expr'
52
53 -- STATEMENT: begin 'expr' line=3
54 prefixexp: <name>
55 str_checkname: 'foo'
56 singlevar: name='foo'
57 expr_stat: assignment k='VLOCAL'
58 assignment: '=' -- RHS elements follows
59 explist1: begin
60 expr:
61 simpleexp: constructor
62 constructor: begin
63 recfield: name
64 checkname:
65 str_checkname: 'bar'
66 codestring: "bar"
67 expr:
68 simpleexp: <number>=77
69 recfield: name
70 checkname:
71 str_checkname: 'baz'
72 codestring: "baz"
73 expr:
74 simpleexp: <number>=88
75 constructor: end
76 explist1: end
77 -- STATEMENT: end 'expr'
78
79 -- STATEMENT: begin 'expr' line=4
80 prefixexp: <name>
81 str_checkname: 'foo'
82 singlevar: name='foo'
83 expr_stat: assignment k='VLOCAL'
84 assignment: '=' -- RHS elements follows
85 explist1: begin
86 expr:
87 simpleexp: constructor
88 constructor: begin
89 recfield: [ exp1 ]
90 index: begin '['
91 expr:
92 simpleexp: <string>=bar
93 codestring: "bar"
94 index: end ']'
95 expr:
96 simpleexp: <number>=77
97 recfield: [ exp1 ]
98 index: begin '['
99 expr:
100 simpleexp: <string>=baz
101 codestring: "baz"
102 index: end ']'
103 expr:
104 simpleexp: <number>=88
105 constructor: end
106 explist1: end
107 -- STATEMENT: end 'expr'
108
109 close_func
110-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_01.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_01.lua
deleted file mode 100644
index 732b4d6..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_01.lua
+++ /dev/null
@@ -1,26 +0,0 @@
1-- START OF SOURCE --
2 print(a)
3-- END OF SOURCE --
4
5-- TOP: begin
6 open_func
7
8 chunk:
9 -- STATEMENT: begin 'expr' line=1
10 prefixexp: <name>
11 str_checkname: 'print'
12 singlevar(kind): 'VGLOBAL'
13 primaryexp: ( funcargs
14 funcargs: begin '('
15 explist1: begin
16 expr:
17 prefixexp: <name>
18 str_checkname: 'a'
19 singlevar(kind): 'VGLOBAL'
20 explist1: end
21 funcargs: end -- expr is a VCALL
22 expr_stat: function call k='VCALL'
23 -- STATEMENT: end 'expr'
24
25 close_func
26-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_02.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_02.lua
deleted file mode 100644
index 9863b4a..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_02.lua
+++ /dev/null
@@ -1,35 +0,0 @@
1-- START OF SOURCE --
2 local a
3 print(a)
4-- END OF SOURCE --
5
6-- TOP: begin
7 open_func
8
9 chunk:
10 -- STATEMENT: begin 'local' line=1
11 local_stat: local statement
12 localstat: begin
13 str_checkname: 'a'
14 new_localvar: 'a'
15 localstat: end
16 -- STATEMENT: end 'local'
17
18 -- STATEMENT: begin 'expr' line=2
19 prefixexp: <name>
20 str_checkname: 'print'
21 singlevar(kind): 'VGLOBAL'
22 primaryexp: ( funcargs
23 funcargs: begin '('
24 explist1: begin
25 expr:
26 prefixexp: <name>
27 str_checkname: 'a'
28 singlevar(kind): 'VLOCAL'
29 explist1: end
30 funcargs: end -- expr is a VCALL
31 expr_stat: function call k='VCALL'
32 -- STATEMENT: end 'expr'
33
34 close_func
35-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_03.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_03.lua
deleted file mode 100644
index bc37280..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_03.lua
+++ /dev/null
@@ -1,64 +0,0 @@
1-- START OF SOURCE --
2 do
3 local a
4 print(a)
5 end
6 print(a)
7-- END OF SOURCE --
8
9-- TOP: begin
10 open_func
11
12 chunk:
13 -- STATEMENT: begin 'do' line=1
14 do_stat: begin
15 block: begin
16 enterblock(isbreakable=false)
17 chunk:
18 -- STATEMENT: begin 'local' line=2
19 local_stat: local statement
20 localstat: begin
21 str_checkname: 'a'
22 new_localvar: 'a'
23 localstat: end
24 -- STATEMENT: end 'local'
25
26 -- STATEMENT: begin 'expr' line=3
27 prefixexp: <name>
28 str_checkname: 'print'
29 singlevar(kind): 'VGLOBAL'
30 primaryexp: ( funcargs
31 funcargs: begin '('
32 explist1: begin
33 expr:
34 prefixexp: <name>
35 str_checkname: 'a'
36 singlevar(kind): 'VLOCAL'
37 explist1: end
38 funcargs: end -- expr is a VCALL
39 expr_stat: function call k='VCALL'
40 -- STATEMENT: end 'expr'
41
42 leaveblock
43 block: end
44 do_stat: end
45 -- STATEMENT: end 'do'
46
47 -- STATEMENT: begin 'expr' line=5
48 prefixexp: <name>
49 str_checkname: 'print'
50 singlevar(kind): 'VGLOBAL'
51 primaryexp: ( funcargs
52 funcargs: begin '('
53 explist1: begin
54 expr:
55 prefixexp: <name>
56 str_checkname: 'a'
57 singlevar(kind): 'VGLOBAL'
58 explist1: end
59 funcargs: end -- expr is a VCALL
60 expr_stat: function call k='VCALL'
61 -- STATEMENT: end 'expr'
62
63 close_func
64-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_04.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_04.lua
deleted file mode 100644
index b2bac4b..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_04.lua
+++ /dev/null
@@ -1,77 +0,0 @@
1-- START OF SOURCE --
2 local a,b,c
3 do
4 local b
5 print(b)
6 end
7 print(b)
8-- END OF SOURCE --
9
10-- TOP: begin
11 open_func
12
13 chunk:
14 -- STATEMENT: begin 'local' line=1
15 local_stat: local statement
16 localstat: begin
17 str_checkname: 'a'
18 new_localvar: 'a'
19 str_checkname: 'b'
20 new_localvar: 'b'
21 str_checkname: 'c'
22 new_localvar: 'c'
23 localstat: end
24 -- STATEMENT: end 'local'
25
26 -- STATEMENT: begin 'do' line=2
27 do_stat: begin
28 block: begin
29 enterblock(isbreakable=false)
30 chunk:
31 -- STATEMENT: begin 'local' line=3
32 local_stat: local statement
33 localstat: begin
34 str_checkname: 'b'
35 new_localvar: 'b'
36 localstat: end
37 -- STATEMENT: end 'local'
38
39 -- STATEMENT: begin 'expr' line=4
40 prefixexp: <name>
41 str_checkname: 'print'
42 singlevar(kind): 'VGLOBAL'
43 primaryexp: ( funcargs
44 funcargs: begin '('
45 explist1: begin
46 expr:
47 prefixexp: <name>
48 str_checkname: 'b'
49 singlevar(kind): 'VLOCAL'
50 explist1: end
51 funcargs: end -- expr is a VCALL
52 expr_stat: function call k='VCALL'
53 -- STATEMENT: end 'expr'
54
55 leaveblock
56 block: end
57 do_stat: end
58 -- STATEMENT: end 'do'
59
60 -- STATEMENT: begin 'expr' line=6
61 prefixexp: <name>
62 str_checkname: 'print'
63 singlevar(kind): 'VGLOBAL'
64 primaryexp: ( funcargs
65 funcargs: begin '('
66 explist1: begin
67 expr:
68 prefixexp: <name>
69 str_checkname: 'b'
70 singlevar(kind): 'VLOCAL'
71 explist1: end
72 funcargs: end -- expr is a VCALL
73 expr_stat: function call k='VCALL'
74 -- STATEMENT: end 'expr'
75
76 close_func
77-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_05.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_05.lua
deleted file mode 100644
index 6885f01..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_05.lua
+++ /dev/null
@@ -1,43 +0,0 @@
1-- START OF SOURCE --
2 local function foo() end
3 bar = foo
4-- END OF SOURCE --
5
6-- TOP: begin
7 open_func
8
9 chunk:
10 -- STATEMENT: begin 'local' line=1
11 local_stat: local function
12 localfunc: begin
13 str_checkname: 'foo'
14 new_localvar: 'foo'
15 localfunc: body
16 open_func
17 body: begin
18 body: parlist
19 parlist: begin
20 parlist: end
21 body: chunk
22 chunk:
23 body: end
24 close_func
25 localfunc: end
26 -- STATEMENT: end 'local'
27
28 -- STATEMENT: begin 'expr' line=2
29 prefixexp: <name>
30 str_checkname: 'bar'
31 singlevar(kind): 'VGLOBAL'
32 expr_stat: assignment k='VGLOBAL'
33 assignment: '=' -- RHS elements follows
34 explist1: begin
35 expr:
36 prefixexp: <name>
37 str_checkname: 'foo'
38 singlevar(kind): 'VLOCAL'
39 explist1: end
40 -- STATEMENT: end 'expr'
41
42 close_func
43-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_06.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_06.lua
deleted file mode 100644
index eb658ed..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_06.lua
+++ /dev/null
@@ -1,70 +0,0 @@
1-- START OF SOURCE --
2 do
3 local function foo() end
4 bar = foo
5 end
6 baz = foo
7-- END OF SOURCE --
8
9-- TOP: begin
10 open_func
11
12 chunk:
13 -- STATEMENT: begin 'do' line=1
14 do_stat: begin
15 block: begin
16 enterblock(isbreakable=false)
17 chunk:
18 -- STATEMENT: begin 'local' line=2
19 local_stat: local function
20 localfunc: begin
21 str_checkname: 'foo'
22 new_localvar: 'foo'
23 localfunc: body
24 open_func
25 body: begin
26 body: parlist
27 parlist: begin
28 parlist: end
29 body: chunk
30 chunk:
31 body: end
32 close_func
33 localfunc: end
34 -- STATEMENT: end 'local'
35
36 -- STATEMENT: begin 'expr' line=3
37 prefixexp: <name>
38 str_checkname: 'bar'
39 singlevar(kind): 'VGLOBAL'
40 expr_stat: assignment k='VGLOBAL'
41 assignment: '=' -- RHS elements follows
42 explist1: begin
43 expr:
44 prefixexp: <name>
45 str_checkname: 'foo'
46 singlevar(kind): 'VLOCAL'
47 explist1: end
48 -- STATEMENT: end 'expr'
49
50 leaveblock
51 block: end
52 do_stat: end
53 -- STATEMENT: end 'do'
54
55 -- STATEMENT: begin 'expr' line=5
56 prefixexp: <name>
57 str_checkname: 'baz'
58 singlevar(kind): 'VGLOBAL'
59 expr_stat: assignment k='VGLOBAL'
60 assignment: '=' -- RHS elements follows
61 explist1: begin
62 expr:
63 prefixexp: <name>
64 str_checkname: 'foo'
65 singlevar(kind): 'VGLOBAL'
66 explist1: end
67 -- STATEMENT: end 'expr'
68
69 close_func
70-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_07.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_07.lua
deleted file mode 100644
index 6403234..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_07.lua
+++ /dev/null
@@ -1,84 +0,0 @@
1-- START OF SOURCE --
2 local foo
3 local function bar()
4 baz = nil
5 foo = bar()
6 end
7 foo = bar
8-- END OF SOURCE --
9
10-- TOP: begin
11 open_func
12
13 chunk:
14 -- STATEMENT: begin 'local' line=1
15 local_stat: local statement
16 localstat: begin
17 str_checkname: 'foo'
18 new_localvar: 'foo'
19 localstat: end
20 -- STATEMENT: end 'local'
21
22 -- STATEMENT: begin 'local' line=2
23 local_stat: local function
24 localfunc: begin
25 str_checkname: 'bar'
26 new_localvar: 'bar'
27 localfunc: body
28 open_func
29 body: begin
30 body: parlist
31 parlist: begin
32 parlist: end
33 body: chunk
34 chunk:
35 -- STATEMENT: begin 'expr' line=3
36 prefixexp: <name>
37 str_checkname: 'baz'
38 singlevar(kind): 'VGLOBAL'
39 expr_stat: assignment k='VGLOBAL'
40 assignment: '=' -- RHS elements follows
41 explist1: begin
42 expr:
43 simpleexp: nil
44 explist1: end
45 -- STATEMENT: end 'expr'
46
47 -- STATEMENT: begin 'expr' line=4
48 prefixexp: <name>
49 str_checkname: 'foo'
50 singlevar(kind): 'VUPVAL'
51 expr_stat: assignment k='VUPVAL'
52 assignment: '=' -- RHS elements follows
53 explist1: begin
54 expr:
55 prefixexp: <name>
56 str_checkname: 'bar'
57 singlevar(kind): 'VUPVAL'
58 primaryexp: ( funcargs
59 funcargs: begin '('
60 funcargs: end -- expr is a VCALL
61 explist1: end
62 -- STATEMENT: end 'expr'
63
64 body: end
65 close_func
66 localfunc: end
67 -- STATEMENT: end 'local'
68
69 -- STATEMENT: begin 'expr' line=6
70 prefixexp: <name>
71 str_checkname: 'foo'
72 singlevar(kind): 'VLOCAL'
73 expr_stat: assignment k='VLOCAL'
74 assignment: '=' -- RHS elements follows
75 explist1: begin
76 expr:
77 prefixexp: <name>
78 str_checkname: 'bar'
79 singlevar(kind): 'VLOCAL'
80 explist1: end
81 -- STATEMENT: end 'expr'
82
83 close_func
84-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_08.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_08.lua
deleted file mode 100644
index 594e267..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_08.lua
+++ /dev/null
@@ -1,159 +0,0 @@
1-- START OF SOURCE --
2 local foo
3 local function bar()
4 local function baz()
5 local foo, bar
6 foo = bar
7 foo = baz
8 end
9 foo = bar
10 foo = baz
11 end
12 foo = bar
13 foo = baz
14-- END OF SOURCE --
15
16-- TOP: begin
17 open_func
18
19 chunk:
20 -- STATEMENT: begin 'local' line=1
21 local_stat: local statement
22 localstat: begin
23 str_checkname: 'foo'
24 new_localvar: 'foo'
25 localstat: end
26 -- STATEMENT: end 'local'
27
28 -- STATEMENT: begin 'local' line=2
29 local_stat: local function
30 localfunc: begin
31 str_checkname: 'bar'
32 new_localvar: 'bar'
33 localfunc: body
34 open_func
35 body: begin
36 body: parlist
37 parlist: begin
38 parlist: end
39 body: chunk
40 chunk:
41 -- STATEMENT: begin 'local' line=3
42 local_stat: local function
43 localfunc: begin
44 str_checkname: 'baz'
45 new_localvar: 'baz'
46 localfunc: body
47 open_func
48 body: begin
49 body: parlist
50 parlist: begin
51 parlist: end
52 body: chunk
53 chunk:
54 -- STATEMENT: begin 'local' line=4
55 local_stat: local statement
56 localstat: begin
57 str_checkname: 'foo'
58 new_localvar: 'foo'
59 str_checkname: 'bar'
60 new_localvar: 'bar'
61 localstat: end
62 -- STATEMENT: end 'local'
63
64 -- STATEMENT: begin 'expr' line=5
65 prefixexp: <name>
66 str_checkname: 'foo'
67 singlevar(kind): 'VLOCAL'
68 expr_stat: assignment k='VLOCAL'
69 assignment: '=' -- RHS elements follows
70 explist1: begin
71 expr:
72 prefixexp: <name>
73 str_checkname: 'bar'
74 singlevar(kind): 'VLOCAL'
75 explist1: end
76 -- STATEMENT: end 'expr'
77
78 -- STATEMENT: begin 'expr' line=6
79 prefixexp: <name>
80 str_checkname: 'foo'
81 singlevar(kind): 'VLOCAL'
82 expr_stat: assignment k='VLOCAL'
83 assignment: '=' -- RHS elements follows
84 explist1: begin
85 expr:
86 prefixexp: <name>
87 str_checkname: 'baz'
88 singlevar(kind): 'VUPVAL'
89 explist1: end
90 -- STATEMENT: end 'expr'
91
92 body: end
93 close_func
94 localfunc: end
95 -- STATEMENT: end 'local'
96
97 -- STATEMENT: begin 'expr' line=8
98 prefixexp: <name>
99 str_checkname: 'foo'
100 singlevar(kind): 'VUPVAL'
101 expr_stat: assignment k='VUPVAL'
102 assignment: '=' -- RHS elements follows
103 explist1: begin
104 expr:
105 prefixexp: <name>
106 str_checkname: 'bar'
107 singlevar(kind): 'VUPVAL'
108 explist1: end
109 -- STATEMENT: end 'expr'
110
111 -- STATEMENT: begin 'expr' line=9
112 prefixexp: <name>
113 str_checkname: 'foo'
114 singlevar(kind): 'VUPVAL'
115 expr_stat: assignment k='VUPVAL'
116 assignment: '=' -- RHS elements follows
117 explist1: begin
118 expr:
119 prefixexp: <name>
120 str_checkname: 'baz'
121 singlevar(kind): 'VLOCAL'
122 explist1: end
123 -- STATEMENT: end 'expr'
124
125 body: end
126 close_func
127 localfunc: end
128 -- STATEMENT: end 'local'
129
130 -- STATEMENT: begin 'expr' line=11
131 prefixexp: <name>
132 str_checkname: 'foo'
133 singlevar(kind): 'VLOCAL'
134 expr_stat: assignment k='VLOCAL'
135 assignment: '=' -- RHS elements follows
136 explist1: begin
137 expr:
138 prefixexp: <name>
139 str_checkname: 'bar'
140 singlevar(kind): 'VLOCAL'
141 explist1: end
142 -- STATEMENT: end 'expr'
143
144 -- STATEMENT: begin 'expr' line=12
145 prefixexp: <name>
146 str_checkname: 'foo'
147 singlevar(kind): 'VLOCAL'
148 expr_stat: assignment k='VLOCAL'
149 assignment: '=' -- RHS elements follows
150 explist1: begin
151 expr:
152 prefixexp: <name>
153 str_checkname: 'baz'
154 singlevar(kind): 'VGLOBAL'
155 explist1: end
156 -- STATEMENT: end 'expr'
157
158 close_func
159-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_09.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_09.lua
deleted file mode 100644
index bfa3920..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_09.lua
+++ /dev/null
@@ -1,53 +0,0 @@
1-- START OF SOURCE --
2 function foo:bar()
3 print(self)
4 end
5-- END OF SOURCE --
6
7-- TOP: begin
8 open_func
9
10 chunk:
11 -- STATEMENT: begin 'function' line=1
12 function_stat: begin
13 funcname: begin
14 str_checkname: 'foo'
15 singlevar(kind): 'VGLOBAL'
16 funcname: -- ':' field
17 field: operator=:
18 checkname:
19 str_checkname: 'bar'
20 codestring: "bar"
21 funcname: end
22 function_stat: body needself='true'
23 open_func
24 body: begin
25 new_localvar: 'self'
26 body: parlist
27 parlist: begin
28 parlist: end
29 body: chunk
30 chunk:
31 -- STATEMENT: begin 'expr' line=2
32 prefixexp: <name>
33 str_checkname: 'print'
34 singlevar(kind): 'VGLOBAL'
35 primaryexp: ( funcargs
36 funcargs: begin '('
37 explist1: begin
38 expr:
39 prefixexp: <name>
40 str_checkname: 'self'
41 singlevar(kind): 'VLOCAL'
42 explist1: end
43 funcargs: end -- expr is a VCALL
44 expr_stat: function call k='VCALL'
45 -- STATEMENT: end 'expr'
46
47 body: end
48 close_func
49 function_stat: end
50 -- STATEMENT: end 'function'
51
52 close_func
53-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_10.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_10.lua
deleted file mode 100644
index 9a38883..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_10.lua
+++ /dev/null
@@ -1,49 +0,0 @@
1-- START OF SOURCE --
2 function foo(...)
3 print(arg)
4 end
5-- END OF SOURCE --
6
7-- TOP: begin
8 open_func
9
10 chunk:
11 -- STATEMENT: begin 'function' line=1
12 function_stat: begin
13 funcname: begin
14 str_checkname: 'foo'
15 singlevar(kind): 'VGLOBAL'
16 funcname: end
17 function_stat: body needself='false'
18 open_func
19 body: begin
20 body: parlist
21 parlist: begin
22 parlist: ... (dots)
23 new_localvar: 'arg'
24 parlist: end
25 body: chunk
26 chunk:
27 -- STATEMENT: begin 'expr' line=2
28 prefixexp: <name>
29 str_checkname: 'print'
30 singlevar(kind): 'VGLOBAL'
31 primaryexp: ( funcargs
32 funcargs: begin '('
33 explist1: begin
34 expr:
35 prefixexp: <name>
36 str_checkname: 'arg'
37 singlevar(kind): 'VLOCAL'
38 explist1: end
39 funcargs: end -- expr is a VCALL
40 expr_stat: function call k='VCALL'
41 -- STATEMENT: end 'expr'
42
43 body: end
44 close_func
45 function_stat: end
46 -- STATEMENT: end 'function'
47
48 close_func
49-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_11.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_11.lua
deleted file mode 100644
index e4c9e21..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_11.lua
+++ /dev/null
@@ -1,79 +0,0 @@
1-- START OF SOURCE --
2 local c,d
3 function foo(a,b,c)
4 print(a,c,d,e)
5 end
6-- END OF SOURCE --
7
8-- TOP: begin
9 open_func
10
11 chunk:
12 -- STATEMENT: begin 'local' line=1
13 local_stat: local statement
14 localstat: begin
15 str_checkname: 'c'
16 new_localvar: 'c'
17 str_checkname: 'd'
18 new_localvar: 'd'
19 localstat: end
20 -- STATEMENT: end 'local'
21
22 -- STATEMENT: begin 'function' line=2
23 function_stat: begin
24 funcname: begin
25 str_checkname: 'foo'
26 singlevar(kind): 'VGLOBAL'
27 funcname: end
28 function_stat: body needself='false'
29 open_func
30 body: begin
31 body: parlist
32 parlist: begin
33 str_checkname: 'a'
34 new_localvar: 'a'
35 str_checkname: 'b'
36 new_localvar: 'b'
37 str_checkname: 'c'
38 new_localvar: 'c'
39 parlist: end
40 body: chunk
41 chunk:
42 -- STATEMENT: begin 'expr' line=3
43 prefixexp: <name>
44 str_checkname: 'print'
45 singlevar(kind): 'VGLOBAL'
46 primaryexp: ( funcargs
47 funcargs: begin '('
48 explist1: begin
49 expr:
50 prefixexp: <name>
51 str_checkname: 'a'
52 singlevar(kind): 'VLOCAL'
53 explist1: ',' -- continuation
54 expr:
55 prefixexp: <name>
56 str_checkname: 'c'
57 singlevar(kind): 'VLOCAL'
58 explist1: ',' -- continuation
59 expr:
60 prefixexp: <name>
61 str_checkname: 'd'
62 singlevar(kind): 'VUPVAL'
63 explist1: ',' -- continuation
64 expr:
65 prefixexp: <name>
66 str_checkname: 'e'
67 singlevar(kind): 'VGLOBAL'
68 explist1: end
69 funcargs: end -- expr is a VCALL
70 expr_stat: function call k='VCALL'
71 -- STATEMENT: end 'expr'
72
73 body: end
74 close_func
75 function_stat: end
76 -- STATEMENT: end 'function'
77
78 close_func
79-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_12.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_12.lua
deleted file mode 100644
index b278ba2..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_12.lua
+++ /dev/null
@@ -1,94 +0,0 @@
1-- START OF SOURCE --
2 function foo(a,b)
3 local bar = function(c,d)
4 print(a,b,c,d)
5 end
6 end
7-- END OF SOURCE --
8
9-- TOP: begin
10 open_func
11
12 chunk:
13 -- STATEMENT: begin 'function' line=1
14 function_stat: begin
15 funcname: begin
16 str_checkname: 'foo'
17 singlevar(kind): 'VGLOBAL'
18 funcname: end
19 function_stat: body needself='false'
20 open_func
21 body: begin
22 body: parlist
23 parlist: begin
24 str_checkname: 'a'
25 new_localvar: 'a'
26 str_checkname: 'b'
27 new_localvar: 'b'
28 parlist: end
29 body: chunk
30 chunk:
31 -- STATEMENT: begin 'local' line=2
32 local_stat: local statement
33 localstat: begin
34 str_checkname: 'bar'
35 new_localvar: 'bar'
36 localstat: -- assignment
37 explist1: begin
38 expr:
39 simpleexp: function
40 open_func
41 body: begin
42 body: parlist
43 parlist: begin
44 str_checkname: 'c'
45 new_localvar: 'c'
46 str_checkname: 'd'
47 new_localvar: 'd'
48 parlist: end
49 body: chunk
50 chunk:
51 -- STATEMENT: begin 'expr' line=3
52 prefixexp: <name>
53 str_checkname: 'print'
54 singlevar(kind): 'VGLOBAL'
55 primaryexp: ( funcargs
56 funcargs: begin '('
57 explist1: begin
58 expr:
59 prefixexp: <name>
60 str_checkname: 'a'
61 singlevar(kind): 'VUPVAL'
62 explist1: ',' -- continuation
63 expr:
64 prefixexp: <name>
65 str_checkname: 'b'
66 singlevar(kind): 'VUPVAL'
67 explist1: ',' -- continuation
68 expr:
69 prefixexp: <name>
70 str_checkname: 'c'
71 singlevar(kind): 'VLOCAL'
72 explist1: ',' -- continuation
73 expr:
74 prefixexp: <name>
75 str_checkname: 'd'
76 singlevar(kind): 'VLOCAL'
77 explist1: end
78 funcargs: end -- expr is a VCALL
79 expr_stat: function call k='VCALL'
80 -- STATEMENT: end 'expr'
81
82 body: end
83 close_func
84 explist1: end
85 localstat: end
86 -- STATEMENT: end 'local'
87
88 body: end
89 close_func
90 function_stat: end
91 -- STATEMENT: end 'function'
92
93 close_func
94-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_13.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_13.lua
deleted file mode 100644
index 6e4850c..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_13.lua
+++ /dev/null
@@ -1,117 +0,0 @@
1-- START OF SOURCE --
2 for i = 1,10 do
3 print(i)
4 end
5 for i = 1,10,-2 do
6 print(i)
7 end
8-- END OF SOURCE --
9
10-- TOP: begin
11 open_func
12
13 chunk:
14 -- STATEMENT: begin 'for' line=1
15 for_stat: begin
16 enterblock(isbreakable=false)
17 str_checkname: 'i'
18 for_stat: numerical loop
19 new_localvar: 'i'
20 new_localvar: '(for limit)'
21 new_localvar: '(for step)'
22 fornum: begin
23 fornum: index start
24 exp1: begin
25 expr:
26 simpleexp: <number>=1
27 exp1: end
28 fornum: index stop
29 exp1: begin
30 expr:
31 simpleexp: <number>=10
32 exp1: end
33 fornum: body
34 enterblock(isbreakable=true)
35 block: begin
36 enterblock(isbreakable=false)
37 chunk:
38 -- STATEMENT: begin 'expr' line=2
39 prefixexp: <name>
40 str_checkname: 'print'
41 singlevar(kind): 'VGLOBAL'
42 primaryexp: ( funcargs
43 funcargs: begin '('
44 explist1: begin
45 expr:
46 prefixexp: <name>
47 str_checkname: 'i'
48 singlevar(kind): 'VLOCAL'
49 explist1: end
50 funcargs: end -- expr is a VCALL
51 expr_stat: function call k='VCALL'
52 -- STATEMENT: end 'expr'
53
54 leaveblock
55 block: end
56 leaveblock
57 fornum: end
58 leaveblock
59 for_stat: end
60 -- STATEMENT: end 'for'
61
62 -- STATEMENT: begin 'for' line=4
63 for_stat: begin
64 enterblock(isbreakable=false)
65 str_checkname: 'i'
66 for_stat: numerical loop
67 new_localvar: 'i'
68 new_localvar: '(for limit)'
69 new_localvar: '(for step)'
70 fornum: begin
71 fornum: index start
72 exp1: begin
73 expr:
74 simpleexp: <number>=1
75 exp1: end
76 fornum: index stop
77 exp1: begin
78 expr:
79 simpleexp: <number>=10
80 exp1: end
81 fornum: index step
82 exp1: begin
83 expr:
84 subexpr: uop='-'
85 simpleexp: <number>=2
86 exp1: end
87 fornum: body
88 enterblock(isbreakable=true)
89 block: begin
90 enterblock(isbreakable=false)
91 chunk:
92 -- STATEMENT: begin 'expr' line=5
93 prefixexp: <name>
94 str_checkname: 'print'
95 singlevar(kind): 'VGLOBAL'
96 primaryexp: ( funcargs
97 funcargs: begin '('
98 explist1: begin
99 expr:
100 prefixexp: <name>
101 str_checkname: 'i'
102 singlevar(kind): 'VLOCAL'
103 explist1: end
104 funcargs: end -- expr is a VCALL
105 expr_stat: function call k='VCALL'
106 -- STATEMENT: end 'expr'
107
108 leaveblock
109 block: end
110 leaveblock
111 fornum: end
112 leaveblock
113 for_stat: end
114 -- STATEMENT: end 'for'
115
116 close_func
117-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_14.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_14.lua
deleted file mode 100644
index f80c33f..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/parser_log/sample_b_14.lua
+++ /dev/null
@@ -1,125 +0,0 @@
1-- START OF SOURCE --
2 for foo in bar() do
3 print(foo)
4 end
5 for foo,bar,baz in spring() do
6 print(foo,bar,baz)
7 end
8-- END OF SOURCE --
9
10-- TOP: begin
11 open_func
12
13 chunk:
14 -- STATEMENT: begin 'for' line=1
15 for_stat: begin
16 enterblock(isbreakable=false)
17 str_checkname: 'foo'
18 for_stat: list-based loop
19 forlist: begin
20 new_localvar: '(for generator)'
21 new_localvar: '(for state)'
22 new_localvar: 'foo'
23 forlist: explist1
24 explist1: begin
25 expr:
26 prefixexp: <name>
27 str_checkname: 'bar'
28 singlevar(kind): 'VGLOBAL'
29 primaryexp: ( funcargs
30 funcargs: begin '('
31 funcargs: end -- expr is a VCALL
32 explist1: end
33 forlist: body
34 enterblock(isbreakable=true)
35 block: begin
36 enterblock(isbreakable=false)
37 chunk:
38 -- STATEMENT: begin 'expr' line=2
39 prefixexp: <name>
40 str_checkname: 'print'
41 singlevar(kind): 'VGLOBAL'
42 primaryexp: ( funcargs
43 funcargs: begin '('
44 explist1: begin
45 expr:
46 prefixexp: <name>
47 str_checkname: 'foo'
48 singlevar(kind): 'VLOCAL'
49 explist1: end
50 funcargs: end -- expr is a VCALL
51 expr_stat: function call k='VCALL'
52 -- STATEMENT: end 'expr'
53
54 leaveblock
55 block: end
56 leaveblock
57 forlist: end
58 leaveblock
59 for_stat: end
60 -- STATEMENT: end 'for'
61
62 -- STATEMENT: begin 'for' line=4
63 for_stat: begin
64 enterblock(isbreakable=false)
65 str_checkname: 'foo'
66 for_stat: list-based loop
67 forlist: begin
68 new_localvar: '(for generator)'
69 new_localvar: '(for state)'
70 new_localvar: 'foo'
71 str_checkname: 'bar'
72 new_localvar: 'bar'
73 str_checkname: 'baz'
74 new_localvar: 'baz'
75 forlist: explist1
76 explist1: begin
77 expr:
78 prefixexp: <name>
79 str_checkname: 'spring'
80 singlevar(kind): 'VGLOBAL'
81 primaryexp: ( funcargs
82 funcargs: begin '('
83 funcargs: end -- expr is a VCALL
84 explist1: end
85 forlist: body
86 enterblock(isbreakable=true)
87 block: begin
88 enterblock(isbreakable=false)
89 chunk:
90 -- STATEMENT: begin 'expr' line=5
91 prefixexp: <name>
92 str_checkname: 'print'
93 singlevar(kind): 'VGLOBAL'
94 primaryexp: ( funcargs
95 funcargs: begin '('
96 explist1: begin
97 expr:
98 prefixexp: <name>
99 str_checkname: 'foo'
100 singlevar(kind): 'VLOCAL'
101 explist1: ',' -- continuation
102 expr:
103 prefixexp: <name>
104 str_checkname: 'bar'
105 singlevar(kind): 'VLOCAL'
106 explist1: ',' -- continuation
107 expr:
108 prefixexp: <name>
109 str_checkname: 'baz'
110 singlevar(kind): 'VLOCAL'
111 explist1: end
112 funcargs: end -- expr is a VCALL
113 expr_stat: function call k='VCALL'
114 -- STATEMENT: end 'expr'
115
116 leaveblock
117 block: end
118 leaveblock
119 forlist: end
120 leaveblock
121 for_stat: end
122 -- STATEMENT: end 'for'
123
124 close_func
125-- TOP: end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/sample.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/sample.lua
deleted file mode 100644
index dc6eaee..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/sample.lua
+++ /dev/null
@@ -1,3 +0,0 @@
1local a = 47
2local b = "hello, world!"
3print(a, b)
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_llex_mk2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_llex_mk2.lua
deleted file mode 100644
index ff8cec5..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_llex_mk2.lua
+++ /dev/null
@@ -1,499 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 test_llex.lua
4 Test for llex.lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2005-2006 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15------------------------------------------------------------------------
16-- if BRIEF is not set to false, auto-test will silently succeed
17------------------------------------------------------------------------
18BRIEF = true -- if set to true, messages are less verbose
19
20local zio_init = require("../lzio_mk2")
21local lex_init = require("../llex_mk2")
22
23------------------------------------------------------------------------
24-- simple manual tests
25------------------------------------------------------------------------
26
27--[[
28local function dump(z, source)
29 local luaX = lex_init(z, source)
30 while true do
31 local tok, seminfo = luaX:lex()
32 if tok == "<name>" then
33 seminfo = " "..seminfo
34 elseif tok == "<number>" then
35 seminfo = " "..seminfo
36 elseif tok == "<string>" then
37 seminfo = " '"..seminfo.."'"
38 else
39 seminfo = ""
40 end
41 io.stdout:write(tok..seminfo.."\n")
42 if tok == "<eof>" then break end
43 end
44end
45
46local function try_string(chunk)
47 dump(zio_init(chunk), "=string")
48end
49local function try_file(filename)
50 local f = "@"..filename
51 dump(zio_init(f), f)
52end
53
54z = try_string("local c = z:getc()")
55z = try_file("test_lzio_mk2.lua")
56z = try_file("test_llex_mk2.lua")
57os.exit()
58--]]
59
60------------------------------------------------------------------------
61-- auto-testing of simple test cases to validate lexer behaviour:
62-- * NOTE coverage has not been checked; not comprehensive
63-- * only test cases with non-empty comments are processed
64-- * if no result, then the output is displayed for manual decision
65-- (output may be used to set expected success or fail text)
66-- * cases expected to be successful may be a partial match
67-- * cases expected to fail may also be a partial match
68------------------------------------------------------------------------
69
70-- [[
71local function auto_test()
72 local PASS, FAIL = true, false
73 ------------------------------------------------------------------
74 -- table of test cases
75 ------------------------------------------------------------------
76 local test_cases =
77 {
78 -------------------------------------------------------------
79 --{ "comment", -- comment about the test
80 -- "chunk", -- chunk to test
81 -- PASS, -- PASS or FAIL outcome
82 -- "output", -- output to compare against
83 --},
84 -------------------------------------------------------------
85 { "empty chunk string, test EOS",
86 "",
87 PASS, "1 <eof>",
88 },
89 -------------------------------------------------------------
90 { "line number counting",
91 "\n\n\r\n",
92 PASS, "4 <eof>",
93 },
94 -------------------------------------------------------------
95 { "various whitespaces",
96 " \n\t\t\n \t \t \n\n",
97 PASS, "5 <eof>",
98 },
99 -------------------------------------------------------------
100 { "short comment ending in EOS",
101 "-- moo moo",
102 PASS, "1 <eof>",
103 },
104 -------------------------------------------------------------
105 { "short comment ending in newline",
106 "-- moo moo\n",
107 PASS, "2 <eof>",
108 },
109 -------------------------------------------------------------
110 { "several lines of short comments",
111 "--moo\n-- moo moo\n\n--\tmoo\n",
112 PASS, "5 <eof>",
113 },
114 -------------------------------------------------------------
115 { "basic block comment",
116 "--[[bovine]]",
117 PASS, "1 <eof>",
118 },
119 -------------------------------------------------------------
120 { "unterminated block comment 1",
121 "--[[bovine",
122 FAIL, ":1: unfinished long comment near '<eof>'",
123 },
124 -------------------------------------------------------------
125 { "unterminated block comment 2",
126 "--[[bovine]",
127 FAIL, ":1: unfinished long comment near '<eof>'",
128 },
129 -------------------------------------------------------------
130 { "unterminated block comment 3",
131 "--[[bovine\nmoo moo\nwoof",
132 FAIL, ":3: unfinished long comment near '<eof>'",
133 },
134 -------------------------------------------------------------
135 { "basic long string",
136 "\n[[bovine]]\n",
137 PASS, "2 <string> = bovine\n3 <eof>",
138 },
139 -------------------------------------------------------------
140 { "first newline consumed in long string",
141 "[[\nmoo]]",
142 PASS, "2 <string> = moo\n2 <eof>",
143 },
144 -------------------------------------------------------------
145 { "multiline long string",
146 "[[moo\nmoo moo\n]]",
147 PASS, "3 <string> = moo\nmoo moo\n\n3 <eof>",
148 },
149 -------------------------------------------------------------
150 { "unterminated long string 1",
151 "\n[[\nbovine",
152 FAIL, ":3: unfinished long string near '<eof>'",
153 },
154 -------------------------------------------------------------
155 { "unterminated long string 2",
156 "[[bovine]",
157 FAIL, ":1: unfinished long string near '<eof>'",
158 },
159 -------------------------------------------------------------
160 { "unterminated long string 3",
161 "[[[[ \n",
162 FAIL, ":2: unfinished long string near '<eof>'",
163 },
164 -------------------------------------------------------------
165 { "nested long string 1",
166 "[[moo[[moo]]moo]]",
167 PASS, "moo[[moo]]moo",
168 },
169 -------------------------------------------------------------
170 { "nested long string 2",
171 "[[moo[[moo[[[[]]]]moo]]moo]]",
172 PASS, "moo[[moo[[[[]]]]moo]]moo",
173 },
174 -------------------------------------------------------------
175 { "nested long string 3",
176 "[[[[[[]]]][[[[]]]]]]",
177 PASS, "[[[[]]]][[[[]]]]",
178 },
179 -------------------------------------------------------------
180 { "brackets in long strings 1",
181 "[[moo[moo]]",
182 PASS, "moo[moo",
183 },
184 -------------------------------------------------------------
185 { "brackets in long strings 2",
186 "[[moo[[moo]moo]]moo]]",
187 PASS, "moo[[moo]moo]]moo",
188 },
189 -------------------------------------------------------------
190 { "unprocessed escapes in long strings",
191 [[ [[\a\b\f\n\r\t\v\123]] ]],
192 PASS, [[\a\b\f\n\r\t\v\123]],
193 },
194 -------------------------------------------------------------
195 { "unbalanced long string",
196 "[[moo]]moo]]",
197 PASS, "1 <string> = moo\n1 <name> = moo\n1 CHAR = ']'\n1 CHAR = ']'\n1 <eof>",
198 },
199 -------------------------------------------------------------
200 { "keywords 1",
201 "and break do else",
202 PASS, "1 and\n1 break\n1 do\n1 else\n1 <eof>",
203 },
204 -------------------------------------------------------------
205 { "keywords 2",
206 "elseif end false for",
207 PASS, "1 elseif\n1 end\n1 false\n1 for\n1 <eof>",
208 },
209 -------------------------------------------------------------
210 { "keywords 3",
211 "function if in local nil",
212 PASS, "1 function\n1 if\n1 in\n1 local\n1 nil\n1 <eof>",
213 },
214 -------------------------------------------------------------
215 { "keywords 4",
216 "not or repeat return",
217 PASS, "1 not\n1 or\n1 repeat\n1 return\n1 <eof>",
218 },
219 -------------------------------------------------------------
220 { "keywords 5",
221 "then true until while",
222 PASS, "1 then\n1 true\n1 until\n1 while\n1 <eof>",
223 },
224 -------------------------------------------------------------
225 { "concat and dots",
226 ".. ...",
227 PASS, "1 ..\n1 ...\n1 <eof>",
228 },
229 -------------------------------------------------------------
230 { "shbang handling 1",
231 "#blahblah",
232 PASS, "1 <eof>",
233 },
234 -------------------------------------------------------------
235 { "shbang handling 2",
236 "#blahblah\nmoo moo\n",
237 PASS, "2 <name> = moo\n2 <name> = moo\n3 <eof>",
238 },
239 -------------------------------------------------------------
240 { "empty string",
241 [['']],
242 PASS, "1 <string> = \n1 <eof>",
243 },
244 -------------------------------------------------------------
245 { "single-quoted string",
246 [['bovine']],
247 PASS, "1 <string> = bovine\n1 <eof>",
248 },
249 -------------------------------------------------------------
250 { "double-quoted string",
251 [["bovine"]],
252 PASS, "1 <string> = bovine\n1 <eof>",
253 },
254 -------------------------------------------------------------
255 { "unterminated string 1",
256 [['moo ]],
257 FAIL, ":1: unfinished string near '<eof>'",
258 },
259 -------------------------------------------------------------
260 { "unterminated string 2",
261 [["moo \n]],
262 FAIL, ":1: unfinished string near '<eof>'",
263 },
264 -------------------------------------------------------------
265 { "escaped newline in string, line number counted",
266 "\"moo\\\nmoo\\\nmoo\"",
267 PASS, "3 <string> = moo\nmoo\nmoo\n3 <eof>",
268 },
269 -------------------------------------------------------------
270 { "escaped characters in string 1",
271 [["moo\amoo"]],
272 PASS, "1 <string> = moo\amoo",
273 },
274 -------------------------------------------------------------
275 { "escaped characters in string 2",
276 [["moo\bmoo"]],
277 PASS, "1 <string> = moo\bmoo",
278 },
279 -------------------------------------------------------------
280 { "escaped characters in string 3",
281 [["moo\f\n\r\t\vmoo"]],
282 PASS, "1 <string> = moo\f\n\r\t\vmoo",
283 },
284 -------------------------------------------------------------
285 { "escaped characters in string 4",
286 [["\\ \" \' \? \[ \]"]],
287 PASS, "1 <string> = \\ \" \' \? \[ \]",
288 },
289 -------------------------------------------------------------
290 { "escaped characters in string 5",
291 [["\z \k \: \;"]],
292 PASS, "1 <string> = z k : ;",
293 },
294 -------------------------------------------------------------
295 { "escaped characters in string 6",
296 [["\8 \65 \160 \180K \097097"]],
297 PASS, "1 <string> = \8 \65 \160 \180K \097097\n",
298 },
299 -------------------------------------------------------------
300 { "escaped characters in string 7",
301 [["\666"]],
302 FAIL, ":1: escape sequence too large near '\"'",
303 },
304 -------------------------------------------------------------
305 { "simple numbers",
306 "123 123+",
307 PASS, "1 <number> = 123\n1 <number> = 123\n1 CHAR = '+'\n1 <eof>",
308 },
309 -------------------------------------------------------------
310 { "longer numbers",
311 "1234567890 12345678901234567890",
312 PASS, "1 <number> = 1234567890\n1 <number> = 1.2345678901235e+19\n",
313 },
314 -------------------------------------------------------------
315 { "fractional numbers",
316 ".123 .12345678901234567890",
317 PASS, "1 <number> = 0.123\n1 <number> = 0.12345678901235\n",
318 },
319 -------------------------------------------------------------
320 { "more numbers with decimal points",
321 "12345.67890 1.1.",
322 PASS, "1 <number> = 12345.6789\n1 <number> = 1.1\n1 CHAR = '.'\n",
323 },
324 -------------------------------------------------------------
325 { "double decimal points",
326 ".1.1",
327 FAIL, ":1: malformed number near '.1.1'",
328 },
329 -------------------------------------------------------------
330 { "double dots within numbers",
331 "1..1",
332 FAIL, ":1: ambiguous syntax (dots follows digits) near '1..'",
333 },
334 -------------------------------------------------------------
335 { "incomplete exponential numbers",
336 "123e",
337 FAIL, ":1: malformed number near '123e'",
338 },
339 -------------------------------------------------------------
340 { "exponential numbers 1",
341 "1234e5 1234e5.",
342 PASS, "1 <number> = 123400000\n1 <number> = 123400000\n1 CHAR = '.'",
343 },
344 -------------------------------------------------------------
345 { "exponential numbers 2",
346 "1234e56 1.23e123",
347 PASS, "1 <number> = 1.234e+59\n1 <number> = 1.23e+123\n",
348 },
349 -------------------------------------------------------------
350 { "exponential numbers 3",
351 "12.34e+",
352 FAIL, ":1: malformed number near '12.34e+'",
353 },
354 -------------------------------------------------------------
355 { "exponential numbers 4",
356 "12.34e+5 123.4e-5 1234.E+5",
357 PASS, "1 <number> = 1234000\n1 <number> = 0.001234\n1 <number> = 123400000\n",
358 },
359 -------------------------------------------------------------
360 { "single character symbols 1",
361 "= > < ~",
362 PASS, "1 CHAR = '='\n1 CHAR = '>'\n1 CHAR = '<'\n1 CHAR = '~'\n",
363 },
364 -------------------------------------------------------------
365 { "double character symbols",
366 "== >= <= ~=",
367 PASS, "1 ==\n1 >=\n1 <=\n1 ~=\n",
368 },
369 -------------------------------------------------------------
370 { "simple identifiers",
371 "abc ABC",
372 PASS, "1 <name> = abc\n1 <name> = ABC\n1 <eof>",
373 },
374 -------------------------------------------------------------
375 { "more identifiers",
376 "_abc _ABC",
377 PASS, "1 <name> = _abc\n1 <name> = _ABC\n1 <eof>",
378 },
379 -------------------------------------------------------------
380 { "still more identifiers",
381 "_aB_ _123",
382 PASS, "1 <name> = _aB_\n1 <name> = _123\n1 <eof>",
383 },
384 -------------------------------------------------------------
385 { "invalid control character",
386 "\4",
387 FAIL, ":1: invalid control char near 'char(4)'",
388 },
389 -------------------------------------------------------------
390 { "single character symbols 2",
391 "` ! @ $ %",
392 PASS, "1 CHAR = '`'\n1 CHAR = '!'\n1 CHAR = '@'\n1 CHAR = '$'\n1 CHAR = '%'\n",
393 },
394 -------------------------------------------------------------
395 { "single character symbols 3",
396 "^ & * ( )",
397 PASS, "1 CHAR = '^'\n1 CHAR = '&'\n1 CHAR = '*'\n1 CHAR = '('\n1 CHAR = ')'\n",
398 },
399 -------------------------------------------------------------
400 { "single character symbols 4",
401 "_ - + \\ |",
402 PASS, "1 <name> = _\n1 CHAR = '-'\n1 CHAR = '+'\n1 CHAR = '\\'\n1 CHAR = '|'\n",
403 },
404 -------------------------------------------------------------
405 { "single character symbols 5",
406 "{ } [ ] :",
407 PASS, "1 CHAR = '{'\n1 CHAR = '}'\n1 CHAR = '['\n1 CHAR = ']'\n1 CHAR = ':'\n",
408 },
409 -------------------------------------------------------------
410 { "single character symbols 6",
411 "; , . / ?",
412 PASS, "1 CHAR = ';'\n1 CHAR = ','\n1 CHAR = '.'\n1 CHAR = '/'\n1 CHAR = '?'\n",
413 },
414 -------------------------------------------------------------
415 }
416 ------------------------------------------------------------------
417 -- perform a test case
418 ------------------------------------------------------------------
419 function do_test_case(count, test_case)
420 if comment == "" then return end -- skip empty entries
421 local comment, chunk, outcome, matcher = unpack(test_case)
422 local result = PASS
423 local output = ""
424 -- initialize lexer
425 local z = zio_init(chunk)
426 local luaX = lex_init(z, "=test")
427 -- lexer test loop
428 local status, token, seminfo
429 repeat
430 -- protected call
431 status, token, seminfo = pcall(luaX.lex, luaX)
432 output = output..luaX.lineno.." "
433 if status then
434 -- successful call
435 if string.len(token) > 1 then
436 if token == "<name>"
437 or token == "<number>"
438 or token == "<string>" then
439 token = token.." = "..seminfo
440 end
441 elseif string.byte(token) >= 32 then -- displayable chars
442 token = "CHAR = '"..token.."'"
443 else -- control characters
444 token = "CHAR = (".. string.byte(token)..")"
445 end
446 output = output..token.."\n"
447 else
448 -- failed call
449 output = output..token -- token is the error message
450 result = FAIL
451 break
452 end
453 until token == "<eof>"
454 -- decision making and reporting
455 local head = "Test "..count..": "..comment
456 if matcher == "" then
457 -- nothing to check against, display for manual check
458 print(head.."\nMANUAL please check manually"..
459 "\n--chunk---------------------------------\n"..chunk..
460 "\n--actual--------------------------------\n"..output..
461 "\n\n")
462 return
463 else
464 if outcome == PASS then
465 -- success expected, may be a partial match
466 if string.find(output, matcher, 1, 1) and result == PASS then
467 if not BRIEF then print(head.."\nOK expected success\n") end
468 return
469 end
470 else
471 -- failure expected, may be a partial match
472 if string.find(output, matcher, 1, 1) and result == FAIL then
473 if not BRIEF then print(head.."\nOK expected failure\n") end
474 return
475 end
476 end
477 -- failed because of unmatched string or boolean result
478 local function passfail(status)
479 if status == PASS then return "PASS" else return "FAIL" end
480 end
481 print(head.." *FAILED*"..
482 "\noutcome="..passfail(outcome)..
483 "\nactual= "..passfail(result)..
484 "\n--chunk---------------------------------\n"..chunk..
485 "\n--expected------------------------------\n"..matcher..
486 "\n--actual--------------------------------\n"..output..
487 "\n\n")
488 end
489 end
490 ------------------------------------------------------------------
491 -- perform auto testing
492 ------------------------------------------------------------------
493 for i,test_case in ipairs(test_cases) do
494 do_test_case(i, test_case)
495 end
496end
497
498auto_test()
499--]]
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_llex_mk3.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_llex_mk3.lua
deleted file mode 100644
index 8b0eec9..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_llex_mk3.lua
+++ /dev/null
@@ -1,500 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 test_llex.lua
4 Test for llex.lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15------------------------------------------------------------------------
16-- if BRIEF is not set to false, auto-test will silently succeed
17------------------------------------------------------------------------
18BRIEF = true -- if set to true, messages are less verbose
19
20local lex_init = require("../llex_mk3")
21
22------------------------------------------------------------------------
23-- simple manual tests
24------------------------------------------------------------------------
25
26--[[
27local function dump(z, source)
28 local luaX = lex_init(z, source)
29 while true do
30 local tok, seminfo = luaX:lex()
31 if tok == "<name>" then
32 seminfo = " "..seminfo
33 elseif tok == "<number>" then
34 seminfo = " "..seminfo
35 elseif tok == "<string>" then
36 seminfo = " '"..seminfo.."'"
37 else
38 seminfo = ""
39 end
40 io.stdout:write(tok..seminfo.."\n")
41 if tok == "<eof>" then break end
42 end
43end
44
45local function try_string(chunk)
46 dump(chunk, "=string")
47end
48local function try_file(filename)
49 local inf = io.open(filename, "r")
50 if not inf then error("file not found") end
51 local data = inf:read("*a")
52 inf:close()
53 dump(data, "@"..filename)
54end
55
56z = try_string("local c = z:getc()")
57z = try_file("test_lzio_mk2.lua")
58z = try_file("test_llex_mk2.lua")
59os.exit()
60--]]
61
62------------------------------------------------------------------------
63-- auto-testing of simple test cases to validate lexer behaviour:
64-- * NOTE coverage has not been checked; not comprehensive
65-- * only test cases with non-empty comments are processed
66-- * if no result, then the output is displayed for manual decision
67-- (output may be used to set expected success or fail text)
68-- * cases expected to be successful may be a partial match
69-- * cases expected to fail may also be a partial match
70------------------------------------------------------------------------
71
72-- [[
73local function auto_test()
74 local PASS, FAIL = true, false
75 ------------------------------------------------------------------
76 -- table of test cases
77 ------------------------------------------------------------------
78 local test_cases =
79 {
80 -------------------------------------------------------------
81 --{ "comment", -- comment about the test
82 -- "chunk", -- chunk to test
83 -- PASS, -- PASS or FAIL outcome
84 -- "output", -- output to compare against
85 --},
86 -------------------------------------------------------------
87 { "empty chunk string, test EOS",
88 "",
89 PASS, "1 <eof>",
90 },
91 -------------------------------------------------------------
92 { "line number counting",
93 "\n\n\r\n",
94 PASS, "4 <eof>",
95 },
96 -------------------------------------------------------------
97 { "various whitespaces",
98 " \n\t\t\n \t \t \n\n",
99 PASS, "5 <eof>",
100 },
101 -------------------------------------------------------------
102 { "short comment ending in EOS",
103 "-- moo moo",
104 PASS, "1 <eof>",
105 },
106 -------------------------------------------------------------
107 { "short comment ending in newline",
108 "-- moo moo\n",
109 PASS, "2 <eof>",
110 },
111 -------------------------------------------------------------
112 { "several lines of short comments",
113 "--moo\n-- moo moo\n\n--\tmoo\n",
114 PASS, "5 <eof>",
115 },
116 -------------------------------------------------------------
117 { "basic block comment",
118 "--[[bovine]]",
119 PASS, "1 <eof>",
120 },
121 -------------------------------------------------------------
122 { "unterminated block comment 1",
123 "--[[bovine",
124 FAIL, ":1: unfinished long comment",
125 },
126 -------------------------------------------------------------
127 { "unterminated block comment 2",
128 "--[[bovine]",
129 FAIL, ":1: unfinished long comment",
130 },
131 -------------------------------------------------------------
132 { "unterminated block comment 3",
133 "--[[bovine\nmoo moo\nwoof",
134 FAIL, ":3: unfinished long comment",
135 },
136 -------------------------------------------------------------
137 { "basic long string",
138 "\n[[bovine]]\n",
139 PASS, "2 <string> = bovine\n3 <eof>",
140 },
141 -------------------------------------------------------------
142 { "first newline consumed in long string",
143 "[[\nmoo]]",
144 PASS, "2 <string> = moo\n2 <eof>",
145 },
146 -------------------------------------------------------------
147 { "multiline long string",
148 "[[moo\nmoo moo\n]]",
149 PASS, "3 <string> = moo\nmoo moo\n\n3 <eof>",
150 },
151 -------------------------------------------------------------
152 { "unterminated long string 1",
153 "\n[[\nbovine",
154 FAIL, ":3: unfinished long string",
155 },
156 -------------------------------------------------------------
157 { "unterminated long string 2",
158 "[[bovine]",
159 FAIL, ":1: unfinished long string",
160 },
161 -------------------------------------------------------------
162 { "unterminated long string 3",
163 "[[[[ \n",
164 FAIL, ":2: unfinished long string",
165 },
166 -------------------------------------------------------------
167 { "nested long string 1",
168 "[[moo[[moo]]moo]]",
169 PASS, "moo[[moo]]moo",
170 },
171 -------------------------------------------------------------
172 { "nested long string 2",
173 "[[moo[[moo[[[[]]]]moo]]moo]]",
174 PASS, "moo[[moo[[[[]]]]moo]]moo",
175 },
176 -------------------------------------------------------------
177 { "nested long string 3",
178 "[[[[[[]]]][[[[]]]]]]",
179 PASS, "[[[[]]]][[[[]]]]",
180 },
181 -------------------------------------------------------------
182 { "brackets in long strings 1",
183 "[[moo[moo]]",
184 PASS, "moo[moo",
185 },
186 -------------------------------------------------------------
187 { "brackets in long strings 2",
188 "[[moo[[moo]moo]]moo]]",
189 PASS, "moo[[moo]moo]]moo",
190 },
191 -------------------------------------------------------------
192 { "unprocessed escapes in long strings",
193 [[ [[\a\b\f\n\r\t\v\123]] ]],
194 PASS, [[\a\b\f\n\r\t\v\123]],
195 },
196 -------------------------------------------------------------
197 { "unbalanced long string",
198 "[[moo]]moo]]",
199 PASS, "1 <string> = moo\n1 <name> = moo\n1 CHAR = ']'\n1 CHAR = ']'\n1 <eof>",
200 },
201 -------------------------------------------------------------
202 { "keywords 1",
203 "and break do else",
204 PASS, "1 and\n1 break\n1 do\n1 else\n1 <eof>",
205 },
206 -------------------------------------------------------------
207 { "keywords 2",
208 "elseif end false for",
209 PASS, "1 elseif\n1 end\n1 false\n1 for\n1 <eof>",
210 },
211 -------------------------------------------------------------
212 { "keywords 3",
213 "function if in local nil",
214 PASS, "1 function\n1 if\n1 in\n1 local\n1 nil\n1 <eof>",
215 },
216 -------------------------------------------------------------
217 { "keywords 4",
218 "not or repeat return",
219 PASS, "1 not\n1 or\n1 repeat\n1 return\n1 <eof>",
220 },
221 -------------------------------------------------------------
222 { "keywords 5",
223 "then true until while",
224 PASS, "1 then\n1 true\n1 until\n1 while\n1 <eof>",
225 },
226 -------------------------------------------------------------
227 { "concat and dots",
228 ".. ...",
229 PASS, "1 ..\n1 ...\n1 <eof>",
230 },
231 -------------------------------------------------------------
232 { "shbang handling 1",
233 "#blahblah",
234 PASS, "1 <eof>",
235 },
236 -------------------------------------------------------------
237 { "shbang handling 2",
238 "#blahblah\nmoo moo\n",
239 PASS, "2 <name> = moo\n2 <name> = moo\n3 <eof>",
240 },
241 -------------------------------------------------------------
242 { "empty string",
243 [['']],
244 PASS, "1 <string> = \n1 <eof>",
245 },
246 -------------------------------------------------------------
247 { "single-quoted string",
248 [['bovine']],
249 PASS, "1 <string> = bovine\n1 <eof>",
250 },
251 -------------------------------------------------------------
252 { "double-quoted string",
253 [["bovine"]],
254 PASS, "1 <string> = bovine\n1 <eof>",
255 },
256 -------------------------------------------------------------
257 { "unterminated string 1",
258 [['moo ]],
259 FAIL, ":1: unfinished string",
260 },
261 -------------------------------------------------------------
262 { "unterminated string 2",
263 [["moo \n]],
264 FAIL, ":1: unfinished string",
265 },
266 -------------------------------------------------------------
267 { "escaped newline in string, line number counted",
268 "\"moo\\\nmoo\\\nmoo\"",
269 PASS, "3 <string> = moo\nmoo\nmoo\n3 <eof>",
270 },
271 -------------------------------------------------------------
272 { "escaped characters in string 1",
273 [["moo\amoo"]],
274 PASS, "1 <string> = moo\amoo",
275 },
276 -------------------------------------------------------------
277 { "escaped characters in string 2",
278 [["moo\bmoo"]],
279 PASS, "1 <string> = moo\bmoo",
280 },
281 -------------------------------------------------------------
282 { "escaped characters in string 3",
283 [["moo\f\n\r\t\vmoo"]],
284 PASS, "1 <string> = moo\f\n\r\t\vmoo",
285 },
286 -------------------------------------------------------------
287 { "escaped characters in string 4",
288 [["\\ \" \' \? \[ \]"]],
289 PASS, "1 <string> = \\ \" \' \? \[ \]",
290 },
291 -------------------------------------------------------------
292 { "escaped characters in string 5",
293 [["\z \k \: \;"]],
294 PASS, "1 <string> = z k : ;",
295 },
296 -------------------------------------------------------------
297 { "escaped characters in string 6",
298 [["\8 \65 \160 \180K \097097"]],
299 PASS, "1 <string> = \8 \65 \160 \180K \097097\n",
300 },
301 -------------------------------------------------------------
302 { "escaped characters in string 7",
303 [["\666"]],
304 FAIL, ":1: escape sequence too large",
305 },
306 -------------------------------------------------------------
307 { "simple numbers",
308 "123 123+",
309 PASS, "1 <number> = 123\n1 <number> = 123\n1 CHAR = '+'\n1 <eof>",
310 },
311 -------------------------------------------------------------
312 { "longer numbers",
313 "1234567890 12345678901234567890",
314 PASS, "1 <number> = 1234567890\n1 <number> = 1.2345678901235e+19\n",
315 },
316 -------------------------------------------------------------
317 { "fractional numbers",
318 ".123 .12345678901234567890",
319 PASS, "1 <number> = 0.123\n1 <number> = 0.12345678901235\n",
320 },
321 -------------------------------------------------------------
322 { "more numbers with decimal points",
323 "12345.67890 1.1.",
324 PASS, "1 <number> = 12345.6789\n1 <number> = 1.1\n1 CHAR = '.'\n",
325 },
326 -------------------------------------------------------------
327 { "double decimal points",
328 ".1.1",
329 FAIL, ":1: malformed number",
330 },
331 -------------------------------------------------------------
332 { "double dots within numbers",
333 "1..1",
334 FAIL, ":1: ambiguous syntax (dots follows digits)",
335 },
336 -------------------------------------------------------------
337 { "incomplete exponential numbers",
338 "123e",
339 FAIL, ":1: malformed number",
340 },
341 -------------------------------------------------------------
342 { "exponential numbers 1",
343 "1234e5 1234e5.",
344 PASS, "1 <number> = 123400000\n1 <number> = 123400000\n1 CHAR = '.'",
345 },
346 -------------------------------------------------------------
347 { "exponential numbers 2",
348 "1234e56 1.23e123",
349 PASS, "1 <number> = 1.234e+59\n1 <number> = 1.23e+123\n",
350 },
351 -------------------------------------------------------------
352 { "exponential numbers 3",
353 "12.34e+",
354 FAIL, ":1: malformed number",
355 },
356 -------------------------------------------------------------
357 { "exponential numbers 4",
358 "12.34e+5 123.4e-5 1234.E+5",
359 PASS, "1 <number> = 1234000\n1 <number> = 0.001234\n1 <number> = 123400000\n",
360 },
361 -------------------------------------------------------------
362 { "single character symbols 1",
363 "= > < ~",
364 PASS, "1 CHAR = '='\n1 CHAR = '>'\n1 CHAR = '<'\n1 CHAR = '~'\n",
365 },
366 -------------------------------------------------------------
367 { "double character symbols",
368 "== >= <= ~=",
369 PASS, "1 ==\n1 >=\n1 <=\n1 ~=\n",
370 },
371 -------------------------------------------------------------
372 { "simple identifiers",
373 "abc ABC",
374 PASS, "1 <name> = abc\n1 <name> = ABC\n1 <eof>",
375 },
376 -------------------------------------------------------------
377 { "more identifiers",
378 "_abc _ABC",
379 PASS, "1 <name> = _abc\n1 <name> = _ABC\n1 <eof>",
380 },
381 -------------------------------------------------------------
382 { "still more identifiers",
383 "_aB_ _123",
384 PASS, "1 <name> = _aB_\n1 <name> = _123\n1 <eof>",
385 },
386 -------------------------------------------------------------
387 { "invalid control character",
388 "\4",
389 FAIL, ":1: invalid control char",
390 },
391 -------------------------------------------------------------
392 { "single character symbols 2",
393 "` ! @ $ %",
394 PASS, "1 CHAR = '`'\n1 CHAR = '!'\n1 CHAR = '@'\n1 CHAR = '$'\n1 CHAR = '%'\n",
395 },
396 -------------------------------------------------------------
397 { "single character symbols 3",
398 "^ & * ( )",
399 PASS, "1 CHAR = '^'\n1 CHAR = '&'\n1 CHAR = '*'\n1 CHAR = '('\n1 CHAR = ')'\n",
400 },
401 -------------------------------------------------------------
402 { "single character symbols 4",
403 "_ - + \\ |",
404 PASS, "1 <name> = _\n1 CHAR = '-'\n1 CHAR = '+'\n1 CHAR = '\\'\n1 CHAR = '|'\n",
405 },
406 -------------------------------------------------------------
407 { "single character symbols 5",
408 "{ } [ ] :",
409 PASS, "1 CHAR = '{'\n1 CHAR = '}'\n1 CHAR = '['\n1 CHAR = ']'\n1 CHAR = ':'\n",
410 },
411 -------------------------------------------------------------
412 { "single character symbols 6",
413 "; , . / ?",
414 PASS, "1 CHAR = ';'\n1 CHAR = ','\n1 CHAR = '.'\n1 CHAR = '/'\n1 CHAR = '?'\n",
415 },
416 -------------------------------------------------------------
417 }
418 ------------------------------------------------------------------
419 -- perform a test case
420 ------------------------------------------------------------------
421 function do_test_case(count, test_case)
422 if comment == "" then return end -- skip empty entries
423 local comment, chunk, outcome, matcher = unpack(test_case)
424 local result = PASS
425 local output = ""
426 -- initialize lexer
427 local luaX = lex_init(chunk, "=test")
428 -- lexer test loop
429 local status, token, seminfo
430 repeat
431 -- protected call
432 status, token, seminfo = pcall(luaX.lex, luaX)
433 output = output..luaX.ln.." "
434 if status then
435 -- successful call
436 if string.len(token) > 1 then
437 if token == "<name>"
438 or token == "<number>"
439 or token == "<string>" then
440 token = token.." = "..seminfo
441 end
442 elseif string.byte(token) >= 32 then -- displayable chars
443 token = "CHAR = '"..token.."'"
444 else -- control characters
445 token = "CHAR = (".. string.byte(token)..")"
446 end
447 output = output..token.."\n"
448 else
449 -- failed call
450 output = output..token -- token is the error message
451 result = FAIL
452 break
453 end
454 until token == "<eof>"
455 -- decision making and reporting
456 local head = "Test "..count..": "..comment
457 if matcher == "" then
458 -- nothing to check against, display for manual check
459 print(head.."\nMANUAL please check manually"..
460 "\n--chunk---------------------------------\n"..chunk..
461 "\n--actual--------------------------------\n"..output..
462 "\n\n")
463 return
464 else
465 if outcome == PASS then
466 -- success expected, may be a partial match
467 if string.find(output, matcher, 1, 1) and result == PASS then
468 if not BRIEF then print(head.."\nOK expected success\n") end
469 return
470 end
471 else
472 -- failure expected, may be a partial match
473 if string.find(output, matcher, 1, 1) and result == FAIL then
474 if not BRIEF then print(head.."\nOK expected failure\n") end
475 return
476 end
477 end
478 -- failed because of unmatched string or boolean result
479 local function passfail(status)
480 if status == PASS then return "PASS" else return "FAIL" end
481 end
482 print(head.." *FAILED*"..
483 "\noutcome="..passfail(outcome)..
484 "\nactual= "..passfail(result)..
485 "\n--chunk---------------------------------\n"..chunk..
486 "\n--expected------------------------------\n"..matcher..
487 "\n--actual--------------------------------\n"..output..
488 "\n\n")
489 end
490 end
491 ------------------------------------------------------------------
492 -- perform auto testing
493 ------------------------------------------------------------------
494 for i,test_case in ipairs(test_cases) do
495 do_test_case(i, test_case)
496 end
497end
498
499auto_test()
500--]]
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_llex_mk4.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_llex_mk4.lua
deleted file mode 100644
index 316a9bf..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_llex_mk4.lua
+++ /dev/null
@@ -1,499 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 test_llex.lua
4 Test for llex.lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2006 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15------------------------------------------------------------------------
16-- if BRIEF is not set to false, auto-test will silently succeed
17------------------------------------------------------------------------
18BRIEF = true -- if set to true, messages are less verbose
19
20local zio_init = require("../lzio_mk4")
21local lex_init = require("../llex_mk4")
22
23------------------------------------------------------------------------
24-- simple manual tests
25------------------------------------------------------------------------
26
27--[[
28local function dump(z, source)
29 local luaX = lex_init(z, source)
30 while true do
31 local tok, seminfo = luaX:lex()
32 if tok == "<name>" then
33 seminfo = " "..seminfo
34 elseif tok == "<number>" then
35 seminfo = " "..seminfo
36 elseif tok == "<string>" then
37 seminfo = " '"..seminfo.."'"
38 else
39 seminfo = ""
40 end
41 io.stdout:write(tok..seminfo.."\n")
42 if tok == "<eof>" then break end
43 end
44end
45
46local function try_string(chunk)
47 dump(zio_init(chunk), "=string")
48end
49local function try_file(filename)
50 local f = "@"..filename
51 dump(zio_init(f), f)
52end
53
54z = try_string("local c = z:getc()")
55z = try_file("test_lzio_mk2.lua")
56z = try_file("test_llex_mk2.lua")
57os.exit()
58--]]
59
60------------------------------------------------------------------------
61-- auto-testing of simple test cases to validate lexer behaviour:
62-- * NOTE coverage has not been checked; not comprehensive
63-- * only test cases with non-empty comments are processed
64-- * if no result, then the output is displayed for manual decision
65-- (output may be used to set expected success or fail text)
66-- * cases expected to be successful may be a partial match
67-- * cases expected to fail may also be a partial match
68------------------------------------------------------------------------
69
70-- [[
71local function auto_test()
72 local PASS, FAIL = true, false
73 ------------------------------------------------------------------
74 -- table of test cases
75 ------------------------------------------------------------------
76 local test_cases =
77 {
78 -------------------------------------------------------------
79 --{ "comment", -- comment about the test
80 -- "chunk", -- chunk to test
81 -- PASS, -- PASS or FAIL outcome
82 -- "output", -- output to compare against
83 --},
84 -------------------------------------------------------------
85 { "empty chunk string, test EOS",
86 "",
87 PASS, "1 <eof>",
88 },
89 -------------------------------------------------------------
90 { "line number counting",
91 "\n\n\r\n",
92 PASS, "4 <eof>",
93 },
94 -------------------------------------------------------------
95 { "various whitespaces",
96 " \n\t\t\n \t \t \n\n",
97 PASS, "5 <eof>",
98 },
99 -------------------------------------------------------------
100 { "short comment ending in EOS",
101 "-- moo moo",
102 PASS, "1 <eof>",
103 },
104 -------------------------------------------------------------
105 { "short comment ending in newline",
106 "-- moo moo\n",
107 PASS, "2 <eof>",
108 },
109 -------------------------------------------------------------
110 { "several lines of short comments",
111 "--moo\n-- moo moo\n\n--\tmoo\n",
112 PASS, "5 <eof>",
113 },
114 -------------------------------------------------------------
115 { "basic block comment",
116 "--[[bovine]]",
117 PASS, "1 <eof>",
118 },
119 -------------------------------------------------------------
120 { "unterminated block comment 1",
121 "--[[bovine",
122 FAIL, ":1: unfinished long comment",
123 },
124 -------------------------------------------------------------
125 { "unterminated block comment 2",
126 "--[[bovine]",
127 FAIL, ":1: unfinished long comment",
128 },
129 -------------------------------------------------------------
130 { "unterminated block comment 3",
131 "--[[bovine\nmoo moo\nwoof",
132 FAIL, ":3: unfinished long comment",
133 },
134 -------------------------------------------------------------
135 { "basic long string",
136 "\n[[bovine]]\n",
137 PASS, "2 <string> = bovine\n3 <eof>",
138 },
139 -------------------------------------------------------------
140 { "first newline consumed in long string",
141 "[[\nmoo]]",
142 PASS, "2 <string> = moo\n2 <eof>",
143 },
144 -------------------------------------------------------------
145 { "multiline long string",
146 "[[moo\nmoo moo\n]]",
147 PASS, "3 <string> = moo\nmoo moo\n\n3 <eof>",
148 },
149 -------------------------------------------------------------
150 { "unterminated long string 1",
151 "\n[[\nbovine",
152 FAIL, ":3: unfinished long string",
153 },
154 -------------------------------------------------------------
155 { "unterminated long string 2",
156 "[[bovine]",
157 FAIL, ":1: unfinished long string",
158 },
159 -------------------------------------------------------------
160 { "unterminated long string 3",
161 "[[[[ \n",
162 FAIL, ":2: unfinished long string",
163 },
164 -------------------------------------------------------------
165 { "nested long string 1",
166 "[[moo[[moo]]moo]]",
167 PASS, "moo[[moo]]moo",
168 },
169 -------------------------------------------------------------
170 { "nested long string 2",
171 "[[moo[[moo[[[[]]]]moo]]moo]]",
172 PASS, "moo[[moo[[[[]]]]moo]]moo",
173 },
174 -------------------------------------------------------------
175 { "nested long string 3",
176 "[[[[[[]]]][[[[]]]]]]",
177 PASS, "[[[[]]]][[[[]]]]",
178 },
179 -------------------------------------------------------------
180 { "brackets in long strings 1",
181 "[[moo[moo]]",
182 PASS, "moo[moo",
183 },
184 -------------------------------------------------------------
185 { "brackets in long strings 2",
186 "[[moo[[moo]moo]]moo]]",
187 PASS, "moo[[moo]moo]]moo",
188 },
189 -------------------------------------------------------------
190 { "unprocessed escapes in long strings",
191 [[ [[\a\b\f\n\r\t\v\123]] ]],
192 PASS, [[\a\b\f\n\r\t\v\123]],
193 },
194 -------------------------------------------------------------
195 { "unbalanced long string",
196 "[[moo]]moo]]",
197 PASS, "1 <string> = moo\n1 <name> = moo\n1 CHAR = ']'\n1 CHAR = ']'\n1 <eof>",
198 },
199 -------------------------------------------------------------
200 { "keywords 1",
201 "and break do else",
202 PASS, "1 and\n1 break\n1 do\n1 else\n1 <eof>",
203 },
204 -------------------------------------------------------------
205 { "keywords 2",
206 "elseif end false for",
207 PASS, "1 elseif\n1 end\n1 false\n1 for\n1 <eof>",
208 },
209 -------------------------------------------------------------
210 { "keywords 3",
211 "function if in local nil",
212 PASS, "1 function\n1 if\n1 in\n1 local\n1 nil\n1 <eof>",
213 },
214 -------------------------------------------------------------
215 { "keywords 4",
216 "not or repeat return",
217 PASS, "1 not\n1 or\n1 repeat\n1 return\n1 <eof>",
218 },
219 -------------------------------------------------------------
220 { "keywords 5",
221 "then true until while",
222 PASS, "1 then\n1 true\n1 until\n1 while\n1 <eof>",
223 },
224 -------------------------------------------------------------
225 { "concat and dots",
226 ".. ...",
227 PASS, "1 ..\n1 ...\n1 <eof>",
228 },
229 -------------------------------------------------------------
230 { "shbang handling 1",
231 "#blahblah",
232 PASS, "1 <eof>",
233 },
234 -------------------------------------------------------------
235 { "shbang handling 2",
236 "#blahblah\nmoo moo\n",
237 PASS, "2 <name> = moo\n2 <name> = moo\n3 <eof>",
238 },
239 -------------------------------------------------------------
240 { "empty string",
241 [['']],
242 PASS, "1 <string> = \n1 <eof>",
243 },
244 -------------------------------------------------------------
245 { "single-quoted string",
246 [['bovine']],
247 PASS, "1 <string> = bovine\n1 <eof>",
248 },
249 -------------------------------------------------------------
250 { "double-quoted string",
251 [["bovine"]],
252 PASS, "1 <string> = bovine\n1 <eof>",
253 },
254 -------------------------------------------------------------
255 { "unterminated string 1",
256 [['moo ]],
257 FAIL, ":1: unfinished string",
258 },
259 -------------------------------------------------------------
260 { "unterminated string 2",
261 [["moo \n]],
262 FAIL, ":1: unfinished string",
263 },
264 -------------------------------------------------------------
265 { "escaped newline in string, line number counted",
266 "\"moo\\\nmoo\\\nmoo\"",
267 PASS, "3 <string> = moo\nmoo\nmoo\n3 <eof>",
268 },
269 -------------------------------------------------------------
270 { "escaped characters in string 1",
271 [["moo\amoo"]],
272 PASS, "1 <string> = moo\amoo",
273 },
274 -------------------------------------------------------------
275 { "escaped characters in string 2",
276 [["moo\bmoo"]],
277 PASS, "1 <string> = moo\bmoo",
278 },
279 -------------------------------------------------------------
280 { "escaped characters in string 3",
281 [["moo\f\n\r\t\vmoo"]],
282 PASS, "1 <string> = moo\f\n\r\t\vmoo",
283 },
284 -------------------------------------------------------------
285 { "escaped characters in string 4",
286 [["\\ \" \' \? \[ \]"]],
287 PASS, "1 <string> = \\ \" \' \? \[ \]",
288 },
289 -------------------------------------------------------------
290 { "escaped characters in string 5",
291 [["\z \k \: \;"]],
292 PASS, "1 <string> = z k : ;",
293 },
294 -------------------------------------------------------------
295 { "escaped characters in string 6",
296 [["\8 \65 \160 \180K \097097"]],
297 PASS, "1 <string> = \8 \65 \160 \180K \097097\n",
298 },
299 -------------------------------------------------------------
300 { "escaped characters in string 7",
301 [["\666"]],
302 FAIL, ":1: escape sequence too large",
303 },
304 -------------------------------------------------------------
305 { "simple numbers",
306 "123 123+",
307 PASS, "1 <number> = 123\n1 <number> = 123\n1 CHAR = '+'\n1 <eof>",
308 },
309 -------------------------------------------------------------
310 { "longer numbers",
311 "1234567890 12345678901234567890",
312 PASS, "1 <number> = 1234567890\n1 <number> = 1.2345678901235e+19\n",
313 },
314 -------------------------------------------------------------
315 { "fractional numbers",
316 ".123 .12345678901234567890",
317 PASS, "1 <number> = 0.123\n1 <number> = 0.12345678901235\n",
318 },
319 -------------------------------------------------------------
320 { "more numbers with decimal points",
321 "12345.67890 1.1.",
322 PASS, "1 <number> = 12345.6789\n1 <number> = 1.1\n1 CHAR = '.'\n",
323 },
324 -------------------------------------------------------------
325 { "double decimal points",
326 ".1.1",
327 FAIL, ":1: malformed number",
328 },
329 -------------------------------------------------------------
330 { "double dots within numbers",
331 "1..1",
332 FAIL, ":1: ambiguous syntax (dots follows digits)",
333 },
334 -------------------------------------------------------------
335 { "incomplete exponential numbers",
336 "123e",
337 FAIL, ":1: malformed number",
338 },
339 -------------------------------------------------------------
340 { "exponential numbers 1",
341 "1234e5 1234e5.",
342 PASS, "1 <number> = 123400000\n1 <number> = 123400000\n1 CHAR = '.'",
343 },
344 -------------------------------------------------------------
345 { "exponential numbers 2",
346 "1234e56 1.23e123",
347 PASS, "1 <number> = 1.234e+59\n1 <number> = 1.23e+123\n",
348 },
349 -------------------------------------------------------------
350 { "exponential numbers 3",
351 "12.34e+",
352 FAIL, ":1: malformed number",
353 },
354 -------------------------------------------------------------
355 { "exponential numbers 4",
356 "12.34e+5 123.4e-5 1234.E+5",
357 PASS, "1 <number> = 1234000\n1 <number> = 0.001234\n1 <number> = 123400000\n",
358 },
359 -------------------------------------------------------------
360 { "single character symbols 1",
361 "= > < ~",
362 PASS, "1 CHAR = '='\n1 CHAR = '>'\n1 CHAR = '<'\n1 CHAR = '~'\n",
363 },
364 -------------------------------------------------------------
365 { "double character symbols",
366 "== >= <= ~=",
367 PASS, "1 ==\n1 >=\n1 <=\n1 ~=\n",
368 },
369 -------------------------------------------------------------
370 { "simple identifiers",
371 "abc ABC",
372 PASS, "1 <name> = abc\n1 <name> = ABC\n1 <eof>",
373 },
374 -------------------------------------------------------------
375 { "more identifiers",
376 "_abc _ABC",
377 PASS, "1 <name> = _abc\n1 <name> = _ABC\n1 <eof>",
378 },
379 -------------------------------------------------------------
380 { "still more identifiers",
381 "_aB_ _123",
382 PASS, "1 <name> = _aB_\n1 <name> = _123\n1 <eof>",
383 },
384 -------------------------------------------------------------
385 { "invalid control character",
386 "\4",
387 FAIL, ":1: invalid control char",
388 },
389 -------------------------------------------------------------
390 { "single character symbols 2",
391 "` ! @ $ %",
392 PASS, "1 CHAR = '`'\n1 CHAR = '!'\n1 CHAR = '@'\n1 CHAR = '$'\n1 CHAR = '%'\n",
393 },
394 -------------------------------------------------------------
395 { "single character symbols 3",
396 "^ & * ( )",
397 PASS, "1 CHAR = '^'\n1 CHAR = '&'\n1 CHAR = '*'\n1 CHAR = '('\n1 CHAR = ')'\n",
398 },
399 -------------------------------------------------------------
400 { "single character symbols 4",
401 "_ - + \\ |",
402 PASS, "1 <name> = _\n1 CHAR = '-'\n1 CHAR = '+'\n1 CHAR = '\\'\n1 CHAR = '|'\n",
403 },
404 -------------------------------------------------------------
405 { "single character symbols 5",
406 "{ } [ ] :",
407 PASS, "1 CHAR = '{'\n1 CHAR = '}'\n1 CHAR = '['\n1 CHAR = ']'\n1 CHAR = ':'\n",
408 },
409 -------------------------------------------------------------
410 { "single character symbols 6",
411 "; , . / ?",
412 PASS, "1 CHAR = ';'\n1 CHAR = ','\n1 CHAR = '.'\n1 CHAR = '/'\n1 CHAR = '?'\n",
413 },
414 -------------------------------------------------------------
415 }
416 ------------------------------------------------------------------
417 -- perform a test case
418 ------------------------------------------------------------------
419 function do_test_case(count, test_case)
420 if comment == "" then return end -- skip empty entries
421 local comment, chunk, outcome, matcher = unpack(test_case)
422 local result = PASS
423 local output = ""
424 -- initialize lexer
425 local z = zio_init(chunk)
426 local luaX = lex_init(z, "=test")
427 -- lexer test loop
428 local status, token, seminfo
429 repeat
430 -- protected call
431 status, token, seminfo = pcall(luaX.lex, luaX)
432 output = output..luaX.ln.." "
433 if status then
434 -- successful call
435 if string.len(token) > 1 then
436 if token == "<name>"
437 or token == "<number>"
438 or token == "<string>" then
439 token = token.." = "..seminfo
440 end
441 elseif string.byte(token) >= 32 then -- displayable chars
442 token = "CHAR = '"..token.."'"
443 else -- control characters
444 token = "CHAR = (".. string.byte(token)..")"
445 end
446 output = output..token.."\n"
447 else
448 -- failed call
449 output = output..token -- token is the error message
450 result = FAIL
451 break
452 end
453 until token == "<eof>"
454 -- decision making and reporting
455 local head = "Test "..count..": "..comment
456 if matcher == "" then
457 -- nothing to check against, display for manual check
458 print(head.."\nMANUAL please check manually"..
459 "\n--chunk---------------------------------\n"..chunk..
460 "\n--actual--------------------------------\n"..output..
461 "\n\n")
462 return
463 else
464 if outcome == PASS then
465 -- success expected, may be a partial match
466 if string.find(output, matcher, 1, 1) and result == PASS then
467 if not BRIEF then print(head.."\nOK expected success\n") end
468 return
469 end
470 else
471 -- failure expected, may be a partial match
472 if string.find(output, matcher, 1, 1) and result == FAIL then
473 if not BRIEF then print(head.."\nOK expected failure\n") end
474 return
475 end
476 end
477 -- failed because of unmatched string or boolean result
478 local function passfail(status)
479 if status == PASS then return "PASS" else return "FAIL" end
480 end
481 print(head.." *FAILED*"..
482 "\noutcome="..passfail(outcome)..
483 "\nactual= "..passfail(result)..
484 "\n--chunk---------------------------------\n"..chunk..
485 "\n--expected------------------------------\n"..matcher..
486 "\n--actual--------------------------------\n"..output..
487 "\n\n")
488 end
489 end
490 ------------------------------------------------------------------
491 -- perform auto testing
492 ------------------------------------------------------------------
493 for i,test_case in ipairs(test_cases) do
494 do_test_case(i, test_case)
495 end
496end
497
498auto_test()
499--]]
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3.lua
deleted file mode 100644
index 662c826..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3.lua
+++ /dev/null
@@ -1,218 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 test_lparser_mk3.lua
4 Test for lparser_mk3.lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2008 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15------------------------------------------------------------------------
16-- test the whole kaboodle
17------------------------------------------------------------------------
18
19local lex_init = require("../llex_mk3")
20local parser_init = require("../lparser_mk3")
21
22------------------------------------------------------------------------
23-- dump contents of log table
24------------------------------------------------------------------------
25
26local function dump_log(fs)
27 local log = fs.log
28 for i = 1, table.getn(log) do
29 print(log[i])
30 end
31end
32
33------------------------------------------------------------------------
34-- try 1
35------------------------------------------------------------------------
36
37local luaX = lex_init("local a = 1", "=string")
38local luaY = parser_init(luaX)
39
40-- nothing is returned, so hope there is an error if problem occurs
41local fs = luaY:parser()
42--dump_log(fs)
43
44------------------------------------------------------------------------
45-- try 2
46------------------------------------------------------------------------
47
48-- llex_mk3.lua cannot load files by itself
49local INF = io.open("sample.lua", "rb")
50if not INF then error("failed to load test file") end
51local sample = INF:read("*a")
52INF:close()
53
54luaX = lex_init(sample, "@sample.lua")
55luaY = parser_init(luaX)
56
57-- nothing is returned, so hope there is an error if problem occurs
58local fs = luaY:parser()
59--dump_log(fs)
60
61------------------------------------------------------------------------
62-- automatic dumper of output log data
63------------------------------------------------------------------------
64
65local test_case = {
66-- 1
67[[
68]],
69-- 2
70[[
71-- foobar
72]],
73-- 3
74[[
75do
76end
77]],
78-- 4
79[[
80do end
81do end
82]],
83-- 5
84[[
85foo()
86foo{}
87foo""
88foo:bar()
89foo=false
90foo.bar=true
91foo[true]=nil
92foo,bar=1,"a"
93]],
94-- 6
95[[
96foo=true
97foo=false
98foo=nil
99foo=1.23e45
100foo=-1
101foo=(0)
102foo=1+2
103foo=1+2*3-4/5
104]],
105-- 7
106[[
107if foo then foo=1 end
108if foo then foo=1 else foo=0 end
109if foo then foo=1 elseif not foo then foo=0 end
110]],
111-- 8
112[[
113do return end
114do return 123 end
115do return "foo","bar" end
116]],
117-- 9
118[[
119while true do foo=not foo end
120while foo~=42 do foo=foo-1 end
121while true do break end
122]],
123-- 10
124[[
125repeat foo=foo.."bar" until false
126repeat foo=foo/2 until foo<1
127repeat break until false
128]],
129-- 11
130[[
131for i=1,10 do foo=i end
132for i=1,10,2 do break end
133for i in foo do bar=0 end
134for i,j in foo,bar do baz=0 end
135]],
136-- 12
137[[
138local foo
139local foo,bar,baz
140local foo,bar="foo","bar"
141]],
142-- 13
143[[
144local function foo() return end
145local function foo(a) return end
146local function foo(x,y,z) return end
147local function foo(x,...) return end
148]],
149-- 14
150[[
151function foo() return end
152function foo(a) return end
153function foo(x,y,z) return end
154function foo(x,...) return end
155]],
156-- 15
157[[
158function foo.bar(p) return end
159function foo.bar.baz(p) return end
160function foo:bar(p) return end
161function foo.bar.baz(p) return end
162]],
163-- 16
164[[
165foo = function() return end
166foo = function(x,y) return end
167foo = function(...) return end
168]],
169-- 17
170[[
171foo = {}
172foo = { 1,2,3; "foo"; }
173foo = { bar=77, baz=88, }
174foo = { ["bar"]=77, ["baz"]=88, }
175]],
176}
177
178-- helps to skip old stuff during development of snippets
179local do_beg, do_end = 1, table.getn(test_case)
180
181-- loop for all example snippets
182for i = do_beg, do_end do
183 local fname = "parser_log/sample_"..string.format("%02d", i)..".lua"
184 local src = test_case[i]
185 local OUTF = io.open(fname, "wb")
186 if not OUTF then error("failed to write to file '"..fname.."'") end
187 -- write out actual source for comparison
188 OUTF:write(
189 "-- START OF SOURCE --\n"..
190 src..
191 "-- END OF SOURCE --\n"..
192 "\n"
193 )
194 -- attempt to parse
195 local luaX = lex_init(src, "=string")
196 local luaY = parser_init(luaX)
197 local fs = luaY:parser()
198 -- grab logged messages and write
199 local log = fs.log
200 local indent = 0
201 for i = 1, table.getn(log) do
202 local ln = log[i]
203 -- handle indentation
204 local tag = string.sub(ln, 1, 2)
205 if tag == ">>" or tag == "<<" then
206 ln = string.sub(ln, 4)
207 end
208 if tag == ">>" then
209 indent = indent + 1
210 end
211 OUTF:write(string.rep(" ", indent)..ln.."\n")
212 if tag == "<<" then
213 indent = indent - 1
214 end
215 end
216 -- we're done
217 OUTF:close()
218end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3_2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3_2.lua
deleted file mode 100644
index 957ee22..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3_2.lua
+++ /dev/null
@@ -1,158 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 test_lparser_mk3_2.lua
4 Test for lparser_mk3.lua, using the test case file
5 This file is part of Yueliang.
6
7 Copyright (c) 2006-2008 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15--[[--------------------------------------------------------------------
16-- Notes:
17-- * unlike the equivalent in the orig-5.0.3/ directory, this version
18-- tests only parsing, lparser_mk3 cannot generate binary chunks
19-- * the test cases are in the test_lua directory (test_parser-5.0.lua)
20----------------------------------------------------------------------]]
21
22-- * true if you want an output of all failure cases in native Lua,
23-- for checking whether test cases fail where you intend them to
24local DEBUG_FAILS = false
25
26------------------------------------------------------------------------
27-- test the whole kaboodle
28------------------------------------------------------------------------
29
30local lex_init = require("../llex_mk3")
31local parser_init = require("../lparser_mk3")
32
33------------------------------------------------------------------------
34-- load test cases
35------------------------------------------------------------------------
36
37require("../../test_lua/test_parser-5.0")
38
39local test, expect, heading = {}, {}, {}
40local total, total_pass, total_fail = 0, 0, 0
41
42for ln in string.gfind(tests_source, "([^\n]*)\n") do
43 if string.find(ln, "^%s*%-%-") then
44 -- comment, ignore
45 else
46 local m, _, head = string.find(ln, "^%s*(TESTS:%s*.*)$")
47 if m then
48 heading[total + 1] = head -- informational heading
49 else
50 total = total + 1
51 local n, _, flag = string.find(ln, "%s*%-%-%s*FAIL%s*$")
52 if n then -- FAIL test case
53 ln = string.sub(ln, 1, n - 1) -- remove comment
54 expect[total] = "FAIL"
55 total_fail = total_fail + 1
56 else -- PASS test case
57 expect[total] = "PASS"
58 total_pass = total_pass + 1
59 end--n
60 test[total] = ln
61 end--m
62 end--ln
63end--for
64
65print("Tests loaded: "..total.." (total), "
66 ..total_pass.." (passes), "
67 ..total_fail.." (fails)")
68
69------------------------------------------------------------------------
70-- verify test cases using native Lua
71------------------------------------------------------------------------
72
73local last_head = "TESTS: no heading yet"
74for i = 1, total do
75 local test_case, expected, head = test[i], expect[i], heading[i]
76 -- show progress
77 if head then
78 last_head = head
79 if DEBUG_FAILS then print("\n"..head.."\n") end
80 end
81 ------------------------------------------------------------------
82 -- perform test
83 local f, err = loadstring(test_case)
84 -- look at outcome
85 ------------------------------------------------------------------
86 if f then-- actual PASS
87 if expected == "FAIL" then
88 print("\nVerified as PASS but expected to FAIL"..
89 "\n-------------------------------------")
90 print("Lastest heading: "..last_head)
91 print("TEST: "..test_case)
92 os.exit()
93 end
94 ------------------------------------------------------------------
95 else-- actual FAIL
96 if expected == "PASS" then
97 print("\nVerified as FAIL but expected to PASS"..
98 "\n-------------------------------------")
99 print("Lastest heading: "..last_head)
100 print("TEST: "..test_case)
101 print("ERROR: "..err)
102 os.exit()
103 end
104 if DEBUG_FAILS then
105 print("TEST: "..test_case)
106 print("ERROR: "..err.."\n")
107 end
108 ------------------------------------------------------------------
109 end--f
110end--for
111
112print("Test cases verified using native Lua, no anomalies.")
113
114------------------------------------------------------------------------
115-- test using Yueliang front end
116------------------------------------------------------------------------
117
118local last_head = "TESTS: no heading yet"
119for i = 1, total do
120 local test_case, expected, head = test[i], expect[i], heading[i]
121 -- show progress
122 if head then last_head = head end
123 ------------------------------------------------------------------
124 -- perform test
125 luaX = lex_init(test_case, "=test_sample")
126 luaY = parser_init(luaX)
127
128 local status, func = pcall(luaY.parser, luaY)
129 -- look at outcome
130 ------------------------------------------------------------------
131 if status then-- actual PASS
132 if expected == "FAIL" then
133 print("\nTested as PASS but expected to FAIL"..
134 "\n-----------------------------------")
135 print("Lastest heading: "..last_head)
136 print("TEST: "..test_case)
137 os.exit()
138 end
139 ------------------------------------------------------------------
140 else-- actual FAIL
141 if expected == "PASS" then
142 print("\nTested as FAIL but expected to PASS"..
143 "\n-----------------------------------")
144 print("Lastest heading: "..last_head)
145 print("TEST: "..test_case)
146 os.exit()
147 else
148 io.stdout:write("-")
149 end
150 ------------------------------------------------------------------
151 end--status
152 io.stdout:write("\rTesting ["..i.."]...")
153end--for
154print(" done.")
155
156print("Test cases run on Yueliang, no anomalies.")
157
158-- end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3b.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3b.lua
deleted file mode 100644
index d8dc33d..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3b.lua
+++ /dev/null
@@ -1,188 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 test_lparser_mk3b.lua
4 Test for lparser_mk3b.lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2008 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15------------------------------------------------------------------------
16-- test the whole kaboodle
17------------------------------------------------------------------------
18
19local lex_init = require("../llex_mk3")
20local parser_init = require("../lparser_mk3b")
21
22------------------------------------------------------------------------
23-- dump contents of log table
24------------------------------------------------------------------------
25
26local function dump_log(fs)
27 local log = fs.log
28 for i = 1, table.getn(log) do
29 print(log[i])
30 end
31end
32
33------------------------------------------------------------------------
34-- automatic dumper of output log data
35------------------------------------------------------------------------
36
37local test_case = {
38-- 1
39[[
40 print(a)
41]],
42-- 2
43[[
44 local a
45 print(a)
46]],
47-- 3
48[[
49 do
50 local a
51 print(a)
52 end
53 print(a)
54]],
55-- 4
56[[
57 local a,b,c
58 do
59 local b
60 print(b)
61 end
62 print(b)
63]],
64-- 5
65[[
66 local function foo() end
67 bar = foo
68]],
69-- 6
70[[
71 do
72 local function foo() end
73 bar = foo
74 end
75 baz = foo
76]],
77-- 7
78[[
79 local foo
80 local function bar()
81 baz = nil
82 foo = bar()
83 end
84 foo = bar
85]],
86-- 8
87[[
88 local foo
89 local function bar()
90 local function baz()
91 local foo, bar
92 foo = bar
93 foo = baz
94 end
95 foo = bar
96 foo = baz
97 end
98 foo = bar
99 foo = baz
100]],
101-- 9
102[[
103 function foo:bar()
104 print(self)
105 end
106]],
107-- 10
108[[
109 function foo(...)
110 print(arg)
111 end
112]],
113-- 11
114[[
115 local c,d
116 function foo(a,b,c)
117 print(a,c,d,e)
118 end
119]],
120-- 11
121[[
122 function foo(a,b)
123 local bar = function(c,d)
124 print(a,b,c,d)
125 end
126 end
127]],
128-- 12
129[[
130 for i = 1,10 do
131 print(i)
132 end
133 for i = 1,10,-2 do
134 print(i)
135 end
136]],
137-- 13
138[[
139 for foo in bar() do
140 print(foo)
141 end
142 for foo,bar,baz in spring() do
143 print(foo,bar,baz)
144 end
145]],
146}
147
148-- helps to skip old stuff during development of snippets
149local do_beg, do_end = 1, table.getn(test_case)
150
151-- loop for all example snippets
152for i = do_beg, do_end do
153 local fname = "parser_log/sample_b_"..string.format("%02d", i)..".lua"
154 local src = test_case[i]
155 local OUTF = io.open(fname, "wb")
156 if not OUTF then error("failed to write to file '"..fname.."'") end
157 -- write out actual source for comparison
158 OUTF:write(
159 "-- START OF SOURCE --\n"..
160 src..
161 "-- END OF SOURCE --\n"..
162 "\n"
163 )
164 -- attempt to parse
165 local luaX = lex_init(src, "=string")
166 local luaY = parser_init(luaX)
167 local fs = luaY:parser()
168 -- grab logged messages and write
169 local log = fs.log
170 local indent = 0
171 for i = 1, table.getn(log) do
172 local ln = log[i]
173 -- handle indentation
174 local tag = string.sub(ln, 1, 2)
175 if tag == ">>" or tag == "<<" then
176 ln = string.sub(ln, 4)
177 end
178 if tag == ">>" then
179 indent = indent + 1
180 end
181 OUTF:write(string.rep(" ", indent)..ln.."\n")
182 if tag == "<<" then
183 indent = indent - 1
184 end
185 end
186 -- we're done
187 OUTF:close()
188end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3b_2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3b_2.lua
deleted file mode 100644
index 4d4e8c5..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lparser_mk3b_2.lua
+++ /dev/null
@@ -1,158 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 test_lparser_mk3b_2.lua
4 Test for lparser_mk3b.lua, using the test case file
5 This file is part of Yueliang.
6
7 Copyright (c) 2006-2008 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15--[[--------------------------------------------------------------------
16-- Notes:
17-- * unlike the equivalent in the orig-5.0.3/ directory, this version
18-- tests only parsing, lparser_mk3 cannot generate binary chunks
19-- * the test cases are in the test_lua directory (test_parser-5.0.lua)
20----------------------------------------------------------------------]]
21
22-- * true if you want an output of all failure cases in native Lua,
23-- for checking whether test cases fail where you intend them to
24local DEBUG_FAILS = false
25
26------------------------------------------------------------------------
27-- test the whole kaboodle
28------------------------------------------------------------------------
29
30local lex_init = require("../llex_mk3")
31local parser_init = require("../lparser_mk3b")
32
33------------------------------------------------------------------------
34-- load test cases
35------------------------------------------------------------------------
36
37require("../../test_lua/test_parser-5.0")
38
39local test, expect, heading = {}, {}, {}
40local total, total_pass, total_fail = 0, 0, 0
41
42for ln in string.gfind(tests_source, "([^\n]*)\n") do
43 if string.find(ln, "^%s*%-%-") then
44 -- comment, ignore
45 else
46 local m, _, head = string.find(ln, "^%s*(TESTS:%s*.*)$")
47 if m then
48 heading[total + 1] = head -- informational heading
49 else
50 total = total + 1
51 local n, _, flag = string.find(ln, "%s*%-%-%s*FAIL%s*$")
52 if n then -- FAIL test case
53 ln = string.sub(ln, 1, n - 1) -- remove comment
54 expect[total] = "FAIL"
55 total_fail = total_fail + 1
56 else -- PASS test case
57 expect[total] = "PASS"
58 total_pass = total_pass + 1
59 end--n
60 test[total] = ln
61 end--m
62 end--ln
63end--for
64
65print("Tests loaded: "..total.." (total), "
66 ..total_pass.." (passes), "
67 ..total_fail.." (fails)")
68
69------------------------------------------------------------------------
70-- verify test cases using native Lua
71------------------------------------------------------------------------
72
73local last_head = "TESTS: no heading yet"
74for i = 1, total do
75 local test_case, expected, head = test[i], expect[i], heading[i]
76 -- show progress
77 if head then
78 last_head = head
79 if DEBUG_FAILS then print("\n"..head.."\n") end
80 end
81 ------------------------------------------------------------------
82 -- perform test
83 local f, err = loadstring(test_case)
84 -- look at outcome
85 ------------------------------------------------------------------
86 if f then-- actual PASS
87 if expected == "FAIL" then
88 print("\nVerified as PASS but expected to FAIL"..
89 "\n-------------------------------------")
90 print("Lastest heading: "..last_head)
91 print("TEST: "..test_case)
92 os.exit()
93 end
94 ------------------------------------------------------------------
95 else-- actual FAIL
96 if expected == "PASS" then
97 print("\nVerified as FAIL but expected to PASS"..
98 "\n-------------------------------------")
99 print("Lastest heading: "..last_head)
100 print("TEST: "..test_case)
101 print("ERROR: "..err)
102 os.exit()
103 end
104 if DEBUG_FAILS then
105 print("TEST: "..test_case)
106 print("ERROR: "..err.."\n")
107 end
108 ------------------------------------------------------------------
109 end--f
110end--for
111
112print("Test cases verified using native Lua, no anomalies.")
113
114------------------------------------------------------------------------
115-- test using Yueliang front end
116------------------------------------------------------------------------
117
118local last_head = "TESTS: no heading yet"
119for i = 1, total do
120 local test_case, expected, head = test[i], expect[i], heading[i]
121 -- show progress
122 if head then last_head = head end
123 ------------------------------------------------------------------
124 -- perform test
125 luaX = lex_init(test_case, "=test_sample")
126 luaY = parser_init(luaX)
127
128 local status, func = pcall(luaY.parser, luaY)
129 -- look at outcome
130 ------------------------------------------------------------------
131 if status then-- actual PASS
132 if expected == "FAIL" then
133 print("\nTested as PASS but expected to FAIL"..
134 "\n-----------------------------------")
135 print("Lastest heading: "..last_head)
136 print("TEST: "..test_case)
137 os.exit()
138 end
139 ------------------------------------------------------------------
140 else-- actual FAIL
141 if expected == "PASS" then
142 print("\nTested as FAIL but expected to PASS"..
143 "\n-----------------------------------")
144 print("Lastest heading: "..last_head)
145 print("TEST: "..test_case)
146 os.exit()
147 else
148 io.stdout:write("-")
149 end
150 ------------------------------------------------------------------
151 end--status
152 io.stdout:write("\rTesting ["..i.."]...")
153end--for
154print(" done.")
155
156print("Test cases run on Yueliang, no anomalies.")
157
158-- end
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lzio_mk2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lzio_mk2.lua
deleted file mode 100644
index 30259c8..0000000
--- a/LuaSL/testLua/yueliang-0.4.1/nat-5.0.3/test/test_lzio_mk2.lua
+++ /dev/null
@@ -1,53 +0,0 @@
1--[[--------------------------------------------------------------------
2
3 test_lzio.lua
4 Test for lzio.lua
5 This file is part of Yueliang.
6
7 Copyright (c) 2005-2006 Kein-Hong Man <khman@users.sf.net>
8 The COPYRIGHT file describes the conditions
9 under which this software may be distributed.
10
11 See the ChangeLog for more information.
12
13----------------------------------------------------------------------]]
14
15-- manual test for lzio.lua lua-style chunk reader
16
17local zio_init = require("../lzio_mk2")
18
19local z
20function dump(z)
21 while true do
22 local c = z:getc()
23 io.stdout:write("("..c..")")
24 if c == "EOZ" then break end
25 end
26 io.stdout:write("\n")
27end
28
29-- z = zio_init("@<filename>") for a file
30-- z = zio_init("<string>") for a string
31
32-- [[
33z = zio_init("hello, world!")
34dump(z)
35z = zio_init("line1\nline2\n")
36dump(z)
37z = zio_init("@test_lzio_mk2.lua")
38dump(z)
39--]]
40
41-- test read beyond end of file
42-- bug reported by Adam429
43--[[
44z = zio_init("@test_lzio_mk2.lua")
45while true do
46 local c = z:getc()
47 io.stdout:write("("..c..")")
48 if c == "EOZ" then break end
49end
50print(z:getc())
51print(z:getc())
52io.stdout:write("\n")
53--]]