Page 1 of 1

Good recources on creating programing languages/compilers?

Posted: Mon Apr 03, 2017 7:13 pm
by FYew
Hey, I know this is probably a really idiotic question to ask but does anyone here know any good recourses on making a custom programing language/compiler? I have made a simple scripting language for my up-coming OS and I plan to have a compiler for it. It probably wont help much but here is some sample code:

Code: Select all

~/Comments are enclosed in '~/' and ended in '/~'. Can be multi-line /~
req 'path/to/api'        ~/ Loads an API /~
bool t set True          ~/ Sets a Boolean variable 't' to True /~
~/ Variable types are integer(int), float(flt), Boolean(bool), character(char) and memory address (mem) ~/


IF(t) START    ~/ If t is true it will execute the code ?/~
~/ Stuffs to do... /~
ELIF(1<2)      ~/ IF the if statement was false it checks this /~
~/ Stuffs to do... /~
ELSE              ~/ If no statement is true then it runs this /~
~/ Stuffs to do... /~
END
Thank you in advance

Re: Good recources on creating programing languages/compiler

Posted: Mon Apr 03, 2017 8:29 pm
by Schol-R-LEA
I would like to recommend our sister site, Compilerdev.org, and its companion forums. It is still a very new site, so the resources are limited so far, but it is probably the best place at the moment.

You could also try the old USENET newsgroup comp.compilers as well (it is mirrored through Google Groups if you don't have a feed), but I have no idea how active it is or how much spam it gets these days (I should probably check, actually). I am pretty sure it is moderated, so junk posts shouldn't be too much of an issue, but volume may be another matter (EDIT: yes, I just checked, it is moderated, and it does seem active if a bit slow; however, it is dominated by experienced compiler designers and academic researchers - which is good to see, by my count, but probably not what you needed).

There are numerous books on the subject, and while public libraries are unlikely to have anything much on the topic (or if they do, it is likely to be a SAMS junkheap - did they ever actually publish a book on that? - or possibly something really dated like A Small C Compiler), most college or university libraries will have, at the very least, a copy of the venerable Dragon Book, and usually at least some of the older texts for less academic audiences such as Introduction to Compiler Construction, Crafting a Compiler in C, Compiler Design in C, or an earlier edition of Writing Compilers and Interpreters: A Software Engineering Approach. Better stocked libraries may also have Engineering a Compiler and/or Modern Compiler Design, both of which are (IMAO) better written, easier to follow, and more up to date than the 3rd edition of the Dragon Book (OK, technically not third ed, but they changed the title after the first one, so...). Even a moderately sized university is likely to have both.

There are any number of other books on the subject, but the values of them are going to be hit and miss, and which one will work best for you is something no one can say until you try them.

If I had to recommend one, I would say Modern Compiler Design, but it you may find it a tough nut to crack; it is at least as academically oriented as Aho and Ullman, even if it is more engagingly written. Mak's Writing Compilers and Interpreters makes for a much gentler learning curve, but it's not nearly as comprehensive. You might want to try Mak first, then go with Grune et. al. for more advanced material if you need or want to later.

You might also want to look at books specifically on 'scripting languages' (which usually means either a shell command language such as BASH shell, or an interpreted/compile-and-go swiss-army-knife like Perl or Python), such as Language Implementation Patterns: Create Your Own Domain-Specific and General Programming Languages, though both Mak and Grune discuss interpreters to some degree as well.

Re: Good recources on creating programing languages/compiler

Posted: Mon Apr 03, 2017 9:07 pm
by Schol-R-LEA
OK, why do I always do this? I spent over an hour tweaking my post after I initially posted it. I am guessing the the OP has already read the older version, and may never see the new edits. Me R Dah Dumas.

Re: Good recources on creating programing languages/compiler

Posted: Thu Apr 06, 2017 2:21 pm
by eryjus
Also, I like Flex & Bison as a tutorial on how to use the respective tools.