compiler-theory

Learning Resources on Parsers, Interpreters, and Compilers

I've been wanting to play around with writing my own language for a while now (ostensibly for the learning experience) and as such need to be relatively grounded in the construction of Parsers, Interpreters, and Compilers. So: Does anyone know of any good resources on constructing Parsers, Interpreters, and Compilers? EDIT: I'm not l...

How to make a Side-by-Side Compiler for .NET

Nikhil Kothari's Script# is quite possibly one of the most amazing concepts I've seen in the JavaScript arena for quite some time. This question isn't about JavaScript, but rather about language compilation in the .NET runtime. I've been rather interested in how, using the .NET platform, one can write a compiler for a language that alre...

What are good resources on compilation?

Summary for the impatient: I'm searching for good references on generating code for common language constructs but not parsing. I am interested in programming languages and try to read the literature as much as possible. But most of them covers the topic in a functional and theoretical perspective that, I find them hard to understand le...

Efficient way to recursively calculate dominator tree?

I'm using the Lengauer and Tarjan algorithm with path compression to calculate the dominator tree for a graph where there are millions of nodes. The algorithm is quite complex and I have to admit I haven't taken the time to fully understand it, I'm just using it. Now I have a need to calculate the dominator trees of the direct children o...

Could C++ have not obviated the pimpl idiom?

As I understand, the pimpl idiom is exists only because C++ forces you to place all the private class members in the header. If the header were to contain only the public interface, theoretically, any change in class implementation would not have necessitated a recompile for the rest of the program. What I want to know is why C++ is no...

Would it be reasonable to self-study the dragon book?

I've been out of school for about 2 years and didn't take a compilers course as an undergrad. At this point, it's something I'm interested in and am wondering if it would be reasonable for me to get a copy of the dragon book and self study? what other resources might you recommend to guide me? I find that I learn best by doing, so I...

LR1 Parser and Epsilon

I'm trying to understand how LR1 Parsers work but I came up with a strange problem: What if the grammar contains Epsilons? For instance: if I have the grammar: S -> A A -> a A | B B -> a It's clear how to start: S -> .A A -> .a A A -> .B ... and so on but I don't know how to do it for such a grammar: S -> A A -> a A a | \epsilon...

(When) Should I learn compilers?

According to this http://steve-yegge.blogspot.com/2007/06/rich-programmer-food.html article, I defnitely should. Quote Gentle, yet insistent executive summary: If you don't know how compilers work, then you don't know how computers work. If you're not 100% sure whether you know how compilers work, then you don't know ho...

Programming Language Pragmatics is worth buying?

As per amazon reviews the book, Programming Language Pragmatics,by Michael L. Scott serves as a very good introductory book for Programming language and compiler design. Did any of you guys read this book and found really helpful? I am planning to learn compiler design, once I am comfortable with this book, can I buy this one ...

What programming languages are context-free?

Or, to be a little more precise: which programming languages are defined by a context-free grammar? From what I gather C++ is not context-free due to things like macros and templates. My gut tells me that functional languages might be context free, but I don't have any hard data to back that up with. Extra rep for concise examples :-) ...

Finding language designers and programmers

I'd like to create a new and open sourced language. Since it's really rare to find programmers that actually dealt with compiler theory I need some advice. How would you make a person interested in your open source project? How do you bring him to a position where he wants to contribute? Is there a special place where I can find those pe...

Does the compiler decide when to inline my functions (in C++)?

I understand you can use the inline keyword or just put a method in a class declaration ala short ctor or a getter method, but does the compiler make the final decision on when to inline my methods? For instance: inline void Foo::vLongBar() { //several function calls and lines of code } Will the compiler ignore my inline declarati...

Converting a CFG to IL

I build a CFG out of an arbitrary IL and want to convert that CFG back to IL. The order of the vertices in the CFG is of course not equal to the order of the original IL instructions. This is fine but overcomplicates some stuff. Imagine: Jump 'B' 'C': Return 'B': Jump 'C' This would result in a flow graph like this: (Jump B) -> (Jump...

What is the reason for the creation of LLVM?

What are the differences between an LLVM and a regular compiler? Is it more dynamic and thus can be used to compile normally very dynamic languages (i.e. Javascript) into static binary code? What are the principles behind creating one? I know the Dragon Book for compilers, but is there such a thing for a LLVM? Thanks in advance, Omer....

will reading compiler construction increase my programming skills?

will reading compiler construction increase my programming skills? ...

Would it be possible to have a compiler that would predict every possible 'situation specific' runtime error?

By 'situation specific' I mean it uses some data that it would have access to such as your current database setup, version of some OS, etc. Imagine if the compiler would check the database you were currently using in your app and call you out a warning saying 'just so you know, the current data in your database will never trigger the st...

Free Lexical Analyzer / Scanner Source

Hello, I'm looking for a hand-written free lexer/scanner for any language, even a toy language written in a language similiar to C/C++. I am a beginner in creating languages and compiler design, I'd like to play around with the source. For example, theres a hand written lexer on this website before the flex generated lex: http://en.wik...

What language features are required in a programming language to make a compiler?

Programming languages seem to go through several stages. Firstly, someone dreams up a new language, Foo Language. The compiler/interpreter is written in another language, usually C or some other low level language. At some point, FooL matures and grows, and eventually someone, somewhere will write a compiler and/or interpreter for FooL i...

Write a compiler for a language that looks ahead and multiple files?

In my language I can use a class variable in my method when the definition appears below the method. It can also call methods below my method and etc. There are no 'headers'. Take this C# example. class A { public void callMethods() { print(); B b; b.notYetSeen(); public void print() { Console.Write("v = {0}", v); } int v=9;...

Pac-Man representation with Finite State Automaton

Hi there, Consider a game similar to pac-mac that we want to represent it with an FSA graph. We have a maze (table) and there are berries into it in random positions. The goal is to eat all the berries in the maze. The commands we have to consider for the control are the following: GOAHEAD, LEFT, RIGHT, CHECKBERRY(that checks if there is...