Search Results

Search found 636 results on 26 pages for 'interpreter'.

Page 1/26 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Scala Interpreter scala.tools.nsc.interpreter.IMain Memory leak

    - by Peter
    I need to write a program using the scala interpreter to run scala code on the fly. The interpreter must be able to run an infinite amount of code without being restarted. I know that each time the method interpret() of the class scala.tools.nsc.interpreter.IMain is called, the request is stored, so the memory usage will keep going up forever. Here is the idea of what I would like to do: var interpreter = new IMain while (true) { interpreter.interpret(some code to be run on the fly) } If the method interpret() stores the request each time, is there a way to clear the buffer of stored requests? What I am trying to do now is to count the number of times the method interpret() is called then get a new instance of IMain when the number of times reaches 100, for instance. Here is my code: var interpreter = new IMain var counter = 0 while (true) { interpreter.interpret(some code to be run on the fly) counter = counter + 1 if (counter > 100) { interpreter = new IMain counter = 0 } } However, I still see that the memory usage is going up forever. It seems that the IMain instances are not garbage-collected by the JVM. Could somebody help me solve this issue? I really need to be able to keep my program running for a long time without restarting, but I cannot afford such a memory usage just for the scala interpreter. Thanks in advance, Pet

    Read the article

  • Interpreter in C++: Function table storage problem

    - by sub
    In my interpreter I have built-in functions available in the language like print exit input, etc. These functions can obviously be accessed from inside the language. The interpreter then looks for the corresponding function with the right name in a vector and calls it via a pointer stored with its name. So I gather all these functions in files like io.cpp, string.cpp, arithmetic.cpp. But I have to add every function to the function list in the interpreter in order for it to be found. So in these function files I have things like: void print( arg ) { cout << arg.ToString; } I'd add this print function to the interpreter function list with: interpreter.AddFunc( "print", print ); But where should I call the interpreter.AddFunc? I can't just put it there below the print function as it has to be in a function according to the C++ syntax. Where and how should all the functions be added to the list?

    Read the article

  • Simplest language to make an interpreter for

    - by None
    I want to make an interpreter of a very simple language for practice. When I say simple I don't mean easy to use, I mean simple. Brainf**k is a good example of a language I want. I already have made a brainf**k interpreter in python (which is the language I would be using to write the interpreter). I would appreciate any suggestions of simple languages. Note: I don't want to make a compiler! I want to make an interpreter.

    Read the article

  • Best Java library(ies) for forgiving command interpreter

    - by vkraemer
    I am looking for a library or set of libraries that will help me write a forgiving command interpreter. A forgiving command interpreter would be a command interpreter which can deal with simple and even not so simple spelling and word order mistakes in the input. My goal is to have an interpreter which would take the input (a command) from a user and then: execute the command, if it is correct. apply corrections to the command, until a correct command is generated and then present that command to the user to confirm whether it is 'what the user meant'.

    Read the article

  • Interpreter typing in C

    - by typus
    I'm developing an interpreter and I have some questions to it. I recently saw a small C interpreter that used a very simple struct like the below for all its objects/values in the language: struct Object { ubyte type; ubyte value; }; This struct can hold strings, integers, bools and lists (I think) used in the language the interpreter is working with. How can you get this Object struct to hold all these types?

    Read the article

  • Implementing Brainf*ck loops in an interpreter

    - by sub
    I want to build a Brainf*ck (Damn that name) interpreter in my freshly created programming language to prove it's turing-completeness. Now, everything is clear so far (<+-,.) - except one thing: The loops ([]). I assume that you know the (extremely hard) BF syntax from here on: How do I implement the BF loops in my interpreter? How could the pseudocode look like? What should I do when the interpreter reaches a loop beginning ([) or a loop end (])? Checking if the loop should continue or stop is not the problem (current cell==0), but: When and where do I have to check? How to know where the loop beginning is located? How to handle nested loops? As loops can be nested I suppose that I can't just use a variable containing the starting position of the current loop. I've seen very small BF interpreters implemented in various languages, I wonder how they managed to get the loops working but can't figure it out.

    Read the article

  • Make a Perl-style regex interpreter behave like a basic or extended regex interpreter

    - by Barry Brown
    I am writing a tool to help students learn regular expressions. I will probably be writing it in Java. The idea is this: the student types in a regular expression and the tool shows which parts of a text will get matched by the regex. Simple enough. But I want to support several different regex "flavors" such as: Basic regular expressions (think: grep) Extended regular expressions (think: egrep) A subset of Perl regular expressions, including the character classes \w, \s, etc. Sed-style regular expressions Java has the java.util.Regex class, but it supports only Perl-style regular expressions, which is a superset of the basic and extended REs. What I think I need is a way to take any given regular expression and escape the meta-characters that aren't part of a given flavor. Then I could give it to the Regex object and it would behave as if it was written for the selected RE interpreter. For example, given the following regex: ^\w+[0-9]{5}-(\d{4})?$ As a basic regular expression, it would be interpreted as: ^\\w\+[0-9]\{5\}-\(\\d\{4\}\)\?$ As an extended regular expression, it would be: ^\\w+[0-9]{5}-(\\d{4})?$ And as a Perl-style regex, it would be the same as the original expression. Is there a "regular expression for regular expressions" than I could run through a regex search-and-replace to quote the non-meta characters? What else could I do? Are there alternative Java classes I could use?

    Read the article

  • Embed python interpreter in a python application

    - by MatToufoutu
    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 writtent in python itself... I don't need to "hide" my code or make a binary like cx_freeze does, i just don't want my users to have to install python to use my app, that's all. Thanks.

    Read the article

  • C++ interpreter conceptual problem

    - by Jan Wilkins
    I've built an interpreter in C++ for a language created by me. One main problem in the design was that I had two different types in the language: number and string. So I have to pass around a struct like: class myInterpreterValue { myInterpreterType type; int intValue; string strValue; } Objects of this class are passed around million times a second during e.g.: a countdown loop in my language. Profiling pointed out: 85% of the performance is eaten by the allocation function of the string template. This is pretty clear to me: My interpreter has bad design and doesn't use pointers enough. Yet, I don't have an option: I can't use pointers in most cases as I just have to make copies. How to do something against this? Is a class like this a better idea? vector<string> strTable; vector<int> intTable; class myInterpreterValue { myInterpreterType type; int locationInTable; } So the class only knows what type it represents and the position in the table This however again has disadvantages: I'd have to add temporary values to the string/int vector table and then remove them again, this would eat a lot of performance again. Help, how do interpreters of languages like Python or Ruby do that? They somehow need a struct that represents a value in the language like something that can either be int or string.

    Read the article

  • I'm trying to ressurrect UnderC C/C++ interpreter [closed]

    - by Domingo
    Hello ! I'm trying to ressurrect UnderC C/C++ interpreter https://code.google.com/p/underc-fltk/ and I got it to compile with modern mingw compilers 3.4.5 and up, I need some experts advice on some topics: -Yacc/Bison grammar (example some problems with recognizing "unsigned" alone and "friend class") -ARM assembler only one function to call native os functions (X86 already there for windows and linux) -General improvements I expect it to work on WINCE, IPHONE, SYMBIAN in the near future. Thanks in advance for your expertize, time and attention !

    Read the article

  • C++: GUI libraries for embedding into an interpreter

    - by sub
    I've got my interpreter up and running - quite bug-free and stable for now - now I want to add some visual options to my language to play around. What is a good GUI library easy to use and mainly easy to embed and "link" to my programming language? What general rules do I have to follow? I'm currently on XP with Microsoft Visual Studio 2010.

    Read the article

  • Is there any sql interpreter for objects?

    - by Behrooz
    Is there any interpreter that takes a string or even a custom object as input and execute it on my datasource? I cannot use linq to object because query always changes and the report i'm working on, has about 6000 queries which i can reduce to 9 if i find some tool doing that for me. Opensource is very applicable. thanks in advance.

    Read the article

  • How does an interpreter switch scope?

    - by Dox
    I'm asking this because I'm relatively new to interpreter development and I wanted to know some basic concepts before reinventing the wheel. I thought of the values of all variables stored in an array which makes the current scope, upon entering a function the array is swapped and the original array put on some sort of stack. When leaving the function the top element of the "scope stack" is popped of and used again. Is this basically right? Isn't swapping arrays (which means moving around a lot of data) not very slow and therefore not used by modern interpreters?

    Read the article

  • Writing a printList method for a Scheme interpreter in C

    - by Rehan Rasool
    I am new to C and working on making an interpreter for Scheme. I am trying to get a suitable printList method to traverse through the structure. The program takes in an input like: (a (b c)) and internally represent it as: [""][ ][ ]--> [""][ ][/] | | ["A"][/][/] [""][ ][ ]--> [""][ ][/] | | ["B"][/][/] ["C"][/][/] Right now, I just want the program to take in the input, make the appropriate cell structure internally and print out the cell structure, thereby getting (a (b c)) at the end. Here is my struct: typedef struct conscell *List; struct conscell { char symbol; struct conscell *first; struct conscell *rest; }; void printList(char token[20]){ List current = S_Expression(token, 0); printf("("); printf("First Value? %c \n", current->first->symbol); printf("Second value? %c \n", current->rest->first->first->symbol); printf("Third value? %c \n", current->rest->first->rest->first->symbol); printf(")"); } In the main method, I get the first token and call: printList(token); I tested the values again for the sublists and I think it is working. However, I will need a method to traverse through the whole structure. Please look at my printList code again. The print calls are what I have to type, to manually get the (a (b c)) list values. So I get this output: First value? a First value? b First value? c It is what I want, but I want a method to do it using a loop, no matter how complex the structure is, also adding brackets where appropriate, so in the end, I should get: (a (b c)) which is the same as the input. Can anyone please help me with this?

    Read the article

  • Web-based code interpreter

    - by detly
    I remember coming across a website where I could type in some code and it would compile and run it (or error out), displaying any console output. It accepted a variety of interpreted and non-interpreted languages — I specifically remember that I could use C (maybe Python too... I'm not completely sure). Does anyone know what site I'm talking about?

    Read the article

  • How to implement arrays in an interpreter?

    - by Ray
    I have managed to write several interpreters including Tokenizing Parsing, including more complicated expressions such as ((x+y)*z)/2 Building bytecode from syntax trees Actual bytecode execution What I didn't manage: Implementation of dictionaries/lists/arrays. I always got stuck with getting multiple values into one variable. My value structure (used for all values passed around, including variables) looks like this, for example: class Value { public: ValueType type; int integerValue; string stringValue; } Works fine with integers and strings, but how could I implement arrays? (From now on with array I mean arrays in my experimental language, not in C++) How can I fit the array concept into the Value class above? Is it possible? How should I make arrays able to be passed around just as you could pass around integers and strings in my language, using the class above? Accessing array elements or memory allocation wouldn't be the problem, I just don't know how to store them.

    Read the article

  • Python interpreter invocation with "-c" and indentation issues

    - by alexander
    I'm trying to invoke Python using the "-c" argument to allow me to run some arbitrary python code easily, like this: python.exe -c "for idx in range(10): print idx" Now this code works fine, from within my batch file, however, I'm running into problems when I want to do anything more than this. Consider the following Python code: foo = 'bar' for idx in range(10): print idx this would then give you 0-9 on the stdout. However, if I collapse this into a single line, using semicolons as delimiters, to get the following: foo = 'bar';for idx in range(10): print idx and try to run it using python.exe -c it get a SyntaxError raised: C:\Python>python.exe -c "foo = 'bar';for idx in range(10): print idx" File "<string>", line 1 foo = 'bar';for idx in range(10): print idx ^ SyntaxError: invalid syntax Anyone know how I can actually use this without switching to a separate .py file?

    Read the article

  • Why does java have an interpreter? and not a compiler?

    - by Galaxin
    Iam a newbie to java and was wondering why java have a interpreter and not a compiler? While shifting from c++ to java we come across the differences between these two Compilation process being one of them. 1.A major difference between a compiler and interpreter is that compiler compiles the whole code at once and displays all the errors at a time whereas an interpreter interprets line by line. 2.Also a compiler takes a less time to compile a code when compared to an interpreter. When java was developed for more advanced and easy features and implementations why has it been restricted to a interpreter based on above facts? Is there any special reason why this is so? If yes what is it?

    Read the article

  • Embedding Perl Interpreter

    - by cam
    Hi, just downloaded ActivePerl. I want to embed the perl interpreter in a C# application (or at least call the perl interpreter from C#). I need to be able to send send out data to Perl from C#, then receive the output back into C#. I just installed ActivePerl, and added MS Script Control 1.0 as a reference. I found this code on the internet, but am having trouble getting it to work. MSScriptControl.ScriptControlClass Interpreter = new MSScriptControl.ScriptControlClass(); Interpreter.Language = @"ActivePerl"; string Program = @"reverse 'abcde'"; string Results = (string)Interpreter.Eval(Program); return Results; Originally, it had 'PerlScript' instead of 'ActivePerl', but neither work for me. I'm not entirely sure what Interpreter.Language expects. Does it require the path to the interpreter? Solved... I'm not sure how, but when I changed it back to PerlScript it works now. Still, I would like to know if MSScript Control is using ActivePerl or another interpreter.

    Read the article

  • How to efficently build an interpreter (lexer+parser) in C?

    - by Rizo
    I'm trying to make a meta-language for writing markup code (such as xml and html) wich can be directly embedded into C/C++ code. Here is a simple sample written in this language, I call it WDI (Web Development Interface): /* * Simple wdi/html sample source code */ #include <mySite> string name = "myName"; string toCapital(string str); html { head { title { mySiteTitle; } link(rel="stylesheet", href="style.css"); } body(id="default") { // Page content wrapper div(id="wrapper", class="some_class") { h1 { "Hello, " + toCapital(name) + "!"; } // Lists post ul(id="post_list") { for(post in posts) { li { a(href=post.getID()) { post.tilte; } } } } } } } Basically it is a C source with a user-friendly interface for html. As you can see the traditional tag-based style is substituted by C-like, with blocks delimited by curly braces. I need to build an interpreter to translate this code to html and posteriorly insert it into C, so that it can be compiled. The C part stays intact. Inside the wdi source it is not necessary to use prints, every return statement will be used for output (in printf function). The program's output will be clean html code. So, for example a heading 1 tag would be transformed like this: h1 { "Hello, " + toCapital(name) + "!"; } // would become: printf("<h1>Hello, %s!</h1>", toCapital(name)); My main goal is to create an interpreter to translate wdi source to html like this: tag(attributes) {content} = <tag attributes>content</tag> Secondly, html code returned by the interpreter has to be inserted into C code with printfs. Variables and functions that occur inside wdi should also be sorted in order to use them as printf parameters (the case of toCapital(name) in sample source). I am searching for efficient (I want to create a fast parser) way to create a lexer and parser for wdi. Already tried flex and bison, but as I am not sure if they are the best tools. Are there any good alternatives? What is the best way to create such an interpreter? Can you advise some brief literature on this issue?

    Read the article

  • Making money from a custom built interpreter?

    - by annoying_squid
    I have been making considerable progress lately on building an interpreter. I am building it from NASM assembly code (for the core engine) and C (cl.exe the Microsoft compiler for the parser). I really don't have a lot of time but I have a lot of good ideas on how to build this so it appeals to a certain niche market. I'd love to finish this but I need to face reality here ... unless I can make some good monetary return on my investment, there is not a lot of time for me to invest. So I ask the following questions to anyone out there, especially those who have experience in monetizing their programs: 1) How easy is it for a programmer to make good money from one design? (I know this is vague but it will be interesting to hear from those who have experience or know of others' experiences). 2) What are the biggest obstacles to making money from a programming design? 3) For the parser, I am using the Microsoft compiler (no IDE) I got from visual express, so will this be an issue? Will I have to pay royalties or a license fee? 4) As far as I know NASM is a 2-clause BSD licensed application. So this should allow me to use NASM for commericial development unless I am missing something? It's good to know these things before launching into the meat and potatoes of the project.

    Read the article

  • dynamically create class in scala, should I use interpreter?

    - by Phil
    Hi, I want to create a class at run-time in Scala. For now, just consider a simple case where I want to make the equivalent of a java bean with some attributes, I only know these attributes at run time. How can I create the scala class? I am willing to create from scala source file if there is a way to compile it and load it at run time, I may want to as I sometimes have some complex function I want to add to the class. How can I do it? I worry that the scala interpreter which I read about is sandboxing the interpreted code that it loads so that it won't be available to the general application hosting the interpreter? If this is the case, then I wouldn't be able to use the dynamically loaded scala class. Anyway, the question is, how can I dynamically create a scala class at run time and use it in my application, best case is to load it from a scala source file at run time, something like interpreterSource("file.scala") and its loaded into my current runtime, second best case is some creation by calling methods ie. createClass(...) to create it at runtime. Thanks, Phil

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >