D12074: Solve problem of appearance input of interpreter in interpreter's output in Lua backend

Nikita Sirgienko noreply at phabricator.kde.org
Wed Apr 25 21:03:58 UTC 2018


sirgienko added a comment.


  In D12074#253885 <https://phabricator.kde.org/D12074#253885>, @asemke wrote:
  
  > This all looks a bit strange...
  
  
  Well, in fact this is a problem of incorrect parse end condition, which produce false positive errors.
  I add printing of readed line from backend whatever make it clear.
  
    final command to be executed  "function fib(n)\n  if n < 2 then return 1 end\n  return fib(n - 2) + fib(n - 1)\nend\n\n-- Closures and anonymous functions are ok:\nfunction adder(x)\n  -- The returned function is created when adder is\n  -- called, and remembers the value of x:\n  return function (y) return x + y end\nend\na1 = adder(9)\na2 = adder(36)\nprint(a1(16))  --> 25\nprint(a2(64))  --> 100\n" 
    
    QSizeF(937, 397) QSizeF(937, 297)
    newLine:  "function fib(n)\n"
    newLine:  ">>   if n < 2 then return 1 end\n"
    newLine:  ">>   return fib(n - 2) + fib(n - 1)\n"
    newLine:  ">> end\n"
    newLine:  "> \n"
    newLine:  "> -- Closures and anonymous functions are ok:\n"
    newLine:  "> function adder(x)\n"
    newLine:  ">>   -- The returned function is created when adder is\n"
    newLine:  ">>   -- called, and remembers the value of x:\n"
    newLine:  ">>   return function (y) return x + y end\n"
    newLine:  ">> end\n"
    newLine:  "> a1 = adder(9)\n"
    newLine:  "> a2 = adder(36)\n"
    newLine:  "> "
    parsing the output  "function fib(n)\n>>   if n < 2 then return 1 end\n>>   return fib(n - 2) + fib(n - 1)\n>> end\n> \n> -- Closures and anonymous functions are ok:\n> function adder(x)\n>>   -- The returned function is created when adder is\n>>   -- called, and remembers the value of x:\n>>   return function (y) return x + y end\n>> end\n> a1 = adder(9)\n> a2 = adder(36)\n> "
    final output of the command  "function fib(n)\n  if n < 2 then return 1 end\n  return fib(n - 2) + fib(n - 1)\nend\n\n-- Closures and anonymous functions are ok:\nfunction adder(x)\n  -- The returned function is created when adder is\n  -- called, and remembers the value of x:\n  return function (y) return x + y end\nend\na1 = adder(9)\na2 = adder(36)\nprint(a1(16))  --> 25\nprint(a2(64))  --> 100" :  ""
  
  Command `a2 = adder(36)` not last, but after this command we read `> ` (lua printing lag) and it satisfy parse end condition. So, backend finish the first command and run next, and then:
  
    QSizeF(937, 157) QSizeF(937, 126)
    newLine:  "print(a1(16))  --> 25\n"
    newLine:  "25\n"
    newLine:  "> print(a2(64))  --> 100\n"
    newLine:  "100\n"
    newLine:  "> "
    parsing the output  "print(a1(16))  --> 25\n25\n> print(a2(64))  --> 100\n100\n> "
    final output of the command  "function bar(a, b, c)\n  print(a, b, c)\n  return 4, 8, 15, 16, 23, 42\nend\n\nx, y = bar('zaphod')  --> prints \"zaphod  nil nil\"" :  "print(a1(16))  --> 25\n25\nprint(a2(64))  --> 100\n100"
  
  We set tail of previous command as result for two command.
  And then:
  
    newLine:  "function bar(a, b, c)\n"
    newLine:  ">>   print(a, b, c)\n"
    newLine:  ">>   return 4, 8, 15, 16, 23, 42\n"
    newLine:  ">> end\n"
    newLine:  "> \n"
    newLine:  "> x, y = bar('zaphod')  --> prints \"zaphod  nil nil\"\n"
    newLine:  "zaphod\tnil\tnil\n"
    newLine:  "> "
    parsing the output  "function bar(a, b, c)\n>>   print(a, b, c)\n>>   return 4, 8, 15, 16, 23, 42\n>> end\n> \n> x, y = bar('zaphod')  --> prints \"zaphod  nil nil\"\nzaphod\tnil\tnil\n> "
    final output of the command  "function bar(a, b, c)\n  print(a, b, c)\n  return 4, 8, 15, 16, 23, 42\nend\n\nx, y = bar('zaphod')  --> prints \"zaphod  nil nil\"" :  "zaphod\tnil\tnil" 
  
  The backend set result again.
  
  In D12074#253921 <https://phabricator.kde.org/D12074#253921>, @asemke wrote:
  
  > In D12074#253885 <https://phabricator.kde.org/D12074#253885>, @asemke wrote:
  >
  > > This all looks a bit strange...
  >
  >
  > The problem was in LuaSession::readOutput(). The patch F5822387: lua_multiline_output_3.patch <https://phabricator.kde.org/F5822387>
  >
  >   handles the outputs correctly. @sirgienko Does it also work for you?
  
  
  No, output have changed, but still have problems:
  F5822390: изображение.png <https://phabricator.kde.org/F5822390>

REPOSITORY
  R55 Cantor

REVISION DETAIL
  https://phabricator.kde.org/D12074

To: sirgienko, #cantor, asemke
Cc: #cantor, #kde_edu, narvaez, apol
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-edu/attachments/20180425/a45e6d41/attachment.html>


More information about the kde-edu mailing list