@@ -212,50 +212,44 @@ describe("lexer", function()
212212 })
213213 end )
214214 it (" can parse a simple function" , function ()
215- assert .same (lexer :match (" func();" ), {{type = " function_call" ,
215+ assert .same (lexer :match (" func();" ), {{type = " function_call" , {
216216 {type = " variable" , " func" }
217- }})
218- end )
219- it (" can parse a simple generated function loop" , function ()
220- assert .same (lexer :match (" func(a in b);" ), {{type = " function_call" ,
221- {type = " variable" , " func" },
222- generator = {
223- {type = " variable" , " b" },
224- variable_list = {{type = " variable" , " a" }}
225- }
226- }})
227- end )
228- it (" can parse a complex generated function loop" , function ()
229- assert .same (lexer :match (" func(a for a in b);" ), {{type = " function_call" ,
230- {type = " variable" , " func" },
231- generator = {
232- {type = " variable" , " b" },
233- expression_list = {{type = " variable" , " a" }},
234- variable_list = {{type = " variable" , " a" }}
217+ }}})
218+ end )
219+ it (" can parse chained functions" , function ()
220+ assert .same (lexer :match (" func().two():three().four:five();" ), {{
221+ type = " function_call" , {
222+ {type = " variable" , " func" }
223+ }, {
224+ {type = " variable" , " two" }
225+ }, {
226+ has_self = " three"
227+ }, {
228+ {type = " variable" , " four" },
229+ has_self = " five"
235230 }
236231 }})
237232 end )
238233 it (" can parse arguments passed to a function" , function ()
239234 assert .same (lexer :match (" func(test, test_two);" ), {
240- {type = " function_call" ,
235+ {type = " function_call" , {
241236 {type = " variable" , " func" },
242237 expression_list = {
243238 {type = " variable" , " test" },
244239 {type = " variable" , " test_two" }
245- }
240+ }}
246241 }
247242 })
248243 end )
249244 it (" can parse a complex function call" , function ()
250- assert .same (lexer :match (" table.instance:method<subclass> (argument);" ), {
251- {type = " function_call" ,
245+ assert .same (lexer :match (" table.instance:method(argument);" ), {
246+ {type = " function_call" , {
252247 {type = " variable" , " table" , " instance" }, -- tables parse -this- way
253248 expression_list = {
254249 {type = " variable" , " argument" }
255250 },
256- has_self = " method" ,
257- index_class = " subclass"
258- }
251+ has_self = " method"
252+ }}
259253 })
260254 end )
261255 it (" can parse a non-generated table" , function ()
@@ -300,13 +294,13 @@ describe("lexer", function()
300294 {type = " variable" , " z" },
301295 operator = " .."
302296 },
303- {type = " function_call" ,
297+ {type = " function_call" , {
304298 {type = " variable" , " y" },
305299 expression_list = {
306300 {type = " variable" , " a" },
307301 {type = " variable" , " b" }
308302 }
309- }
303+ }}
310304 }
311305 }}
312306 }
@@ -326,21 +320,21 @@ describe("lexer", function()
326320 it (" can parse while loops" , function ()
327321 assert .same (lexer :match (" while true print('hi!');" ), {
328322 {type = " while_loop" ,
329- {type = " function_call" ,
323+ {type = " function_call" , {
330324 {type = " variable" , " print" },
331325 expression_list = {{type = " sqstring" , " hi!" }}
332- },
326+ }} ,
333327 condition = {type = " boolean" , true }
334328 }
335329 })
336330 end )
337331 it (" can parse numeric for loops" , function ()
338332 assert .same (lexer :match (" for (i=1, 100, 5) print(i);" ), {
339333 {type = " numeric_for_loop" ,
340- {type = " function_call" ,
334+ {type = " function_call" , {
341335 {type = " variable" , " print" },
342336 expression_list = {{type = " variable" , " i" }}
343- },
337+ }} ,
344338 start = {type = " number" , 1 , base = " 10" },
345339 stop = {type = " number" , 100 , base = " 10" },
346340 step = {type = " number" , 5 , base = " 10" },
@@ -352,10 +346,10 @@ describe("lexer", function()
352346 assert .same (lexer :match (" for (i in x) print(i);" ), {
353347 {type = " iterative_for_loop" ,
354348 {type = " variable" , " x" },
355- {type = " function_call" ,
349+ {type = " function_call" , {
356350 {type = " variable" , " print" },
357351 expression_list = {{type = " variable" , " i" }}
358- },
352+ }} ,
359353 variable_list = {{type = " variable" , " i" }}
360354 }
361355 })
@@ -465,25 +459,25 @@ describe("lexer", function()
465459 it (" can parse simple if statements" , function ()
466460 assert .same (lexer :match (" if x print('test');" ), {{type = " if" ,
467461 condition = {type = " variable" , " x" },
468- {type = " function_call" ,
462+ {type = " function_call" , {
469463 {type = " variable" , " print" },
470464 expression_list = {{type = " sqstring" , " test" }}
471- },
465+ }} ,
472466 [" elseif" ] = {}
473467 }})
474468 end )
475469 it (" can parse complex if statements" , function ()
476470 assert .same (lexer :match (" if x print('test'); else print(x);" ), {
477471 {type = " if" ,
478472 condition = {type = " variable" , " x" },
479- {type = " function_call" ,
473+ {type = " function_call" , {
480474 {type = " variable" , " print" },
481475 expression_list = {{type = " sqstring" , " test" }}
482- },
483- [' else' ] = {type = " function_call" ,
476+ }} ,
477+ [' else' ] = {type = " function_call" , {
484478 {type = " variable" , " print" },
485479 expression_list = {{type = " variable" , " x" }}
486- },
480+ }} ,
487481 [" elseif" ] = {}
488482 }
489483 })
0 commit comments