Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating your own language

If I were looking to create my own language are there any tools that would help me along? I have heard of yacc but I'm wondering how I would implement features that I want in the language.

like image 251
billcoke Avatar asked Dec 13 '08 19:12

billcoke


2 Answers

Closely related questions (all taken by searching on [compiler] on stackoverflow):

  • Learning Resources on Parsers, Interpreters, and Compilers

  • Learning to write a compiler

  • Constructing a simple interpreter

  • ...

And similar topics (from the same search):

  • Bootstrapping a language

  • How much of the compiler should we know?

  • Writing a compiler in its own language

  • ...


Edit: I know the stackoverflow related question search isn't what we'd like it to be, but did we really need the nth iteration of this topic? Meh!

like image 145
dmckee --- ex-moderator kitten Avatar answered Oct 13 '22 20:10

dmckee --- ex-moderator kitten


The first tool I would recommend is the Dragon Book. That is the reference for building compilers. Designing a language is no easy task, implementing it is even more difficult. The dragon book helps there. The book even reference to the standard unix tools lex and yacc. The gnu equivalent tools are called flex and bison. They both generate lexer and parser. There exist also more modern tools for generating lexer and parser, e.g. for java there are ANTLR (I also remember javacc and CUP, but I used myself only ANTLR). The fact that ANTLR combines parser and lexer and that eclipse plugin is availabe make it very comfortable to use. But to compare them, the type of parser you need, and know for what you need them, you should read the Dragon book. There are also other things you have to consider, like runtime environment, programming paradigm, ....

If you have already certain design ideas and need help for a certain step or detail the anwsers could be more helpful.

like image 43
flolo Avatar answered Oct 13 '22 19:10

flolo