interpreter

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

孤街浪徒 提交于 2019-12-04 08:11:18
问题 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. 回答1: The

What language can a junior programmer implement an interpreter for it?

笑着哭i 提交于 2019-12-04 08:05:39
My college is going to start soon, but I want to do something in the remaining weeks :) I've taken a course last semester about programming languages and I want to bring my knowledge into reality. What simple , elegant language can a junior programmer implement an interpreter for? I don't mind if the language is very small or experimental. RPAL compiles down to lambda expressions, which can then be interpreted. assembly I'm not talking about compiling it to machine code. Just an interpreter. We did it in first year, but the prof wrote the virtual machine, but you can still write it on your own

create my own programming language [duplicate]

◇◆丶佛笑我妖孽 提交于 2019-12-04 07:25:59
问题 This question already has answers here : Closed 9 years ago . 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? 回答1: If you're interested in compiler design (

Is it possible to explicitly free memory with JVM Bytecode?

 ̄綄美尐妖づ 提交于 2019-12-04 06:12:24
There are several computer programming languages using JVM bytecode as, lets say, target language for their interpreter/compilers. It seems to me that many new programming languages (less than 15 years old) run over JVM and I wonder whether explicit memory deallocation is forbidden for all of them: Is it possible to explicitly allocate-deallocate memory using in bytecode through any instruction? Is, on de contrary, the garbage collector always resposible for memory liberation? The JVM abstracts away all memory management. There is no bytecode for memory deallocation, just as there is no

Will the Javascript performance improvements from Trace Trees find their way into other interpreted languages?

别说谁变了你拦得住时间么 提交于 2019-12-04 05:09:38
It sounds like Mozilla is having good luck improving JavaScript performance with TraceMonkey . See also Andreas Gal's paper on Trace Trees . Are these improvements available to other interpreters/compilers and if so, does this mean we'll see a cascade of improvements in other interpreted languages? There's a research JVM by Andreas Gal called HotPath , and some people from his team are currently working on adding nested trace tree based JITting to Maxine (Sun's new research JVM written in Java) and HotSpot. So, at least it is showing up in other VMs for other languages as well. Also, the new

Converting bytes to string with str() returns string with speech marks

↘锁芯ラ 提交于 2019-12-04 05:04:30
问题 Say I have a variable containing bytes: >>> a = b'Hello World' It can be verified with: >>> type(a) <class 'bytes'> Now I try and convert a into a string with str() : >>> b = str(a) and sure enough it is a string: >>> type(b) <class 'str'> Now I try and print b but I get a totally unexpected result: >>> print(b) b'Hello World' It returns a string, as I would expect but also it keeps the b (byte symbol) and the ' (quotation marks). Why does it do this, and not just print the message between

global.eval is not able to visit variables in the lexical scope. Does the behavior comply ECMAScript standard?

China☆狼群 提交于 2019-12-04 05:03:11
问题 I have a JavaScript file, e.js var global = Function('return this')(); var i = 1; console.log(eval("100-1")); console.log(eval("i")); console.log(global.eval("100-1")); console.log(global.eval("i")); When I execute it by V8: $ node e.js 99 1 99 undefined:1 i ^ ReferenceError: i is not defined at eval (eval at <anonymous> (/private/tmp/xxxx/e.js:8:20), <anonymous>:1:1) at eval (native) at Object.<anonymous> (/private/tmp/xxxx/e.js:8:20) at Module._compile (module.js:456:26) at Object.Module.

How to determine which Python install is being used by the interpreter? [duplicate]

廉价感情. 提交于 2019-12-04 03:48:46
问题 This question already has answers here : Find full path of the Python interpreter? (3 answers) Closed 3 years ago . I have several software packages that install various installs of Python. For example: C:\Python27\ArcGIS10.1 C:\Python27\ArcGIS10.2 C:\Python27|ArcGISx6410.1 Using sys.version does not work for my case since I need to know where the actual install is located, not the version. How can I determine which install my Python interpreter is using? 回答1: What you want is sys.executable,

How do Ruby and Python implement their interactive consoles?

眉间皱痕 提交于 2019-12-04 03:44:54
When implementing the interpreter for my programming language I first thought of a simple console window which allows the user to enter some code which is then executed as a standalone program as a shell. But there are severe problems: If every line of code the user enters is handled as a standalone program, it has to go through the tokenizer and parser and is then just executed by the interpreter - what about functions then? How can the Python/Ruby interactive consoles (IDLE, irb) "share" the code? How is the code entered handled? Example: >> def x: >> print("Blah") >> >> x() Where is the

How programs written in interpreted languages are executed if they are never translated into machine language?

做~自己de王妃 提交于 2019-12-04 03:28:23
问题 Computers can only understand machine language. Then how come interepreters execute a program directly without translating it into machine language? For example: <?php echo "Hello, World!" ; It's a simple Hello World program written in PHP. How does it execute in machine while the machine has no idea what echo is? How does it output what's expected, in this case, the string Hello, World!? 回答1: Many interpreters, including the official PHP interpreter, actually translate the code to a byte