4 ms·
Got any recommendations for resources to get started creating one's own language?
by juliangregorian 12y ago
Got any recommendations for resources to get started creating one's own language?
- jeorgun 12y agoPat Shaughnessy's Ruby Under a Microscope[1] is a fantastic resource for looking at Ruby's internals, especially concerning parsing, Ruby's class structure, and the YARV virtual machine. It's probably easiest to begin with a Lisp dialect, since a basic one needs only two data types (singly-linked lists and symbols) and its eval function is so simple. Peter Norvig has a great tutorial[2] on implementing a Lisp in Python. Beyond that, it can be helpful to look at the source code for other languages similar to what you're looking to create, to get a sense of how they do things. That's more or less what I found helpful, in any case. Good luck! [1] http://patshaughnessy.net/ruby-under-a-microscope http://patshaughnessy.net/ruby-under-a-microscope [2] http://norvig.com/lispy.html http://norvig.com/lispy.html
- rtpg 12y agoFor the parsing aspects, reading about parser generators or the like would be super useful
- gorgas 12y agoI would not recommend using a parser generator tool to build a recognizer por any programming language,unless you design your language to be LL(1) or LL(k) witk a low value of k. Otherwise you are going to suffer a lot with parsing issues. Parser generators usually have a very limited number of target languages, so you might find yourself stuck into a language you do not want to code in.
- rtpg 12y agohmm, your results may vary (whitespace-sensitive languages, but that's tricky in pretty much any toolkit), but in my experience most DSLs that people want to write fit well within LL(k). Java works in it, after all. I started out with Yacc, though, and that helped me out a lot more...