Could you explain it briefly.In addition could you explain or give a small tour on how to create a programming language.
What are the techniques used in creating a programming language like C?
Creating programming languages is a well-studied area of computer science, and there are lots of tools to help.
There's no way I can describe the design and implementation of a language in this tiny box, but I can point you to some excellent resources.
First, you need to learn about language processing. I personally like the new ANTLR book that's come out. You can get a copy, or you can read the documentation on the ANTLR site.
http://www.antlr.org/
Reading up on implementing language processors and the like will help you with the next item.
Next there's LCC.
http://www.cs.princeton.edu/software/lcc...
At this link you'll find a book describing the implementation of a complete non-toy C compiler called LCC. After making your way through this text, you'll know how a real C compiler works. In way, way, WAY too much detail. :-) This will make you a much better C programmer, by the way.
Finally, I always recommend people read Structure and Interpretation of Computer Programs by Abelson and Sussman. It is a complete education in computer science in one book, from computer arithmetic to compiler and interpreter design. You could buy a copy, but the whole thing is online for free at MIT:
http://mitpress.mit.edu/sicp/full-text/b...
Hope this helps!
Reply:It's a fairly large process, but you can take it in small steps and workup to a sizeable language.
First, you need to write out the grammar that will be standard to the language - it will contain the syntactic and semantic conventions of the language (keywords/reserved words, punctuations, basically the way different elements of the language will be used)
The language compiler will be written in another language more than likely, so you'll need to develop a lexical analyzer from your grammar and run it against something like JLex (free lexical tool that reads your tokens and outputs a JLex file as a keyword reference basically)
Next you'll need to develop the a syntax analyzer - this will run through to make sure the code you write out in your language is used correctly. It generally parses through your code recursively and are known as recursive decent parsers.
From here you basically need to write up the compiler/interpreter and you're good. An interpreter will probably be easier but has it's drawbacks in performance.
Sorry this is so broad and vague, but there are alot of ways of implementation - this is just the path I've taken. Look each of these elements up and you will get a better idea.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment