ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Qdepartment on yahoo.com is a really good forum/group to help with compilers/interpretors, I think in C/C++ only, though I'm sure there must be others there who knows Pascal. Yet everything I've seen so far is only for C/C++.
Learn all you can about Flex and Bison, as they will save you many hours of programming tedium with any reasonably complex language.
I did a couple of compilers for course projects at university. A compiler for a very simple language, written in C++ without the aid of Flex or Bison, took most of a semester to write. Probably 40 or 50 hours went into it; part of it was already written for us. The next semester, I wrote a compiler for a language that was nearly as complex as C is (probably 2 or 3 times as complicated as the language used in the previous semester), which, thanks to Flex and Bison, took far less time to write - maybe more like 20 hours to finish, once I understood how to do it.
hey wapcaplet - thanks.
i did write a scanner using flex/bison.
are u saying that you had a compiler from scanner to code generator done in ~20 hours in total?
i think im startin to feel ill now. i'll now downgrade "reasonably good C programmer" to something else.
Yacc is a pretty good tool as well. If you get the right set of tools all you really need to make your own little compiler is a good grammer. I did a compiler project in college for a simple language kind of like lisp (hey... it was an assignment) and once I had a good understanding of lex and yacc I got it working in about 10 hours. Of course the grammer was really simple so that is partially why it took so little time. That and the fact the language really was useless.
Perl was designed in Lex and Yacc so they must be good for something.
If you are doing it for a college project you can use the any language and I prefer C or C++ for the first time people because there is much docs about it and implementations as well so you can learn by example (memory mapping!) and if you are doing it for business (only you can calculate its outcome/income!).
while bison, yacc, and flex are indeed great tools for getting compilers written faster, imo, there's still something to be said about the nitty gritty theory on creating a language especially if your prof, like mine, won't allow you to use those tools.
Well, language design and language implementation are two entirely different things. All bison and flex do is automate the fairly simple (but all too time-consuming) task of writing a parser for the language. You still have to design the language properly, write the code-generation stuff yourself as well as the optimizer if you're going to have one, etc. The hard part you still have to do yourself.
Also, if the design of the language is what you want to concentrate on first (which you should if you're developing a serious language rather than a toy language so you can concentrate on the compiler), check out this: http://www.nondot.org/sabre/Mirrored/AdvProgLangDesign/
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.