interpreter

When implementing an interpreter, is it a good or bad to piggyback off the host language's garbage collector?

Let's say you are implementing an interpreter for a GCed language in a language that is GCed. It seems to me you'd get garbage collection for free as long as you are reasonably careful about your design. Is this generally how it's done? Are there good reasons not to do this? ...

How do scripting languages set/modify/read out variables?

Assuming the interpreter for the language (Can be anything from PHP to Ruby) is written in C. How are variables (or more complex data structures not only containg name and value), which are defined by the script that is currently being executed, stored and read out? I, with my rather poor knowledge of C, would end up with the conclusion...

Interpreting a variable number of tree nodes in ANTLR Tree Grammar

Whilst creating an inline ANTLR Tree Grammar interpreter I have come across an issue regarding the multiplicity of procedure call arguments. Consider the following (faulty) tree grammar definition. procedureCallStatement : ^(PROCEDURECALL procedureName=NAME arguments=expression*) { if(procedureName.equals("foo...

Using a debugger and curses at the same time?

I'm calling python -m pdb myapp.py, when an exception fires, and I'd normally be thrown back to the pdb interpreter to investigate the problem. However this exception is being thrown after I've called through curses.wrapper() and entered curses mode, rendering the pdb interpreter useless. How can I work around this? ...

Is there an alternative for flex/bison that is usable on 8-bit embedded systems?

Hi, I'm writing a small interpreter for a simple BASIC like language as an exercise on an AVR microcontroller in C using the avr-gcc toolchain. However, I'm wondering if there are any open source tools out there that could help me writing the lexer and parser. If I would write this to run on my Linux box, I could use flex/bison. Now th...

Operators and methods in Ruby

Most things that look like operators are methods in Ruby; 1 + 2 is syntactic sugar for 1.+(2). Even though + and * are methods that a program can redefine, Ruby has special magic to evaluate 1 + 2 * 3 as 1.+(2.*(3)) instead of 1.+(2).*(3). I wonder where this special magic lives in Ruby--if it is hard-wired into the interpreter. Ari. ...

Deferred evaluation in python

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? ...

What kind of advantages are there to changing 'cond' to be a special form

What kind of advantages are there to changing 'cond' to be a special form instead of syntactic sugar? ...

How does an interpreter/compiler work

How does an interpreter/compiler work? What is the difference between interpreter and compiler. ...

Runtime definition

What is the runtime? And I don't mean "at run time" = as the program/script is running. I mean The <your-interpreted-language-here> runtime ...

In Javascript/jQuery, is there a difference in rendering performance if I condense my code into "one-liners"?

Is there a difference in performance (I am not asking about readability) if I condense my code into one line versus two? For example: var slide = 'images/' + n + '.png'; $('img').attr('src',slide); versus $('img').attr('src','images/' + n + '.png'); Personally, I like fewer lines of code. Often, I am the only one reading my co...

Understanding run time code interpretation and execution

I'm creating a game in XNA and was thinking of creating my own scripting language (extremely simple mind you). I know there's better ways to go about this (and that I'm reinventing the wheel), but I want the learning experience more than to be productive and fast. When confronted with code at run time, from what I understand, the usual ...

What are the differences between a Just-in-Time-Compiler and an Interpreter?

What are the differences between a Just-in-Time-Compiler and an Interpreter, and are there differences between the .NET and the JAVA JIT compiler? ...

Embed python interpreter in a python application

Hi, i'm looking for a way to ship the python interpreter with my application (also written in python), so that it doesn't need to have python installed on the machine. I searched google and found a bunch of results about how to embed the python interpreter in applications written in various languages, but nothing for applications writte...

Where can these be posted besides the Python Cookbook?

Whitespace Assembler #! /usr/bin/env python """Assembler.py Compiles a program from "Assembly" folder into "Program" folder. Can be executed directly by double-click or on the command line. Give name of *.WSA file without extension (example: stack_calc).""" ##############################################################################...

Interpret a rule applying multiple xpath queries on multiple XML documents

Hi, I need to build a component which would take a few XML documents in input and check the following kind of rules: XML1:/bookstore/book[price>35.00] != null and (XML2:/city/name = 'Montreal' or XML3://customer[@language] contains 'en') Basically my component should be able to: substitute the XML tokens with the correspondin...

programming language implemented in pure python

hi, 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 ...

Languages and VMs: Features that are hard to optimize and why

I'm doing a survey of features in preparation for a research project. Name a mainstream language or language feature that is hard to optimize, and why the feature is or isn't worth the price paid, or instead, just debunk my theories below with anecdotal evidence. Before anyone flags this as subjective, I am asking for specific examples ...

Statement hierarchy in programming languages

I quickly wrote an interpreter for some sort of experimental programing language i came up with, in PHP (yes, in PHP). The language itself doesn't have anything really special, I just wanted to give it a try. I got the basic things working (Hello World, input to output, string manipulation, arithmetics) but I'm getting stuck with the ma...

How do interpreters written in C and C++ bind identifiers to C(++) functions

I'm talking about C and/or C++ here as this are the only languages I know used for interpreters where the following could be a problem: If we have an interpreted language X how can a library written for it add functions to the language which can then be called from within programs written in the language? PHP example: substr( $str, 5,...