954,499 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to write a compiler

I want to learn how to write a compiler. Can someone help with the path, what
i need to be able to write a compiler. Any tutorial links?
And can someone help me with becoming a system programmer. What i need
and some tutorial links?
thnx.

egoleo.

egoleo
Newbie Poster
19 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

>I want to learn how to write a compiler.
Okay, you need to know the language that the compiler processes inside and out, as well as assembly for all of the machines that the compiler will be run on (assuming you're compiling to machine code, it's easiest to output assembly and then assemble it into machine code). You need to figure out the grammar for the language, then design a parsing scheme. Naturally, any decent compiler will also have extensive error checking abilities so that it can produce useful diagnostic messages. Those tasks should give you a start.

>Any tutorial links?
Not off the top of my head, but you might consider picking up the dragon book as well as something more modern for a fairly thorough introduction.

>And can someone help me with becoming a system programmer.
What system? Systems programming is a very broad category that includes operating systems, networking, and databases. We implement the tools that applications programmers use to build and run applications. So what exactly do you want to do?

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

yeah what i want is the operating systems.
and also some free links to get the compiler tutorials from?

egoleo
Newbie Poster
19 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 

>yeah what i want is the operating systems.
Okay, do you want to write operating systems or maintain them? Are you more interested in working on the bare metal kernel or the system control operations that are delegated away from the kernel? Do you want to work with Windows based systems or POSIX based systems? Have you considered mainframes and embedded development?

>and also some free links to get the compiler tutorials from?
...What part of "not off the top of my head" is difficult for you? If I knew of any good tutorials I would mention them, but I have yet to see a systems or compiler programming tutorial that's worth a damn. Look at the books I suggested. For systems programming, there are plenty of books out there, but Richard Stevens' books are an excellent first step for UNIX systems programming, and the various "we can write a kernel!" books focused on Linux are informative. MSDN is a good reference for Windows systems programming, but you're not likely to find any material on the kernel or other back end stuff unless you make their OS development team. ;)

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

Yeah what i want to do is POSIX systems.

egoleo
Newbie Poster
19 posts since Jul 2005
Reputation Points: 10
Solved Threads: 0
 
Stoned_coder
Junior Poster
164 posts since Jul 2005
Reputation Points: 19
Solved Threads: 5
 

I'm only new here, but it seems that a lot of the posts in the forum are from people who say things like:

"I want to learn how to do ray tracing in cobol on a palm pilot; I don't know anything about programming yet, and clearly I'm not able to use a search engine either, but I want to be able to complete my project by noon tomorrow".

Is this as common as it appears?

leelee
Junior Poster in Training
77 posts since Aug 2005
Reputation Points: 31
Solved Threads: 1
 

yes, it's extremely common.
And the last few years it's getting ever worse, and seems to be coming more and more from people whose names and/or locations identify themselves as Indians.

They're basically only interested in getting a piece of paper showing themselves programmers, then cheating past a recruitment interview not much more involved than spelling out the word "computer", and then taking our jobs for their own.

But it's always been there, many kids have no idea what it takes to create software.
This is perfectly apparent from the many excuses they have for piracy, often hinging around "software costs only $1 for the CD".
They think writing something like Doom 3 or Photoshop takes a single person a few days at most, not realising it's teams of dozens or hundreds of people who need years.
And even if they did they don't know economics (never having had to pay the rent or bring in money to buy their own food and clothes) so they don't know what the cost of running such a team is.

jwenting
duckman
Team Colleague
8,392 posts since Nov 2004
Reputation Points: 1,662
Solved Threads: 337
 

I wrote one back in college. My partner and I used BNF to initially describe it. From there, it was simply a matter of constructing it (we used C++ and Assembly).

Here's a good BNF tutorial: http://www.garshol.priv.no/download/text/bnf.html

It doesn't tell you everything, but it's a good starting point.

garraeth
Newbie Poster
5 posts since Sep 2005
Reputation Points: 10
Solved Threads: 0
 

pls if u get this answer then PM mmmmme too

nidhi.juneja
Newbie Poster
3 posts since Oct 2008
Reputation Points: 4
Solved Threads: 0
 

let me start by appologizing for stumbling across your forums and necroing a year old thread... but this is what you get for having the first search result in google! :P

anyway, im in a programming languages course at college and my instructor DOES NOT HAVE A DEGREE IN PROGRAMMING!!! what is wrong with the world today?
our next project is due in 1 week, we just got it extended from being due in 2 days because he has yet to mention building a compiler yet in class and that is what is our next project is!

im angry because i now have to explain passing by value vs passing by refference TO MY INSTRUCTOR OF A HIGH LEVEL PROGRAMMING COURSE!

this is stupid... :(
why did i pay for this? :(

mr_ewe
Newbie Poster
1 post since Nov 2009
Reputation Points: 10
Solved Threads: 0
 
this is stupid... :(


yeahwhy did i pay for this? :(
Why would you pay for something stupid? Maybe you are stupid :P

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 

Check the project DelphiBasic - it is a simple implementation of Basic core language written on Delphi. You can modify semantics file to realize syntaxis of any other language you want.

http://code.google.com/p/delphibasic/

bitek
Newbie Poster
1 post since Dec 2010
Reputation Points: 10
Solved Threads: 0
 

I strongly condemn jwenting's post. Please don't just label as 'Indians' in general. For your kind information, it is Ramanujan's Mathematics, which stands as the base for Modern Computer Electronic Systems. I have great respect for Ramanujan, Ritchie, Gosling and for all those who contribute for the development of this e-world. Please think before you post.

rmahendrababu
Newbie Poster
3 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

@jwenting: I accept that the Education / Teaching standards or not as good when compared to western countries. But even then we learn and achieve. Think what if, if we get an education and guidance equivalent to the one in US and Canada.

rmahendrababu
Newbie Poster
3 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 
I strongly condemn jwenting's post. Please don't just label as 'Indians' in general. For your kind information, it is Ramanujan's Mathematics, which stands as the base for Modern Computer Electronic Systems

Lolwut?

Ramanujan has practically nothing to do with computing. Maybe he devised a few quicker algorithms for computing pi.

Rashakil Fol
Super Senior Demiposter
Team Colleague
2,658 posts since Jun 2005
Reputation Points: 1,135
Solved Threads: 177
 
I strongly condemn jwenting's post. Please don't just label as 'Indians' in general.


I don't see a problem. jwenting clearly specified the context of posts on Daniweb from programmers who clearly don't want to put forth any real effort. He also made the observation that "more and more" of these posts are coming from members in India (according to their names and/or location). In my experience, that observation is accurate.

There was no generalization or racism, just a simple observation in a very specific context. I'm sorry you were offended, but the post you "condemn" is within the bounds of Daniweb's rules, which already makes provisions against racist remarks.For your kind information, it is Ramanujan's Mathematics, which stands as the base for Modern Computer Electronic Systems.
So you're using Ramanujan's contributions to mathematics (note that he died in 1920) as an excuse for the current Indian CS educational system and apparent laziness of a statistically significant majority of students from that educational system who choose to post on Daniweb?

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

I accept that there are majority of such posts in Daniweb, of course that's the cause of our edu. standards, I accept that too. But I would like put the point that amidst this, there are people who really performs very well. I regret if I have hurt anybody.

rmahendrababu
Newbie Poster
3 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 

Two good books that I have on my shelf are:

Crafting a Compiler, Fischer & LeBlanc
Compiler Design in C, Holub

rubberman
Posting Virtuoso
1,564 posts since Mar 2010
Reputation Points: 277
Solved Threads: 179
 
But I would like put the point that amidst this, there are people who really performs very well.


Indeed, nobody claimed otherwise. As a prime example, our super moderator ~s.o.s~ is both a skilled programmer and from India.

Please don't take offense at this next statement as it's once again an innocent observation, but a common behavioral pattern of racists is seeing racism against themselves where none exists. You've shown such a pattern with this imagined offense against Indians, so rather than claiming racism in others, I'd suggest tolerance on your part first. Especially since it's so easy to misunderstand others on the web.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You