compiler-design

What is the known limit for compiler performance on the current hardware?

Are there a real reason to use dynamic linking and binary distributions these days? For binary distributions there's an alternative in distributing everything in source code and letting the platform do the choice of compiling binaries or not. But whether it is usable or not depends about how well can today's computers compile from sourc...

Compiler test cases or how to test a compiler

Compilers like all software, would also be prone to bugs, logical errors. How does one validate the output generated by the compiler. Typically, my question is(are) How to validate that the machine code generated is correct? How to ensure that the machine code generated is according to the language specification. Does it make sense to...

how can a compiler that recognizes the iterators be implemented?

I have been using iterators for a while and I love them. But although I have thought hard about it, I could not figure out "how a compiler that recognizes the iterators" be implemented. I have also researched about it, but could not find any resource explaining the situation in the compiler-design context. To elaborate, most of the art...

Methodologies for designing a simple programming language

In my ongoing effort to quench my undying thirst for more programming knowledge I have come up with the idea of attempting to write a (at least for now) simple programming language that compiles into bytecode. The problem is I don't know the first thing about language design. Does anyone have any advice on a methodology to build a pars...

C#'s compiler design - forward referencing.

Hello. In forward referencing language such as c#, how does the compiler handle this? What are the steps in which the compiler operate? ...

How was the first compiler written?

I heard about the chicken and the egg and bootstrapping. I have a few questions. What wrote the first compiler that converted something into binary instructions? Is assembly compiled or translated into binary instructions? ...I'd find it hard to believe they wrote a compiler in binary. ...

Difference in compiler design for OOP languages

Hello. I'm doing a research on how the design compiler for an OOP language differs from traditional imperative languages. I'd just like some topics to send me on my way, and if you wish, you can explain them. For eg. I found that the type table is built differently. ...

Currying and compiler design

This is a homework question: Explain the transformations the type of a routine undergoes in partial parameterization. So far I understand currying. But I cannot find any resources on how a function like this is implemented by the compiler in memory. Could I be pointed in the right direction, maybe keywords to search for or link...

When can typeid return different type_info instances for same type?

Andrei Alexandrescu writes in Modern C++ Design: The objects returned by typeid have static storage, so you don't have to worry about lifetime issues. Andrei continues: The standard does not guarantee that each invocation of, say, typeid(int) returns a reference to the same type_info object. Even though the standard...

Dragon Book - answers?

Hey guys, I went out and bought a copy of the Dragon Book (second edition) but most of the exercises don't seem to have answers. Any idea where I can get them? Edit: Couldn't find solutions anywhere. Also, further research revealed that the gradiant quesions/answers do not match those in the book. Therefore you guys will probably see ...

Question on lexical analysis

I am reading the dragon book. Quoting the text from the book (3.1.4 Lexical errors, Pno 114) It is hard for a lexical analyzer to tell, without the aid of other components, that there is a source-code error. For instance, if the string fi is encountered for the first time in a C program in the context: fi ( a == f(x) ) ....

ANTLR, steps order

I am trying to design a compiler for a language like C# in ANTLR. But I don't fully comprehend the proper order of steps that should be undertaken. This is how I see it: First I define Lexer tokens Then grammar rules (with rewrite rules to build AST) with actions that gather informations about classes and methods declarations (so that...

Has the use of C to implement other languages constrained their designs in any way?

It seems that most new programming languages that have appeared in the last 20 years have been written in C. This makes complete sense as C can be seen as a sort of portable assembly language. But what I'm curious about is whether this has constrained the design of the languages in any way. What prompted my question was thinking about ho...

Creating programming languages and compiler designing. Are they related?

Alright, I guess this question has been asked a lot of times here. I want to create a programming language, not necessarily starting today, but over a span of 2-3 yrs. I'm not a very good programmer, but I'm improving. What I wanted to ask is how closely creating a language and writing a compiler related? Since, a compiler translates a...

What are some tips for optimizing the assembly code generated by a compiler?

I am currently in the process of writing a compiler and I seem to have run into some problems getting it to output code that executes in a decent timeframe. A brief overview of the compiler: 7Basic is a compiler that aims to compile 7Basic code directly into machine code for the target architecture / platform. Currently 7Basic gener...

How should i deduce when the GC should run?

I am writing a statically compiled language and i would like to support garbage collection. before designing it i would like to know how i should i deduce when the GC should run? Should it be after every 16mb allocate interval? (checking after enough rises or just before it allocates 16+mb). Is there a case to check ealier so loops can ...

How should i name expressions that dont have a brace?

I am adding more to my language using bison and in the rules i am getting a little confused. How do i name expressions that have {} such as class, functions, switch etc VS expressions that need a semicolon at the end of them (Int i;) I had them as typeExprWO VS typeExpr but i mixed them up having WO meaning without the need a semicolon...