compiler

Question about storing array in a std::vector in C++

I am unclear about the following. First, this code compiles fine: #include <vector> typedef struct{ int x1,x2,x3,x4; } ints; typedef std::vector<ints> vec; int main(){ vec v; ints a = {0,1,2,3}; v.push_back(a); } The following code is near identical: #include <vector> typedef std::vector<int[4]> vec; int main(){ vec v; i...

C# dictionary initializer compilation inconsistency

The following code compiles, but fails with a NullReferenceException: class Test { public Dictionary<string, string> Dictionary { get; set; } } static void Main(string[] args) { var x = new Test { Dictionary = // fails { { "key", "value" }, { "key2", "value2" } } }; } If you repla...

how to manage a compiler project ?

I am a CS student and I have a compiler project this year. I want to know how to manage my project with my three partners. I know that the compiler has many level and process, and I want to make use of these features to mange my project. Thanks for any tips/pointers/resources you can provide for me to start. ...

Building GCC cross compiler (from "Linux" to "Windows")

Hello, I want to build "gcc cross-compiler" to compile "c/c++" applications on "Linux" environment but for "Windows" target. I have made this so far: Installed the necessary tools and packages for building GCC listed on "Prerequisites for GCC" page. Downloaded required sources: "gcc-core-4.4.1", "gcc-g++-4.4.1", "binutils-2.19.1", "w...

External RoleProviders and compiling?

I've built a custom RoleProvider which uses an already existing datasource (from a web service) to dtermine roles. It's written in C#, and I want to be able to compile it as a DLL so I can distribute it to others within the organisation and they can use it too. When compiling, how do I reference the web service? Currently getting this ...

What's a stupidly simple way to compile an OCaml project?

I'm toying around with OCaml. The first thing I want to know how to do is build an OCaml project. Right now, I just want something stupidly simple since I'm just learning. Could anyone point me towards a build system along with a "hello world" type example for using that build system? ...

EBNF for math equations and inequalities

I would like to design a math language satisfying EBNF, to let me write equation systems and inequalities as close to natural math language as possible. I would like to have two parsers for this little language, one parser prepares the equalities/inequalities written in this language for publication, another parser prepares it for comput...

Arranging global/static objects sequentially in memory

In C++, is it possible to force the compiler to arrange a series of global or static objects in a sequential memory position? Or is this the default behavior? For example, if I write… MyClass g_first (“first”); MyClass g_second (“second”); MyClass g_third (“third”); … will these objects occupy a continuous chunk of memory, or is the...

How to create a compiler in vb.net

Before answering this question, understand that I am not asking how to create my own programming language, I am asking how, using vb.net code, I can create a compiler for a language like vb.net itself. Essentially, the user inputs code, they get a .exe. By NO MEANS do I want to write my own language, as it seems other compiler related qu...

Compiler Error- only when compiling from the command line

error CS0583: Internal Compiler Error (0xc0000017 at address 7C812AFB): likely culprit is 'IMPORT'. An internal error has occurred in the compiler. To work around this problem, try simplifying or changing the program near the locations listed below. Locations at the top of the list are closer to the point at which the internal error occu...

Bootstrapping a compiler: why?

I understand how a language can bootstrap itself, but I haven't been able to find much reference on why you should consider bootstrapping. The intuitive answer is that the language you're writing offers utilities that are not found in the "base" language of the compiler, and the language's features are relatively well-suited for a compi...

Compiler Design

Is newline and whitespaces the same in compiler design? what if you write a macro to replace newlines by whitespaces, is this correct or would it cause some form of problems? ...

Lexical analysis and Macros

I'm writing a demo compiler for a toy programming language in C. What problems can arise if we do macro processing in a separate phase between reading the program and lexical analysis? ...

How can I see parse tree, intermediate code, optimization code and assembly code during COMPILATION ?

I am studying Compilers course, compilation of program follows below steps Lexical analysis Syntax analysis Semantic analysis Intermediate code generation Code optimization Target code generation. How can I see output of each step e.g I want to see parse tree after syntax analysis. I am compiling program on Linux machine with GCC co...

Compile Using MONO - C# with Reference To A C# Library?

Hi there, I have a C# library (DLL) // ProgramLib.cs // using System; namespace ProgramLibrary { public class Lib { public Lib() { Console.WriteLine("Lib Created"); } } } And I have the following console program // Program.cs // using System; using ProgramLibrary; class MainClass { ...

C++ & GCC: How Does GCC's C++ Implementation Handle Division by Zero?

Just out of interest. How does GCC's C++ implementation handle it's standard number types being divided by zero? Also interested in hearing about how other compiler's work in relation to zero division. Feel free to go into detail. This is not purely for entertainment as it semi-relates to a uni assignment. Cheers, Chaz ...

Compile C# code extension at runtime

I have a system that compiles C# code at runtime. I would like the generated assemblies to be linked to the system itself. Here's some example code that I am using: CSharpCodeProvider provider = new CSharpCodeProvider(new Dictionary<String, String> { { "CompilerVersion", "v3.5" } }); CompilerParameters compilerparams = new CompilerParam...

Why compiler provides default copy constructor

Hi, I wanted to know Why compiler provides default copy constructor..Whats the strategy behind that idea. Thanks in Advance. ...

Smalltalk compilers that target either Java, .NET or Ruby

Looking for a Smalltalk compiler that given Smalltalk (Instantiations) will emit either Java bytecode, .NET CLR or Ruby. Not looking for porting utilities as I want to leave the application in Smalltalk. I have googled for solutions and ran across a company who had a website (http://www.smalltalkmigrations.com/) but it seems as if they ...

Reference type and pointer in disassembly

Why reference types and pointers are same in compiled code?(You can see in third and fourth line). I tried to figure it out but apparently I could not achieve. If a reference type variable must be initialized at declaration and can not be changed so is there any need to do indirection as in pointers? int x = 10; mov dword ptr...