Methodologies for designing a simple programming language

前端 未结 3 1330
温柔的废话
温柔的废话 2021-01-06 02:04

In my ongoing effort to quench my undying thirst for more programming knowledge I have come up with the idea of attempting to write a (at least for now) simple programming l

相关标签:
3条回答
  • 2021-01-06 02:47

    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.

    0 讨论(0)
  • 2021-01-06 03:05

    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.

    0 讨论(0)
  • 2021-01-06 03:05

    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.

    0 讨论(0)
提交回复
热议问题