Port Lua to QProcess
ClosedPublic

Authored by rishabhg on Jul 23 2017, 10:27 AM.

Details

Summary
  • setup communication between Cantor and Lua interpreter through QProcess
  • use Lua interpreter for all the calculations
  • use Lua C Api for tab completion

Diff Detail

Repository
R55 Cantor
Lint
Lint Skipped
Unit
Unit Tests Skipped
rishabhg created this revision.Jul 23 2017, 10:27 AM
rishabhg updated this revision to Diff 18836.Aug 27 2017, 9:15 AM

Do not explicitly add 'return' to the commands given by the user.

filipesaraiva requested changes to this revision.EditedOct 7 2017, 11:23 AM

Please, reply the last point. I will address the others.

src/backends/lua/luaexpression.cpp
65

I think we need to use return in order to reproduce the 'interpreter behavior' of Lua in Cantor (that behavior like send-a-command-get-the-answer-without-print-command).

src/backends/lua/luasession.cpp
50

I must ask to Lucas Negri (the original author of this backend) if it is more interesting to use Lua or Luajit.

64–72

Do you have an example where readIntroMessage will be used?

This revision now requires changes to proceed.Oct 7 2017, 11:23 AM
rishabhg added inline comments.Oct 7 2017, 11:35 AM
src/backends/lua/luasession.cpp
64–72

'Lua 5.2.4 Copyright (C) 1994-2015 Lua.org, PUC-Rio', this is the initial message produced when Lua is started.
If we don't do it this way, we will have to parse it in 'readOutput()' function and I can't find any option to suppress this initial message

filipesaraiva added inline comments.Oct 7 2017, 11:36 AM
src/backends/lua/luasession.cpp
64–72

Ah ok! :)

rishabhg added inline comments.Oct 7 2017, 11:55 AM
src/backends/lua/luaexpression.cpp
65

It would be great if we can eliminate the use of 'print' statement from user's side. There's a case where using 'return' statement produces wrong output/behavior, I can't recall that case atm.
We will have to think of cases where user might give a 'print' statement from his/her side. example 'print string.reverse("abcd")' , if we add 'return' to the user input, output will be stdin:1: <eof> expected near 'string'

  • Fix the output for Lua backend
  • Fix the output for Lua backend
filipesaraiva accepted this revision.Oct 7 2017, 2:50 PM

Ok, now it is ok. Please @rishabhg, merge this patch in qprocess_port branch.

This revision is now accepted and ready to land.Oct 7 2017, 2:50 PM

Well, I will push @rishabhg. Maybe I lost the previous changes in this revision. :(

This revision was automatically updated to reflect the committed changes.
filipesaraiva added a subscriber: KDE Edu.

Trying to send a message to Phabricator from e-mail.

Em 07-10-2017 17:26, Filipe Saraiva escreveu:

Trying to send a message to Phabricator from e-mail.

That works :)