problem about interpreter-Collection of common programming errors
Peter Taylor
code-golf interpreter
Given a file named hello_world that contains 2-100 bytes of printable ASCII, create a Turing-complete language in which hello_world is a valid program that prints
Peter Taylor
code-golf interpreter
The challenge is to write an interpreter for the untyped lambda calculus in as few characters as possible. We define the untyped lambda calculus as follows:SyntaxThere are the following three kinds of expressions:A lambda expression has the form (λ x. e) where x could be any legal variable name and e any legal expression. Here x is called the parameter and e is called the function body.For simplicity’s sake we add the further restriction that there must not be a variable with the same name as x currently in scope. A variable starts to be in scope when its name appears between (λ and . and stops to be in scope at the corresponding ). Function application has the form (f a) where f and a are legal expressions. Here f is called the function and a is called the argument. A variable has the form x where x is a legal variable name.SemanticsA function is applied by replacing each occurrence of the parameter in the functions body with its argument. More formally an expression of the form ((λ x. e) a), where x is a variab
FUZxxl
code-golf quine interpreter
There are many challenges that say “interpret x”, where X is a simple language. In my opinion, that is way top boring. To give all the procrastinating people on the internet something interesting to do, you can try to do this challenge:ChallengeChoose a language $LANG. $LANG can be any turing complete programming language or a turing complete subset of a programming language. Beware that if you omit a feature of your language in $LANG for interpretation, you must not use it for your own programm, too, since your submission must be written in
Nemo157
code-golf interpreter
The program will be provided as the first argument, stdin should be used for all read requests by the program and stdout for all write requests. It can be assumed that the program is less than 80 characters wide and less than 25 lines high.~ should push -1 if there is nothing to read. Any pop off the bottom of the list should simply return 0, including for any calculations. For p and g, x and y are 0 based indices. Input should be fully buffered, i.e. & and ~ block the program until EOF is encountered on stdin then any remaining input is kept to serve future requests.The following commands must be available:0-9 Push this number on the stack+ Addition: Pop a then b, push a+b- Subtraction: Pop a then b, push b-a* Multiplication: Pop a then b, push a*b/ Int
Peter Taylor
code-golf interpreter
There are many formalisms, so while you may find other sources useful I hope to specify this clearly enough that they’re not necessary.A RM consists of a finite state machine and a finite number of named registers, each of which holds a non-negative integer. For ease of textual input this task requires that the states also be named.There are three types of state: increment and decrement, which both reference a specific register; and terminate. An increment state increments its register and passes control to its one successor. A decrement state has two successors: if its register is non-zero then it decrements it and passes control to the first successor; otherwise (i.e. register is zero) it simply passes control to the second successor.For “niceness” as a programming language, the terminate states take a hard-coded string to print (so you can indicate exceptional termination).Input is from stdin. The input format consists of one li
sepp2k
code-golf interpreter
Write the shortest program in your favourite language to interpret a Brainfuck program. The program is read from a file. Input and output are standard input
Bobo
haskell boolean interpreter short-circuiting
I’m building a call by name Haskell interpreter and I want to implement a function short :: Val -> Exp -> Error Val that will evaluate a value applied to an expression. I don’t want to evaluate the second arguments of the short-circuited boolean binary operators (i.e. ((&&) False
Jonathan Leffler
c language-design interpreter coroutine
I’m adding coroutine support to an interpreter I’m writing and I’d like to do something like the following:typedef enum {bar_stuff,bar_other} Bar;typedef enum {foo_error=-1,foo_none=0,foo_again} Foo_state;Foo_state do_foo(Bar bar,Foo_state foo){switch(foo){case foo_none: //startswitch(bar){case bar_stuff://do stuffreturn foo_none;case bar_other://do other stuffreturn foo_again;case foo_again: //!! this doesn’t work/* edit: this is supposed to be a case of* switch(foo), not switch(bar
Thomas Larsen
c++ c interpreter
At the moment I am considering whether or not to rewrite a programming language interpreter that I maintain in C++. The interpreter is currently implemented in C.But I was
vainolo
javascript interpreter
My question is based on the example from a book “Object Oriented JavaScript” (page 81 – Lexical Scope)So, i understand from this example …func
Loïc Février
java javascript c gwt interpreter
Is there any C interpreter written in javascript or java ?I don’t need a full interpreter but I need to be able to do a step by step execution of the program and being able to see the values of variables, the stack…all that in a web interface.The idea is to help C beginners by showing them the step by step execution of the program. We are using GWT to build the interface so
ljackman
parsing lisp scheme implementation interpreter
I’m currently implementing a web-based Scheme environment for the kicks and giggles. Whilst implementing the parser, I stumbled across an oddity: some Scheme implementations state that a number’s digits are read until a delimiter is met, but t
tehgeekmeister
javascript programming-languages metaprogramming interpreter
I’ve been building a basic live-evaluation javascript development environment (I call it the WEPL.) over the past few days, and realized it’d be nice to be able to associate error messages to line numbers. Unfortunately, eval() doesn’t provide a nice way to do this, th
jcubic
javascript eval interpreter
It should be simple to create JavaScript intepreter in JavaScript using eval. I got this (using jQuery terminal):term = $(‘#term_demo’).terminal(function(command, term) {if (command !== ”) {var
katrielalex
orb
javascript oop interpreter modularity prototypal-inheritance
I am trying to write a javaScript application that is of sufficient size that modularity is probably a good idea. I am using the famous inherit function to enable objects to inherit from constructors that have parameters. The problem is I get an error that the parent being passed into the inherit function is undefined. This is because, well, the parent constructor hasn’t been defined when inherit is called.I have come up with a few ugly solutions to this problem:Declare all child constructors after their parent (yuk). Bind all prototype assignments to a custom event and use an ordered callback chain to ensure all the prototypes are assigned in order (perhaps there is potential there). Move all prototype assignments from the area in the code that their constructor lives and consolidate (and exile) them to some ‘assign prototypes’ function (twice the yuk of item one, no?).The bottom li
Luke Sapan
javascript date input format interpreter
I was looking for a convenient method to take a date entered by a user and do the following:1) Determine if the Date entered is valid, and if it is valid, return an object with:2) A JavaScript Date object3) The date formatted in mySQL for
Anisha
ruby eclipse interpreter
I just installed the Ruby plugin for Eclipse, but ran into problems selecting the interpreter on my first project.I
hakre
php interpreter var-dump
Last time I’m exploring PHP pretty much and I was curious if it’s possible to define variable without initializing it like in C++.Well interpreter doesn’t output an fatal eror (only a notice that variable test is undefined) if I’ll run this code:And
Yaba
java interpreter smalltalk executor
I am trying to convert this Java interpreter I wrote for my compiler to a Smalltalk interpreter. Is it possible? If so, what would be a good resources to look at? I am completely new to Smalltalk, looks weird to me for now. I would appreciate any help, thanks. Some more info on the program: The input would be an intermediate code file a sample of which is as below.Intermediate code file, which computes the factorial of a number:read store x push x store i push 1.0 store fact push i push 1.0 greater testfgoto 21 push fact push i multiply store fact push i push 1.0 minus store i push 1.0 testtgoto 7 push fact print endJavaExecutor.java Program :public void executor(){String operation = null;StringTokenizer tokens = null;String key,value = null;Double tempVar = null;// Traverse the Arraylist to get the operationsfor(int i=0; i < operations.size(); i++){operation = (String)operations.get(i);System.out.println(“Operation ——-“+ operation);tokens = new StringTokenizer(operation);while(tokens.hasMoreTokens()){key = tokens.nextToken();//System.out.prin
sub
c++ design-patterns interpreter
I’ve created an interpreter for a stupid programming language in C++ and the whole core structure is finished (Tokenizer, Parser, Interpreter including Symbol tables, core functions, etc.).Now I have a problem with creating and managing the function libraries for this interpreter (I’ll explain what I mean with that later) So currently my core function handler is horrible:// Simplified version myLangResult SystemFunction( name, argc, argv ) {if ( name == “print” ){if( argc < 1 ){Error(‘blah’);}cout
Calvin Cheng
javascript python llvm interpreter emscripten
I am reading through the tutorial for emscripten here – https://github.com/kripken/emscripten/wiki/Tutorial as well as checking out some of the demo projects in the source on my local machine.So far, I have downloaded the source and set my .emscripten settings file appropriately.I am searching for a reference to find out: what are the series of emcc commands needed, in order to create/output the “python.cc.js” and “python.html”? Appreciate any tips from developers who have tried out emscripten before.Here’s my .emscripten file:EMSCRIPTEN_ROOT = os.path.expanduser(‘~/Dev/emscripten’) # this helps projects using emscripten find it# LLVM_ROOT = os.path.expanduser(‘~/Dev/llvm-3.0/cbuild/bin’) LLVM_ROOT = os.path.expanduser(‘/opt/local/bin’)# See below for notes on which JS engine(s) you need NODE_JS = ‘node’ SPIDERMONKEY_ENGINE = [os.path.expanduser(‘~/Dev/mozilla-central/js/src/js’), ‘-m’, ‘-n’] V8_ENGINE = os.path.expanduser(‘~/Dev/v8/d8’)CLOSURE_COMPILER = os.path.expanduser(‘~/work/closure-compiler/compiler.jar’) # optional (needed for the benchmarks)TEMP_DIR = ‘/tmp’######################################################################################################### Pick the JS engine to use for running the compiler. This engine must exist, or # nothing can be compiled. # # Recommendation: If you already have node installed, use that. Otherwise, build v8 or # spidermonkey from source. Any of these three is fine, as long as it’s # a recent version (especially for v8 and spidermonkey).COMPILER_ENGINE = NODE_JS #COMPILER_ENGINE = V8_ENGINE #COMPILER_ENGINE = SPIDERMONKEY_ENGINE# All JS engines to use when running the automatic tests. Not all the engines in this list # must exist (if they don’t, they will be skipped in the test runner). # # Recommendation: If you already have node installed, use that. If you can, also build # spidermonkey from source as well to get more test coverage (node can’t # run all the tests due to node issue 1669). v8 is currently not recommended # here because of v8 issue 1822.JS_ENGINES = [NODE_JS, SPIDERMONKEY_ENGINE]And here’s the emconfigure ./configure command that I am running:calvins-MacBook ttys000 Sun Feb 05 11:47:32 |~/community/Python-2.7.2| calvin$ emconfigure ./configure checking for –enable-universalsdk… no checking for –with-universal-archs… 32-bit checking MACHDEP… darwin checking EXTRAPLATDIR… $(PLATMACDIRS) checking machine type as reported by uname -m… x86_64 checking for –without-gcc… no checking for gcc… /Users/calvin/work/emscripten/emcc checking whether the C compiler works… no configure: error: in `/Users/calvin/community/Pyt
Will Ness
lambda scheme interpreter
I am trying to write an interpreter for Scheme using Scheme, I implemented if let define statements and some other numerical operations, but I have no idea how to start to implement lambda procedure. Below is my current situation. It would be much appreciated if you can point me into the right direction.(define get-operator (lambda (op-symbol)(cond((equal? op-symbol ‘+) +)((equal? op-symbol ‘-) -)((equal? op-symbol ‘*) *)((equal? op-symbol ‘/) /)(else (error “s6-interpret: operator not implemented –>” op-symbol)))))(define if-stmt?
Originally posted 2013-11-09 23:31:55.