Questions tagged [compiler-construction]

The tag compiler-construction should be applied to questions concerning the programming of compilers or for questions about the detailed inner workings of compilers. DO NOT USE for questions about *using* specific compilers or compilation errors.

A compiler is a program which translates one language into another. Compiler construction is the process of creating a compiler.

The tag should be applied to questions concerning the programming of compilers or for questions about the detailed inner workings of compilers.

One language to another? I thought they made executables!

Few compilers do exactly that:

  • They mostly translate a human readable computer programming language (like Fortran, Cobol, Algol, PL/1, Pascal, C, C++, C#, etc.) into an object-code file which has to be subsequently linked.

  • Many real world compilers translate a high level language into assembly code which is subsequently assembled by a separate program and then linked.

  • The standard Java compiler translate Java code into JVM bytecode, which must be run by a dedicated program (the JVM) which may include a Just In Time (JIT) or HotSpot compiler that translates the bytecode into native machine instructions on the fly.
  • Early versions of Unix came with a Fortran-to-C compiler.
  • The earliest versions of the language that became C++ were compiled into C by a program called cfront.
  • Many other examples of source-to-source compilers exist.
  • Some languages such as JavaScript and many other 'scripting' languages don't have compilers at all, but are executed directly from source code.

Big List of Resources:

11618 questions
8
votes
3 answers

Why Android used Java concept instead of D language or C or C++? But Chromium web browser is in C++, its very complicated match

Android is 32-bit ARM. wiki Description: 1) So, 32/64 or 8/12/16 Bit compiler is available with D language if not it can be builded by a compiler, if i am not wrong? 2) Linux standard kernel: Libraries written in C and other languages can be…
user285594
8
votes
5 answers

Design Pattern For Making An Assembler

I'm making an 8051 assembler. Before everything is a tokenizer which reads next tokens, sets error flags, recognizes EOF, etc. Then there is the main loop of the compiler, which reads next tokens and check for valid mnemonics: mnemonic=…
Hossein
  • 4,097
  • 2
  • 24
  • 46
8
votes
1 answer

Broken Mono C# code using System.Windows.Forms

A couple of months back I started a relatively simple C# app which I was compiling with Mono. I try to resume work on this today, and despite having an executable proving it compiled fine before, it is now complaining about…
Peter Boughton
  • 110,170
  • 32
  • 120
  • 176
8
votes
2 answers

Generating intermediate code in a compiler. Is an AST or parse tree always necessary when dealing with conditionals?

I'm taking a compiler-design class where we have to implement our own compiler (using flex and bison). I have had experience in parsing (writing EBNF's and recursive-descent parsers), but this is my first time writing a compiler. The language design…
8
votes
2 answers

Java Compiler: Stop complaining about dead code

For testing purposes, I often start typing some code in an already existing project. So, my code I want to test comes before all the other code, like this: public static void main(String[] args) { char a = '%'; System.out.println((int)a); …
Martijn Courteaux
  • 67,591
  • 47
  • 198
  • 287
8
votes
4 answers

What is the purpose of a double negative in macro definition, like (!!(expr))?

Possible Duplicate: Double Negation in C++ code. I'm reading a code base, and find something like this: #define uassert(msgid, msg, expr) (void)((!!(expr))||(uasserted(msgid, msg), 0)) I cannot figure out why (!!(expr)) is used instead of a…
Fan
  • 1,133
  • 1
  • 9
  • 14
8
votes
6 answers

Is Scalas/Haskells parser combinators sufficient?

I'm wondering if Scalas/Haskells parser combinators are sufficient for parsing a programming language. More specifically the language MiniJava. I'm currently reading compiller construction and jflex and java cup is quite painful to work with so I'm…
Daniel O
  • 4,607
  • 6
  • 44
  • 52
8
votes
2 answers

Recursive Descent vs. Generated Parsers - Efficiency

How do hand-written recursive descent parsers (which are inevitably LL(k)) compare to generated LALR parsers in terms of performance? I know that LALR parsers are able to handle far more grammars than LL(k); however it's my intention to write my…
ljs
  • 37,275
  • 36
  • 106
  • 124
8
votes
4 answers

Unwinding frame but do not return in C

My programming language compiles to C, I want to implement tail recursion optimization. The question here is how to pass control to another function without "returning" from the current function. It is quite easy if the control is passed to the same…
exebook
  • 32,014
  • 33
  • 141
  • 226
8
votes
6 answers

How exactly an access violation exception is triggered

Sometimes bugs can cause memory access violation exception. How exactly this exception is triggered? What mechanism works behind the scenes? Does it need support from the CPU (starting at what CPU?) / from the OS (starting at what version?) / from…
Lior Kogan
  • 19,919
  • 6
  • 53
  • 85
8
votes
2 answers

Why does the C# compiler differentiates between these 2 cases?

When you have some property that's like: using Algebra; public Algebra.Vector3 Direction { get { return this.direction; } } then compile and later change it to: using Algebra; public Vector3 Direction { get { return this.direction;…
Joan Venge
  • 315,713
  • 212
  • 479
  • 689
8
votes
8 answers

warning: format ‘%d’ expects type ‘int *’, but argument 2 has type ‘int’

So I'm new to C and am having trouble with whats happening with this warning. What does the warning mean and how can i fix it. The code i wrote is here: void main(void) { char* name = ""; int age = 0; printf("input your name\n"); …
Zieklecknerizer
  • 275
  • 3
  • 6
  • 15
8
votes
2 answers

C++ Library Compatibility

I am currently writing a library and am considering moving from GCC 4.1.2 to 4.5.2 (latest release) of GCC. If I compile my code into a static library can I assume compiler compatibility (on the same OS obviously) should be a non-issue for…
Graeme
  • 4,514
  • 5
  • 43
  • 71
8
votes
3 answers

Is it possible to regenerate symbols for an exe?

One of my co-workers shipped a hot fix build to a customer, and subsequently deleted the pdb file. The build in question is crashing (intermittently) and we have a couple of crash dumps. We have all the source code in version control, and can…
Michael
  • 1,022
  • 6
  • 7
8
votes
10 answers

Compile Error CS0433 on pre-compiled ASP.NET 2.0 site

I keep getting this error ever so often when I launch the debugger to debug my site. I'm using the Telerik controls, and usually the error is in my tab strip. Here is an example of the error I'm looking at right now: Compiler Error Message:…
LarryF
  • 4,925
  • 4
  • 32
  • 40