interpreter

Lua: understanding table array part and hash part

不羁岁月 提交于 2019-12-05 14:55:18
In section 4, Tables, in The Implementation of Lua 5.0 there is and example: local t = {100, 200, 300, x = 9.3} So we have t[4] == nil . If I write t[0] = 0 , this will go to hash part . If I write t[5] = 500 where it will go? Array part or hash part ? I would eager to hear answer for Lua 5.1, Lua 5.2 and LuaJIT 2 implementation if there is difference. Contiguous integer keys starting from 1 always go in the array part. Keys that are not positive integers always go in the hash part. Other than that, it is unspecified, so you cannot predict where t[5] will be stored according to the spec (and

Window doesn't show in python interpreter in GTK3 without Gtk.main()

依然范特西╮ 提交于 2019-12-05 12:47:51
In GTK2, I enjoyed building a gui in the interpreter (ipython or plain python) "on the fly" and seeing the changes in real time like this: >>> import gtk >>> win = gtk.Window() >>> win.connect('delete-event', gtk.main_quit) 10L >>> win.show_all() Which will result in showing a window to which I could add objects. I'm changing to Gtk3 in part because it is the future and in part because I sometimes use Glade which now is only Gtk3. In doing the same with GTK3 DOESN'T show the window: >>> from gi.repository import Gtk >>> win = Gtk.Window() >>> win.connect('delete-event', Gtk.main_quit) 13L >>>

Need a formula interpreter for .Net [closed]

爷,独闯天下 提交于 2019-12-05 07:21:45
I'm looking for a formula interpreter that I can use in a C# application. It needs to be able to interpret a string like this: max(1+2, 4) * x I found Writing a fast formula interpreter (codeproject.com) which almost does what I need but it doesn't allow for functions with multiple parameters. I could probably add that functionality to it but I was just wondering if something like this already exists. Thanks A couple I've used in the past with no problems: NCalc Fast Lightweight Expression Evaluator You can actually build a very effective interpreter by parsing and replacing certain functional

How would I code a complex formula parser manually?

青春壹個敷衍的年華 提交于 2019-12-05 04:31:33
Hm, this is language - agnostic, I would prefer doing it in C# or F#, but I'm more interested this time in the question "how would that work anyway". What I want to accomplish ist: a) I want to LEARN it - it's about my ego this time, it's for a fun project where I want to show myself that I'm a really good at this stuff b) I know a tiny little bit about EBNF (although I don't know yet, how operator precedence works in EBNF - Irony.NET does it right, I checked the examples, but this is a bit ominous to me) c) My parser should be able to take this: 5 * (3 + (2 - 9 * (5 / 7)) + 9) for example and

how to check errors happening inside scala interpreter programatically

谁都会走 提交于 2019-12-05 02:09:29
问题 I am executing scala code snippets using scala.tools.nsc.Interpreter When the code snippet is correct, everything is fine, but when it is buggy, my code is unable to find out and happily goes on. I would like to get an exception or method to call to get any error that happened during last evaluation by the interpreter. my code: import scala.tools.nsc.Interpreter import scala.tools.nsc.Settings object RuntimeEval { def main(args: Array[String]): Unit = { var msg = "fail" val eval = new

Any C/C++ to non-native bytecode compiler/interpreters?

时间秒杀一切 提交于 2019-12-05 02:01:57
As the title indicates, are there any C/C++ bytecode compilers/interpreters? I'm writing an application in an interpreted language that depends on certain libraries that are fully cross-compilable (there are no special flags to indicate code changes during compilation for a certain platform) but are written in C and C++. Rather than shipping n-platform-specific-libs with each platform, it would be nice to ship one set of libs which are interpreted by one platform specific interpreter. Possible and/or available? EDIT1: The interpreted language in question is Python, though I may also use Ruby.

How can I start the python console within a program (for easy debugging)?

空扰寡人 提交于 2019-12-05 00:16:25
问题 After years of research programming in Matlab, I miss the way I could pause a program mid-execution and inspect the variables, do plotting, save/modify data, etc. via the interactive console, and then resume execution. Is there a way to do the same thing in python? For example: # ... python code ... RunInterpreter # Interactive console is displayed, so user can inspect local/global variables # User types CTRL-D to exit, and script then continues to run # ... more python code ... This would

Interpret something, and run the generated bytecode in Java?

只谈情不闲聊 提交于 2019-12-04 23:10:08
问题 I'm writing a toy interpreter with a REPL in Java. I'd like to generate bytecode from the language and run that, instead of interpreting an AST and running that instead. Since my Java is a bit rusty, is it possible to run generated bytecode on the fly on the JVM? 回答1: You can use java.lang.Classloader.defineClass(), which turns bytecode into a Class object. You can the call newInstance() on the resulting Class object, and off you go. 回答2: Have a look at Javassist which contains a snippet

Restarting a Python Interpreter Quietly

做~自己de王妃 提交于 2019-12-04 21:47:41
问题 I have a python interpreter embedded inside an application. The application takes a long time to start up and I have no ability to restart the interpreter without restarting the whole application. What I would like to do is to essentially save the state of the interpreter and return to that state easily. I started by storing the names of all modules in sys.modules that the python interpreter started with and then deleting all new modules from sys.modules when requested. This appears to make

How can I interpret strings in textarea with JavaScript/jQuery?

时间秒杀一切 提交于 2019-12-04 18:50:45
I am trying to make a small interpreting program with JavaScript/jQuery. So what I want is that when the user enter some text in the textarea the program should interpret that text and print the output in another text area. Till now I have achieved this: https://jsfiddle.net/7462hbv1/ With this I am able to catch each of the string that the user inputs in the text area. But now I want that when the user for example enter: number a =1 number b=2 number sum=0 sum =a +b print sum the program should interpret this and the output should be 3 in this case. Can anyone give me any idea how can I do