Need help designing an interpreter [closed] - interpreter

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
i'm thinking on doing an undergrad project on building an interpreter for a simple/rudimentary custom language (perl / C like). I would be be glad if someone could point me in the right direction to start. Most of the books/resources i find are on theoretical implementation of compilers. Are there any resources aimed at interpreters ? i'm thinking of implementing it in C++, but have very little knowledge on the subject of interpreter design, so any pointers to books/references will be appreciated

The parsing of the source code is not very much different between a compiler and an interpreter. And that is what most textbooks on compilers are about.

There are some nice tools now to implement custom languages.
You might want to checkout Xtext in the Eclipse Modelling Package (http://www.eclipse.org) or MPS (http://www.jetbrains.com/mps/), the language workbench of IntelliJ which is freely available.
Both allow you to create languages and provide the tools to generate code from the source and the tooling to help creating the code.
They also create abstract syntax trees which may be directly manipulated, i.e. executed. Then you have an interpreter.
The classical approach would be to use bison/yacc for as a lexer, respectively parser, and many newer tools are currently available like antlr. The output of the parser is then again the abstract syntax tree ready to do interprete or generate code from.

An Incremental Approach to Compiler Construction - it's about creating compilers, but it might be a good starting point to find references from.

I wrote an interpreter for reading and converting logic expressions at Uni. Wrote it in C, Lexx and Yacc which old school Unix and C programmers seem to swear by. Pretty powerful once you get the hang of them, but reasonably steep learning curve I would say.
http://www.lugbe.ch/action/reports/lex_yacc.pdf

Related

C++ disassembler? [duplicate]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I have a program in which I've lost the C++ source code. Are there any good C++ decompilers out there?
I've already ran across Boomerang.
You can use IDA Pro by Hex-Rays. You will usually not get good C++ out of a binary unless you compiled in debugging information. Prepare to spend a lot of manual labor reversing the code.
If you didn't strip the binaries there is some hope as IDA Pro can produce C-alike code for you to work with. Usually it is very rough though, at least when I used it a couple of years ago.
information is discarded in the compiling process. Even if a decompiler could produce the logical equivalent code with classes and everything (it probably can't), the self-documenting part is gone in optimized release code. No variable names, no routine names, no class names - just addresses.
Yes, but none of them will manage to produce readable enough code to worth the effort. You will spend more time trying to read the decompiled source with assembler blocks inside, than rewriting your old app from scratch.
I haven't seen any decompilers that generate C++ code. I've seen a few experimental ones that make a reasonable attempt at generating C code, but they tended to be dependent on matching the code-generation patterns of a particular compiler (that may have changed, it's been awhile since I last looked into this). Of course any symbolic information will be gone. Google for "decompiler".
Depending on how large and how well-written the original code was, it might be worth starting again in your favourite language (which might still be C++) and learning from any mistakes made in the last version. Didn't someone once say about writing one to throw away?
n.b. Clearly if this is a huge product, then it may not be worth the time.

Intermediate Books/Resources about Best Practice and Idiomatic Obj-C [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
I'm looking for a book in the vein of Eloquent Ruby which, while not being targeted at the ruby beginner, gives a great overview of what 'grown up' idiomatic ruby code looks like, and gives great examples of how people might use the powers of the language. I found that the book almost perfectly mirrored what the experienced real world rubyists were writing.
I've settled quite comfortably now into obj-c, but I'd love to read a book like this that would take me from competent to enlightened. Are there any books/resources that might achieve this?
Take a look at this book: Programming in Objective-C
I only have read some sections from it, but I think it mets your requirements, has a lot of helpful code and easy to follow tutorials and it's targeted to beginners and experienced programmers. As you can confirm in the book description:
The book makes no assumptions about prior experience with object-oriented programming languages or with the C language (which Objective-C is based upon). Because of this, both beginners and experienced programmers alike can use this book to quickly and effectively learn the fundamentals of Objective-C. Readers can also learn the concepts of object-oriented programming without having to first learn all of the intricacies of the underlying procedural language (C).

Any library for basic science chemistry/physics programming? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
I am wondering if there is an open source scientific library for chemistry and/or physics
for C++ (or maybe C)?
I am NOT looking for simulation models, visualization, 3-d modeling.
I am just looking for a basic toolbox that would have, for example: various constants such as Ideal Gas Constant, Avogadro constant, periodic table of the elements values; molecular weight calculation; maybe basic functions implementing equations for stoichiometry, gas laws, thermal dynamics, kinetics.
Chemistry/Physics 101 kind of stuff.
I have found on SourceForge:
Christoph Steinbeck's The Chemical Development Kit (Java) on SourceForge.
NIST-const
I would take a look at the GNU Scientific Library:
http://www.gnu.org/software/gsl/
It should have most of the physical constants you're looking for. As far as the chemistry related stuff, I don't know of any basic packages that do all of those calculations right out of the box.
Update:
I forgot about another project that would have all of the periodic table stuff (and probably more):
http://openbabel.org
specifically check out:
http://openbabel.org/api/2.2.0/classOpenBabel_1_1OBElementTable.shtml#_details
Since you excluded simulations, PyQuante probably isn't what you're looking for, but you might find kinpy and thermopy interesting.
I really like this book for it:
http://www.amazon.com/Physics-Game-Programmers-Grant-Palmer/dp/159059472X
I has the physics formulas in there and the source code is available online:
http://apress.com/book/view/159059472X
I haven't seen much in the way of chemistry. Physics is more popular because it has direct affect on gaming, of course. :-)
Update: a few on chemistry:
http://www.iupac.org/inchi/
http://code.google.com/p/simsoup/
http://gchemutils.nongnu.org/
http://www.simsoup.info/SimSoup/Design/Chemistry_Subsystem.html
Kalzium, part of the KDE tools. Periodic table plus (based on the screenshots) an equation solver and more.
In High Energy Physics, two common c++ libraries/frameworks are CLHEP and ROOT. Both of these contain units and physical constants - see e.g. CLHEP Units. CLHEP also contains a lot of libraries for linear algebra, while ROOT has a lot of tools for data analysis.
Probably not entirely what you are looking for, but may be useful to someone

Do tools exist which automatically find copy-and-paste code? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 6 years ago.
Improve this question
Are there tools out there which could automatically find copy-and-paste code among a set of files?
I was thinking of writing a script for this, which would just search for equal strings, but such script would find mostly irrelevant equalities. (Such as private final static ...).
Yes, try the Copy Paste Detector.
Our CloneDR is a tool for finding exact and near-miss blocks of code constructed by copy and paste activities.
It can handle systems of millions of lines of code.
It uses precise language grammars to pick out language structures (identifiers, expressions, statements, blocks, functions, classes, packages, ...) that have been copied, and to determine the points of variation across the sets of clones (any of those structures can be parameters!)
CloneDR operates on a wide variety of languages: C, C++, C#, Java, PHP, COBOL, Python, Ada, Fortran, EGL and visual basic (VBScript, VB6, VB.net).
The website has a number of sample clone detection reports from a variety of those languages.
This product is available for evaluation on http://www.semanticdesigns.com. Other open source alternatives are Simian and PMD CPD
http://patterninsight.com/products/cp-miner.php
Related paper - http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.123.113
CloneDigger for Python and Java.

SBCL standard library documentation? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I want to learn and use SBCL because of its ease of learning and speed. (I've been playing with Lisp 3 years ago, and now am refreshing it.) But how can I learn what's included in the standard library, so that I don't re-implement things?
After Python this is like a nightmare: the SBCL website has a manual that covers the software only, not a word on the standard library. (For comparison, Gnu Common Lisp's website has only sources and binaries.)
Firstly: that problem isn't really SBCL specific. The CL library is standardised and thus you can use the documentation of any lisp.
As mentioned, the CL HyperSpec is very useful. It is however a reference and thus not very suitable for learning in my opinion.
For learning, there are various books out there. I personally like these a lot:
ANSI Common Lisp by Paul Graham
Practical Common Lisp by Peter Seibel
Successful Lisp by David Lamkins
You should also look at existing code. I particularly enjoyed reading any of the libs by Edi Weitz but spread out and read from different sources to see how other people use Lisp and its huge library to solve problems.
If you can spend that much time you can even log onto IRC (the #lisp channel) and ask questions there. Or post code you have written to comp.lang.lisp and ask for a critique to learn via direct feedback.
Consult the Common Lisp HyperSpec for documentation about what is included in Common Lisp
Also, if you are learning lisp, consider using CLISP instead of SBCL. CLISP has (IMHO) a much more intuitive debugger. For any non-production stuff the difference between most Common Lisp implementations are negligible.
If you are developing on Windows, CLHS (Common Lisp HyperSpec) and CLtL2 (Common Lisp the Language, 2nd Edition) are available as CHM help files, which makes looking for CL standard library functions much easier. I find that it's faster than using the (online or offline) HTML version.
The CHM files are probably available from more than one source. One convenient download is:
http://www.daansystems.com/lispide/
(They're bundled with LispIDE package.)