interpreter

Persistent Python Command-Line History

 ̄綄美尐妖づ 提交于 2019-12-02 23:07:41
I'd like to be able to "up-arrow" to commands that I input in a previous Python interpreter. I have found the readline module which offers functions like: read_history_file , write_history_file , and set_startup_hook . I'm not quite savvy enough to put this into practice though, so could someone please help? My thoughts on the solution are: (1) Modify .login PYTHONSTARTUP to run a python script. (2) In that python script file do something like: def command_history_hook(): import readline readline.read_history_file('.python_history') command_history_hook() (3) Whenever the interpreter exits,

How to implement LOOP in a FORTH-like language interpreter written in C

痞子三分冷 提交于 2019-12-02 22:59:51
I'm writing a simple stack-based language in C and was wondering how I should go about implementing a loop structure of some kind, and/or lookahead symbols. Since the code is a bit long for this page (over 200 lines) I've put it in a GitHub repository . EDIT: The main program is in file stack.c . EDIT: The code just takes in input in words , kind of like FORTH. It uses scanf and works left to right. Then it uses a series of if s and strcmp s to decide what to do. That's really it. The Forth approach is to add a separate loop stack alongside the data stack. You then define operations that work

Is there a JavaScript (ECMAScript) implementation written in Python?

巧了我就是萌 提交于 2019-12-02 22:41:34
Are there any JavaScript (ECMAScript) implementations written in pure Python? It is okay even if its implementation is very slow. There is one, of an unknown level of completeness, written in RPython (a subset of Python, that is to say, it runs as normal Python): https://bitbucket.org/pypy/lang-js/overview Doesn't seem to be under active development anymore but you could check out pynarcissus , http://code.google.com/p/pynarcissus/source/browse/trunk/jsparser.py Seems like a binding to V8 (JavaScript interpreter in Google Chromium) is available also, http://www.advogato.org/article/985.html

Proof of the Futamura projections in Haskell

若如初见. 提交于 2019-12-02 22:23:14
I read Dan Piponi's excellent blog post on The Three Projections of Doctor Futamura . Towards the end of the article he has an appendix with a proof of the Futamura projections in Haskell. However, I find his article lacking information about the languages involved. What must the source, target and object languages of the specializer be in order for the Futamura projections to work? For example, would the Futamura projections work if I wrote a Haskell to LLVM specializer in Haskell? It would be helpful if you wrote a Haskell program to prove this just like Dan Piponi did in his article. Yes,

Custom interpreter for mathematical expressions

这一生的挚爱 提交于 2019-12-02 22:20:31
I have to evaluate a large number of expressions containing variables and I am thinking about writing a small custom interpreter to keep compilation fast and small. However I have no experience with this topic and have a few questions. Say we have a file with mathematical expressions and a limited set of objects. The file could look like: expr[x,y,z] = 2*x*y + x^2 + 28/14*z*(x*y^2 + 15*z) + ... I'd like to parse this somehow so I can evaluate the expressions numerically in my application by simply calling a function expr(float x, float y, float z) . The number of parameters should not be fixed

Difference between a Java interpreter and JVM

时间秒杀一切 提交于 2019-12-02 22:16:46
I have heard people saying "a JVM is necessarily a Java interpreter but a Java interpreter is not necessarily a JVM". Is that true? I mean is there a difference between a Java interpreter and JVM? YoK Yes, there is a difference. Java virtual machine: A software "execution engine" that safely and compatibly executes the byte codes in Java class files on a microprocessor (whether in a computer or in another electronic device). Java interpreter: A module that alternately decodes and executes every statement in some body of code. The Java interpreter decodes and executes bytecode for the Java

Include jar file in Scala interpreter

徘徊边缘 提交于 2019-12-02 20:24:36
Is it possible to include a jar file run running the Scala interpreter? My code is working when I compile from scalac: scalac script.scala -classpath *.jar But I would like to be able to include a jar file when running the interpreter. According to scala executable help all options of scalac are allowed , so you can run scala -classpath some.jar , i've just tried and it looks like it works Eastsun In scala2.8,you can use scala>:jar JarName.jar to add a jar to the classpath. In Scala 2.8.1, it is not :jar but :cp And in Scala 2.11.7 it is not :cp but :re(quire) Include multiple jars int Scala

Bundle Python app without interpreter

烂漫一生 提交于 2019-12-02 19:29:03
问题 I have a Python script with just minimal import (=psutil) and have bundled it with py2app. However, the resulting app is almost 9 MB because it includes the interpreter. I am looking for ways to reduce the size - the best way I can think of is to exclude the interpreter from the bundle and let the app use the client's native interpreter. Right now I am doing it only for Mac but will need to do it for all platforms. I have looked at squeeze ( http://effbot.org/zone/squeeze.htm ) but it seems

Is there a quick-starting Haskell interpreter suitable for scripting?

∥☆過路亽.° 提交于 2019-12-02 19:22:49
Does anyone know of a quick-starting Haskell interpreter that would be suitable for use in writing shell scripts? Running 'hello world' using Hugs took 400ms on my old laptop and takes 300ms on my current Thinkpad X300. That's too slow for instantaneous response. Times with GHCi are similar. Functional languages don't have to be slow: both Objective Caml and Moscow ML run hello world in 1ms or less. Clarification : I am a heavy user of GHC and I know how to use GHCi. I know all about compiling to get things fast. Parsing costs should be completely irrelevant: if ML and OCaml can start 300x

How do I run a python interpreter in Emacs?

拈花ヽ惹草 提交于 2019-12-02 18:57:01
I just downloaded GNU emacs23.4, and I already have python3.2 installed in Windows7. I have been using Python IDLE to edit python files. The problem is that I can edit python files with Emacs but I do not know how to run python interpreter in Emacs. When i click on "switch to interpreter", then it says "Searching for program: no such file or directory, python" Someone says i need to make some change on .emacs file, but i do not know where to look for. And I am very unexperienced and just started to learn programming. I am not familiar with commonly used terminologies. I have been searching for