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

Erlang : variable 'Result' unsafe in 'try'

I'm using Erlang R16B03. This code: list_dir(Directory, Retries) when is_integer(Retries), Retries > 0 -> Port = get_efile_port(), try erlang:port_info(Port) of Result -> error_logger:info_msg("list_dir -…
bryan hunt
  • 644
  • 4
  • 20
8
votes
4 answers

Is a C++ compiler allowed to emit different machine code compiling the same program?

Consider a situation. We have some specific C++ compiler, a specific set of compiler settings and a specific C++ program. We compile that specific programs with that compiler and those settings two times, doing a "clean compile" each time. Should…
sharptooth
  • 167,383
  • 100
  • 513
  • 979
8
votes
1 answer

Register Allocation in Compilers

What is meant by spilling of registers or spill code which appears in Register allocation phase of Code generation where compiler backend must allocate variables to memory or registers?.
8
votes
2 answers

Left recursion parsing

Description: While reading Compiler Design in C book I came across the following rules to describe a context-free grammar: a grammar that recognizes a list of one or more statements, each of which is an arithmetic expression followed by a…
8
votes
4 answers

Is there any program that obfuscates C# source code?

Our requirement is being able to integrate our DLLs with ClickOnce. Dotfuscator does the obfuscation job nicely but the obfuscated DLLs cannot be deployed with ClickOnce on customer side. On our side, we can handle it perfectly. Moreover, the…
Mark Attwood
  • 4,206
  • 5
  • 27
  • 24
8
votes
2 answers

How do I run C# 4.0 compiler with CSharpCodeProvider class?

I'm using this snippet CSharpCodeProvider codeProvider = new CSharpCodeProvider( new Dictionary { { "CompilerVersion", "v3.5" } }); for the 3.5 compiler for dynamic code compilation. I'm assuming I should use "v4.0" to…
scope_creep
  • 4,213
  • 11
  • 35
  • 64
8
votes
2 answers

'Lexical' scoping of type parameters in C#

I have 2 scenarios. This fails: class F { public X X { get; set; } } error CS0102: The type 'F' already contains a definition for 'X' This works: class F { class G { public X X { get; set; } } } The only logical explanation…
leppie
  • 115,091
  • 17
  • 196
  • 297
8
votes
1 answer

What is the state of C99 support in major compilers / toolchains?

A response to a comment I made here made me stop and think: "I don't really know what the state of C99 support is." Wikipedia gives details for a few compilers, but I'm not familiar enough with C99 to know all the bits and pieces of the standard, so…
pkh
  • 3,639
  • 1
  • 23
  • 18
8
votes
2 answers

What programming language is FogBugz written in?

From what I've read it appears that FogBugz was originally written in VBScript. Now apparently they use their own custom compiler and language that will translate the source code to more "accessible" languages such as PHP and (I think) C#. Is there…
Earlz
  • 62,085
  • 98
  • 303
  • 499
8
votes
1 answer

GHC Partial Evaluation and Separate Compilation

Whole-program compilers like MLton create optimized binaries in part to their ability to use the total source of the binary to perform partial evaluation: aggressively inlining constants and evaluating them until stuck—all during compilation! This…
J. Abrahamson
  • 72,246
  • 9
  • 135
  • 180
8
votes
2 answers

What's the difference among Expression,Statements and Declaration from the view of compiler?

I am going through the Go source code of ast.go at here,and there are 3 types of interfaces that are Expression,Statement and Declaration. But only with the source code I couldn't figure out the difference between them.What I could figure out is…
ggaaooppeenngg
  • 1,323
  • 3
  • 17
  • 27
8
votes
4 answers

How do production compilers implement destructor handling on flow control

Long story short - I am writing a compiler, and reaching the OOP features I am faced with a dilemma involving the handling of destructors. Basically I have two options: 1 - put all destructors for objects that need calling at that point in the…
user3735658
8
votes
4 answers

What is special about numbers starting with zero?

This is kinda stupid question, but it's interesting for me ) This is what i get with visual studio 2013 int i = 07; // i == 7 int i = 16; // i == 16 int i = 00016; // i == 14, why? int i = 05016; // i == 2574, wow ) int i = 08; //…
Grigor
  • 107
  • 1
  • 1
  • 3
8
votes
7 answers

Example compilers

I'm searching for the source code of a compiler capable of creating Win32 programs from an input program in a programming language (It doesn't matter which, maybe the simpler the better) Yet I can't find anything right for me and huge compilers like…
saf
  • 99
  • 1
8
votes
3 answers

Do you have to build a new compiler for a new operating system?

I would like to build an OS some time in the future, and now thinking of some light sketches on how it would be. I have pretty much been coding in C compiled for the Windows environment (and some little Java). I would have to recompile any of my C…
user3810155
1 2 3
99
100