Reputation: 225
I am kind new to writing custom languages. Before diving to Flex,Bison based Lexers,Parsers,Compilers I would like to ask if possible to do that before I begin to research maybe after week work I will realize that's its impossible. My goal is to create simply scripting language which would be translated to C language not to compiled further until machine code because of this code goes to embedded platform and needs to be compiled differently than normal languages. My point is to make something like this: Written script -> Parser translates that code to C code based on rules -> compiles to embedded machine code.
So maybe someone could suggest me the way to do this. Currently I reading about Flex & Bison based custom languages which get compiled to machine code but I think this isn't that I need.
Upvotes: 1
Views: 1441
Reputation: 1
You might read some literature concerning domain specific languages, e.g. DSL2011 and earlier proceedings.
Don't focus that much on lexing and parsing. Most of the work and the issues are in defining the language semantics and implementation.
Making a DSL translated to C is not an easy task. See for instance my DSL2011 paper on MELT.
Read some good books on language semantics and pragmatics, e.g. Programming Language Pragmatics by Scott.
Read also the Garbage Collection Handbook (Jones, Hosking, Moss).
At last, read some edition of C.Queinnec Lisp in Small Pieces, which notably covers translating a dynamically typed language to C.
Be aware that lexing and parsing is the most easy task in your work.
Did you consider embedding some existing scripting language like e.g. lua, python or guile or using existing VMs like Parrot or nekovm
Don't forget to study several different domain specific or scripting or programming languages. You need to know much more than one!
I strongly suggest making your implementation freely available in source form. It is quite difficult to attract users to a new DSL, and providing a free implementation lowers the barrier.
Upvotes: 4