interpreter

How to handle a stackoverflow?

♀尐吖头ヾ 提交于 2019-12-13 00:19:43
问题 I'm trying to fix up the error handling in my postscript interpreter, and I'm having difficulty coming up with ways for the handler to execute when one of the stacks is full. The postscript-level handler procedure I'm using is the "standard" one described in Frank Merritt Braswell, Inside Postscript. /.error { //$error exch /errorname exch put //$error exch /command exch put //$error /newerror true put //$error /errorname get /VMerror ne { //$error /ostackarray get null eq { //$error

How to implement closures into a LISP interpreter

守給你的承諾、 提交于 2019-12-12 19:55:09
问题 I'm currently working on a LISP interpreter written in Java. Now I stuck at the closures. I want to enable closures like this: (define a 1000) (define closure (lambda (a) (lambda (b) (+ a b)))) (define x (closure 10)) (x 20) --> 30 So, (x 20) should return 30 . But, guess what, it returns 1020 in my interpreter. I think the mistake is in my lambda class. It looks like this: public class LLambda extends LOperation { private LList parameters; private LList definitions; public LLambda(LList

Why the id of an object would change depending on the line in the python shell

痞子三分冷 提交于 2019-12-12 18:11:25
问题 This questions is just out of curiosity. While I was reading the python's object model documentation, I decided to experiment a little with the id of a class method and found this behavior: Python 3.2.2 (default, Sep 4 2011, 09:07:29) [MSC v.1500 64 bit (AMD64)] on win32 Type "copyright", "credits" or "license()" for more information. >>> class A(): def a(self): pass >>> id(A().a) 54107080 >>> id(A().a) 54108104 >>> id(A().a) 54107080 >>> id(A().a) 54108104 >>> >>> id(A().a) 54108104 >>> >>>

Execution tree meta interpreting

末鹿安然 提交于 2019-12-12 16:15:27
问题 I have tracing meta-interpreter made from my previous questions here and I would like to make similar meta-interpreter but this time for making execution trees. I've made something like this below using similar to same code found on the web and techniques from my previous questions. clause_tree(true,_,true) :- !, true. clause_tree((G,R),Trail,(TG,TR)) :- !, clause_tree(G,Trail,TG), clause_tree(R,Trail,TR). clause_tree(G,_,prolog(G)) :- (predicate_property(G,built_in) ; predicate_property(G

Ocaml representation of values - Atoms

霸气de小男生 提交于 2019-12-12 12:11:06
问题 I looked at the internal representation of some OCaml values. The representation of an empty array is an atom(0) , i.e. a block with tag=0 and size=0 . Empty arrays of floats are represented by an atom(0) too. Is there any OCaml value represented by an atom with tag > 0 ? If not: for what purpose the OCaml bytecode set contains the ATOM n instruction? 回答1: A tag > 0 is used for constructors with arguments, which would make them not atoms. Constructors without arguments on the other hand are

Are there any simple languages implemented using ANTLR or similar?

帅比萌擦擦* 提交于 2019-12-12 10:41:46
问题 I'm trying to build a simple interpreted language for learning purposes. I've read countless theory and tutorials on ANTLR and JavaCC, but I can't figure out how to actually make it do something useful. I learn best by "taking something apart and putting it back together again", so, are there any working examples of simple languages implemented with the help of tools such as ANTLR, or similar? Something like the following might be nice: x = 1 if x == 1 print "true" 回答1: [shameless plug] Why

Picking a front-end/interpreter for a scientific code

六眼飞鱼酱① 提交于 2019-12-12 08:05:02
问题 The simulation tool I have developed over the past couple of years, is written in C++ and currently has a tcl interpreted front-end. It was written such that it can be run either in an interactive shell, or by passing an input file. Either way, the input file is written in tcl (with many additional simulation-specific commands I have added). This allows for quite powerful input files (e.g.- when running monte-carlo sims, random distributions can be programmed as tcl procedures directly in the

Interpreter for the iPhone?

你。 提交于 2019-12-12 07:45:44
问题 I'm interesting in making an interpreter for the iPhone. It will be an experimental idea but could be great. I like the idea of making my own language geared towards on-the-go computing and mathematics. I've read around and I have seen mixed information about interpreters on the iphone. What will Apple allow? I've seen this app which is a nice idea but doesn't work apparently - http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=415827304&mt=8&u1=web&affId=1860684 Thank you for

Pycharm running Kivy applications

南楼画角 提交于 2019-12-12 04:55:17
问题 I'm running Pycharm 3.4.1 and i just downloaded the Kivy 1.8.0 for python 2.7 pack for windows. http://kivy.org/#download I chose the kivy interpreter as my python interpreter for the project: C:\Python_Kivy_1.8.0\Python27\python.exe The problem i'm having is that i can't get my Pycharm to run or recognize Kivy at all. There is no auto-completion when writing code and it can't execute via Pycharm. The only way i can execute the program is by running the python file with the kivy.bat file, and

How to make “print” statement to print multiple strings Javascript?

∥☆過路亽.° 提交于 2019-12-12 03:35:11
问题 I am trying to make a small interpreter for print statement. Here is a demo of what I have done till now: DEMO What I want to reach now is to print multiple string connected with + like: print "My book" + "is" + "xx" print a (where a is varible name) print a + "is my number" I have tried something till now and build something but I have two problems: First I tried to build a new print regexp: /^ *print +(?:"([^"]*)"|([a-zA-Z]\w*)) *(.*)$/ so this will match the print statement, the first