diff options
Diffstat (limited to '')
37 files changed, 0 insertions, 5385 deletions
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/README b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/README deleted file mode 100644 index 215b555..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/README +++ /dev/null | |||
@@ -1,55 +0,0 @@ | |||
1 | nat-5.1.3 | ||
2 | |||
3 | This directory contains versions of front end files that are rewritten | ||
4 | to be more "native" to Lua. These files should be considered as | ||
5 | exercises in exploring ways to write the front end, for example, to | ||
6 | write a front end that is optimized for size, etc. See also file size | ||
7 | data further below. | ||
8 | |||
9 | The following are the different versions available (mk2 == "mark 2", | ||
10 | this is commonly used in the UK, e.g. for aeroplanes during WWII): | ||
11 | |||
12 | Lexers | ||
13 | ------ | ||
14 | |||
15 | NOTE: These lexers should behave mostly identically to the original C | ||
16 | lexer. Locale support for non-standard decimal points is missing. Also, | ||
17 | all strings and long strings have line endings normalized to LF. | ||
18 | |||
19 | llex_mk2 Rewritten from original ported code to become more | ||
20 | Lua-like. Needs input to be entered as a single string. | ||
21 | Unless an application's need is very unusual, this | ||
22 | should not be a problem. It will not work for per-line | ||
23 | interaction, though. This version is also somewhat | ||
24 | optimized for size; its stripped binary chunk size is | ||
25 | 3716 bytes. | ||
26 | |||
27 | Status: TESTED | ||
28 | |||
29 | Parsers | ||
30 | ------- | ||
31 | |||
32 | lparser_mk2 Written for the simplified lexer interface of llex_mk2. | ||
33 | This is a lexer skeleton, stripped of codegen code. Has | ||
34 | a minimum of variable management code added, and tracks | ||
35 | the is_vararg flag of a function. See the comments in | ||
36 | the source code for more information. Without logging | ||
37 | messages and comments, it should be under 600 LOC. A | ||
38 | binary chunk of lparser_mk2 (stripped) is 15783 bytes. | ||
39 | |||
40 | Sample output of the parser message logger can be found | ||
41 | in the test/parser_log subdirectory. | ||
42 | |||
43 | Tested with test_parser-5.1.lua, the Lua 5.1.x parser test | ||
44 | cases in the test_lua/ directory, appears to be fine. | ||
45 | |||
46 | Compared to the 5.0.x parser skeleton, the main changes | ||
47 | are: (a) 'arg' not implemented, so it appears as a global, | ||
48 | and (b) '...' recognized as the last function parameter. | ||
49 | |||
50 | Status: SNIPPETS APPEAR TO WORK | ||
51 | |||
52 | Other notes: | ||
53 | ------------ | ||
54 | |||
55 | None. | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/llex_mk2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/llex_mk2.lua deleted file mode 100644 index dae57f1..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/llex_mk2.lua +++ /dev/null | |||
@@ -1,314 +0,0 @@ | |||
1 | --[[-------------------------------------------------------------------- | ||
2 | |||
3 | llex.lua | ||
4 | Lua 5.1 lexical analyzer 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 | -- * takes in the entire source at once | ||
18 | -- * greatly simplified chunkid, error handling | ||
19 | -- * NO shbang handling (it's done elsewhere in Lua 5.1) | ||
20 | -- * NO localized decimal point replacement magic | ||
21 | -- * NO limit to number of lines (MAX_INT = 2147483645) | ||
22 | -- * NO support for compatible long strings (LUA_COMPAT_LSTR) | ||
23 | -- * NO next(), lookahead() because I want next() to set tok and | ||
24 | -- seminfo that are locals, and that can only be done easily in | ||
25 | -- lparser, not llex. lastline would be handled in lparser too. | ||
26 | -- | ||
27 | -- Usage example: | ||
28 | -- local llex = require("llex_mk2") | ||
29 | -- llex.init(source_code, source_code_name) | ||
30 | -- repeat | ||
31 | -- local token, seminfo = llex.llex() | ||
32 | -- until token == "<eof>" | ||
33 | -- | ||
34 | ----------------------------------------------------------------------]] | ||
35 | |||
36 | local base = _G | ||
37 | local string = require "string" | ||
38 | module "llex" | ||
39 | |||
40 | ---------------------------------------------------------------------- | ||
41 | -- initialize keyword list | ||
42 | ---------------------------------------------------------------------- | ||
43 | local kw = {} | ||
44 | for v in string.gmatch([[ | ||
45 | and break do else elseif end false for function if in | ||
46 | local nil not or repeat return then true until while]], "%S+") do | ||
47 | kw[v] = true | ||
48 | end | ||
49 | |||
50 | ---------------------------------------------------------------------- | ||
51 | -- initialize lexer for given source _z and source name _sourceid | ||
52 | ---------------------------------------------------------------------- | ||
53 | local z, sourceid, I | ||
54 | local find = string.find | ||
55 | local match = string.match | ||
56 | local sub = string.sub | ||
57 | |||
58 | function init(_z, _sourceid) | ||
59 | z = _z -- source | ||
60 | sourceid = _sourceid -- name of source | ||
61 | I = 1 -- lexer's position in source | ||
62 | ln = 1 -- line number | ||
63 | end | ||
64 | |||
65 | ---------------------------------------------------------------------- | ||
66 | -- returns a chunk name or id, no truncation for long names | ||
67 | ---------------------------------------------------------------------- | ||
68 | function chunkid() | ||
69 | if sourceid and match(sourceid, "^[=@]") then | ||
70 | return sub(sourceid, 2) -- remove first char | ||
71 | end | ||
72 | return "[string]" | ||
73 | end | ||
74 | |||
75 | ---------------------------------------------------------------------- | ||
76 | -- formats error message and throws error | ||
77 | -- * a simplified version, does not report what token was responsible | ||
78 | ---------------------------------------------------------------------- | ||
79 | function errorline(s, line) | ||
80 | base.error(string.format("%s:%d: %s", chunkid(), line or ln, s)) | ||
81 | end | ||
82 | |||
83 | ---------------------------------------------------------------------- | ||
84 | -- handles line number incrementation and end-of-line characters | ||
85 | ---------------------------------------------------------------------- | ||
86 | |||
87 | local function inclinenumber(i) | ||
88 | local sub = sub | ||
89 | local old = sub(z, i, i) | ||
90 | i = i + 1 -- skip '\n' or '\r' | ||
91 | local c = sub(z, i, i) | ||
92 | if (c == "\n" or c == "\r") and (c ~= old) then | ||
93 | i = i + 1 -- skip '\n\r' or '\r\n' | ||
94 | end | ||
95 | ln = ln + 1 | ||
96 | I = i | ||
97 | return i | ||
98 | end | ||
99 | |||
100 | ------------------------------------------------------------------------ | ||
101 | -- count separators ("=") in a long string delimiter | ||
102 | ------------------------------------------------------------------------ | ||
103 | local function skip_sep(i) | ||
104 | local sub = sub | ||
105 | local s = sub(z, i, i) | ||
106 | i = i + 1 | ||
107 | local count = #match(z, "=*", i) -- note, take the length | ||
108 | i = i + count | ||
109 | I = i | ||
110 | return (sub(z, i, i) == s) and count or (-count) - 1 | ||
111 | end | ||
112 | |||
113 | ---------------------------------------------------------------------- | ||
114 | -- reads a long string or long comment | ||
115 | ---------------------------------------------------------------------- | ||
116 | |||
117 | local function read_long_string(is_str, sep) | ||
118 | local i = I + 1 -- skip 2nd '[' | ||
119 | local sub = sub | ||
120 | local buff = "" | ||
121 | local c = sub(z, i, i) | ||
122 | if c == "\r" or c == "\n" then -- string starts with a newline? | ||
123 | i = inclinenumber(i) -- skip it | ||
124 | end | ||
125 | local j = i | ||
126 | while true do | ||
127 | local p, q, r = find(z, "([\r\n%]])", i) -- (long range) | ||
128 | if not p then | ||
129 | errorline(is_str and "unfinished long string" or | ||
130 | "unfinished long comment") | ||
131 | end | ||
132 | if is_str then | ||
133 | buff = buff..sub(z, i, p - 1) -- save string portions | ||
134 | end | ||
135 | i = p | ||
136 | if r == "]" then -- delimiter test | ||
137 | if skip_sep(i) == sep then | ||
138 | i = I + 1 -- skip 2nd ']' | ||
139 | break | ||
140 | end | ||
141 | buff = buff..sub(z, i, I - 1) | ||
142 | i = I | ||
143 | else -- newline | ||
144 | buff = buff.."\n" | ||
145 | i = inclinenumber(i) | ||
146 | end | ||
147 | end--while | ||
148 | I = i | ||
149 | return buff | ||
150 | end | ||
151 | |||
152 | ---------------------------------------------------------------------- | ||
153 | -- reads a string | ||
154 | ---------------------------------------------------------------------- | ||
155 | local function read_string(del) | ||
156 | local i = I | ||
157 | local find = find | ||
158 | local sub = sub | ||
159 | local buff = "" | ||
160 | while true do | ||
161 | local p, q, r = find(z, "([\n\r\\\"\'])", i) -- (long range) | ||
162 | if p then | ||
163 | if r == "\n" or r == "\r" then | ||
164 | errorline("unfinished string") | ||
165 | end | ||
166 | buff = buff..sub(z, i, p - 1) -- normal portions | ||
167 | i = p | ||
168 | if r == "\\" then -- handle escapes | ||
169 | i = i + 1 | ||
170 | r = sub(z, i, i) | ||
171 | if r == "" then break end -- (EOZ error) | ||
172 | p = find("abfnrtv\n\r", r, 1, true) | ||
173 | ------------------------------------------------------ | ||
174 | if p then -- special escapes | ||
175 | if p > 7 then | ||
176 | r = "\n" | ||
177 | i = inclinenumber(i) | ||
178 | else | ||
179 | r = sub("\a\b\f\n\r\t\v", p, p) | ||
180 | i = i + 1 | ||
181 | end | ||
182 | ------------------------------------------------------ | ||
183 | elseif find(r, "%D") then -- other non-digits | ||
184 | i = i + 1 | ||
185 | ------------------------------------------------------ | ||
186 | else -- \xxx sequence | ||
187 | local p, q, s = find(z, "^(%d%d?%d?)", i) | ||
188 | i = q + 1 | ||
189 | if s + 1 > 256 then -- UCHAR_MAX | ||
190 | errorline("escape sequence too large") | ||
191 | end | ||
192 | r = string.char(s) | ||
193 | ------------------------------------------------------ | ||
194 | end--if p | ||
195 | else | ||
196 | i = i + 1 | ||
197 | if r == del then -- ending delimiter | ||
198 | I = i; return buff -- return string | ||
199 | end | ||
200 | end--if r | ||
201 | buff = buff..r -- handled escapes falls through to here | ||
202 | else | ||
203 | break -- (error) | ||
204 | end--if p | ||
205 | end--while | ||
206 | errorline("unfinished string") | ||
207 | end | ||
208 | |||
209 | ------------------------------------------------------------------------ | ||
210 | -- main lexer function | ||
211 | ------------------------------------------------------------------------ | ||
212 | function llex() | ||
213 | local find = find | ||
214 | local match = match | ||
215 | while true do--outer | ||
216 | local i = I | ||
217 | -- inner loop allows break to be used to nicely section tests | ||
218 | while true do--inner | ||
219 | ---------------------------------------------------------------- | ||
220 | local p, _, r = find(z, "^([_%a][_%w]*)", i) | ||
221 | if p then | ||
222 | I = i + #r | ||
223 | if kw[r] then return r end -- reserved word (keyword) | ||
224 | return "<name>", r -- identifier | ||
225 | end | ||
226 | ---------------------------------------------------------------- | ||
227 | local p, _, r = find(z, "^(%.?)%d", i) | ||
228 | if p then -- numeral | ||
229 | if r == "." then i = i + 1 end | ||
230 | local _, q, r = find(z, "^%d*[%.%d]*([eE]?)", i) | ||
231 | i = q + 1 | ||
232 | if #r == 1 then -- optional exponent | ||
233 | if match(z, "^[%+%-]", i) then -- optional sign | ||
234 | i = i + 1 | ||
235 | end | ||
236 | end | ||
237 | local _, q = find(z, "^[_%w]*", i) | ||
238 | I = q + 1 | ||
239 | local v = base.tonumber(sub(z, p, q)) -- handles hex also | ||
240 | if not v then errorline("malformed number") end | ||
241 | return "<number>", v | ||
242 | end | ||
243 | ---------------------------------------------------------------- | ||
244 | local p, q, r = find(z, "^(%s)[ \t]*", i) | ||
245 | if p then | ||
246 | if r == "\n" or r == "\r" then -- newline | ||
247 | inclinenumber(i) | ||
248 | else | ||
249 | I = q + 1 -- whitespace | ||
250 | end | ||
251 | break -- (continue) | ||
252 | end | ||
253 | ---------------------------------------------------------------- | ||
254 | local r = match(z, "^%p", i) | ||
255 | if r then | ||
256 | local p = find("-[\"\'.=<>~", r, 1, true) | ||
257 | if p then | ||
258 | -- two-level if block for punctuation/symbols | ||
259 | -------------------------------------------------------- | ||
260 | if p <= 2 then | ||
261 | if p == 1 then -- minus | ||
262 | local c = match(z, "^%-%-(%[?)", i) | ||
263 | if c then | ||
264 | i = i + 2 | ||
265 | local sep = -1 | ||
266 | if c == "[" then | ||
267 | sep = skip_sep(i) | ||
268 | end | ||
269 | if sep >= 0 then -- long comment | ||
270 | read_long_string(false, sep) | ||
271 | else -- short comment | ||
272 | I = find(z, "[\n\r]", i) or (#z + 1) | ||
273 | end | ||
274 | break -- (continue) | ||
275 | end | ||
276 | -- (fall through for "-") | ||
277 | else -- [ or long string | ||
278 | local sep = skip_sep(i) | ||
279 | if sep >= 0 then | ||
280 | return "<string>", read_long_string(true, sep) | ||
281 | elseif sep == -1 then | ||
282 | return "[" | ||
283 | else | ||
284 | errorline("invalid long string delimiter") | ||
285 | end | ||
286 | end | ||
287 | -------------------------------------------------------- | ||
288 | elseif p <= 5 then | ||
289 | if p < 5 then -- strings | ||
290 | I = i + 1 | ||
291 | return "<string>", read_string(r) | ||
292 | end | ||
293 | r = match(z, "^%.%.?%.?", i) -- .|..|... dots | ||
294 | -- (fall through) | ||
295 | -------------------------------------------------------- | ||
296 | else -- relational | ||
297 | r = match(z, "^%p=?", i) | ||
298 | -- (fall through) | ||
299 | end | ||
300 | end | ||
301 | I = i + #r; return r -- for other symbols, fall through | ||
302 | end | ||
303 | ---------------------------------------------------------------- | ||
304 | local r = sub(z, i, i) | ||
305 | if r ~= "" then | ||
306 | I = i + 1; return r -- other single-char tokens | ||
307 | end | ||
308 | return "<eof>" -- end of stream | ||
309 | ---------------------------------------------------------------- | ||
310 | end--while inner | ||
311 | end--while outer | ||
312 | end | ||
313 | |||
314 | return base.getfenv() | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/lparser_mk2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/lparser_mk2.lua deleted file mode 100644 index f94fb84..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/lparser_mk2.lua +++ /dev/null | |||
@@ -1,1294 +0,0 @@ | |||
1 | --[[-------------------------------------------------------------------- | ||
2 | |||
3 | lparser.lua | ||
4 | Lua 5.1 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.1.x parser skeleton, for the llex_mk2.lua lexer | ||
18 | -- * builds some data, performs logging for educational purposes | ||
19 | -- * target is to have relatively efficient and clear code | ||
20 | -- * NO parsing limitations, since it is only a parser skeleton. Some | ||
21 | -- limits set in the default sources (in luaconf.h) are: | ||
22 | -- LUAI_MAXVARS = 200 | ||
23 | -- LUAI_MAXUPVALUES = 60 | ||
24 | -- LUAI_MAXCCALLS = 200 | ||
25 | -- * NO support for 'arg' vararg functions (LUA_COMPAT_VARARG) | ||
26 | -- * init(llex) needs one parameter, a lexer module that implements: | ||
27 | -- llex.lex() - returns appropriate [token, semantic info] pairs | ||
28 | -- llex.ln - current line number | ||
29 | -- llex.errorline(s, [line]) - dies with error message | ||
30 | -- | ||
31 | -- Usage example: | ||
32 | -- local llex = require("llex_mk2") | ||
33 | -- local lparser = require("lparser_mk2") | ||
34 | -- llex.init(source_code, source_code_name) | ||
35 | -- lparser.init(llex) | ||
36 | -- local fs = lparser.parser() | ||
37 | -- | ||
38 | -- Development notes: | ||
39 | -- * see test_parser-5.1.lua for grammar elements based on lparser.c | ||
40 | -- * next() (renamed to nextt) and lookahead() has been moved from llex; | ||
41 | -- it's more convenient to keep tok, seminfo as local variables here | ||
42 | -- * syntaxerror() is from llex, easier to keep here since little token | ||
43 | -- translation needed in preparation of error message | ||
44 | -- * lparser has a few extra items to help parsing/syntax checking | ||
45 | -- (a) line number (error reporting), lookahead token storage | ||
46 | -- * (b) per-prototype states needs a storage list | ||
47 | -- * (c) 'break' needs a per-block flag in a stack | ||
48 | -- * (d) 'kind' (v.k) testing needed in expr_stat() and assignment() | ||
49 | -- for disambiguation, thus v.k manipulation is retained | ||
50 | -- * (e) one line # var (lastln) for ambiguous (split line) function | ||
51 | -- call checking | ||
52 | -- * (f) LUA_COMPAT_VARARG compatibility code completely removed | ||
53 | -- * (g) minimal variable management code to differentiate each type | ||
54 | -- * parsing starts from the end of this file in parser() | ||
55 | ----------------------------------------------------------------------]] | ||
56 | |||
57 | local base = _G | ||
58 | local string = require "string" | ||
59 | module "lparser" | ||
60 | local _G = base.getfenv() | ||
61 | |||
62 | --[[-------------------------------------------------------------------- | ||
63 | -- variable and data structure initialization | ||
64 | ----------------------------------------------------------------------]] | ||
65 | |||
66 | ---------------------------------------------------------------------- | ||
67 | -- initialization: main variables | ||
68 | ---------------------------------------------------------------------- | ||
69 | |||
70 | local llex, llex_lex -- references lexer module, function | ||
71 | local line -- start line # for error messages | ||
72 | local lastln -- last line # for ambiguous syntax chk | ||
73 | local tok, seminfo -- token, semantic info pair | ||
74 | local peek_tok, peek_sem -- ditto, for lookahead | ||
75 | local fs -- current function state | ||
76 | local top_fs -- top-level function state | ||
77 | |||
78 | -- forward references for local functions | ||
79 | local explist1, expr, block, exp1, body | ||
80 | |||
81 | ---------------------------------------------------------------------- | ||
82 | -- initialization: data structures | ||
83 | ---------------------------------------------------------------------- | ||
84 | |||
85 | local gmatch = string.gmatch | ||
86 | |||
87 | local block_follow = {} -- lookahead check in chunk(), returnstat() | ||
88 | for v in gmatch("else elseif end until <eof>", "%S+") do | ||
89 | block_follow[v] = true | ||
90 | end | ||
91 | |||
92 | local stat_call = {} -- lookup for calls in stat() | ||
93 | for v in gmatch("if while do for repeat function local return break", "%S+") do | ||
94 | stat_call[v] = v.."_stat" | ||
95 | end | ||
96 | |||
97 | local binopr_left = {} -- binary operators, left priority | ||
98 | local binopr_right = {} -- binary operators, right priority | ||
99 | for op, lt, rt in gmatch([[ | ||
100 | {+ 6 6}{- 6 6}{* 7 7}{/ 7 7}{% 7 7} | ||
101 | {^ 10 9}{.. 5 4} | ||
102 | {~= 3 3}{== 3 3} | ||
103 | {< 3 3}{<= 3 3}{> 3 3}{>= 3 3} | ||
104 | {and 2 2}{or 1 1} | ||
105 | ]], "{(%S+)%s(%d+)%s(%d+)}") do | ||
106 | binopr_left[op] = lt + 0 | ||
107 | binopr_right[op] = rt + 0 | ||
108 | end | ||
109 | |||
110 | local unopr = { ["not"] = true, ["-"] = true, | ||
111 | ["#"] = true, } -- unary operators | ||
112 | local UNARY_PRIORITY = 8 -- priority for unary operators | ||
113 | |||
114 | --[[-------------------------------------------------------------------- | ||
115 | -- logging: this logging function is for educational purposes | ||
116 | -- * logged data can be retrieved from the returned data structure | ||
117 | ----------------------------------------------------------------------]] | ||
118 | |||
119 | local function log(msg) | ||
120 | local log = top_fs.log | ||
121 | if not log then -- initialize message table | ||
122 | log = {}; top_fs.log = log | ||
123 | end | ||
124 | log[#log + 1] = msg | ||
125 | end | ||
126 | |||
127 | --[[-------------------------------------------------------------------- | ||
128 | -- support functions | ||
129 | ----------------------------------------------------------------------]] | ||
130 | |||
131 | ---------------------------------------------------------------------- | ||
132 | -- handles incoming token, semantic information pairs; these two | ||
133 | -- functions are from llex, they are put here because keeping the | ||
134 | -- tok, seminfo variables here as locals is more convenient | ||
135 | -- * NOTE: 'nextt' is named 'next' originally | ||
136 | ---------------------------------------------------------------------- | ||
137 | |||
138 | -- reads in next token | ||
139 | local function nextt() | ||
140 | lastln = llex.ln | ||
141 | if peek_tok then -- is there a look-ahead token? if yes, use it | ||
142 | tok, seminfo = peek_tok, peek_sem | ||
143 | peek_tok = nil | ||
144 | else | ||
145 | tok, seminfo = llex_lex() -- read next token | ||
146 | end | ||
147 | end | ||
148 | |||
149 | -- peek at next token (single lookahead for table constructor) | ||
150 | local function lookahead() | ||
151 | peek_tok, peek_sem = llex_lex() | ||
152 | return peek_tok | ||
153 | end | ||
154 | |||
155 | ---------------------------------------------------------------------- | ||
156 | -- throws a syntax error, or if token expected is not there | ||
157 | ---------------------------------------------------------------------- | ||
158 | |||
159 | local function syntaxerror(msg) | ||
160 | local tok = tok | ||
161 | if tok ~= "<number>" and tok ~= "<string>" then | ||
162 | if tok == "<name>" then tok = seminfo end | ||
163 | tok = "'"..tok.."'" | ||
164 | end | ||
165 | llex.errorline(msg.." near "..tok) | ||
166 | end | ||
167 | |||
168 | local function error_expected(token) | ||
169 | syntaxerror("'"..token.."' expected") | ||
170 | end | ||
171 | |||
172 | ---------------------------------------------------------------------- | ||
173 | -- tests for a token, returns outcome | ||
174 | -- * return value changed to boolean | ||
175 | ---------------------------------------------------------------------- | ||
176 | |||
177 | local function testnext(c) | ||
178 | if tok == c then nextt(); return true end | ||
179 | end | ||
180 | |||
181 | ---------------------------------------------------------------------- | ||
182 | -- check for existence of a token, throws error if not found | ||
183 | ---------------------------------------------------------------------- | ||
184 | |||
185 | local function check(c) | ||
186 | if tok ~= c then error_expected(c) end | ||
187 | end | ||
188 | |||
189 | ---------------------------------------------------------------------- | ||
190 | -- verify existence of a token, then skip it | ||
191 | ---------------------------------------------------------------------- | ||
192 | |||
193 | local function checknext(c) | ||
194 | check(c); nextt() | ||
195 | end | ||
196 | |||
197 | ---------------------------------------------------------------------- | ||
198 | -- throws error if condition not matched | ||
199 | ---------------------------------------------------------------------- | ||
200 | |||
201 | local function check_condition(c, msg) | ||
202 | if not c then syntaxerror(msg) end | ||
203 | end | ||
204 | |||
205 | ---------------------------------------------------------------------- | ||
206 | -- verifies token conditions are met or else throw error | ||
207 | ---------------------------------------------------------------------- | ||
208 | |||
209 | local function check_match(what, who, where) | ||
210 | if not testnext(what) then | ||
211 | if where == llex.ln then | ||
212 | error_expected(what) | ||
213 | else | ||
214 | syntaxerror("'"..what.."' expected (to close '"..who.."' at line "..where..")") | ||
215 | end | ||
216 | end | ||
217 | end | ||
218 | |||
219 | ---------------------------------------------------------------------- | ||
220 | -- expect that token is a name, return the name | ||
221 | ---------------------------------------------------------------------- | ||
222 | |||
223 | local function str_checkname() | ||
224 | check("<name>") | ||
225 | local ts = seminfo | ||
226 | nextt() | ||
227 | log(" str_checkname: '"..ts.."'") | ||
228 | return ts | ||
229 | end | ||
230 | |||
231 | ---------------------------------------------------------------------- | ||
232 | -- adds given string s in string pool, sets e as VK | ||
233 | ---------------------------------------------------------------------- | ||
234 | |||
235 | local function codestring(e, s) | ||
236 | e.k = "VK" | ||
237 | log(" codestring: "..string.format("%q", s)) | ||
238 | end | ||
239 | |||
240 | ---------------------------------------------------------------------- | ||
241 | -- consume a name token, adds it to string pool | ||
242 | ---------------------------------------------------------------------- | ||
243 | |||
244 | local function checkname(e) | ||
245 | log(" checkname:") | ||
246 | codestring(e, str_checkname()) | ||
247 | end | ||
248 | |||
249 | --[[-------------------------------------------------------------------- | ||
250 | -- state management functions with open/close pairs | ||
251 | ----------------------------------------------------------------------]] | ||
252 | |||
253 | ---------------------------------------------------------------------- | ||
254 | -- enters a code unit, initializes elements | ||
255 | ---------------------------------------------------------------------- | ||
256 | |||
257 | local function enterblock(isbreakable) | ||
258 | local bl = {} -- per-block state | ||
259 | bl.isbreakable = isbreakable | ||
260 | bl.prev = fs.bl | ||
261 | bl.locallist = {} | ||
262 | fs.bl = bl | ||
263 | log(">> enterblock(isbreakable="..base.tostring(isbreakable)..")") | ||
264 | end | ||
265 | |||
266 | ---------------------------------------------------------------------- | ||
267 | -- leaves a code unit, close any upvalues | ||
268 | ---------------------------------------------------------------------- | ||
269 | |||
270 | local function leaveblock() | ||
271 | local bl = fs.bl | ||
272 | fs.bl = bl.prev | ||
273 | log("<< leaveblock") | ||
274 | end | ||
275 | |||
276 | ---------------------------------------------------------------------- | ||
277 | -- opening of a function | ||
278 | -- * top_fs is only for anchoring the top fs, so that parser() can | ||
279 | -- return it to the caller function along with useful output | ||
280 | -- * used in parser() and body() | ||
281 | ---------------------------------------------------------------------- | ||
282 | |||
283 | local function open_func() | ||
284 | local new_fs -- per-function state | ||
285 | if not fs then -- top_fs is created early | ||
286 | new_fs = top_fs | ||
287 | else | ||
288 | new_fs = {} | ||
289 | end | ||
290 | new_fs.prev = fs -- linked list of function states | ||
291 | new_fs.bl = nil | ||
292 | new_fs.locallist = {} | ||
293 | fs = new_fs | ||
294 | log(">> open_func") | ||
295 | end | ||
296 | |||
297 | ---------------------------------------------------------------------- | ||
298 | -- closing of a function | ||
299 | -- * used in parser() and body() | ||
300 | ---------------------------------------------------------------------- | ||
301 | |||
302 | local function close_func() | ||
303 | fs = fs.prev | ||
304 | log("<< close_func") | ||
305 | end | ||
306 | |||
307 | --[[-------------------------------------------------------------------- | ||
308 | -- variable (global|local|upvalue) handling | ||
309 | -- * a pure parser does not really need this, but if we want to produce | ||
310 | -- useful output, might as well write minimal code to manage this... | ||
311 | -- * entry point is singlevar() for variable lookups | ||
312 | -- * three entry points for local variable creation, in order to keep | ||
313 | -- to original C calls, but the extra arguments such as positioning | ||
314 | -- are removed as we are not allocating registers -- we are only | ||
315 | -- doing simple classification | ||
316 | -- * lookup tables (bl.locallist) are maintained awkwardly in the basic | ||
317 | -- block data structures, PLUS the function data structure (this is | ||
318 | -- an inelegant hack, since bl is nil for the top level of a function) | ||
319 | ----------------------------------------------------------------------]] | ||
320 | |||
321 | ---------------------------------------------------------------------- | ||
322 | -- register a local variable, set in active variable list | ||
323 | -- * code for a simple lookup only | ||
324 | -- * used in new_localvarliteral(), parlist(), fornum(), forlist(), | ||
325 | -- localfunc(), localstat() | ||
326 | ---------------------------------------------------------------------- | ||
327 | |||
328 | local function new_localvar(name) | ||
329 | local bl = fs.bl | ||
330 | local locallist | ||
331 | if bl then | ||
332 | locallist = bl.locallist | ||
333 | else | ||
334 | locallist = fs.locallist | ||
335 | end | ||
336 | locallist[name] = true | ||
337 | log(" new_localvar: '"..name.."'") | ||
338 | end | ||
339 | |||
340 | ---------------------------------------------------------------------- | ||
341 | -- creates a new local variable given a name | ||
342 | -- * used in fornum(), forlist(), parlist(), body() | ||
343 | ---------------------------------------------------------------------- | ||
344 | |||
345 | local function new_localvarliteral(name) | ||
346 | new_localvar(name) | ||
347 | end | ||
348 | |||
349 | ---------------------------------------------------------------------- | ||
350 | -- search the local variable namespace of the given fs for a match | ||
351 | -- * a simple lookup only, no active variable list kept, so no useful | ||
352 | -- index value can be returned by this function | ||
353 | -- * used only in singlevaraux() | ||
354 | ---------------------------------------------------------------------- | ||
355 | |||
356 | local function searchvar(fs, n) | ||
357 | local bl = fs.bl | ||
358 | if bl then | ||
359 | locallist = bl.locallist | ||
360 | while locallist do | ||
361 | if locallist[n] then return 1 end -- found | ||
362 | bl = bl.prev | ||
363 | locallist = bl and bl.locallist | ||
364 | end | ||
365 | end | ||
366 | locallist = fs.locallist | ||
367 | if locallist[n] then return 1 end -- found | ||
368 | return -1 -- not found | ||
369 | end | ||
370 | |||
371 | ---------------------------------------------------------------------- | ||
372 | -- handle locals, globals and upvalues and related processing | ||
373 | -- * search mechanism is recursive, calls itself to search parents | ||
374 | -- * used only in singlevar() | ||
375 | ---------------------------------------------------------------------- | ||
376 | |||
377 | local function singlevaraux(fs, n, var, base) | ||
378 | if fs == nil then -- no more levels? | ||
379 | var.k = "VGLOBAL" -- default is global variable | ||
380 | return "VGLOBAL" | ||
381 | else | ||
382 | local v = searchvar(fs, n) -- look up at current level | ||
383 | if v >= 0 then | ||
384 | var.k = "VLOCAL" | ||
385 | -- codegen may need to deal with upvalue here | ||
386 | return "VLOCAL" | ||
387 | else -- not found at current level; try upper one | ||
388 | if singlevaraux(fs.prev, n, var, 0) == "VGLOBAL" then | ||
389 | return "VGLOBAL" | ||
390 | end | ||
391 | -- else was LOCAL or UPVAL, handle here | ||
392 | var.k = "VUPVAL" -- upvalue in this level | ||
393 | return "VUPVAL" | ||
394 | end--if v | ||
395 | end--if fs | ||
396 | end | ||
397 | |||
398 | ---------------------------------------------------------------------- | ||
399 | -- consume a name token, creates a variable (global|local|upvalue) | ||
400 | -- * used in prefixexp(), funcname() | ||
401 | ---------------------------------------------------------------------- | ||
402 | |||
403 | local function singlevar(v) | ||
404 | local varname = str_checkname() | ||
405 | singlevaraux(fs, varname, v, 1) | ||
406 | log(" singlevar(kind): '"..v.k.."'") | ||
407 | end | ||
408 | |||
409 | --[[-------------------------------------------------------------------- | ||
410 | -- other parsing functions | ||
411 | -- * for table constructor, parameter list, argument list | ||
412 | ----------------------------------------------------------------------]] | ||
413 | |||
414 | ---------------------------------------------------------------------- | ||
415 | -- parse a function name suffix, for function call specifications | ||
416 | -- * used in primaryexp(), funcname() | ||
417 | ---------------------------------------------------------------------- | ||
418 | |||
419 | local function field(v) | ||
420 | -- field -> ['.' | ':'] NAME | ||
421 | local key = {} | ||
422 | log(" field: operator="..tok) | ||
423 | nextt() -- skip the dot or colon | ||
424 | checkname(key) | ||
425 | v.k = "VINDEXED" | ||
426 | end | ||
427 | |||
428 | ---------------------------------------------------------------------- | ||
429 | -- parse a table indexing suffix, for constructors, expressions | ||
430 | -- * used in recfield(), primaryexp() | ||
431 | ---------------------------------------------------------------------- | ||
432 | |||
433 | local function yindex(v) | ||
434 | -- index -> '[' expr ']' | ||
435 | log(">> index: begin '['") | ||
436 | nextt() -- skip the '[' | ||
437 | expr(v) | ||
438 | checknext("]") | ||
439 | log("<< index: end ']'") | ||
440 | end | ||
441 | |||
442 | ---------------------------------------------------------------------- | ||
443 | -- parse a table record (hash) field | ||
444 | -- * used in constructor() | ||
445 | ---------------------------------------------------------------------- | ||
446 | |||
447 | local function recfield(cc) | ||
448 | -- recfield -> (NAME | '['exp1']') = exp1 | ||
449 | local key, val = {}, {} | ||
450 | if tok == "<name>" then | ||
451 | log("recfield: name") | ||
452 | checkname(key) | ||
453 | else-- tok == '[' | ||
454 | log("recfield: [ exp1 ]") | ||
455 | yindex(key) | ||
456 | end | ||
457 | checknext("=") | ||
458 | expr(val) | ||
459 | end | ||
460 | |||
461 | ---------------------------------------------------------------------- | ||
462 | -- emit a set list instruction if enough elements (LFIELDS_PER_FLUSH) | ||
463 | -- * note: retained in this skeleton because it modifies cc.v.k | ||
464 | -- * used in constructor() | ||
465 | ---------------------------------------------------------------------- | ||
466 | |||
467 | local function closelistfield(cc) | ||
468 | if cc.v.k == "VVOID" then return end -- there is no list item | ||
469 | cc.v.k = "VVOID" | ||
470 | end | ||
471 | |||
472 | ---------------------------------------------------------------------- | ||
473 | -- parse a table list (array) field | ||
474 | -- * used in constructor() | ||
475 | ---------------------------------------------------------------------- | ||
476 | |||
477 | local function listfield(cc) | ||
478 | log("listfield: expr") | ||
479 | expr(cc.v) | ||
480 | end | ||
481 | |||
482 | ---------------------------------------------------------------------- | ||
483 | -- parse a table constructor | ||
484 | -- * used in funcargs(), simpleexp() | ||
485 | ---------------------------------------------------------------------- | ||
486 | |||
487 | local function constructor(t) | ||
488 | -- constructor -> '{' [ field { fieldsep field } [ fieldsep ] ] '}' | ||
489 | -- field -> recfield | listfield | ||
490 | -- fieldsep -> ',' | ';' | ||
491 | log(">> constructor: begin") | ||
492 | local line = llex.ln | ||
493 | local cc = {} | ||
494 | cc.v = {} | ||
495 | cc.t = t | ||
496 | t.k = "VRELOCABLE" | ||
497 | cc.v.k = "VVOID" | ||
498 | checknext("{") | ||
499 | repeat | ||
500 | if tok == "}" then break end | ||
501 | -- closelistfield(cc) here | ||
502 | local c = tok | ||
503 | if c == "<name>" then -- may be listfields or recfields | ||
504 | if lookahead() ~= "=" then -- look ahead: expression? | ||
505 | listfield(cc) | ||
506 | else | ||
507 | recfield(cc) | ||
508 | end | ||
509 | elseif c == "[" then -- constructor_item -> recfield | ||
510 | recfield(cc) | ||
511 | else -- constructor_part -> listfield | ||
512 | listfield(cc) | ||
513 | end | ||
514 | until not testnext(",") and not testnext(";") | ||
515 | check_match("}", "{", line) | ||
516 | -- lastlistfield(cc) here | ||
517 | log("<< constructor: end") | ||
518 | end | ||
519 | |||
520 | ---------------------------------------------------------------------- | ||
521 | -- parse the arguments (parameters) of a function declaration | ||
522 | -- * used in body() | ||
523 | ---------------------------------------------------------------------- | ||
524 | |||
525 | local function parlist() | ||
526 | -- parlist -> [ param { ',' param } ] | ||
527 | log(">> parlist: begin") | ||
528 | if tok ~= ")" then -- is 'parlist' not empty? | ||
529 | repeat | ||
530 | local c = tok | ||
531 | if c == "<name>" then -- param -> NAME | ||
532 | new_localvar(str_checkname()) | ||
533 | elseif c == "..." then | ||
534 | log("parlist: ... (dots)") | ||
535 | nextt() | ||
536 | fs.is_vararg = true | ||
537 | else | ||
538 | syntaxerror("<name> or '...' expected") | ||
539 | end | ||
540 | until fs.is_vararg or not testnext(",") | ||
541 | end--if | ||
542 | log("<< parlist: end") | ||
543 | end | ||
544 | |||
545 | ---------------------------------------------------------------------- | ||
546 | -- parse the parameters of a function call | ||
547 | -- * contrast with parlist(), used in function declarations | ||
548 | -- * used in primaryexp() | ||
549 | ---------------------------------------------------------------------- | ||
550 | |||
551 | local function funcargs(f) | ||
552 | local args = {} | ||
553 | local line = llex.ln | ||
554 | local c = tok | ||
555 | if c == "(" then -- funcargs -> '(' [ explist1 ] ')' | ||
556 | log(">> funcargs: begin '('") | ||
557 | if line ~= lastln then | ||
558 | syntaxerror("ambiguous syntax (function call x new statement)") | ||
559 | end | ||
560 | nextt() | ||
561 | if tok == ")" then -- arg list is empty? | ||
562 | args.k = "VVOID" | ||
563 | else | ||
564 | explist1(args) | ||
565 | end | ||
566 | check_match(")", "(", line) | ||
567 | elseif c == "{" then -- funcargs -> constructor | ||
568 | log(">> funcargs: begin '{'") | ||
569 | constructor(args) | ||
570 | elseif c == "<string>" then -- funcargs -> STRING | ||
571 | log(">> funcargs: begin <string>") | ||
572 | codestring(args, seminfo) | ||
573 | nextt() -- must use 'seminfo' before 'next' | ||
574 | else | ||
575 | syntaxerror("function arguments expected") | ||
576 | return | ||
577 | end--if c | ||
578 | f.k = "VCALL" | ||
579 | log("<< funcargs: end -- expr is a VCALL") | ||
580 | end | ||
581 | |||
582 | --[[-------------------------------------------------------------------- | ||
583 | -- mostly expression functions | ||
584 | ----------------------------------------------------------------------]] | ||
585 | |||
586 | ---------------------------------------------------------------------- | ||
587 | -- parses an expression in parentheses or a single variable | ||
588 | -- * used in primaryexp() | ||
589 | ---------------------------------------------------------------------- | ||
590 | |||
591 | local function prefixexp(v) | ||
592 | -- prefixexp -> NAME | '(' expr ')' | ||
593 | local c = tok | ||
594 | if c == "(" then | ||
595 | log(">> prefixexp: begin ( expr ) ") | ||
596 | local line = llex.ln | ||
597 | nextt() | ||
598 | expr(v) | ||
599 | check_match(")", "(", line) | ||
600 | log("<< prefixexp: end ( expr ) ") | ||
601 | elseif c == "<name>" then | ||
602 | log("prefixexp: <name>") | ||
603 | singlevar(v) | ||
604 | else | ||
605 | syntaxerror("unexpected symbol") | ||
606 | end--if c | ||
607 | end | ||
608 | |||
609 | ---------------------------------------------------------------------- | ||
610 | -- parses a prefixexp (an expression in parentheses or a single | ||
611 | -- variable) or a function call specification | ||
612 | -- * used in simpleexp(), assignment(), expr_stat() | ||
613 | ---------------------------------------------------------------------- | ||
614 | |||
615 | local function primaryexp(v) | ||
616 | -- primaryexp -> | ||
617 | -- prefixexp { '.' NAME | '[' exp ']' | ':' NAME funcargs | funcargs } | ||
618 | prefixexp(v) | ||
619 | while true do | ||
620 | local c = tok | ||
621 | if c == "." then -- field | ||
622 | log("primaryexp: '.' field") | ||
623 | field(v) | ||
624 | elseif c == "[" then -- '[' exp1 ']' | ||
625 | log("primaryexp: [ exp1 ]") | ||
626 | local key = {} | ||
627 | yindex(key) | ||
628 | elseif c == ":" then -- ':' NAME funcargs | ||
629 | log("primaryexp: :<name> funcargs") | ||
630 | local key = {} | ||
631 | nextt() | ||
632 | checkname(key) | ||
633 | funcargs(v) | ||
634 | elseif c == "(" or c == "<string>" or c == "{" then -- funcargs | ||
635 | log("primaryexp: "..c.." funcargs") | ||
636 | funcargs(v) | ||
637 | else | ||
638 | return | ||
639 | end--if c | ||
640 | end--while | ||
641 | end | ||
642 | |||
643 | ---------------------------------------------------------------------- | ||
644 | -- parses general expression types, constants handled here | ||
645 | -- * used in subexpr() | ||
646 | ---------------------------------------------------------------------- | ||
647 | |||
648 | local function simpleexp(v) | ||
649 | -- simpleexp -> NUMBER | STRING | NIL | TRUE | FALSE | ... | | ||
650 | -- constructor | FUNCTION body | primaryexp | ||
651 | local c = tok | ||
652 | if c == "<number>" then | ||
653 | log("simpleexp: <number>="..seminfo) | ||
654 | v.k = "VKNUM" | ||
655 | elseif c == "<string>" then | ||
656 | log("simpleexp: <string>="..seminfo) | ||
657 | codestring(v, seminfo) | ||
658 | elseif c == "nil" then | ||
659 | log("simpleexp: nil") | ||
660 | v.k = "VNIL" | ||
661 | elseif c == "true" then | ||
662 | log("simpleexp: true") | ||
663 | v.k = "VTRUE" | ||
664 | elseif c == "false" then | ||
665 | log("simpleexp: false") | ||
666 | v.k = "VFALSE" | ||
667 | elseif c == "..." then -- vararg | ||
668 | check_condition(fs.is_vararg == true, | ||
669 | "cannot use '...' outside a vararg function"); | ||
670 | log("simpleexp: ...") | ||
671 | v.k = "VVARARG" | ||
672 | elseif c == "{" then -- constructor | ||
673 | log("simpleexp: constructor") | ||
674 | constructor(v) | ||
675 | return | ||
676 | elseif c == "function" then | ||
677 | log("simpleexp: function") | ||
678 | nextt() | ||
679 | body(v, false, llex.ln) | ||
680 | return | ||
681 | else | ||
682 | primaryexp(v) | ||
683 | return | ||
684 | end--if c | ||
685 | nextt() | ||
686 | end | ||
687 | |||
688 | ------------------------------------------------------------------------ | ||
689 | -- Parse subexpressions. Includes handling of unary operators and binary | ||
690 | -- operators. A subexpr is given the rhs priority level of the operator | ||
691 | -- immediately left of it, if any (limit is -1 if none,) and if a binop | ||
692 | -- is found, limit is compared with the lhs priority level of the binop | ||
693 | -- in order to determine which executes first. | ||
694 | -- * recursively called | ||
695 | -- * used in expr() | ||
696 | ------------------------------------------------------------------------ | ||
697 | |||
698 | local function subexpr(v, limit) | ||
699 | -- subexpr -> (simpleexp | unop subexpr) { binop subexpr } | ||
700 | -- * where 'binop' is any binary operator with a priority | ||
701 | -- higher than 'limit' | ||
702 | local op = tok | ||
703 | local uop = unopr[op] | ||
704 | if uop then | ||
705 | log(" subexpr: uop='"..op.."'") | ||
706 | nextt() | ||
707 | subexpr(v, UNARY_PRIORITY) | ||
708 | else | ||
709 | simpleexp(v) | ||
710 | end | ||
711 | -- expand while operators have priorities higher than 'limit' | ||
712 | op = tok | ||
713 | local binop = binopr_left[op] | ||
714 | while binop and binop > limit do | ||
715 | local v2 = {} | ||
716 | log(">> subexpr: binop='"..op.."'") | ||
717 | nextt() | ||
718 | -- read sub-expression with higher priority | ||
719 | local nextop = subexpr(v2, binopr_right[op]) | ||
720 | log("<< subexpr: -- evaluate") | ||
721 | op = nextop | ||
722 | binop = binopr_left[op] | ||
723 | end | ||
724 | return op -- return first untreated operator | ||
725 | end | ||
726 | |||
727 | ---------------------------------------------------------------------- | ||
728 | -- Expression parsing starts here. Function subexpr is entered with the | ||
729 | -- left operator (which is non-existent) priority of -1, which is lower | ||
730 | -- than all actual operators. Expr information is returned in parm v. | ||
731 | -- * used in cond(), explist1(), index(), recfield(), listfield(), | ||
732 | -- prefixexp(), while_stat(), exp1() | ||
733 | ---------------------------------------------------------------------- | ||
734 | |||
735 | -- this is a forward-referenced local | ||
736 | function expr(v) | ||
737 | -- expr -> subexpr | ||
738 | log("expr:") | ||
739 | subexpr(v, 0) | ||
740 | end | ||
741 | |||
742 | --[[-------------------------------------------------------------------- | ||
743 | -- third level parsing functions | ||
744 | ----------------------------------------------------------------------]] | ||
745 | |||
746 | ------------------------------------------------------------------------ | ||
747 | -- parse a variable assignment sequence | ||
748 | -- * recursively called | ||
749 | -- * used in expr_stat() | ||
750 | ------------------------------------------------------------------------ | ||
751 | |||
752 | local function assignment(v) | ||
753 | local e = {} | ||
754 | local c = v.v.k | ||
755 | check_condition(c == "VLOCAL" or c == "VUPVAL" or c == "VGLOBAL" | ||
756 | or c == "VINDEXED", "syntax error") | ||
757 | if testnext(",") then -- assignment -> ',' primaryexp assignment | ||
758 | local nv = {} -- expdesc | ||
759 | nv.v = {} | ||
760 | log("assignment: ',' -- next LHS element") | ||
761 | primaryexp(nv.v) | ||
762 | -- lparser.c deals with some register usage conflict here | ||
763 | assignment(nv) | ||
764 | else -- assignment -> '=' explist1 | ||
765 | checknext("=") | ||
766 | log("assignment: '=' -- RHS elements follows") | ||
767 | explist1(e) | ||
768 | return -- avoid default | ||
769 | end | ||
770 | e.k = "VNONRELOC" | ||
771 | end | ||
772 | |||
773 | ---------------------------------------------------------------------- | ||
774 | -- parse a for loop body for both versions of the for loop | ||
775 | -- * used in fornum(), forlist() | ||
776 | ---------------------------------------------------------------------- | ||
777 | |||
778 | local function forbody(isnum) | ||
779 | -- forbody -> DO block | ||
780 | checknext("do") | ||
781 | enterblock(false) -- scope for declared variables | ||
782 | block() | ||
783 | leaveblock() -- end of scope for declared variables | ||
784 | end | ||
785 | |||
786 | ---------------------------------------------------------------------- | ||
787 | -- parse a numerical for loop, calls forbody() | ||
788 | -- * used in for_stat() | ||
789 | ---------------------------------------------------------------------- | ||
790 | |||
791 | local function fornum(varname) | ||
792 | -- fornum -> NAME = exp1, exp1 [, exp1] DO body | ||
793 | local line = line | ||
794 | new_localvarliteral("(for index)") | ||
795 | new_localvarliteral("(for limit)") | ||
796 | new_localvarliteral("(for step)") | ||
797 | new_localvar(varname) | ||
798 | log(">> fornum: begin") | ||
799 | checknext("=") | ||
800 | log("fornum: index start") | ||
801 | exp1() -- initial value | ||
802 | checknext(",") | ||
803 | log("fornum: index stop") | ||
804 | exp1() -- limit | ||
805 | if testnext(",") then | ||
806 | log("fornum: index step") | ||
807 | exp1() -- optional step | ||
808 | else | ||
809 | -- default step = 1 | ||
810 | end | ||
811 | log("fornum: body") | ||
812 | forbody(true) | ||
813 | log("<< fornum: end") | ||
814 | end | ||
815 | |||
816 | ---------------------------------------------------------------------- | ||
817 | -- parse a generic for loop, calls forbody() | ||
818 | -- * used in for_stat() | ||
819 | ---------------------------------------------------------------------- | ||
820 | |||
821 | local function forlist(indexname) | ||
822 | -- forlist -> NAME {, NAME} IN explist1 DO body | ||
823 | log(">> forlist: begin") | ||
824 | local e = {} | ||
825 | -- create control variables | ||
826 | new_localvarliteral("(for generator)") | ||
827 | new_localvarliteral("(for state)") | ||
828 | new_localvarliteral("(for control)") | ||
829 | -- create declared variables | ||
830 | new_localvar(indexname) | ||
831 | while testnext(",") do | ||
832 | new_localvar(str_checkname()) | ||
833 | end | ||
834 | checknext("in") | ||
835 | local line = line | ||
836 | log("forlist: explist1") | ||
837 | explist1(e) | ||
838 | log("forlist: body") | ||
839 | forbody(false) | ||
840 | log("<< forlist: end") | ||
841 | end | ||
842 | |||
843 | ---------------------------------------------------------------------- | ||
844 | -- parse a function name specification | ||
845 | -- * used in func_stat() | ||
846 | ---------------------------------------------------------------------- | ||
847 | |||
848 | local function funcname(v) | ||
849 | -- funcname -> NAME {field} [':' NAME] | ||
850 | log(">> funcname: begin") | ||
851 | local needself = false | ||
852 | singlevar(v) | ||
853 | while tok == "." do | ||
854 | log("funcname: -- '.' field") | ||
855 | field(v) | ||
856 | end | ||
857 | if tok == ":" then | ||
858 | log("funcname: -- ':' field") | ||
859 | needself = true | ||
860 | field(v) | ||
861 | end | ||
862 | log("<< funcname: end") | ||
863 | return needself | ||
864 | end | ||
865 | |||
866 | ---------------------------------------------------------------------- | ||
867 | -- parse the single expressions needed in numerical for loops | ||
868 | -- * used in fornum() | ||
869 | ---------------------------------------------------------------------- | ||
870 | |||
871 | -- this is a forward-referenced local | ||
872 | function exp1() | ||
873 | -- exp1 -> expr | ||
874 | local e = {} | ||
875 | log(">> exp1: begin") | ||
876 | expr(e) | ||
877 | log("<< exp1: end") | ||
878 | end | ||
879 | |||
880 | ---------------------------------------------------------------------- | ||
881 | -- parse condition in a repeat statement or an if control structure | ||
882 | -- * used in repeat_stat(), test_then_block() | ||
883 | ---------------------------------------------------------------------- | ||
884 | |||
885 | local function cond() | ||
886 | -- cond -> expr | ||
887 | log(">> cond: begin") | ||
888 | local v = {} | ||
889 | expr(v) -- read condition | ||
890 | log("<< cond: end") | ||
891 | end | ||
892 | |||
893 | ---------------------------------------------------------------------- | ||
894 | -- parse part of an if control structure, including the condition | ||
895 | -- * used in if_stat() | ||
896 | ---------------------------------------------------------------------- | ||
897 | |||
898 | local function test_then_block() | ||
899 | -- test_then_block -> [IF | ELSEIF] cond THEN block | ||
900 | nextt() -- skip IF or ELSEIF | ||
901 | log("test_then_block: test condition") | ||
902 | cond() | ||
903 | checknext("then") | ||
904 | log("test_then_block: then block") | ||
905 | block() -- 'then' part | ||
906 | end | ||
907 | |||
908 | ---------------------------------------------------------------------- | ||
909 | -- parse a local function statement | ||
910 | -- * used in local_stat() | ||
911 | ---------------------------------------------------------------------- | ||
912 | |||
913 | local function localfunc() | ||
914 | -- localfunc -> NAME body | ||
915 | local v, b = {} | ||
916 | log("localfunc: begin") | ||
917 | new_localvar(str_checkname()) | ||
918 | v.k = "VLOCAL" | ||
919 | log("localfunc: body") | ||
920 | body(b, false, llex.ln) | ||
921 | log("localfunc: end") | ||
922 | end | ||
923 | |||
924 | ---------------------------------------------------------------------- | ||
925 | -- parse a local variable declaration statement | ||
926 | -- * used in local_stat() | ||
927 | ---------------------------------------------------------------------- | ||
928 | |||
929 | local function localstat() | ||
930 | -- localstat -> NAME {',' NAME} ['=' explist1] | ||
931 | log(">> localstat: begin") | ||
932 | local e = {} | ||
933 | repeat | ||
934 | new_localvar(str_checkname()) | ||
935 | until not testnext(",") | ||
936 | if testnext("=") then | ||
937 | log("localstat: -- assignment") | ||
938 | explist1(e) | ||
939 | else | ||
940 | e.k = "VVOID" | ||
941 | end | ||
942 | log("<< localstat: end") | ||
943 | end | ||
944 | |||
945 | ---------------------------------------------------------------------- | ||
946 | -- parse a list of comma-separated expressions | ||
947 | -- * used in return_stat(), localstat(), funcargs(), assignment(), | ||
948 | -- forlist() | ||
949 | ---------------------------------------------------------------------- | ||
950 | |||
951 | -- this is a forward-referenced local | ||
952 | function explist1(e) | ||
953 | -- explist1 -> expr { ',' expr } | ||
954 | log(">> explist1: begin") | ||
955 | expr(e) | ||
956 | while testnext(",") do | ||
957 | log("explist1: ',' -- continuation") | ||
958 | expr(e) | ||
959 | end | ||
960 | log("<< explist1: end") | ||
961 | end | ||
962 | |||
963 | ---------------------------------------------------------------------- | ||
964 | -- parse function declaration body | ||
965 | -- * used in simpleexp(), localfunc(), func_stat() | ||
966 | ---------------------------------------------------------------------- | ||
967 | |||
968 | -- this is a forward-referenced local | ||
969 | function body(e, needself, line) | ||
970 | -- body -> '(' parlist ')' chunk END | ||
971 | open_func() | ||
972 | log("body: begin") | ||
973 | checknext("(") | ||
974 | if needself then | ||
975 | new_localvarliteral("self") | ||
976 | end | ||
977 | log("body: parlist") | ||
978 | parlist() | ||
979 | checknext(")") | ||
980 | log("body: chunk") | ||
981 | chunk() | ||
982 | check_match("end", "function", line) | ||
983 | log("body: end") | ||
984 | close_func() | ||
985 | end | ||
986 | |||
987 | ---------------------------------------------------------------------- | ||
988 | -- parse a code block or unit | ||
989 | -- * used in do_stat(), while_stat(), forbody(), test_then_block(), | ||
990 | -- if_stat() | ||
991 | ---------------------------------------------------------------------- | ||
992 | |||
993 | -- this is a forward-referenced local | ||
994 | function block() | ||
995 | -- block -> chunk | ||
996 | log("block: begin") | ||
997 | enterblock(false) | ||
998 | chunk() | ||
999 | leaveblock() | ||
1000 | log("block: end") | ||
1001 | end | ||
1002 | |||
1003 | --[[-------------------------------------------------------------------- | ||
1004 | -- second level parsing functions, all with '_stat' suffix | ||
1005 | -- * since they are called via a table lookup, they cannot be local | ||
1006 | -- functions (a lookup table of local functions might be smaller...) | ||
1007 | -- * stat() -> *_stat() | ||
1008 | ----------------------------------------------------------------------]] | ||
1009 | |||
1010 | ---------------------------------------------------------------------- | ||
1011 | -- initial parsing for a for loop, calls fornum() or forlist() | ||
1012 | -- * removed 'line' parameter (used to set debug information only) | ||
1013 | -- * used in stat() | ||
1014 | ---------------------------------------------------------------------- | ||
1015 | |||
1016 | function for_stat() | ||
1017 | -- stat -> for_stat -> FOR (fornum | forlist) END | ||
1018 | local line = line | ||
1019 | log("for_stat: begin") | ||
1020 | enterblock(true) -- scope for loop and control variables | ||
1021 | nextt() -- skip 'for' | ||
1022 | local varname = str_checkname() -- first variable name | ||
1023 | local c = tok | ||
1024 | if c == "=" then | ||
1025 | log("for_stat: numerical loop") | ||
1026 | fornum(varname) | ||
1027 | elseif c == "," or c == "in" then | ||
1028 | log("for_stat: list-based loop") | ||
1029 | forlist(varname) | ||
1030 | else | ||
1031 | syntaxerror("'=' or 'in' expected") | ||
1032 | end | ||
1033 | check_match("end", "for", line) | ||
1034 | leaveblock() -- loop scope (`break' jumps to this point) | ||
1035 | log("for_stat: end") | ||
1036 | end | ||
1037 | |||
1038 | ---------------------------------------------------------------------- | ||
1039 | -- parse a while-do control structure, body processed by block() | ||
1040 | -- * used in stat() | ||
1041 | ---------------------------------------------------------------------- | ||
1042 | |||
1043 | function while_stat() | ||
1044 | -- stat -> while_stat -> WHILE cond DO block END | ||
1045 | local line = line | ||
1046 | nextt() -- skip WHILE | ||
1047 | log("while_stat: begin/condition") | ||
1048 | cond() -- parse condition | ||
1049 | enterblock(true) | ||
1050 | checknext("do") | ||
1051 | log("while_stat: block") | ||
1052 | block() | ||
1053 | check_match("end", "while", line) | ||
1054 | leaveblock() | ||
1055 | log("while_stat: end") | ||
1056 | end | ||
1057 | |||
1058 | ---------------------------------------------------------------------- | ||
1059 | -- parse a repeat-until control structure, body parsed by chunk() | ||
1060 | -- * originally, repeatstat() calls breakstat() too if there is an | ||
1061 | -- upvalue in the scope block; nothing is actually lexed, it is | ||
1062 | -- actually the common code in breakstat() for closing of upvalues | ||
1063 | -- * used in stat() | ||
1064 | ---------------------------------------------------------------------- | ||
1065 | |||
1066 | function repeat_stat() | ||
1067 | -- stat -> repeat_stat -> REPEAT block UNTIL cond | ||
1068 | local line = line | ||
1069 | log("repeat_stat: begin") | ||
1070 | enterblock(true) -- loop block | ||
1071 | enterblock(false) -- scope block | ||
1072 | nextt() -- skip REPEAT | ||
1073 | chunk() | ||
1074 | check_match("until", "repeat", line) | ||
1075 | log("repeat_stat: condition") | ||
1076 | cond() | ||
1077 | -- close upvalues at scope level below | ||
1078 | leaveblock() -- finish scope | ||
1079 | leaveblock() -- finish loop | ||
1080 | log("repeat_stat: end") | ||
1081 | end | ||
1082 | |||
1083 | ---------------------------------------------------------------------- | ||
1084 | -- parse an if control structure | ||
1085 | -- * used in stat() | ||
1086 | ---------------------------------------------------------------------- | ||
1087 | |||
1088 | function if_stat() | ||
1089 | -- stat -> if_stat -> IF cond THEN block | ||
1090 | -- {ELSEIF cond THEN block} [ELSE block] END | ||
1091 | local line = line | ||
1092 | local v = {} | ||
1093 | log("if_stat: if...then") | ||
1094 | test_then_block() -- IF cond THEN block | ||
1095 | while tok == "elseif" do | ||
1096 | log("if_stat: elseif...then") | ||
1097 | test_then_block() -- ELSEIF cond THEN block | ||
1098 | end | ||
1099 | if tok == "else" then | ||
1100 | log("if_stat: else...") | ||
1101 | nextt() -- skip ELSE | ||
1102 | block() -- 'else' part | ||
1103 | end | ||
1104 | check_match("end", "if", line) | ||
1105 | log("if_stat: end") | ||
1106 | end | ||
1107 | |||
1108 | ---------------------------------------------------------------------- | ||
1109 | -- parse a return statement | ||
1110 | -- * used in stat() | ||
1111 | ---------------------------------------------------------------------- | ||
1112 | |||
1113 | function return_stat() | ||
1114 | -- stat -> return_stat -> RETURN explist | ||
1115 | local e = {} | ||
1116 | nextt() -- skip RETURN | ||
1117 | local c = tok | ||
1118 | if block_follow[c] or c == ";" then | ||
1119 | -- return no values | ||
1120 | log("return_stat: no return values") | ||
1121 | else | ||
1122 | log("return_stat: begin") | ||
1123 | explist1(e) -- optional return values | ||
1124 | log("return_stat: end") | ||
1125 | end | ||
1126 | end | ||
1127 | |||
1128 | ---------------------------------------------------------------------- | ||
1129 | -- parse a break statement | ||
1130 | -- * used in stat() | ||
1131 | ---------------------------------------------------------------------- | ||
1132 | |||
1133 | function break_stat() | ||
1134 | -- stat -> break_stat -> BREAK | ||
1135 | local bl = fs.bl | ||
1136 | nextt() -- skip BREAK | ||
1137 | while bl and not bl.isbreakable do -- find a breakable block | ||
1138 | bl = bl.prev | ||
1139 | end | ||
1140 | if not bl then | ||
1141 | syntaxerror("no loop to break") | ||
1142 | end | ||
1143 | log("break_stat: -- break out of loop") | ||
1144 | end | ||
1145 | |||
1146 | ---------------------------------------------------------------------- | ||
1147 | -- parse a function call with no returns or an assignment statement | ||
1148 | -- * the struct with .prev is used for name searching in lparse.c, | ||
1149 | -- so it is retained for now; present in assignment() also | ||
1150 | -- * used in stat() | ||
1151 | ---------------------------------------------------------------------- | ||
1152 | |||
1153 | function expr_stat() | ||
1154 | -- stat -> expr_stat -> func | assignment | ||
1155 | local v = {} | ||
1156 | v.v = {} | ||
1157 | primaryexp(v.v) | ||
1158 | if v.v.k == "VCALL" then -- stat -> func | ||
1159 | -- call statement uses no results | ||
1160 | log("expr_stat: function call k='"..v.v.k.."'") | ||
1161 | else -- stat -> assignment | ||
1162 | log("expr_stat: assignment k='"..v.v.k.."'") | ||
1163 | v.prev = nil | ||
1164 | assignment(v) | ||
1165 | end | ||
1166 | end | ||
1167 | |||
1168 | ---------------------------------------------------------------------- | ||
1169 | -- parse a function statement | ||
1170 | -- * used in stat() | ||
1171 | ---------------------------------------------------------------------- | ||
1172 | |||
1173 | function function_stat() | ||
1174 | -- stat -> function_stat -> FUNCTION funcname body | ||
1175 | local line = line | ||
1176 | local v, b = {}, {} | ||
1177 | log("function_stat: begin") | ||
1178 | nextt() -- skip FUNCTION | ||
1179 | local needself = funcname(v) | ||
1180 | log("function_stat: body needself='"..base.tostring(needself).."'") | ||
1181 | body(b, needself, line) | ||
1182 | log("function_stat: end") | ||
1183 | end | ||
1184 | |||
1185 | ---------------------------------------------------------------------- | ||
1186 | -- parse a simple block enclosed by a DO..END pair | ||
1187 | -- * used in stat() | ||
1188 | ---------------------------------------------------------------------- | ||
1189 | |||
1190 | function do_stat() | ||
1191 | -- stat -> do_stat -> DO block END | ||
1192 | local line = line | ||
1193 | nextt() -- skip DO | ||
1194 | log("do_stat: begin") | ||
1195 | block() | ||
1196 | log("do_stat: end") | ||
1197 | check_match("end", "do", line) | ||
1198 | end | ||
1199 | |||
1200 | ---------------------------------------------------------------------- | ||
1201 | -- parse a statement starting with LOCAL | ||
1202 | -- * used in stat() | ||
1203 | ---------------------------------------------------------------------- | ||
1204 | |||
1205 | function local_stat() | ||
1206 | -- stat -> local_stat -> LOCAL FUNCTION localfunc | ||
1207 | -- -> LOCAL localstat | ||
1208 | nextt() -- skip LOCAL | ||
1209 | if testnext("function") then -- local function? | ||
1210 | log("local_stat: local function") | ||
1211 | localfunc() | ||
1212 | else | ||
1213 | log("local_stat: local statement") | ||
1214 | localstat() | ||
1215 | end | ||
1216 | end | ||
1217 | |||
1218 | --[[-------------------------------------------------------------------- | ||
1219 | -- main functions, top level parsing functions | ||
1220 | -- * accessible functions are: init(lexer), parser() | ||
1221 | -- * [entry] -> parser() -> chunk() -> stat() | ||
1222 | ----------------------------------------------------------------------]] | ||
1223 | |||
1224 | ---------------------------------------------------------------------- | ||
1225 | -- initial parsing for statements, calls '_stat' suffixed functions | ||
1226 | -- * used in chunk() | ||
1227 | ---------------------------------------------------------------------- | ||
1228 | |||
1229 | local function stat() | ||
1230 | -- stat -> if_stat while_stat do_stat for_stat repeat_stat | ||
1231 | -- function_stat local_stat return_stat break_stat | ||
1232 | -- expr_stat | ||
1233 | line = llex.ln -- may be needed for error messages | ||
1234 | local c = tok | ||
1235 | local fn = stat_call[c] | ||
1236 | -- handles: if while do for repeat function local return break | ||
1237 | if fn then | ||
1238 | log("-- STATEMENT: begin '"..c.."' line="..line) | ||
1239 | _G[fn]() | ||
1240 | log("-- STATEMENT: end '"..c.."'") | ||
1241 | -- return or break must be last statement | ||
1242 | if c == "return" or c == "break" then return true end | ||
1243 | else | ||
1244 | log("-- STATEMENT: begin 'expr' line="..line) | ||
1245 | expr_stat() | ||
1246 | log("-- STATEMENT: end 'expr'") | ||
1247 | end | ||
1248 | log("") | ||
1249 | return false | ||
1250 | end | ||
1251 | |||
1252 | ---------------------------------------------------------------------- | ||
1253 | -- parse a chunk, which consists of a bunch of statements | ||
1254 | -- * used in parser(), body(), block(), repeat_stat() | ||
1255 | ---------------------------------------------------------------------- | ||
1256 | |||
1257 | function chunk() | ||
1258 | -- chunk -> { stat [';'] } | ||
1259 | log("chunk:") | ||
1260 | local islast = false | ||
1261 | while not islast and not block_follow[tok] do | ||
1262 | islast = stat() | ||
1263 | testnext(";") | ||
1264 | end | ||
1265 | end | ||
1266 | |||
1267 | ---------------------------------------------------------------------- | ||
1268 | -- performs parsing, returns parsed data structure | ||
1269 | ---------------------------------------------------------------------- | ||
1270 | |||
1271 | function parser() | ||
1272 | log("-- TOP: begin") | ||
1273 | open_func() | ||
1274 | fs.is_vararg = true -- main func. is always vararg | ||
1275 | log("") | ||
1276 | nextt() -- read first token | ||
1277 | chunk() | ||
1278 | check("<eof>") | ||
1279 | close_func() | ||
1280 | log("-- TOP: end") | ||
1281 | return top_fs | ||
1282 | end | ||
1283 | |||
1284 | ---------------------------------------------------------------------- | ||
1285 | -- initialization function | ||
1286 | ---------------------------------------------------------------------- | ||
1287 | |||
1288 | function init(lexer) | ||
1289 | llex = lexer -- set lexer (assume user-initialized) | ||
1290 | llex_lex = llex.llex | ||
1291 | top_fs = {} -- reset top level function state | ||
1292 | end | ||
1293 | |||
1294 | return _G | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_01.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_01.lua deleted file mode 100644 index 379cc9d..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.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.1.3/test/parser_log/sample_02.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_02.lua deleted file mode 100644 index 13eb2e6..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.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.1.3/test/parser_log/sample_03.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_03.lua deleted file mode 100644 index 33df29c..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_03.lua +++ /dev/null | |||
@@ -1,21 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | do | ||
3 | 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 | close_func | ||
21 | -- TOP: end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_04.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_04.lua deleted file mode 100644 index d0fefbc..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_04.lua +++ /dev/null | |||
@@ -1,31 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | do end | ||
3 | do 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.1.3/test/parser_log/sample_05.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_05.lua deleted file mode 100644 index 17a9231..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_05.lua +++ /dev/null | |||
@@ -1,129 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | foo() | ||
3 | foo{} | ||
4 | foo"" | ||
5 | foo:bar() | ||
6 | foo=false | ||
7 | foo.bar=true | ||
8 | foo[true]=nil | ||
9 | foo,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(kind): 'VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
66 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
95 | primaryexp: [ exp1 ] | ||
96 | index: begin '[' | ||
97 | expr: | ||
98 | simpleexp: true | ||
99 | index: end ']' | ||
100 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
112 | expr_stat: assignment k='VGLOBAL' | ||
113 | assignment: ',' -- next LHS element | ||
114 | prefixexp: <name> | ||
115 | str_checkname: 'bar' | ||
116 | singlevar(kind): 'VGLOBAL' | ||
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.1.3/test/parser_log/sample_06.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_06.lua deleted file mode 100644 index 29f1703..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_06.lua +++ /dev/null | |||
@@ -1,132 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | foo=true | ||
3 | foo=false | ||
4 | foo=nil | ||
5 | foo=1.23e45 | ||
6 | foo=-1 | ||
7 | foo=(0) | ||
8 | foo=1+2 | ||
9 | foo=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(kind): 'VGLOBAL' | ||
20 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
32 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
44 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
56 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
68 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
81 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
96 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
111 | expr_stat: assignment k='VGLOBAL' | ||
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.1.3/test/parser_log/sample_07.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_07.lua deleted file mode 100644 index c3a4600..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_07.lua +++ /dev/null | |||
@@ -1,147 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | if foo then foo=1 end | ||
3 | if foo then foo=1 else foo=0 end | ||
4 | if 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(kind): 'VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
28 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
58 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
76 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
106 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
133 | expr_stat: assignment k='VGLOBAL' | ||
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.1.3/test/parser_log/sample_08.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_08.lua deleted file mode 100644 index d086c98..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_08.lua +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | do return end | ||
3 | do return 123 end | ||
4 | do 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.1.3/test/parser_log/sample_09.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_09.lua deleted file mode 100644 index 67c6cf3..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_09.lua +++ /dev/null | |||
@@ -1,103 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | while true do foo=not foo end | ||
3 | while foo~=42 do foo=foo-1 end | ||
4 | while 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 | cond: begin | ||
14 | expr: | ||
15 | simpleexp: true | ||
16 | cond: end | ||
17 | enterblock(isbreakable=true) | ||
18 | while_stat: block | ||
19 | block: begin | ||
20 | enterblock(isbreakable=false) | ||
21 | chunk: | ||
22 | -- STATEMENT: begin 'expr' line=1 | ||
23 | prefixexp: <name> | ||
24 | str_checkname: 'foo' | ||
25 | singlevar(kind): 'VGLOBAL' | ||
26 | expr_stat: assignment k='VGLOBAL' | ||
27 | assignment: '=' -- RHS elements follows | ||
28 | explist1: begin | ||
29 | expr: | ||
30 | subexpr: uop='not' | ||
31 | prefixexp: <name> | ||
32 | str_checkname: 'foo' | ||
33 | singlevar(kind): 'VGLOBAL' | ||
34 | explist1: end | ||
35 | -- STATEMENT: end 'expr' | ||
36 | |||
37 | leaveblock | ||
38 | block: end | ||
39 | leaveblock | ||
40 | while_stat: end | ||
41 | -- STATEMENT: end 'while' | ||
42 | |||
43 | -- STATEMENT: begin 'while' line=2 | ||
44 | while_stat: begin/condition | ||
45 | cond: begin | ||
46 | expr: | ||
47 | prefixexp: <name> | ||
48 | str_checkname: 'foo' | ||
49 | singlevar(kind): 'VGLOBAL' | ||
50 | subexpr: binop='~=' | ||
51 | simpleexp: <number>=42 | ||
52 | subexpr: -- evaluate | ||
53 | cond: end | ||
54 | enterblock(isbreakable=true) | ||
55 | while_stat: block | ||
56 | block: begin | ||
57 | enterblock(isbreakable=false) | ||
58 | chunk: | ||
59 | -- STATEMENT: begin 'expr' line=2 | ||
60 | prefixexp: <name> | ||
61 | str_checkname: 'foo' | ||
62 | singlevar(kind): 'VGLOBAL' | ||
63 | expr_stat: assignment k='VGLOBAL' | ||
64 | assignment: '=' -- RHS elements follows | ||
65 | explist1: begin | ||
66 | expr: | ||
67 | prefixexp: <name> | ||
68 | str_checkname: 'foo' | ||
69 | singlevar(kind): 'VGLOBAL' | ||
70 | subexpr: binop='-' | ||
71 | simpleexp: <number>=1 | ||
72 | subexpr: -- evaluate | ||
73 | explist1: end | ||
74 | -- STATEMENT: end 'expr' | ||
75 | |||
76 | leaveblock | ||
77 | block: end | ||
78 | leaveblock | ||
79 | while_stat: end | ||
80 | -- STATEMENT: end 'while' | ||
81 | |||
82 | -- STATEMENT: begin 'while' line=3 | ||
83 | while_stat: begin/condition | ||
84 | cond: begin | ||
85 | expr: | ||
86 | simpleexp: true | ||
87 | cond: end | ||
88 | enterblock(isbreakable=true) | ||
89 | while_stat: block | ||
90 | block: begin | ||
91 | enterblock(isbreakable=false) | ||
92 | chunk: | ||
93 | -- STATEMENT: begin 'break' line=3 | ||
94 | break_stat: -- break out of loop | ||
95 | -- STATEMENT: end 'break' | ||
96 | leaveblock | ||
97 | block: end | ||
98 | leaveblock | ||
99 | while_stat: end | ||
100 | -- STATEMENT: end 'while' | ||
101 | |||
102 | close_func | ||
103 | -- TOP: end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_10.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_10.lua deleted file mode 100644 index b8e7754..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_10.lua +++ /dev/null | |||
@@ -1,100 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | repeat foo=foo.."bar" until false | ||
3 | repeat foo=foo/2 until foo<1 | ||
4 | repeat 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 | enterblock(isbreakable=false) | ||
15 | chunk: | ||
16 | -- STATEMENT: begin 'expr' line=1 | ||
17 | prefixexp: <name> | ||
18 | str_checkname: 'foo' | ||
19 | singlevar(kind): 'VGLOBAL' | ||
20 | expr_stat: assignment k='VGLOBAL' | ||
21 | assignment: '=' -- RHS elements follows | ||
22 | explist1: begin | ||
23 | expr: | ||
24 | prefixexp: <name> | ||
25 | str_checkname: 'foo' | ||
26 | singlevar(kind): 'VGLOBAL' | ||
27 | subexpr: binop='..' | ||
28 | simpleexp: <string>=bar | ||
29 | codestring: "bar" | ||
30 | subexpr: -- evaluate | ||
31 | explist1: end | ||
32 | -- STATEMENT: end 'expr' | ||
33 | |||
34 | repeat_stat: condition | ||
35 | cond: begin | ||
36 | expr: | ||
37 | simpleexp: false | ||
38 | cond: end | ||
39 | leaveblock | ||
40 | leaveblock | ||
41 | repeat_stat: end | ||
42 | -- STATEMENT: end 'repeat' | ||
43 | |||
44 | -- STATEMENT: begin 'repeat' line=2 | ||
45 | repeat_stat: begin | ||
46 | enterblock(isbreakable=true) | ||
47 | enterblock(isbreakable=false) | ||
48 | chunk: | ||
49 | -- STATEMENT: begin 'expr' line=2 | ||
50 | prefixexp: <name> | ||
51 | str_checkname: 'foo' | ||
52 | singlevar(kind): 'VGLOBAL' | ||
53 | expr_stat: assignment k='VGLOBAL' | ||
54 | assignment: '=' -- RHS elements follows | ||
55 | explist1: begin | ||
56 | expr: | ||
57 | prefixexp: <name> | ||
58 | str_checkname: 'foo' | ||
59 | singlevar(kind): 'VGLOBAL' | ||
60 | subexpr: binop='/' | ||
61 | simpleexp: <number>=2 | ||
62 | subexpr: -- evaluate | ||
63 | explist1: end | ||
64 | -- STATEMENT: end 'expr' | ||
65 | |||
66 | repeat_stat: condition | ||
67 | cond: begin | ||
68 | expr: | ||
69 | prefixexp: <name> | ||
70 | str_checkname: 'foo' | ||
71 | singlevar(kind): 'VGLOBAL' | ||
72 | subexpr: binop='<' | ||
73 | simpleexp: <number>=1 | ||
74 | subexpr: -- evaluate | ||
75 | cond: end | ||
76 | leaveblock | ||
77 | leaveblock | ||
78 | repeat_stat: end | ||
79 | -- STATEMENT: end 'repeat' | ||
80 | |||
81 | -- STATEMENT: begin 'repeat' line=3 | ||
82 | repeat_stat: begin | ||
83 | enterblock(isbreakable=true) | ||
84 | enterblock(isbreakable=false) | ||
85 | chunk: | ||
86 | -- STATEMENT: begin 'break' line=3 | ||
87 | break_stat: -- break out of loop | ||
88 | -- STATEMENT: end 'break' | ||
89 | repeat_stat: condition | ||
90 | cond: begin | ||
91 | expr: | ||
92 | simpleexp: false | ||
93 | cond: end | ||
94 | leaveblock | ||
95 | leaveblock | ||
96 | repeat_stat: end | ||
97 | -- STATEMENT: end 'repeat' | ||
98 | |||
99 | close_func | ||
100 | -- TOP: end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_11.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_11.lua deleted file mode 100644 index 461ea82..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_11.lua +++ /dev/null | |||
@@ -1,192 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | for i=1,10 do foo=i end | ||
3 | for i=1,10,2 do break end | ||
4 | for i in foo do bar=0 end | ||
5 | for 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=true) | ||
15 | str_checkname: 'i' | ||
16 | for_stat: numerical loop | ||
17 | new_localvar: '(for index)' | ||
18 | new_localvar: '(for limit)' | ||
19 | new_localvar: '(for step)' | ||
20 | new_localvar: 'i' | ||
21 | fornum: begin | ||
22 | fornum: index start | ||
23 | exp1: begin | ||
24 | expr: | ||
25 | simpleexp: <number>=1 | ||
26 | exp1: end | ||
27 | fornum: index stop | ||
28 | exp1: begin | ||
29 | expr: | ||
30 | simpleexp: <number>=10 | ||
31 | exp1: end | ||
32 | fornum: body | ||
33 | enterblock(isbreakable=false) | ||
34 | block: begin | ||
35 | enterblock(isbreakable=false) | ||
36 | chunk: | ||
37 | -- STATEMENT: begin 'expr' line=1 | ||
38 | prefixexp: <name> | ||
39 | str_checkname: 'foo' | ||
40 | singlevar(kind): 'VGLOBAL' | ||
41 | expr_stat: assignment k='VGLOBAL' | ||
42 | assignment: '=' -- RHS elements follows | ||
43 | explist1: begin | ||
44 | expr: | ||
45 | prefixexp: <name> | ||
46 | str_checkname: 'i' | ||
47 | singlevar(kind): 'VLOCAL' | ||
48 | explist1: end | ||
49 | -- STATEMENT: end 'expr' | ||
50 | |||
51 | leaveblock | ||
52 | block: end | ||
53 | leaveblock | ||
54 | fornum: end | ||
55 | leaveblock | ||
56 | for_stat: end | ||
57 | -- STATEMENT: end 'for' | ||
58 | |||
59 | -- STATEMENT: begin 'for' line=2 | ||
60 | for_stat: begin | ||
61 | enterblock(isbreakable=true) | ||
62 | str_checkname: 'i' | ||
63 | for_stat: numerical loop | ||
64 | new_localvar: '(for index)' | ||
65 | new_localvar: '(for limit)' | ||
66 | new_localvar: '(for step)' | ||
67 | new_localvar: 'i' | ||
68 | fornum: begin | ||
69 | fornum: index start | ||
70 | exp1: begin | ||
71 | expr: | ||
72 | simpleexp: <number>=1 | ||
73 | exp1: end | ||
74 | fornum: index stop | ||
75 | exp1: begin | ||
76 | expr: | ||
77 | simpleexp: <number>=10 | ||
78 | exp1: end | ||
79 | fornum: index step | ||
80 | exp1: begin | ||
81 | expr: | ||
82 | simpleexp: <number>=2 | ||
83 | exp1: end | ||
84 | fornum: body | ||
85 | enterblock(isbreakable=false) | ||
86 | block: begin | ||
87 | enterblock(isbreakable=false) | ||
88 | chunk: | ||
89 | -- STATEMENT: begin 'break' line=2 | ||
90 | break_stat: -- break out of loop | ||
91 | -- STATEMENT: end 'break' | ||
92 | leaveblock | ||
93 | block: end | ||
94 | leaveblock | ||
95 | fornum: end | ||
96 | leaveblock | ||
97 | for_stat: end | ||
98 | -- STATEMENT: end 'for' | ||
99 | |||
100 | -- STATEMENT: begin 'for' line=3 | ||
101 | for_stat: begin | ||
102 | enterblock(isbreakable=true) | ||
103 | str_checkname: 'i' | ||
104 | for_stat: list-based loop | ||
105 | forlist: begin | ||
106 | new_localvar: '(for generator)' | ||
107 | new_localvar: '(for state)' | ||
108 | new_localvar: '(for control)' | ||
109 | new_localvar: 'i' | ||
110 | forlist: explist1 | ||
111 | explist1: begin | ||
112 | expr: | ||
113 | prefixexp: <name> | ||
114 | str_checkname: 'foo' | ||
115 | singlevar(kind): 'VGLOBAL' | ||
116 | explist1: end | ||
117 | forlist: body | ||
118 | enterblock(isbreakable=false) | ||
119 | block: begin | ||
120 | enterblock(isbreakable=false) | ||
121 | chunk: | ||
122 | -- STATEMENT: begin 'expr' line=3 | ||
123 | prefixexp: <name> | ||
124 | str_checkname: 'bar' | ||
125 | singlevar(kind): 'VGLOBAL' | ||
126 | expr_stat: assignment k='VGLOBAL' | ||
127 | assignment: '=' -- RHS elements follows | ||
128 | explist1: begin | ||
129 | expr: | ||
130 | simpleexp: <number>=0 | ||
131 | explist1: end | ||
132 | -- STATEMENT: end 'expr' | ||
133 | |||
134 | leaveblock | ||
135 | block: end | ||
136 | leaveblock | ||
137 | forlist: end | ||
138 | leaveblock | ||
139 | for_stat: end | ||
140 | -- STATEMENT: end 'for' | ||
141 | |||
142 | -- STATEMENT: begin 'for' line=4 | ||
143 | for_stat: begin | ||
144 | enterblock(isbreakable=true) | ||
145 | str_checkname: 'i' | ||
146 | for_stat: list-based loop | ||
147 | forlist: begin | ||
148 | new_localvar: '(for generator)' | ||
149 | new_localvar: '(for state)' | ||
150 | new_localvar: '(for control)' | ||
151 | new_localvar: 'i' | ||
152 | str_checkname: 'j' | ||
153 | new_localvar: 'j' | ||
154 | forlist: explist1 | ||
155 | explist1: begin | ||
156 | expr: | ||
157 | prefixexp: <name> | ||
158 | str_checkname: 'foo' | ||
159 | singlevar(kind): 'VGLOBAL' | ||
160 | explist1: ',' -- continuation | ||
161 | expr: | ||
162 | prefixexp: <name> | ||
163 | str_checkname: 'bar' | ||
164 | singlevar(kind): 'VGLOBAL' | ||
165 | explist1: end | ||
166 | forlist: body | ||
167 | enterblock(isbreakable=false) | ||
168 | block: begin | ||
169 | enterblock(isbreakable=false) | ||
170 | chunk: | ||
171 | -- STATEMENT: begin 'expr' line=4 | ||
172 | prefixexp: <name> | ||
173 | str_checkname: 'baz' | ||
174 | singlevar(kind): 'VGLOBAL' | ||
175 | expr_stat: assignment k='VGLOBAL' | ||
176 | assignment: '=' -- RHS elements follows | ||
177 | explist1: begin | ||
178 | expr: | ||
179 | simpleexp: <number>=0 | ||
180 | explist1: end | ||
181 | -- STATEMENT: end 'expr' | ||
182 | |||
183 | leaveblock | ||
184 | block: end | ||
185 | leaveblock | ||
186 | forlist: end | ||
187 | leaveblock | ||
188 | for_stat: end | ||
189 | -- STATEMENT: end 'for' | ||
190 | |||
191 | close_func | ||
192 | -- TOP: end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_12.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_12.lua deleted file mode 100644 index c423d85..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_12.lua +++ /dev/null | |||
@@ -1,52 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | local foo | ||
3 | local foo,bar,baz | ||
4 | local 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 | new_localvar: 'foo' | ||
16 | localstat: end | ||
17 | -- STATEMENT: end 'local' | ||
18 | |||
19 | -- STATEMENT: begin 'local' line=2 | ||
20 | local_stat: local statement | ||
21 | localstat: begin | ||
22 | str_checkname: 'foo' | ||
23 | new_localvar: 'foo' | ||
24 | str_checkname: 'bar' | ||
25 | new_localvar: 'bar' | ||
26 | str_checkname: 'baz' | ||
27 | new_localvar: 'baz' | ||
28 | localstat: end | ||
29 | -- STATEMENT: end 'local' | ||
30 | |||
31 | -- STATEMENT: begin 'local' line=3 | ||
32 | local_stat: local statement | ||
33 | localstat: begin | ||
34 | str_checkname: 'foo' | ||
35 | new_localvar: 'foo' | ||
36 | str_checkname: 'bar' | ||
37 | new_localvar: 'bar' | ||
38 | localstat: -- assignment | ||
39 | explist1: begin | ||
40 | expr: | ||
41 | simpleexp: <string>=foo | ||
42 | codestring: "foo" | ||
43 | explist1: ',' -- continuation | ||
44 | expr: | ||
45 | simpleexp: <string>=bar | ||
46 | codestring: "bar" | ||
47 | explist1: end | ||
48 | localstat: end | ||
49 | -- STATEMENT: end 'local' | ||
50 | |||
51 | close_func | ||
52 | -- TOP: end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_13.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_13.lua deleted file mode 100644 index b5f598a..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_13.lua +++ /dev/null | |||
@@ -1,108 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | local function foo() return end | ||
3 | local function foo(a) return end | ||
4 | local function foo(x,y,z) return end | ||
5 | local 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 | new_localvar: 'foo' | ||
17 | localfunc: body | ||
18 | open_func | ||
19 | body: begin | ||
20 | body: parlist | ||
21 | parlist: begin | ||
22 | parlist: end | ||
23 | body: chunk | ||
24 | chunk: | ||
25 | -- STATEMENT: begin 'return' line=1 | ||
26 | return_stat: no return values | ||
27 | -- STATEMENT: end 'return' | ||
28 | body: end | ||
29 | close_func | ||
30 | localfunc: end | ||
31 | -- STATEMENT: end 'local' | ||
32 | |||
33 | -- STATEMENT: begin 'local' line=2 | ||
34 | local_stat: local function | ||
35 | localfunc: begin | ||
36 | str_checkname: 'foo' | ||
37 | new_localvar: 'foo' | ||
38 | localfunc: body | ||
39 | open_func | ||
40 | body: begin | ||
41 | body: parlist | ||
42 | parlist: begin | ||
43 | str_checkname: 'a' | ||
44 | new_localvar: 'a' | ||
45 | parlist: end | ||
46 | body: chunk | ||
47 | chunk: | ||
48 | -- STATEMENT: begin 'return' line=2 | ||
49 | return_stat: no return values | ||
50 | -- STATEMENT: end 'return' | ||
51 | body: end | ||
52 | close_func | ||
53 | localfunc: end | ||
54 | -- STATEMENT: end 'local' | ||
55 | |||
56 | -- STATEMENT: begin 'local' line=3 | ||
57 | local_stat: local function | ||
58 | localfunc: begin | ||
59 | str_checkname: 'foo' | ||
60 | new_localvar: 'foo' | ||
61 | localfunc: body | ||
62 | open_func | ||
63 | body: begin | ||
64 | body: parlist | ||
65 | parlist: begin | ||
66 | str_checkname: 'x' | ||
67 | new_localvar: 'x' | ||
68 | str_checkname: 'y' | ||
69 | new_localvar: 'y' | ||
70 | str_checkname: 'z' | ||
71 | new_localvar: 'z' | ||
72 | parlist: end | ||
73 | body: chunk | ||
74 | chunk: | ||
75 | -- STATEMENT: begin 'return' line=3 | ||
76 | return_stat: no return values | ||
77 | -- STATEMENT: end 'return' | ||
78 | body: end | ||
79 | close_func | ||
80 | localfunc: end | ||
81 | -- STATEMENT: end 'local' | ||
82 | |||
83 | -- STATEMENT: begin 'local' line=4 | ||
84 | local_stat: local function | ||
85 | localfunc: begin | ||
86 | str_checkname: 'foo' | ||
87 | new_localvar: 'foo' | ||
88 | localfunc: body | ||
89 | open_func | ||
90 | body: begin | ||
91 | body: parlist | ||
92 | parlist: begin | ||
93 | str_checkname: 'x' | ||
94 | new_localvar: 'x' | ||
95 | parlist: ... (dots) | ||
96 | parlist: end | ||
97 | body: chunk | ||
98 | chunk: | ||
99 | -- STATEMENT: begin 'return' line=4 | ||
100 | return_stat: no return values | ||
101 | -- STATEMENT: end 'return' | ||
102 | body: end | ||
103 | close_func | ||
104 | localfunc: end | ||
105 | -- STATEMENT: end 'local' | ||
106 | |||
107 | close_func | ||
108 | -- TOP: end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_14.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_14.lua deleted file mode 100644 index a6b9ad0..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_14.lua +++ /dev/null | |||
@@ -1,112 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | function foo() return end | ||
3 | function foo(a) return end | ||
4 | function foo(x,y,z) return end | ||
5 | function 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(kind): 'VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
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 | new_localvar: 'a' | ||
47 | parlist: end | ||
48 | body: chunk | ||
49 | chunk: | ||
50 | -- STATEMENT: begin 'return' line=2 | ||
51 | return_stat: no return values | ||
52 | -- STATEMENT: end 'return' | ||
53 | body: end | ||
54 | close_func | ||
55 | function_stat: end | ||
56 | -- STATEMENT: end 'function' | ||
57 | |||
58 | -- STATEMENT: begin 'function' line=3 | ||
59 | function_stat: begin | ||
60 | funcname: begin | ||
61 | str_checkname: 'foo' | ||
62 | singlevar(kind): 'VGLOBAL' | ||
63 | funcname: end | ||
64 | function_stat: body needself='false' | ||
65 | open_func | ||
66 | body: begin | ||
67 | body: parlist | ||
68 | parlist: begin | ||
69 | str_checkname: 'x' | ||
70 | new_localvar: 'x' | ||
71 | str_checkname: 'y' | ||
72 | new_localvar: 'y' | ||
73 | str_checkname: 'z' | ||
74 | new_localvar: 'z' | ||
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 | function_stat: end | ||
84 | -- STATEMENT: end 'function' | ||
85 | |||
86 | -- STATEMENT: begin 'function' line=4 | ||
87 | function_stat: begin | ||
88 | funcname: begin | ||
89 | str_checkname: 'foo' | ||
90 | singlevar(kind): 'VGLOBAL' | ||
91 | funcname: end | ||
92 | function_stat: body needself='false' | ||
93 | open_func | ||
94 | body: begin | ||
95 | body: parlist | ||
96 | parlist: begin | ||
97 | str_checkname: 'x' | ||
98 | new_localvar: 'x' | ||
99 | parlist: ... (dots) | ||
100 | parlist: end | ||
101 | body: chunk | ||
102 | chunk: | ||
103 | -- STATEMENT: begin 'return' line=4 | ||
104 | return_stat: no return values | ||
105 | -- STATEMENT: end 'return' | ||
106 | body: end | ||
107 | close_func | ||
108 | function_stat: end | ||
109 | -- STATEMENT: end 'function' | ||
110 | |||
111 | close_func | ||
112 | -- TOP: end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_15.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_15.lua deleted file mode 100644 index 497eeaf..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_15.lua +++ /dev/null | |||
@@ -1,140 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | function foo.bar(p) return end | ||
3 | function foo.bar.baz(p) return end | ||
4 | function foo:bar(p) return end | ||
5 | function 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(kind): 'VGLOBAL' | ||
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 | new_localvar: 'p' | ||
30 | parlist: end | ||
31 | body: chunk | ||
32 | chunk: | ||
33 | -- STATEMENT: begin 'return' line=1 | ||
34 | return_stat: no return values | ||
35 | -- STATEMENT: end 'return' | ||
36 | body: end | ||
37 | close_func | ||
38 | function_stat: end | ||
39 | -- STATEMENT: end 'function' | ||
40 | |||
41 | -- STATEMENT: begin 'function' line=2 | ||
42 | function_stat: begin | ||
43 | funcname: begin | ||
44 | str_checkname: 'foo' | ||
45 | singlevar(kind): 'VGLOBAL' | ||
46 | funcname: -- '.' field | ||
47 | field: operator=. | ||
48 | checkname: | ||
49 | str_checkname: 'bar' | ||
50 | codestring: "bar" | ||
51 | funcname: -- '.' field | ||
52 | field: operator=. | ||
53 | checkname: | ||
54 | str_checkname: 'baz' | ||
55 | codestring: "baz" | ||
56 | funcname: end | ||
57 | function_stat: body needself='false' | ||
58 | open_func | ||
59 | body: begin | ||
60 | body: parlist | ||
61 | parlist: begin | ||
62 | str_checkname: 'p' | ||
63 | new_localvar: 'p' | ||
64 | parlist: end | ||
65 | body: chunk | ||
66 | chunk: | ||
67 | -- STATEMENT: begin 'return' line=2 | ||
68 | return_stat: no return values | ||
69 | -- STATEMENT: end 'return' | ||
70 | body: end | ||
71 | close_func | ||
72 | function_stat: end | ||
73 | -- STATEMENT: end 'function' | ||
74 | |||
75 | -- STATEMENT: begin 'function' line=3 | ||
76 | function_stat: begin | ||
77 | funcname: begin | ||
78 | str_checkname: 'foo' | ||
79 | singlevar(kind): 'VGLOBAL' | ||
80 | funcname: -- ':' field | ||
81 | field: operator=: | ||
82 | checkname: | ||
83 | str_checkname: 'bar' | ||
84 | codestring: "bar" | ||
85 | funcname: end | ||
86 | function_stat: body needself='true' | ||
87 | open_func | ||
88 | body: begin | ||
89 | new_localvar: 'self' | ||
90 | body: parlist | ||
91 | parlist: begin | ||
92 | str_checkname: 'p' | ||
93 | new_localvar: 'p' | ||
94 | parlist: end | ||
95 | body: chunk | ||
96 | chunk: | ||
97 | -- STATEMENT: begin 'return' line=3 | ||
98 | return_stat: no return values | ||
99 | -- STATEMENT: end 'return' | ||
100 | body: end | ||
101 | close_func | ||
102 | function_stat: end | ||
103 | -- STATEMENT: end 'function' | ||
104 | |||
105 | -- STATEMENT: begin 'function' line=4 | ||
106 | function_stat: begin | ||
107 | funcname: begin | ||
108 | str_checkname: 'foo' | ||
109 | singlevar(kind): 'VGLOBAL' | ||
110 | funcname: -- '.' field | ||
111 | field: operator=. | ||
112 | checkname: | ||
113 | str_checkname: 'bar' | ||
114 | codestring: "bar" | ||
115 | funcname: -- '.' field | ||
116 | field: operator=. | ||
117 | checkname: | ||
118 | str_checkname: 'baz' | ||
119 | codestring: "baz" | ||
120 | funcname: end | ||
121 | function_stat: body needself='false' | ||
122 | open_func | ||
123 | body: begin | ||
124 | body: parlist | ||
125 | parlist: begin | ||
126 | str_checkname: 'p' | ||
127 | new_localvar: 'p' | ||
128 | parlist: end | ||
129 | body: chunk | ||
130 | chunk: | ||
131 | -- STATEMENT: begin 'return' line=4 | ||
132 | return_stat: no return values | ||
133 | -- STATEMENT: end 'return' | ||
134 | body: end | ||
135 | close_func | ||
136 | function_stat: end | ||
137 | -- STATEMENT: end 'function' | ||
138 | |||
139 | close_func | ||
140 | -- TOP: end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_16.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_16.lua deleted file mode 100644 index b7907b8..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_16.lua +++ /dev/null | |||
@@ -1,128 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | foo = function() return end | ||
3 | foo = function(x,y) return end | ||
4 | foo = function(...) return end | ||
5 | foo = function(...) local bar = ... return end | ||
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(kind): 'VGLOBAL' | ||
16 | expr_stat: assignment k='VGLOBAL' | ||
17 | assignment: '=' -- RHS elements follows | ||
18 | explist1: begin | ||
19 | expr: | ||
20 | simpleexp: function | ||
21 | open_func | ||
22 | body: begin | ||
23 | body: parlist | ||
24 | parlist: begin | ||
25 | parlist: end | ||
26 | body: chunk | ||
27 | chunk: | ||
28 | -- STATEMENT: begin 'return' line=1 | ||
29 | return_stat: no return values | ||
30 | -- STATEMENT: end 'return' | ||
31 | body: end | ||
32 | close_func | ||
33 | explist1: end | ||
34 | -- STATEMENT: end 'expr' | ||
35 | |||
36 | -- STATEMENT: begin 'expr' line=2 | ||
37 | prefixexp: <name> | ||
38 | str_checkname: 'foo' | ||
39 | singlevar(kind): 'VGLOBAL' | ||
40 | expr_stat: assignment k='VGLOBAL' | ||
41 | assignment: '=' -- RHS elements follows | ||
42 | explist1: begin | ||
43 | expr: | ||
44 | simpleexp: function | ||
45 | open_func | ||
46 | body: begin | ||
47 | body: parlist | ||
48 | parlist: begin | ||
49 | str_checkname: 'x' | ||
50 | new_localvar: 'x' | ||
51 | str_checkname: 'y' | ||
52 | new_localvar: 'y' | ||
53 | parlist: end | ||
54 | body: chunk | ||
55 | chunk: | ||
56 | -- STATEMENT: begin 'return' line=2 | ||
57 | return_stat: no return values | ||
58 | -- STATEMENT: end 'return' | ||
59 | body: end | ||
60 | close_func | ||
61 | explist1: end | ||
62 | -- STATEMENT: end 'expr' | ||
63 | |||
64 | -- STATEMENT: begin 'expr' line=3 | ||
65 | prefixexp: <name> | ||
66 | str_checkname: 'foo' | ||
67 | singlevar(kind): 'VGLOBAL' | ||
68 | expr_stat: assignment k='VGLOBAL' | ||
69 | assignment: '=' -- RHS elements follows | ||
70 | explist1: begin | ||
71 | expr: | ||
72 | simpleexp: function | ||
73 | open_func | ||
74 | body: begin | ||
75 | body: parlist | ||
76 | parlist: begin | ||
77 | parlist: ... (dots) | ||
78 | parlist: end | ||
79 | body: chunk | ||
80 | chunk: | ||
81 | -- STATEMENT: begin 'return' line=3 | ||
82 | return_stat: no return values | ||
83 | -- STATEMENT: end 'return' | ||
84 | body: end | ||
85 | close_func | ||
86 | explist1: end | ||
87 | -- STATEMENT: end 'expr' | ||
88 | |||
89 | -- STATEMENT: begin 'expr' line=4 | ||
90 | prefixexp: <name> | ||
91 | str_checkname: 'foo' | ||
92 | singlevar(kind): 'VGLOBAL' | ||
93 | expr_stat: assignment k='VGLOBAL' | ||
94 | assignment: '=' -- RHS elements follows | ||
95 | explist1: begin | ||
96 | expr: | ||
97 | simpleexp: function | ||
98 | open_func | ||
99 | body: begin | ||
100 | body: parlist | ||
101 | parlist: begin | ||
102 | parlist: ... (dots) | ||
103 | parlist: end | ||
104 | body: chunk | ||
105 | chunk: | ||
106 | -- STATEMENT: begin 'local' line=4 | ||
107 | local_stat: local statement | ||
108 | localstat: begin | ||
109 | str_checkname: 'bar' | ||
110 | new_localvar: 'bar' | ||
111 | localstat: -- assignment | ||
112 | explist1: begin | ||
113 | expr: | ||
114 | simpleexp: ... | ||
115 | explist1: end | ||
116 | localstat: end | ||
117 | -- STATEMENT: end 'local' | ||
118 | |||
119 | -- STATEMENT: begin 'return' line=4 | ||
120 | return_stat: no return values | ||
121 | -- STATEMENT: end 'return' | ||
122 | body: end | ||
123 | close_func | ||
124 | explist1: end | ||
125 | -- STATEMENT: end 'expr' | ||
126 | |||
127 | close_func | ||
128 | -- TOP: end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_17.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_17.lua deleted file mode 100644 index fadc7f9..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_17.lua +++ /dev/null | |||
@@ -1,110 +0,0 @@ | |||
1 | -- START OF SOURCE -- | ||
2 | foo = {} | ||
3 | foo = { 1,2,3; "foo"; } | ||
4 | foo = { bar=77, baz=88, } | ||
5 | foo = { ["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(kind): 'VGLOBAL' | ||
16 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
30 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
57 | expr_stat: assignment k='VGLOBAL' | ||
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(kind): 'VGLOBAL' | ||
83 | expr_stat: assignment k='VGLOBAL' | ||
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.1.3/test/parser_log/sample_18.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_18.lua deleted file mode 100644 index 732b4d6..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_18.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.1.3/test/parser_log/sample_19.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_19.lua deleted file mode 100644 index 9863b4a..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_19.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.1.3/test/parser_log/sample_20.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_20.lua deleted file mode 100644 index bc37280..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_20.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.1.3/test/parser_log/sample_21.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_21.lua deleted file mode 100644 index b2bac4b..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_21.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.1.3/test/parser_log/sample_22.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_22.lua deleted file mode 100644 index 6885f01..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_22.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.1.3/test/parser_log/sample_23.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_23.lua deleted file mode 100644 index eb658ed..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_23.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.1.3/test/parser_log/sample_24.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_24.lua deleted file mode 100644 index 6403234..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_24.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.1.3/test/parser_log/sample_25.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_25.lua deleted file mode 100644 index 594e267..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_25.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.1.3/test/parser_log/sample_26.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_26.lua deleted file mode 100644 index bfa3920..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_26.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.1.3/test/parser_log/sample_27.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_27.lua deleted file mode 100644 index 77db3ef..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_27.lua +++ /dev/null | |||
@@ -1,48 +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 | parlist: end | ||
24 | body: chunk | ||
25 | chunk: | ||
26 | -- STATEMENT: begin 'expr' line=2 | ||
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: 'arg' | ||
36 | singlevar(kind): 'VGLOBAL' | ||
37 | explist1: end | ||
38 | funcargs: end -- expr is a VCALL | ||
39 | expr_stat: function call k='VCALL' | ||
40 | -- STATEMENT: end 'expr' | ||
41 | |||
42 | body: end | ||
43 | close_func | ||
44 | function_stat: end | ||
45 | -- STATEMENT: end 'function' | ||
46 | |||
47 | close_func | ||
48 | -- TOP: end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_28.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_28.lua deleted file mode 100644 index e4c9e21..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_28.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.1.3/test/parser_log/sample_29.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_29.lua deleted file mode 100644 index b278ba2..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_29.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.1.3/test/parser_log/sample_30.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_30.lua deleted file mode 100644 index 3807d14..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_30.lua +++ /dev/null | |||
@@ -1,119 +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=true) | ||
17 | str_checkname: 'i' | ||
18 | for_stat: numerical loop | ||
19 | new_localvar: '(for index)' | ||
20 | new_localvar: '(for limit)' | ||
21 | new_localvar: '(for step)' | ||
22 | new_localvar: 'i' | ||
23 | fornum: begin | ||
24 | fornum: index start | ||
25 | exp1: begin | ||
26 | expr: | ||
27 | simpleexp: <number>=1 | ||
28 | exp1: end | ||
29 | fornum: index stop | ||
30 | exp1: begin | ||
31 | expr: | ||
32 | simpleexp: <number>=10 | ||
33 | exp1: end | ||
34 | fornum: body | ||
35 | enterblock(isbreakable=false) | ||
36 | block: begin | ||
37 | enterblock(isbreakable=false) | ||
38 | chunk: | ||
39 | -- STATEMENT: begin 'expr' line=2 | ||
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: 'i' | ||
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 | leaveblock | ||
58 | fornum: end | ||
59 | leaveblock | ||
60 | for_stat: end | ||
61 | -- STATEMENT: end 'for' | ||
62 | |||
63 | -- STATEMENT: begin 'for' line=4 | ||
64 | for_stat: begin | ||
65 | enterblock(isbreakable=true) | ||
66 | str_checkname: 'i' | ||
67 | for_stat: numerical loop | ||
68 | new_localvar: '(for index)' | ||
69 | new_localvar: '(for limit)' | ||
70 | new_localvar: '(for step)' | ||
71 | new_localvar: 'i' | ||
72 | fornum: begin | ||
73 | fornum: index start | ||
74 | exp1: begin | ||
75 | expr: | ||
76 | simpleexp: <number>=1 | ||
77 | exp1: end | ||
78 | fornum: index stop | ||
79 | exp1: begin | ||
80 | expr: | ||
81 | simpleexp: <number>=10 | ||
82 | exp1: end | ||
83 | fornum: index step | ||
84 | exp1: begin | ||
85 | expr: | ||
86 | subexpr: uop='-' | ||
87 | simpleexp: <number>=2 | ||
88 | exp1: end | ||
89 | fornum: body | ||
90 | enterblock(isbreakable=false) | ||
91 | block: begin | ||
92 | enterblock(isbreakable=false) | ||
93 | chunk: | ||
94 | -- STATEMENT: begin 'expr' line=5 | ||
95 | prefixexp: <name> | ||
96 | str_checkname: 'print' | ||
97 | singlevar(kind): 'VGLOBAL' | ||
98 | primaryexp: ( funcargs | ||
99 | funcargs: begin '(' | ||
100 | explist1: begin | ||
101 | expr: | ||
102 | prefixexp: <name> | ||
103 | str_checkname: 'i' | ||
104 | singlevar(kind): 'VLOCAL' | ||
105 | explist1: end | ||
106 | funcargs: end -- expr is a VCALL | ||
107 | expr_stat: function call k='VCALL' | ||
108 | -- STATEMENT: end 'expr' | ||
109 | |||
110 | leaveblock | ||
111 | block: end | ||
112 | leaveblock | ||
113 | fornum: end | ||
114 | leaveblock | ||
115 | for_stat: end | ||
116 | -- STATEMENT: end 'for' | ||
117 | |||
118 | close_func | ||
119 | -- TOP: end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_31.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_31.lua deleted file mode 100644 index 0d0a602..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/parser_log/sample_31.lua +++ /dev/null | |||
@@ -1,127 +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=true) | ||
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: '(for control)' | ||
23 | new_localvar: 'foo' | ||
24 | forlist: explist1 | ||
25 | explist1: begin | ||
26 | expr: | ||
27 | prefixexp: <name> | ||
28 | str_checkname: 'bar' | ||
29 | singlevar(kind): 'VGLOBAL' | ||
30 | primaryexp: ( funcargs | ||
31 | funcargs: begin '(' | ||
32 | funcargs: end -- expr is a VCALL | ||
33 | explist1: end | ||
34 | forlist: body | ||
35 | enterblock(isbreakable=false) | ||
36 | block: begin | ||
37 | enterblock(isbreakable=false) | ||
38 | chunk: | ||
39 | -- STATEMENT: begin 'expr' line=2 | ||
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: 'foo' | ||
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 | leaveblock | ||
58 | forlist: end | ||
59 | leaveblock | ||
60 | for_stat: end | ||
61 | -- STATEMENT: end 'for' | ||
62 | |||
63 | -- STATEMENT: begin 'for' line=4 | ||
64 | for_stat: begin | ||
65 | enterblock(isbreakable=true) | ||
66 | str_checkname: 'foo' | ||
67 | for_stat: list-based loop | ||
68 | forlist: begin | ||
69 | new_localvar: '(for generator)' | ||
70 | new_localvar: '(for state)' | ||
71 | new_localvar: '(for control)' | ||
72 | new_localvar: 'foo' | ||
73 | str_checkname: 'bar' | ||
74 | new_localvar: 'bar' | ||
75 | str_checkname: 'baz' | ||
76 | new_localvar: 'baz' | ||
77 | forlist: explist1 | ||
78 | explist1: begin | ||
79 | expr: | ||
80 | prefixexp: <name> | ||
81 | str_checkname: 'spring' | ||
82 | singlevar(kind): 'VGLOBAL' | ||
83 | primaryexp: ( funcargs | ||
84 | funcargs: begin '(' | ||
85 | funcargs: end -- expr is a VCALL | ||
86 | explist1: end | ||
87 | forlist: body | ||
88 | enterblock(isbreakable=false) | ||
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: 'foo' | ||
102 | singlevar(kind): 'VLOCAL' | ||
103 | explist1: ',' -- continuation | ||
104 | expr: | ||
105 | prefixexp: <name> | ||
106 | str_checkname: 'bar' | ||
107 | singlevar(kind): 'VLOCAL' | ||
108 | explist1: ',' -- continuation | ||
109 | expr: | ||
110 | prefixexp: <name> | ||
111 | str_checkname: 'baz' | ||
112 | singlevar(kind): 'VLOCAL' | ||
113 | explist1: end | ||
114 | funcargs: end -- expr is a VCALL | ||
115 | expr_stat: function call k='VCALL' | ||
116 | -- STATEMENT: end 'expr' | ||
117 | |||
118 | leaveblock | ||
119 | block: end | ||
120 | leaveblock | ||
121 | forlist: end | ||
122 | leaveblock | ||
123 | for_stat: end | ||
124 | -- STATEMENT: end 'for' | ||
125 | |||
126 | close_func | ||
127 | -- TOP: end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/test_llex_mk2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/test_llex_mk2.lua deleted file mode 100644 index e9ad45f..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/test_llex_mk2.lua +++ /dev/null | |||
@@ -1,566 +0,0 @@ | |||
1 | --[[-------------------------------------------------------------------- | ||
2 | |||
3 | test_llex_mk2.lua | ||
4 | Test for llex_mk2.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 | -- if BRIEF is not set to false, auto-test will silently succeed | ||
17 | ------------------------------------------------------------------------ | ||
18 | BRIEF = true -- if set to true, messages are less verbose | ||
19 | |||
20 | package.path = "../?.lua;"..package.path | ||
21 | local llex = require "llex_mk2" | ||
22 | |||
23 | ------------------------------------------------------------------------ | ||
24 | -- simple manual tests | ||
25 | ------------------------------------------------------------------------ | ||
26 | |||
27 | --[[ | ||
28 | local function dump(z) | ||
29 | llex.init(z) | ||
30 | while true do | ||
31 | local token, seminfo = llex.llex() | ||
32 | if token == "<name>" then | ||
33 | seminfo = " "..seminfo | ||
34 | elseif token == "<number>" then | ||
35 | seminfo = " "..seminfo | ||
36 | elseif token == "<string>" then | ||
37 | seminfo = " '"..seminfo.."'" | ||
38 | else | ||
39 | seminfo = "" | ||
40 | end | ||
41 | io.stdout:write(token..seminfo.."\n") | ||
42 | if token == "<eof>" then break end | ||
43 | end | ||
44 | end | ||
45 | |||
46 | dump("local c = luaZ:zgetc(z)") | ||
47 | os.exit() | ||
48 | --]] | ||
49 | |||
50 | ------------------------------------------------------------------------ | ||
51 | -- auto-testing of simple test cases to validate lexer behaviour: | ||
52 | -- * NOTE coverage has not been checked; not comprehensive | ||
53 | -- * only test cases with non-empty comments are processed | ||
54 | -- * if no result, then the output is displayed for manual decision | ||
55 | -- (output may be used to set expected success or fail text) | ||
56 | -- * cases expected to be successful may be a partial match | ||
57 | -- * cases expected to fail may also be a partial match | ||
58 | ------------------------------------------------------------------------ | ||
59 | |||
60 | -- [=====[ | ||
61 | local function auto_test() | ||
62 | local PASS, FAIL = true, false | ||
63 | ------------------------------------------------------------------ | ||
64 | -- table of test cases | ||
65 | ------------------------------------------------------------------ | ||
66 | local test_cases = | ||
67 | { | ||
68 | ------------------------------------------------------------- | ||
69 | --{ "comment", -- comment about the test | ||
70 | -- "chunk", -- chunk to test | ||
71 | -- PASS, -- PASS or FAIL outcome | ||
72 | -- "output", -- output to compare against | ||
73 | --}, | ||
74 | ------------------------------------------------------------- | ||
75 | { "empty chunk string, test EOS", | ||
76 | "", | ||
77 | PASS, "1 <eof>", | ||
78 | }, | ||
79 | ------------------------------------------------------------- | ||
80 | { "line number counting", | ||
81 | "\n\n\r\n", | ||
82 | PASS, "4 <eof>", | ||
83 | }, | ||
84 | ------------------------------------------------------------- | ||
85 | { "various whitespaces", | ||
86 | " \n\t\t\n \t \t \n\n", | ||
87 | PASS, "5 <eof>", | ||
88 | }, | ||
89 | ------------------------------------------------------------- | ||
90 | { "short comment ending in EOS", | ||
91 | "-- moo moo", | ||
92 | PASS, "1 <eof>", | ||
93 | }, | ||
94 | ------------------------------------------------------------- | ||
95 | { "short comment ending in newline", | ||
96 | "-- moo moo\n", | ||
97 | PASS, "2 <eof>", | ||
98 | }, | ||
99 | ------------------------------------------------------------- | ||
100 | { "several lines of short comments", | ||
101 | "--moo\n-- moo moo\n\n--\tmoo\n", | ||
102 | PASS, "5 <eof>", | ||
103 | }, | ||
104 | ------------------------------------------------------------- | ||
105 | { "basic block comment 1", | ||
106 | "--[[bovine]]", | ||
107 | PASS, "1 <eof>", | ||
108 | }, | ||
109 | ------------------------------------------------------------- | ||
110 | { "basic block comment 2", | ||
111 | "--[=[bovine]=]", | ||
112 | PASS, "1 <eof>", | ||
113 | }, | ||
114 | ------------------------------------------------------------- | ||
115 | { "basic block comment 3", | ||
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]", | ||
132 | FAIL, ":1: unfinished long comment", | ||
133 | }, | ||
134 | ------------------------------------------------------------- | ||
135 | { "unterminated block comment 4", | ||
136 | "--[[bovine\nmoo moo\nwoof", | ||
137 | FAIL, ":3: unfinished long comment", | ||
138 | }, | ||
139 | ------------------------------------------------------------- | ||
140 | { "basic long string 1", | ||
141 | "\n[[bovine]]\n", | ||
142 | PASS, "2 <string> = bovine\n3 <eof>", | ||
143 | }, | ||
144 | ------------------------------------------------------------- | ||
145 | { "basic long string 2", | ||
146 | "\n[=[bovine]=]\n", | ||
147 | PASS, "2 <string> = bovine\n3 <eof>", | ||
148 | }, | ||
149 | ------------------------------------------------------------- | ||
150 | { "first newline consumed in long string", | ||
151 | "[[\nmoo]]", | ||
152 | PASS, "2 <string> = moo\n2 <eof>", | ||
153 | }, | ||
154 | ------------------------------------------------------------- | ||
155 | { "multiline long string 1", | ||
156 | "[[moo\nmoo moo\n]]", | ||
157 | PASS, "3 <string> = moo\nmoo moo\n\n3 <eof>", | ||
158 | }, | ||
159 | ------------------------------------------------------------- | ||
160 | { "multiline long string 2", | ||
161 | "[===[moo\n[=[moo moo]=]\n]===]", | ||
162 | PASS, "3 <string> = moo\n[=[moo moo]=]\n\n3 <eof>", | ||
163 | }, | ||
164 | ------------------------------------------------------------- | ||
165 | { "unterminated long string 1", | ||
166 | "\n[[\nbovine", | ||
167 | FAIL, ":3: unfinished long string", | ||
168 | }, | ||
169 | ------------------------------------------------------------- | ||
170 | { "unterminated long string 2", | ||
171 | "[[bovine]", | ||
172 | FAIL, ":1: unfinished long string", | ||
173 | }, | ||
174 | ------------------------------------------------------------- | ||
175 | { "unterminated long string 2", | ||
176 | "[==[bovine]==", | ||
177 | FAIL, ":1: unfinished long string", | ||
178 | }, | ||
179 | ------------------------------------------------------------- | ||
180 | { "complex long string 1", | ||
181 | "[=[moo[[moo]]moo]=]", | ||
182 | PASS, "moo[[moo]]moo", | ||
183 | }, | ||
184 | ------------------------------------------------------------- | ||
185 | { "complex long string 2", | ||
186 | "[=[moo[[moo[[[[]]]]moo]]moo]=]", | ||
187 | PASS, "moo[[moo[[[[]]]]moo]]moo", | ||
188 | }, | ||
189 | ------------------------------------------------------------- | ||
190 | { "complex long string 3", | ||
191 | "[=[[[[[]]]][[[[]]]]]=]", | ||
192 | PASS, "[[[[]]]][[[[]]]]", | ||
193 | }, | ||
194 | ------------------------------------------------------------- | ||
195 | -- NOTE: this native lexer does not support compatible long | ||
196 | -- strings (LUA_COMPAT_LSTR) | ||
197 | ------------------------------------------------------------- | ||
198 | --{ "deprecated long string 1", | ||
199 | -- "[[moo[[moo]]moo]]", | ||
200 | -- FAIL, ":1: nesting of [[...]] is deprecated near '['", | ||
201 | --}, | ||
202 | --------------------------------------------------------------- | ||
203 | --{ "deprecated long string 2", | ||
204 | -- "[[[[ \n", | ||
205 | -- FAIL, ":1: nesting of [[...]] is deprecated near '['", | ||
206 | --}, | ||
207 | --------------------------------------------------------------- | ||
208 | --{ "deprecated long string 3", | ||
209 | -- "[[moo[[moo[[[[]]]]moo]]moo]]", | ||
210 | -- FAIL, ":1: nesting of [[...]] is deprecated near '['", | ||
211 | --}, | ||
212 | --------------------------------------------------------------- | ||
213 | --{ "deprecated long string 4", | ||
214 | -- "[[[[[[]]]][[[[]]]]]]", | ||
215 | -- FAIL, ":1: nesting of [[...]] is deprecated near '['", | ||
216 | --}, | ||
217 | ------------------------------------------------------------- | ||
218 | { "brackets in long strings 1", | ||
219 | "[[moo[moo]]", | ||
220 | PASS, "moo[moo", | ||
221 | }, | ||
222 | ------------------------------------------------------------- | ||
223 | { "brackets in long strings 2", | ||
224 | "[=[moo[[moo]moo]]moo]=]", | ||
225 | PASS, "moo[[moo]moo]]moo", | ||
226 | }, | ||
227 | ------------------------------------------------------------- | ||
228 | { "unprocessed escapes in long strings", | ||
229 | [[ [=[\a\b\f\n\r\t\v\123]=] ]], | ||
230 | PASS, [[\a\b\f\n\r\t\v\123]], | ||
231 | }, | ||
232 | ------------------------------------------------------------- | ||
233 | { "unbalanced long string", | ||
234 | "[[moo]]moo]]", | ||
235 | PASS, "1 <string> = moo\n1 <name> = moo\n1 CHAR = ']'\n1 CHAR = ']'\n1 <eof>", | ||
236 | }, | ||
237 | ------------------------------------------------------------- | ||
238 | { "keywords 1", | ||
239 | "and break do else", | ||
240 | PASS, "1 and\n1 break\n1 do\n1 else\n1 <eof>", | ||
241 | }, | ||
242 | ------------------------------------------------------------- | ||
243 | { "keywords 2", | ||
244 | "elseif end false for", | ||
245 | PASS, "1 elseif\n1 end\n1 false\n1 for\n1 <eof>", | ||
246 | }, | ||
247 | ------------------------------------------------------------- | ||
248 | { "keywords 3", | ||
249 | "function if in local nil", | ||
250 | PASS, "1 function\n1 if\n1 in\n1 local\n1 nil\n1 <eof>", | ||
251 | }, | ||
252 | ------------------------------------------------------------- | ||
253 | { "keywords 4", | ||
254 | "not or repeat return", | ||
255 | PASS, "1 not\n1 or\n1 repeat\n1 return\n1 <eof>", | ||
256 | }, | ||
257 | ------------------------------------------------------------- | ||
258 | { "keywords 5", | ||
259 | "then true until while", | ||
260 | PASS, "1 then\n1 true\n1 until\n1 while\n1 <eof>", | ||
261 | }, | ||
262 | ------------------------------------------------------------- | ||
263 | { "concat and dots", | ||
264 | ".. ...", | ||
265 | PASS, "1 ..\n1 ...\n1 <eof>", | ||
266 | }, | ||
267 | ------------------------------------------------------------- | ||
268 | -- NOTE: in Lua 5.1.x, shbang handling is no longer performed | ||
269 | -- in the lexer; it is now done in lauxlib.c (luaL_loadfile) | ||
270 | -- so the following cannot be performed by the lexer... | ||
271 | ------------------------------------------------------------- | ||
272 | --{ "shbang handling 1", | ||
273 | -- "#blahblah", | ||
274 | -- PASS, "1 <eof>", | ||
275 | --}, | ||
276 | ------------------------------------------------------------- | ||
277 | --{ "shbang handling 2", | ||
278 | -- "#blahblah\nmoo moo\n", | ||
279 | -- PASS, "2 <name> = moo\n2 <name> = moo\n3 <eof>", | ||
280 | --}, | ||
281 | ------------------------------------------------------------- | ||
282 | { "empty string", | ||
283 | [['']], | ||
284 | PASS, "1 <string> = \n1 <eof>", | ||
285 | }, | ||
286 | ------------------------------------------------------------- | ||
287 | { "single-quoted string", | ||
288 | [['bovine']], | ||
289 | PASS, "1 <string> = bovine\n1 <eof>", | ||
290 | }, | ||
291 | ------------------------------------------------------------- | ||
292 | { "double-quoted string", | ||
293 | [["bovine"]], | ||
294 | PASS, "1 <string> = bovine\n1 <eof>", | ||
295 | }, | ||
296 | ------------------------------------------------------------- | ||
297 | { "unterminated string 1", | ||
298 | [['moo ]], | ||
299 | FAIL, ":1: unfinished string", | ||
300 | }, | ||
301 | ------------------------------------------------------------- | ||
302 | { "unterminated string 2", | ||
303 | [["moo \n]], | ||
304 | FAIL, ":1: unfinished string", | ||
305 | }, | ||
306 | ------------------------------------------------------------- | ||
307 | { "escaped newline in string, line number counted", | ||
308 | "\"moo\\\nmoo\\\nmoo\"", | ||
309 | PASS, "3 <string> = moo\nmoo\nmoo\n3 <eof>", | ||
310 | }, | ||
311 | ------------------------------------------------------------- | ||
312 | { "escaped characters in string 1", | ||
313 | [["moo\amoo"]], | ||
314 | PASS, "1 <string> = moo\amoo", | ||
315 | }, | ||
316 | ------------------------------------------------------------- | ||
317 | { "escaped characters in string 2", | ||
318 | [["moo\bmoo"]], | ||
319 | PASS, "1 <string> = moo\bmoo", | ||
320 | }, | ||
321 | ------------------------------------------------------------- | ||
322 | { "escaped characters in string 3", | ||
323 | [["moo\f\n\r\t\vmoo"]], | ||
324 | PASS, "1 <string> = moo\f\n\r\t\vmoo", | ||
325 | }, | ||
326 | ------------------------------------------------------------- | ||
327 | { "escaped characters in string 4", | ||
328 | [["\\ \" \' \? \[ \]"]], | ||
329 | PASS, "1 <string> = \\ \" \' \? \[ \]", | ||
330 | }, | ||
331 | ------------------------------------------------------------- | ||
332 | { "escaped characters in string 5", | ||
333 | [["\z \k \: \;"]], | ||
334 | PASS, "1 <string> = z k : ;", | ||
335 | }, | ||
336 | ------------------------------------------------------------- | ||
337 | { "escaped characters in string 6", | ||
338 | [["\8 \65 \160 \180K \097097"]], | ||
339 | PASS, "1 <string> = \8 \65 \160 \180K \097097\n", | ||
340 | }, | ||
341 | ------------------------------------------------------------- | ||
342 | { "escaped characters in string 7", | ||
343 | [["\666"]], | ||
344 | FAIL, ":1: escape sequence too large", | ||
345 | }, | ||
346 | ------------------------------------------------------------- | ||
347 | { "simple numbers", | ||
348 | "123 123+", | ||
349 | PASS, "1 <number> = 123\n1 <number> = 123\n1 CHAR = '+'\n1 <eof>", | ||
350 | }, | ||
351 | ------------------------------------------------------------- | ||
352 | { "longer numbers", | ||
353 | "1234567890 12345678901234567890", | ||
354 | PASS, "1 <number> = 1234567890\n1 <number> = 1.2345678901235e+19\n", | ||
355 | }, | ||
356 | ------------------------------------------------------------- | ||
357 | { "fractional numbers", | ||
358 | ".123 .12345678901234567890", | ||
359 | PASS, "1 <number> = 0.123\n1 <number> = 0.12345678901235\n", | ||
360 | }, | ||
361 | ------------------------------------------------------------- | ||
362 | { "more numbers with decimal points", | ||
363 | "12345.67890", | ||
364 | PASS, "1 <number> = 12345.6789\n", | ||
365 | }, | ||
366 | ------------------------------------------------------------- | ||
367 | { "malformed number with decimal points", | ||
368 | "1.1.", | ||
369 | FAIL, ":1: malformed number", | ||
370 | }, | ||
371 | ------------------------------------------------------------- | ||
372 | { "double decimal points", | ||
373 | ".1.1", | ||
374 | FAIL, ":1: malformed number", | ||
375 | }, | ||
376 | ------------------------------------------------------------- | ||
377 | { "double dots within numbers", | ||
378 | "1..1", | ||
379 | FAIL, ":1: malformed number", | ||
380 | }, | ||
381 | ------------------------------------------------------------- | ||
382 | { "incomplete exponential numbers", | ||
383 | "123e", | ||
384 | FAIL, ":1: malformed number", | ||
385 | }, | ||
386 | ------------------------------------------------------------- | ||
387 | { "exponential numbers 1", | ||
388 | "1234e5 1234e5.", | ||
389 | PASS, "1 <number> = 123400000\n1 <number> = 123400000\n1 CHAR = '.'", | ||
390 | }, | ||
391 | ------------------------------------------------------------- | ||
392 | { "exponential numbers 2", | ||
393 | "1234e56 1.23e123", | ||
394 | PASS, "1 <number> = 1.234e+59\n1 <number> = 1.23e+123\n", | ||
395 | }, | ||
396 | ------------------------------------------------------------- | ||
397 | { "exponential numbers 3", | ||
398 | "12.34e+", | ||
399 | FAIL, ":1: malformed number", | ||
400 | }, | ||
401 | ------------------------------------------------------------- | ||
402 | { "exponential numbers 4", | ||
403 | "12.34e+5 123.4e-5 1234.E+5", | ||
404 | PASS, "1 <number> = 1234000\n1 <number> = 0.001234\n1 <number> = 123400000\n", | ||
405 | }, | ||
406 | ------------------------------------------------------------- | ||
407 | { "hexadecimal numbers", | ||
408 | "0x00FF 0X1234 0xDEADBEEF", | ||
409 | PASS, "1 <number> = 255\n1 <number> = 4660\n1 <number> = 3735928559\n", | ||
410 | }, | ||
411 | ------------------------------------------------------------- | ||
412 | { "invalid hexadecimal numbers 1", | ||
413 | "0xFOO", | ||
414 | FAIL, ":1: malformed number", | ||
415 | }, | ||
416 | ------------------------------------------------------------- | ||
417 | { "invalid hexadecimal numbers 2", | ||
418 | "0.BAR", | ||
419 | FAIL, ":1: malformed number", | ||
420 | }, | ||
421 | ------------------------------------------------------------- | ||
422 | { "invalid hexadecimal numbers 3", | ||
423 | "0BAZ", | ||
424 | FAIL, ":1: malformed number", | ||
425 | }, | ||
426 | ------------------------------------------------------------- | ||
427 | { "single character symbols 1", | ||
428 | "= > < ~ #", | ||
429 | PASS, "1 CHAR = '='\n1 CHAR = '>'\n1 CHAR = '<'\n1 CHAR = '~'\n1 CHAR = '#'\n", | ||
430 | }, | ||
431 | ------------------------------------------------------------- | ||
432 | { "double character symbols", | ||
433 | "== >= <= ~=", | ||
434 | PASS, "1 ==\n1 >=\n1 <=\n1 ~=\n", | ||
435 | }, | ||
436 | ------------------------------------------------------------- | ||
437 | { "simple identifiers", | ||
438 | "abc ABC", | ||
439 | PASS, "1 <name> = abc\n1 <name> = ABC\n1 <eof>", | ||
440 | }, | ||
441 | ------------------------------------------------------------- | ||
442 | { "more identifiers", | ||
443 | "_abc _ABC", | ||
444 | PASS, "1 <name> = _abc\n1 <name> = _ABC\n1 <eof>", | ||
445 | }, | ||
446 | ------------------------------------------------------------- | ||
447 | { "still more identifiers", | ||
448 | "_aB_ _123", | ||
449 | PASS, "1 <name> = _aB_\n1 <name> = _123\n1 <eof>", | ||
450 | }, | ||
451 | ------------------------------------------------------------- | ||
452 | -- NOTE: in Lua 5.1.x, this test is no longer performed | ||
453 | ------------------------------------------------------------- | ||
454 | --{ "invalid control character", | ||
455 | -- "\4", | ||
456 | -- FAIL, ":1: invalid control char near 'char(4)'", | ||
457 | --}, | ||
458 | ------------------------------------------------------------- | ||
459 | { "single character symbols 2", | ||
460 | "` ! @ $ %", | ||
461 | PASS, "1 CHAR = '`'\n1 CHAR = '!'\n1 CHAR = '@'\n1 CHAR = '$'\n1 CHAR = '%'\n", | ||
462 | }, | ||
463 | ------------------------------------------------------------- | ||
464 | { "single character symbols 3", | ||
465 | "^ & * ( )", | ||
466 | PASS, "1 CHAR = '^'\n1 CHAR = '&'\n1 CHAR = '*'\n1 CHAR = '('\n1 CHAR = ')'\n", | ||
467 | }, | ||
468 | ------------------------------------------------------------- | ||
469 | { "single character symbols 4", | ||
470 | "_ - + \\ |", | ||
471 | PASS, "1 <name> = _\n1 CHAR = '-'\n1 CHAR = '+'\n1 CHAR = '\\'\n1 CHAR = '|'\n", | ||
472 | }, | ||
473 | ------------------------------------------------------------- | ||
474 | { "single character symbols 5", | ||
475 | "{ } [ ] :", | ||
476 | PASS, "1 CHAR = '{'\n1 CHAR = '}'\n1 CHAR = '['\n1 CHAR = ']'\n1 CHAR = ':'\n", | ||
477 | }, | ||
478 | ------------------------------------------------------------- | ||
479 | { "single character symbols 6", | ||
480 | "; , . / ?", | ||
481 | PASS, "1 CHAR = ';'\n1 CHAR = ','\n1 CHAR = '.'\n1 CHAR = '/'\n1 CHAR = '?'\n", | ||
482 | }, | ||
483 | ------------------------------------------------------------- | ||
484 | } | ||
485 | ------------------------------------------------------------------ | ||
486 | -- perform a test case | ||
487 | ------------------------------------------------------------------ | ||
488 | function do_test_case(count, test_case) | ||
489 | if comment == "" then return end -- skip empty entries | ||
490 | local comment, chunk, outcome, matcher = unpack(test_case) | ||
491 | local result = PASS | ||
492 | local output = "" | ||
493 | -- initialize lexer | ||
494 | llex.init(chunk, "=test") | ||
495 | -- lexer test loop | ||
496 | repeat | ||
497 | -- protected call | ||
498 | local status, token, seminfo = pcall(llex.llex) | ||
499 | output = output..llex.ln.." " | ||
500 | if status then | ||
501 | -- successful call | ||
502 | if #token > 1 then | ||
503 | if token == "<name>" | ||
504 | or token == "<number>" | ||
505 | or token == "<string>" then | ||
506 | token = token.." = "..seminfo | ||
507 | end | ||
508 | elseif string.byte(token) >= 32 then -- displayable chars | ||
509 | token = "CHAR = '"..token.."'" | ||
510 | else -- control characters | ||
511 | token = "CHAR = (".. string.byte(token)..")" | ||
512 | end | ||
513 | output = output..token.."\n" | ||
514 | else | ||
515 | -- failed call | ||
516 | output = output..token -- token is the error message | ||
517 | result = FAIL | ||
518 | break | ||
519 | end | ||
520 | until token == "<eof>" | ||
521 | -- decision making and reporting | ||
522 | local head = "Test "..count..": "..comment | ||
523 | if matcher == "" then | ||
524 | -- nothing to check against, display for manual check | ||
525 | print(head.."\nMANUAL please check manually".. | ||
526 | "\n--chunk---------------------------------\n"..chunk.. | ||
527 | "\n--actual--------------------------------\n"..output.. | ||
528 | "\n\n") | ||
529 | return | ||
530 | else | ||
531 | if outcome == PASS then | ||
532 | -- success expected, may be a partial match | ||
533 | if string.find(output, matcher, 1, 1) and result == PASS then | ||
534 | if not BRIEF then print(head.."\nOK expected success\n") end | ||
535 | return | ||
536 | end | ||
537 | else | ||
538 | -- failure expected, may be a partial match | ||
539 | if string.find(output, matcher, 1, 1) and result == FAIL then | ||
540 | if not BRIEF then print(head.."\nOK expected failure\n") end | ||
541 | return | ||
542 | end | ||
543 | end | ||
544 | -- failed because of unmatched string or boolean result | ||
545 | local function passfail(status) | ||
546 | if status == PASS then return "PASS" else return "FAIL" end | ||
547 | end | ||
548 | print(head.." *FAILED*".. | ||
549 | "\noutcome="..passfail(outcome).. | ||
550 | "\nactual= "..passfail(result).. | ||
551 | "\n--chunk---------------------------------\n"..chunk.. | ||
552 | "\n--expected------------------------------\n"..matcher.. | ||
553 | "\n--actual--------------------------------\n"..output.. | ||
554 | "\n\n") | ||
555 | end | ||
556 | end | ||
557 | ------------------------------------------------------------------ | ||
558 | -- perform auto testing | ||
559 | ------------------------------------------------------------------ | ||
560 | for i,test_case in ipairs(test_cases) do | ||
561 | do_test_case(i, test_case) | ||
562 | end | ||
563 | end | ||
564 | |||
565 | auto_test() | ||
566 | --]=====] | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/test_lparser_mk2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/test_lparser_mk2.lua deleted file mode 100644 index 11f2827..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/test_lparser_mk2.lua +++ /dev/null | |||
@@ -1,329 +0,0 @@ | |||
1 | --[[-------------------------------------------------------------------- | ||
2 | |||
3 | test_lparser_mk2.lua | ||
4 | Test for lparser_mk2.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 | |||
19 | package.path = "../?.lua;"..package.path | ||
20 | local llex = require "llex_mk2" | ||
21 | local lparser = require "lparser_mk2" | ||
22 | |||
23 | ------------------------------------------------------------------------ | ||
24 | -- dump contents of log table | ||
25 | ------------------------------------------------------------------------ | ||
26 | |||
27 | local function dump_log(fs) | ||
28 | local log = fs.log | ||
29 | for i = 1, #log do | ||
30 | print(log[i]) | ||
31 | end | ||
32 | end | ||
33 | |||
34 | ------------------------------------------------------------------------ | ||
35 | -- try 1 | ||
36 | ------------------------------------------------------------------------ | ||
37 | |||
38 | --[=[ | ||
39 | llex.init("local a = 1", "=string") | ||
40 | lparser.init(llex) | ||
41 | -- nothing is returned, so hope there is an error if problem occurs | ||
42 | local fs = lparser.parser() | ||
43 | dump_log(fs) | ||
44 | --]=] | ||
45 | |||
46 | ------------------------------------------------------------------------ | ||
47 | -- try 2 | ||
48 | ------------------------------------------------------------------------ | ||
49 | |||
50 | -- a slightly larger sample | ||
51 | --[=[ | ||
52 | llex.init([[ | ||
53 | local a = 47 | ||
54 | local b = "hello, world!" | ||
55 | print(a, b) | ||
56 | ]], "@sample.lua") | ||
57 | lparser.init(llex) | ||
58 | -- nothing is returned, so hope there is an error if problem occurs | ||
59 | local fs = lparser.parser() | ||
60 | dump_log(fs) | ||
61 | --]=] | ||
62 | |||
63 | ------------------------------------------------------------------------ | ||
64 | -- automatic dumper of output log data | ||
65 | ------------------------------------------------------------------------ | ||
66 | |||
67 | local test_case = { | ||
68 | -- 1 attempts to exercise most parts, extent of coverage not known | ||
69 | [[ | ||
70 | ]], | ||
71 | -- 2 | ||
72 | [[ | ||
73 | -- foobar | ||
74 | ]], | ||
75 | -- 3 | ||
76 | [[ | ||
77 | do | ||
78 | end | ||
79 | ]], | ||
80 | -- 4 | ||
81 | [[ | ||
82 | do end | ||
83 | do end | ||
84 | ]], | ||
85 | -- 5 | ||
86 | [[ | ||
87 | foo() | ||
88 | foo{} | ||
89 | foo"" | ||
90 | foo:bar() | ||
91 | foo=false | ||
92 | foo.bar=true | ||
93 | foo[true]=nil | ||
94 | foo,bar=1,"a" | ||
95 | ]], | ||
96 | -- 6 | ||
97 | [[ | ||
98 | foo=true | ||
99 | foo=false | ||
100 | foo=nil | ||
101 | foo=1.23e45 | ||
102 | foo=-1 | ||
103 | foo=(0) | ||
104 | foo=1+2 | ||
105 | foo=1+2*3-4/5 | ||
106 | ]], | ||
107 | -- 7 | ||
108 | [[ | ||
109 | if foo then foo=1 end | ||
110 | if foo then foo=1 else foo=0 end | ||
111 | if foo then foo=1 elseif not foo then foo=0 end | ||
112 | ]], | ||
113 | -- 8 | ||
114 | [[ | ||
115 | do return end | ||
116 | do return 123 end | ||
117 | do return "foo","bar" end | ||
118 | ]], | ||
119 | -- 9 | ||
120 | [[ | ||
121 | while true do foo=not foo end | ||
122 | while foo~=42 do foo=foo-1 end | ||
123 | while true do break end | ||
124 | ]], | ||
125 | -- 10 | ||
126 | [[ | ||
127 | repeat foo=foo.."bar" until false | ||
128 | repeat foo=foo/2 until foo<1 | ||
129 | repeat break until false | ||
130 | ]], | ||
131 | -- 11 | ||
132 | [[ | ||
133 | for i=1,10 do foo=i end | ||
134 | for i=1,10,2 do break end | ||
135 | for i in foo do bar=0 end | ||
136 | for i,j in foo,bar do baz=0 end | ||
137 | ]], | ||
138 | -- 12 | ||
139 | [[ | ||
140 | local foo | ||
141 | local foo,bar,baz | ||
142 | local foo,bar="foo","bar" | ||
143 | ]], | ||
144 | -- 13 | ||
145 | [[ | ||
146 | local function foo() return end | ||
147 | local function foo(a) return end | ||
148 | local function foo(x,y,z) return end | ||
149 | local function foo(x,...) return end | ||
150 | ]], | ||
151 | -- 14 | ||
152 | [[ | ||
153 | function foo() return end | ||
154 | function foo(a) return end | ||
155 | function foo(x,y,z) return end | ||
156 | function foo(x,...) return end | ||
157 | ]], | ||
158 | -- 15 | ||
159 | [[ | ||
160 | function foo.bar(p) return end | ||
161 | function foo.bar.baz(p) return end | ||
162 | function foo:bar(p) return end | ||
163 | function foo.bar.baz(p) return end | ||
164 | ]], | ||
165 | -- 16 | ||
166 | [[ | ||
167 | foo = function() return end | ||
168 | foo = function(x,y) return end | ||
169 | foo = function(...) return end | ||
170 | foo = function(...) local bar = ... return end | ||
171 | ]], | ||
172 | -- 17 | ||
173 | [[ | ||
174 | foo = {} | ||
175 | foo = { 1,2,3; "foo"; } | ||
176 | foo = { bar=77, baz=88, } | ||
177 | foo = { ["bar"]=77, ["baz"]=88, } | ||
178 | ]], | ||
179 | -- 18 simple tests for variable management follows | ||
180 | [[ | ||
181 | print(a) | ||
182 | ]], | ||
183 | -- 19 | ||
184 | [[ | ||
185 | local a | ||
186 | print(a) | ||
187 | ]], | ||
188 | -- 20 | ||
189 | [[ | ||
190 | do | ||
191 | local a | ||
192 | print(a) | ||
193 | end | ||
194 | print(a) | ||
195 | ]], | ||
196 | -- 21 | ||
197 | [[ | ||
198 | local a,b,c | ||
199 | do | ||
200 | local b | ||
201 | print(b) | ||
202 | end | ||
203 | print(b) | ||
204 | ]], | ||
205 | -- 22 | ||
206 | [[ | ||
207 | local function foo() end | ||
208 | bar = foo | ||
209 | ]], | ||
210 | -- 23 | ||
211 | [[ | ||
212 | do | ||
213 | local function foo() end | ||
214 | bar = foo | ||
215 | end | ||
216 | baz = foo | ||
217 | ]], | ||
218 | -- 24 | ||
219 | [[ | ||
220 | local foo | ||
221 | local function bar() | ||
222 | baz = nil | ||
223 | foo = bar() | ||
224 | end | ||
225 | foo = bar | ||
226 | ]], | ||
227 | -- 25 | ||
228 | [[ | ||
229 | local foo | ||
230 | local function bar() | ||
231 | local function baz() | ||
232 | local foo, bar | ||
233 | foo = bar | ||
234 | foo = baz | ||
235 | end | ||
236 | foo = bar | ||
237 | foo = baz | ||
238 | end | ||
239 | foo = bar | ||
240 | foo = baz | ||
241 | ]], | ||
242 | -- 26 | ||
243 | [[ | ||
244 | function foo:bar() | ||
245 | print(self) | ||
246 | end | ||
247 | ]], | ||
248 | -- 27 | ||
249 | [[ | ||
250 | function foo(...) | ||
251 | print(arg) | ||
252 | end | ||
253 | ]], | ||
254 | -- 28 | ||
255 | [[ | ||
256 | local c,d | ||
257 | function foo(a,b,c) | ||
258 | print(a,c,d,e) | ||
259 | end | ||
260 | ]], | ||
261 | -- 29 | ||
262 | [[ | ||
263 | function foo(a,b) | ||
264 | local bar = function(c,d) | ||
265 | print(a,b,c,d) | ||
266 | end | ||
267 | end | ||
268 | ]], | ||
269 | -- 30 | ||
270 | [[ | ||
271 | for i = 1,10 do | ||
272 | print(i) | ||
273 | end | ||
274 | for i = 1,10,-2 do | ||
275 | print(i) | ||
276 | end | ||
277 | ]], | ||
278 | -- 31 | ||
279 | [[ | ||
280 | for foo in bar() do | ||
281 | print(foo) | ||
282 | end | ||
283 | for foo,bar,baz in spring() do | ||
284 | print(foo,bar,baz) | ||
285 | end | ||
286 | ]], | ||
287 | } | ||
288 | |||
289 | -- helps to skip old stuff during development of snippets | ||
290 | local do_beg, do_end = 1, #test_case | ||
291 | |||
292 | -- loop for all example snippets | ||
293 | for i = do_beg, do_end do | ||
294 | local fname = "parser_log/sample_"..string.format("%02d", i)..".lua" | ||
295 | local src = test_case[i] | ||
296 | local OUTF = io.open(fname, "wb") | ||
297 | if not OUTF then error("failed to write to file '"..fname.."'") end | ||
298 | -- write out actual source for comparison | ||
299 | OUTF:write( | ||
300 | "-- START OF SOURCE --\n".. | ||
301 | src.. | ||
302 | "-- END OF SOURCE --\n".. | ||
303 | "\n" | ||
304 | ) | ||
305 | -- attempt to parse | ||
306 | llex.init(src, "=string") | ||
307 | lparser.init(llex) | ||
308 | local fs = lparser.parser() | ||
309 | -- grab logged messages and write | ||
310 | local log = fs.log | ||
311 | local indent = 0 | ||
312 | for i = 1, #log do | ||
313 | local ln = log[i] | ||
314 | -- handle indentation | ||
315 | local tag = string.sub(ln, 1, 2) | ||
316 | if tag == ">>" or tag == "<<" then | ||
317 | ln = string.sub(ln, 4) | ||
318 | end | ||
319 | if tag == ">>" then | ||
320 | indent = indent + 1 | ||
321 | end | ||
322 | OUTF:write(string.rep(" ", indent)..ln.."\n") | ||
323 | if tag == "<<" then | ||
324 | indent = indent - 1 | ||
325 | end | ||
326 | end | ||
327 | -- we're done | ||
328 | OUTF:close() | ||
329 | end | ||
diff --git a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/test_lparser_mk2_2.lua b/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/test_lparser_mk2_2.lua deleted file mode 100644 index c135a8c..0000000 --- a/LuaSL/testLua/yueliang-0.4.1/nat-5.1.3/test/test_lparser_mk2_2.lua +++ /dev/null | |||
@@ -1,159 +0,0 @@ | |||
1 | --[[-------------------------------------------------------------------- | ||
2 | |||
3 | test_lparser_mk2_2.lua | ||
4 | Test for lparser_mk2.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.1.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.1.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 | ||
24 | local DEBUG_FAILS = false | ||
25 | |||
26 | ------------------------------------------------------------------------ | ||
27 | -- test the whole kaboodle | ||
28 | ------------------------------------------------------------------------ | ||
29 | |||
30 | package.path = "../?.lua;"..package.path | ||
31 | local llex = require "llex_mk2" | ||
32 | local lparser = require "lparser_mk2" | ||
33 | |||
34 | ------------------------------------------------------------------------ | ||
35 | -- load test cases | ||
36 | ------------------------------------------------------------------------ | ||
37 | |||
38 | dofile("../../test_lua/test_parser-5.1.lua") | ||
39 | |||
40 | local test, expect, heading = {}, {}, {} | ||
41 | local total, total_pass, total_fail = 0, 0, 0 | ||
42 | |||
43 | for ln in string.gfind(tests_source, "([^\n]*)\n") do | ||
44 | if string.find(ln, "^%s*%-%-") then | ||
45 | -- comment, ignore | ||
46 | else | ||
47 | local m, _, head = string.find(ln, "^%s*(TESTS:%s*.*)$") | ||
48 | if m then | ||
49 | heading[total + 1] = head -- informational heading | ||
50 | else | ||
51 | total = total + 1 | ||
52 | local n, _, flag = string.find(ln, "%s*%-%-%s*FAIL%s*$") | ||
53 | if n then -- FAIL test case | ||
54 | ln = string.sub(ln, 1, n - 1) -- remove comment | ||
55 | expect[total] = "FAIL" | ||
56 | total_fail = total_fail + 1 | ||
57 | else -- PASS test case | ||
58 | expect[total] = "PASS" | ||
59 | total_pass = total_pass + 1 | ||
60 | end--n | ||
61 | test[total] = ln | ||
62 | end--m | ||
63 | end--ln | ||
64 | end--for | ||
65 | |||
66 | print("Tests loaded: "..total.." (total), " | ||
67 | ..total_pass.." (passes), " | ||
68 | ..total_fail.." (fails)") | ||
69 | |||
70 | ------------------------------------------------------------------------ | ||
71 | -- verify test cases using native Lua | ||
72 | ------------------------------------------------------------------------ | ||
73 | |||
74 | local last_head = "TESTS: no heading yet" | ||
75 | for i = 1, total do | ||
76 | local test_case, expected, head = test[i], expect[i], heading[i] | ||
77 | -- show progress | ||
78 | if head then | ||
79 | last_head = head | ||
80 | if DEBUG_FAILS then print("\n"..head.."\n") end | ||
81 | end | ||
82 | ------------------------------------------------------------------ | ||
83 | -- perform test | ||
84 | local f, err = loadstring(test_case) | ||
85 | -- look at outcome | ||
86 | ------------------------------------------------------------------ | ||
87 | if f then-- actual PASS | ||
88 | if expected == "FAIL" then | ||
89 | print("\nVerified as PASS but expected to FAIL".. | ||
90 | "\n-------------------------------------") | ||
91 | print("Lastest heading: "..last_head) | ||
92 | print("TEST: "..test_case) | ||
93 | os.exit() | ||
94 | end | ||
95 | ------------------------------------------------------------------ | ||
96 | else-- actual FAIL | ||
97 | if expected == "PASS" then | ||
98 | print("\nVerified as FAIL but expected to PASS".. | ||
99 | "\n-------------------------------------") | ||
100 | print("Lastest heading: "..last_head) | ||
101 | print("TEST: "..test_case) | ||
102 | print("ERROR: "..err) | ||
103 | os.exit() | ||
104 | end | ||
105 | if DEBUG_FAILS then | ||
106 | print("TEST: "..test_case) | ||
107 | print("ERROR: "..err.."\n") | ||
108 | end | ||
109 | ------------------------------------------------------------------ | ||
110 | end--f | ||
111 | end--for | ||
112 | |||
113 | print("Test cases verified using native Lua, no anomalies.") | ||
114 | |||
115 | ------------------------------------------------------------------------ | ||
116 | -- test using Yueliang front end | ||
117 | ------------------------------------------------------------------------ | ||
118 | |||
119 | local last_head = "TESTS: no heading yet" | ||
120 | for i = 1, total do | ||
121 | local test_case, expected, head = test[i], expect[i], heading[i] | ||
122 | -- show progress | ||
123 | if head then last_head = head end | ||
124 | ------------------------------------------------------------------ | ||
125 | -- perform test | ||
126 | llex.init(test_case, "=test_sample") | ||
127 | lparser.init(llex) | ||
128 | |||
129 | local status, func = pcall(lparser.parser) | ||
130 | -- look at outcome | ||
131 | ------------------------------------------------------------------ | ||
132 | if status then-- actual PASS | ||
133 | if expected == "FAIL" then | ||
134 | print("\nTested as PASS but expected to FAIL".. | ||
135 | "\n-----------------------------------") | ||
136 | print("Lastest heading: "..last_head) | ||
137 | print("TEST: "..test_case) | ||
138 | os.exit() | ||
139 | end | ||
140 | ------------------------------------------------------------------ | ||
141 | else-- actual FAIL | ||
142 | if expected == "PASS" then | ||
143 | print("\nTested as FAIL but expected to PASS".. | ||
144 | "\n-----------------------------------") | ||
145 | print("Lastest heading: "..last_head) | ||
146 | print("TEST: "..test_case) | ||
147 | os.exit() | ||
148 | else | ||
149 | io.stdout:write("-") | ||
150 | end | ||
151 | ------------------------------------------------------------------ | ||
152 | end--status | ||
153 | io.stdout:write("\rTesting ["..i.."]...") | ||
154 | end--for | ||
155 | print(" done.") | ||
156 | |||
157 | print("Test cases run on Yueliang, no anomalies.") | ||
158 | |||
159 | -- end | ||