Lua unexpected identifier issue in VSC - lua

i was transfering code from my tablet's ide to VSC to tweak it and continue it on PC but i've ran into an issue. I'm trying to define a variable by using local xyz = 0 but it keeps returning SyntaxError: Unexpected identifier when i try to run it but it worked perfectly fine on my mobile IDE. (on pc i'm using Visual Studio Code with the Lua extension by sumneko and on pc i was using an app called TouchLua+)debug console output
i've tried looking it up on google but there were no posts describing any similar issue

It's hard to say without more code or context(not familiar with the touchapp) but this as a standalone piece of lua is valid.
However notice your debug screenshot, you are executing a piece of lua with nodejs, Look at the cli
C:\ProgramFiles\nodejs\node.exe RPSbot.lua
^ ^
| |
Path to node |
your lua file given to the node.exe
Unsure if there is some other js process that you used on your tablet that ran lua via nodejs or you are trying this from js yourself. But nodejs is intended for javascript files.
Using node on this piece of code produces the same error. You should run this using the lua runtime. If you haven't already, you can download lua here, be sure to add it to your path if needed.
Then you can run it from cli as following:
lua RPSbot.lua
Or create a batch script to call it by name without lua before it, i.e. create a file called RPSbot.cmd or RPSbot.bat and place calling code in it lua RPSbot.lua. The calling code might need to use the full path to lua and your script. Then you can just run that batch script each time.
If it is intended to run trough node you might need to provide more code and/or context.

Use Zerobranestudio or jdoodle. I give up to compile Lua with vsc.

Related

Can't debug using Informix 4GL Interactive Debugger

I am pretty new to Informix and I have a program that I am adding some functionality to.
It seems that the program has some existing issues with it though.
When I run make -f makefile.mk I get success and the .4ge gets generated and I am able to run it.
However I am trying to get the program to run within informix 4gl interactive debugger but I get the error: Invalid module name [main] specified.
Any assistance would be greatly appreciated. Unfortunately I am unable to share code as the program contains confidential information
The Informix-4GL Interactive Debugger (ID) is for debugging programs compiled with the Informix-4GL Rapid Development System (RDS). The object files created by RDS (fglpc) have the extension .4go (I4GL p-code object file) and the executables are conventionally given the extension .4gi (I4GL p-code interpretable file — run using fglgo or ID's fgldb).
By contrast, the plain Informix-4GL (c-code) system uses an I4GL compiler to generate first ESQL/C code and then C code, and a C compiler to create regular object files (.o) and to create its executables, which are conventionally given the extension .4ge (I4GL c-code executable).
The ID cannot debug c-code executables. It can only debug p-code interpretable files.
On the face of it, therefore, your problem is that you are using the wrong tool for the job. Either you need to compile with RDS and create an interpretable, or you need to use a C code debugger such as GDB. However, be warned that debugging I4GL code with GDB is mainly an exercise in frustration as the bulk of the code is a series of function calls to library functions — or is an incredibly tortuous sequence of goto statements if you're debugging inside an I4GL report function. It is machine-generated C code; it is not intended to be comprehensible to humans.

How to run Derric

I'm trying to run Derric with command
import lang::derric::testparse;
I followed all instructions and got everything to work with eclipse and Rascal. I am running the rascal console with Derric. I have tried downloading older versions of eclipse, used windows 7, and windows 10. Nothing is working, I even read the rascal tutorial on modules to see if everything looks right and it does. I need it to work for a school assignment, if someone can get it to run can you tell me under which circumstances (i.e eclipse version, windows version, steps taken) to run the program?
rascal>import lang::derric::testparse;
Error: Cannot import module lang::derric::testparse
Time: 484ms
ok
rascal>
It's suppose to say ok at the end, and then I can run command generate().
Hi #yoyo great that you are trying Rascal, but you need to give more explanation about what you are trying to do. There are potentially two main causes of the message you get:
the module is correct but it cannot be found, or
the module is incorrect (e.g. it does not even parse correctly).
It would therefore be helpful if you show
where lang::derric::testparse is located in your file system, and
to show its contents.
As a side question: is there any relation with the Derric language (a DSL for file formats) Jeroen van den Bos has been working on a few years ago?

How can I run dart2js dynamically in a Dart server web app?

I want to compile dart code to JS on-the-fly without invoking dart2js at the command line. Eg., (written in Dart) read in some dart code from a file and transform it to JS (must be in memory, filesystem is not writable).
I thought maybe dart2js would effectively just be a cli over a pub package I can call manually, but I can't find any information on doing this at runtime :(
(note: I know this idea sucks and it'll be very slow; it's just for something I'm prototyping and will ultimately use dart2js normally, I just can't address that yet)
https://try-dart-lang.appspot.com/ does this. The source is available. Its basically dart2js run through dart2js.
Not sure if this is the right repository https://github.com/peter-ahe-google/orphan-try
I guess Peter would be ok with pinging him about more information.
The project was replaced by pub.dartlang.org which uses a service running on the server https://github.com/dart-lang/dart-services where source is posted to for dart2js translation.

Lua obfuscator, how to

I understand this question will appear silly but I'm clueless what to do, which makes it even more silly. I have written a lua script for a game - which works, but I've never actually run any lua with the lua programs(from the site download). I would like to obfuscate my lua code with this tool: https://github.com/mlnlover11/XFuscator but I'm unsure how to do it, I tried running the lua program and browsing there, dropping the xfuscator file on top of the program etc but nothing has given any result.How should I do it?
Open a command line (e.g. under windows, that's cmd). Go into the directory where you have your local copy of XFuscator. Make sure lua is on your PATH. Type
lua XFuscator.lua -h
This should show the help message, which will describe the next steps.

Lua Debugger that can Attach to Process

My company has a program that uses Lua embedded in its runtime, loading up .lua files from disk and executing functions defined in them repeatedly.
Is there a way to attach to the running process and set breakpoints in my .lua files? (I'd accept either gdb-style command-line debugging as part of the Lua distribution, or perhaps a third-party IDE that provides Visual-Studio-like GUI breakpoints.)
Or is what I'm asking for entirely nonsensical and impossible given the nature of the runtime loading up random files from disk?
Edit: Looks like it's not nonsensical, given that Lua's own debug.getinfo() function can determine the source file for a given function, and debug.sethook() allows a callback for each new line of code entered. So, it's reasonable to load source code from disk and be able to tell when the interpreter is executing a particular line of code from that file. The question remains: how do I latch onto an existing process that has a Lua interpreter and inject my own trace function (which can then watch for file/line number pairs and pause execution)?
If you can modify the .lua files, you can insert the following call just before anything you need to debug:
require 'remdebug.engine'.start()
It starts the RemDebug Lua debugger engine and tries to connect to a controller. If it cannot connect, it will just continue running as normal. I did some fixes to the debugger engine, such as dealing with temporary variables, and my student is working on a debugger GUI (due next year).
In the meantime, you can try if Lua Development Tools works for you. It features a debugger similar to RemDebug, which should be possible to set up as follows:
require("debugger")(host, port, idekey)
Alternatively, you can use SciTE-debug, which is an extension to the SciTE editor, and can serve as a controller to RemDebug. Just make sure you insert the call to remdebug.engine.start somewhere in your Lua code and insert this into the SciTE output window:
:debug.target=remote.lua
When you start your program, SciTE should show the source and current line.
I've been using Decoda editor for that. It allows you to attach to a running C++ application, after that it detects that you're running a Lua Interpreter within your C++ code and show your Lua source code, where you can add beakpoints and inspect variables as usual.
This is an alternative I use after much searching. If you have an external executable that loads lua, I got this working in a few minutes. The op is very responsive, it has an interactive debugger which loads your code you can place debug points interactively. It doesn't have an editor, but I use scite or crimson editor and start the executable, one line in your main lua module enables the debugger.
http://www.cushy-code.com/grld/ - this link seems dead now
I've moved to eclipse.org/ldt it has an ide and integrated debugger, recommended
hth
The Lua plugin for IntelliJ has a working debugger with no special setup required other than pointing to your Lua interpreter.
Here's a screencast of it:
http://www.screencast.com/t/CBWIkoZPg
Similar to what Michal Kottman described, I have implemented a debugger based on RemDebug, but with additional fixes and features (on github: https://github.com/pkulchenko/MobDebug).
You can update your .lua file with require("mobdebug").start("localhost", 8171) at the point where you want the debugging to start. You can then use the command line debugger to execute commands, set breakpoints, evaluate/execute expressions and so on.
As an alternative, you can use ZeroBrane Studio IDE, which integrates with the debugger and gives you a front-end to load your code and execute same debugger commands in a nice GUI. If you want to see the IDE in action, I have a simple demo here: http://notebook.kulchenko.com/zerobrane/live-coding-in-lua-bret-victor-style.
You should probably use Decoda.
Go to Debug -> Processes -> Attach to attach your process. This should work fine.
Well the easiest way is this, thanks to the genius author
https://github.com/slembcke/debugger.lua
you don't need to setup a remote debug server ,just require one file,and simplely call dbg() and it will pause,just like gdb
an tutorial is also shipped with it, check it out.

Resources