Methodologies for designing a simple programming language

余生颓废 提交于 2019-11-30 21:21:05
Daniel C. Sobral

There are so many ways...

You could look into stack languages and Forth. It's not very useful when it comes to designing other languages, but it's something that can be done very quickly.

You could look into functional languages. Most of them are based on a few simple concepts, and have simple parsing. And, yet, they are very powerful.

And, then, the traditional languages. They are the hardest. You'll need to learn about lexical analysers, parsers, LALR grammars, LL grammars, EBNF and regular languages just to get past the parsing.

Targeting a bytecode is not just a good idea – doing otherwise is just insane, and mostly useless, in a learning exercise.

Do yourself a favour, and look up books and tutorials about compilers.

Either C or Java will do. Java probably has an advantage, as object orientation is a good match for this type of task. My personal recommendation is Scala. It's a good language to do this type of thing, and it will teach you interesting things about language design along the way.

You might want to read a book on compilers first.

For really understanding what's going on, you'll likely want to write your code in C.

Java wouldn't be a bad choice if you wanted to write an interpreted language, such as Jython. But since it sounds like you want to compile down to machine code, it might be easier in C.

I recommend reading the following books:

ANTLR

Language Design Patterns

This will give you tools and techniques for creating parsers, lexers, and compilers for custom languages.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!