interpreter

programming language implemented in pure python

我的未来我决定 提交于 2019-12-04 15:06:52
i am creating ( researching possibility of ) a highly customizable python client and would like to allow users to actually edit the code in another language to customize the running of program. ( analogous to browser which itself coded in c/c++ and run another language html/js ). so my question is , is there any programming language implemented in pure python which i can see as a reference ( or use directly ? ) -- i need simple language ( simple statements and ifs can do ) edit: sorry if i did not make myself clear but what i want is "a language to customize the running of program" , even

Interpreting custom language

天大地大妈咪最大 提交于 2019-12-04 14:34:17
I need to develop an application that will read and understand text file in which I'll find a custom language that describe a list of operations (ie cooking recipe). This language has not been defined yet, but it will probably take one of the following shape : C++ like code (This code is randomly generated, just for example purpose) : begin repeat(10) { bar(toto, 10, 1999, xxx); } result = foo(xxxx, 10); if(foo == ok) { ... } else { ... } end XML code (This code is randomly generated, just for example purpose) : <recipe> <action name="foo" argument"bar, toto, xxx" repeat=10/> <action name="bar

Why list comprehension can be faster than map() in Python?

倾然丶 夕夏残阳落幕 提交于 2019-12-04 12:14:21
I am looking in to the performance issues of the loop like structures in Python and found the following statements: Besides the syntactic benefit of list comprehensions, they are often as fast or faster than equivalent use of map. ( Performance Tips ) List comprehensions run a bit faster than equivalent for-loops (unless you're just going to throw away the result). ( Python Speed ) I am wondering what difference under the hood gives list comprehension this advantage. Thanks. Test one : throwing away the result. Here's our dummy function: def examplefunc(x): pass And here are our challengers:

Deferred evaluation in python

不打扰是莪最后的温柔 提交于 2019-12-04 11:09:16
问题 I have heard of deferred evaluation in python (for example here), is it just referring to how lambdas are evaluated by the interpreter only when they are used? Or is this the proper term for describing how, due to python's dynamic design, it will not catch many errors until runtime? Or am I missing something entirely? 回答1: Dietrich's answer is a good one, but I just want to add that the simplest form of deferred evaluation is the if statement: if True: x = 5 else: x = y # huh? what is y? This

Interpreted languages with manual memory management?

谁说胖子不能爱 提交于 2019-12-04 10:35:22
问题 Which interpreted languages pointer-free languages (IE: Python, Java, Perl, PHP, Ruby, Javascript, etc) have manual memory management? I don't recall ever hearing of one. Isn't the major concern about interpreted languages the non-deterministic delays (or space complexity when there isn't enough delay) of garbage collection? So why not just write something exactly like Java, but forces you free memory manually? EDIT What I mean by manual memory management is that the language would have

What are the tasks of the “reader” during Lisp interpretation?

本秂侑毒 提交于 2019-12-04 09:23:39
问题 I'm wondering about the purpose, or perhaps more correctly, the tasks of the "reader" during interpretation/compilation of Lisp programs. From the pre-question-research I've just done, it seems to me that a reader (particular to Clojure in this case) can be thought of as a "syntactic preprocessor". It's main duties are the expansion of reader macros and primitive forms. So, two examples: 'cheese --> (quote cheese) {"a" 1 "b" 2} --> (array-map "a" 1 "b" 2) So the reader takes in the text of a

if javascript interpreter does “JIT compilation”, does it cache results of it for use on the same script next time I load the website?

北城以北 提交于 2019-12-04 09:14:27
问题 to make it more specific, I mostly care about SpiderMonkey interpreter in Firefox. So suppose I want to speed up the loading of a particular website in my browser or else speed up loading of all websites that have some popular script, e.g. JQuery. Presumably the scripts involved don't change between the page reloads. Will SeaMonkey understand that much and avoid full recompilation? If SpiderMonkey wouldn't, will any other interpreter? Or is this basically a potential new feature which nobody

Why does the Interpreter Pattern suck?

蓝咒 提交于 2019-12-04 09:14:02
问题 In Steve Yegge's review of Design Patterns, he calls the Interpreter Pattern an "in-joke". He goes on to talk about how the perception of compilers have changed, yet how interpreted languages are still s*** on, although I can't see how this ties into the pattern. Anyone want to enlighten this ignorant student? 回答1: That was irony :) Everybody loves interpreted languages nowadays but 10 years earlier people just thought they are too slow for anything practical. Much like today most of people

How can I start an interactive console for VBS?

微笑、不失礼 提交于 2019-12-04 09:00:50
Very similar to this question: How can I start an interactive console for Perl? I just want to be able to start entering VBS statements, one at a time, and have them evaluated straight away, like Python's IDLE. Ansgar Wiechers I wrote this a couple years ago. It's based on this blog post (archived here ), but with a couple enhancements. Essentially it's a REPL (Read, Execute, Print, Loop) using the Execute statement: Do While True WScript.StdOut.Write(">>> ") line = Trim(WScript.StdIn.ReadLine) If LCase(line) = "exit" Then Exit Do On Error Resume Next Execute line If Err.Number <> 0 Then

Interpreter vs. Code Generator Xtext

无人久伴 提交于 2019-12-04 08:53:11
I've a DSL written using Xtext. What I want is to execute that DSL to perform something good out of it. I wrote myDslGenerator class implementing the interface IGenerator in xtend to generate java code and it's working fine. I've two questions; What is the difference between Interpreter and Code Generator? Aren't both for executing DSL? How to write an interpreter? Any step by step tutorial link? I found many tutorial to generate code using xtend but couldn't find any for writing an interpreter. Thank you, Salman Basically, interpreters and code generators work really differently. Code