Good recources on creating programing languages/compilers?

Programming, for all ages and all languages.
Post Reply
FYew
Posts: 1
Joined: Mon Apr 03, 2017 6:49 pm
Libera.chat IRC: FYew

Good recources on creating programing languages/compilers?

Post 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
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: Good recources on creating programing languages/compiler

Post 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.
Last edited by Schol-R-LEA on Thu Apr 06, 2017 1:44 pm, edited 3 times in total.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
User avatar
Schol-R-LEA
Member
Member
Posts: 1925
Joined: Fri Oct 27, 2006 9:42 am
Location: Athens, GA, USA

Re: Good recources on creating programing languages/compiler

Post 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.
Rev. First Speaker Schol-R-LEA;2 LCF ELF JAM POEE KoR KCO PPWMTF
Ordo OS Project
Lisp programmers tend to seem very odd to outsiders, just like anyone else who has had a religious experience they can't quite explain to others.
User avatar
eryjus
Member
Member
Posts: 286
Joined: Fri Oct 21, 2011 9:47 pm
Libera.chat IRC: eryjus
Location: Tustin, CA USA

Re: Good recources on creating programing languages/compiler

Post by eryjus »

Also, I like Flex & Bison as a tutorial on how to use the respective tools.
Adam

The name is fitting: Century Hobby OS -- At this rate, it's gonna take me that long!
Read about my mistakes and missteps with this iteration: Journal

"Sometimes things just don't make sense until you figure them out." -- Phil Stahlheber
Post Reply