interpreter

How to call the scala interpreter in a Simple Build Tool project?

和自甴很熟 提交于 2019-12-03 11:04:10
问题 my scala program is using the compiler interface from scala.tools.nsc.interpreter.IMain. When I am compiling with scalac, everything works as expected. But when I compile with sbt it still compiles, but on execution it throws the following error message in the call of the interpret-method from the IMain instance: Failed to initialize compiler: object scala not found. ** Note that as of 2.8 scala does not assume use of the java classpath. ** For the old behavior pass -usejavacp to scala, or if

Interpreter for the iPhone?

99封情书 提交于 2019-12-03 10:59:01
I'm interesting in making an interpreter for the iPhone. It will be an experimental idea but could be great. I like the idea of making my own language geared towards on-the-go computing and mathematics. I've read around and I have seen mixed information about interpreters on the iphone. What will Apple allow? I've seen this app which is a nice idea but doesn't work apparently - http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=415827304&mt=8&u1=web&affId=1860684 Thank you for any reply. In the meantime I'll produce some ideas for this language. Apple started officially allowing

Persistent Python Command-Line History

丶灬走出姿态 提交于 2019-12-03 09:59:16
问题 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

Proof of the Futamura projections in Haskell

我们两清 提交于 2019-12-03 09:28:02
问题 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

What are motivations behind compiling to byte-code?

与世无争的帅哥 提交于 2019-12-03 09:13:15
问题 I'm working on my own toy programming language. For now I'm interpreting the source language from AST and I'm wondering what advantages compiling to a byte-code and then interpreting it could provide me. For now I have three things in mind: Traversing the syntax tree hundreds of time may be slower than running instructions in an array, especially if the array support O(1) random access(ie. jumping 10 instructions up and down). In typed execution environment, I have some run-time costs because

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

三世轮回 提交于 2019-12-03 08:49:21
问题 Are there any JavaScript (ECMAScript) implementations written in pure Python? It is okay even if its implementation is very slow. 回答1: 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 回答2: 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

Detecting infinite loop in brainfuck program

夙愿已清 提交于 2019-12-03 08:29:28
问题 I have written a simple brainfuck interpreter in MATLAB script language. It is fed random bf programs to execute (as part of a genetic algorithm project). The problem I face is, the program turns out to have an infinite loop in a sizeable number of cases, and hence the GA gets stuck at the point. So, I need a mechanism to detect infinite loops and avoid executing that code in bf. One obvious (trivial) case is when I have [] I can detect this and refuse to run that program. For the non-trivial

What is the process of creating an interpreted language? [duplicate]

跟風遠走 提交于 2019-12-03 08:08:10
This question already has answers here : Learning to write a compiler [closed] (40 answers) I want to create a very simple experimental programming language. What are some resources can i check out to get an overview of the process of creating an interpreted language. I will be using c++ to build and compile the interpreter. You need to implement both a parser and an interpreter. There is a great free text book called "Programming Languages: Application and Interpretation" that uses scheme to build increasingly more complex interpreters. It also serves as a great introduction to programming

Access the Abstract Syntax Tree of V8 Engine

无人久伴 提交于 2019-12-03 07:42:39
问题 Is it possible to access the AST of the v8 engine, for a given JavaScript code? I'm working on a JavaScript Static Analyzer using V8 engine. 回答1: This is pretty old but maybe the answer helps someone stumbling upon this. The answer is yes, assuming you are willing to modify V8 and compile your own version of it. If so, then in compiler.cc you find a spot where MakeCode is called throughout MakeFunctionInfo which transforms the AST that is stored in the passed in CompilationInfo object into

Custom interpreter for mathematical expressions

天涯浪子 提交于 2019-12-03 07:30:26
问题 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