interpreter

Understanding how Python “Compiles” or “Interprets” Function Objects

时间秒杀一切 提交于 2019-12-02 18:41:05
问题 I have read the following posts but I am still unsure of something. Python Compilation/Interpretation Process Why python compile the source to bytecode before interpreting? If I have a single Python file myfunctions.py containing the following code. x = 3 def f(): print x x = 2 Then, saying $ python myfunctions.py runs perfectly fine. But now make one small change to the above file. The new file looks as shown below. x = 3 def f(): print x x = 2 f() # there is a function call now This time,

Are there any tutorials on building a simple interpreter using Alex + Happy?

六眼飞鱼酱① 提交于 2019-12-02 18:30:51
I'm working on a school project where I have to build an interpreter for a simple language using Alex + Happy in Haskell. After looking through the documentation I understand most of it, but would like to see a full blown example on using the tools. Not on building interpreters, but on building lexers and parsers, yes. See the example for a lexical analyzer in Alex, here , combined with an intro to Happy here . I found the haskell.x and haskell.y files distributed in the darcs repos for Alex and Happy useful. You can find those here and here. I wrote a series of posts at bjbell.wordpress.com

Compiler Vs Interpreter Vs Transpiler

折月煮酒 提交于 2019-12-02 17:53:58
During a reactJs session that I was attending, the presenter used a term transpiler for some code conversion/porting happening. I've always used and heard the terms compiler and interpreter when it comes to converting a language code to a runnable form on a computer system/machine. Transpiler is completely new to me. Can someone help me to understand how a Transpiler is different from a compiler or an interpreter and why it is really needed? As is mentioned in this Wiki article , it is a type of compiler which translates source code from one programming language to another programming language

How does code written in one language get called from another language

廉价感情. 提交于 2019-12-02 17:21:18
This is a question that I've always wanted to know the answer, but never really asked. How does code written by one language, particularly an interpreted language, get called by code written by a compiled language. For example, say I'm writing a game in C++ and I outsource some of the AI behavior to be written in Scheme. How does the code written in Scheme get to a point that is usable by the compiled C++ code? How is it used by the C++ source code, and how is it used by the C++ compiled code? Is there a difference in the way it's used? Related How do multiple-languages interact in one project

What is the difference between compilation and interpretation?

霸气de小男生 提交于 2019-12-02 17:18:40
I just had a conversation with a colleague and where were talking about the V8 JavaScript engine. According to Wikipedia, V8 compiles JavaScript to native machine code [...] before executing it, instead of more traditional techniques such as interpreting bytecode or compiling the whole program to machine code and executing it from a filesystem. where (correct me if I'm wrong) " interpreting bytecode " is the way Java works, and " compiling the whole program " would apply for languages like C or C++. Now we were wondering, debating and posing false assertions and presumptions about differences,

How does one implement a “stackless” interpreted language?

不想你离开。 提交于 2019-12-02 16:22:45
I am making my own Lisp-like interpreted language, and I want to do tail call optimization. I want to free my interpreter from the C stack so I can manage my own jumps from function to function and my own stack magic to achieve TCO. (I really don't mean stackless per se, just the fact that calls don't add frames to the C stack. I would like to use a stack of my own that does not grow with tail calls). Like Stackless Python, and unlike Ruby or... standard Python I guess. But, as my language is a Lisp derivative, all evaluation of s-expressions is currently done recursively (because it's the

What does PyPy have to offer over CPython, Jython, and IronPython?

被刻印的时光 ゝ 提交于 2019-12-02 16:17:07
From what I have seen and read on blogs, PyPy is a very ambitious project. What are some advantages it will bring to the table over its siblings (CPython, Jython, and IronPython)? Is it speed, cross-platform compatibility (including mobile platforms), the ability to use c-extensions without the GIL, or is this more of a technical exercise on what can be done? PyPy is really two projects: An interpreter compiler toolchain allowing you to write interpreters in RPython (a static subset of Python) and have cross-platform interpreters compiled standalone, for the JVM, for .NET (etc) An

Measure and Benchmark Time for Ruby Methods

淺唱寂寞╮ 提交于 2019-12-02 15:01:40
How can i measure the time taken by a method and the individual statements in that method in Ruby. If you see the below method i want to measure the total time taken by the method and the time taken for database access and redis access. I do not want to write Benchmark.measure before every statement. Does the ruby interpreter gives us any hooks for doing this ? def foo # code to access database # code to access redis. end You could use the Time object. ( Time Docs ) For example, start = Time.now # code to time finish = Time.now diff = finish - start diff would be in seconds, as a floating

create my own programming language [duplicate]

自作多情 提交于 2019-12-02 13:59:40
Possible Duplicates: References Needed for Implementing an Interpreter in C/C++ How to create a language these days? Learning to write a compiler I know some c++, VERY good at php, pro at css html, okay at javascript. So I was thinking of how was c++ created I mean how can computer understand what codes mean? How can it read... so is it possible I can create my own language and how? If you're interested in compiler design ("how can computer understand what codes mean"), I highly recommend Dragon Book . I used it while in college and went as far as to create programming language myself. "Every

Variable assigned to the last executed line? [closed]

让人想犯罪 __ 提交于 2019-12-02 12:42:08
问题 It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center. Closed 7 years ago . I just found something weird in the Python interpreter. Let me show you: $ python Python 2.7.1+ (r271:86832, Apr 11 2011, 18:13:53) [GCC 4.5.2] on linux2 Type "help", "copyright", "credits" or "license" for more