Design Methodologies for a Simple Programming Language

In my ongoing efforts to quench my undying thirst for additional programming knowledge, I came up with an attempt to write (at least for now) a simple programming language that compiles to bytecode. The problem is that I do not know, first of all, about the design of the language. Does anyone have any tips on the parser construction methodology and what are the main functions that every language should have? What reading would you recommend for language design? How high should I shoot? Is it wrong to hope that you can enable a function that allows you to embed the bytecode in the same way as gcc allows the built-in assembler? Seeing that I'm mostly C and Java code, what would be better for writing a compiler?

+5
language-design bytecode compiler-design
source share
3 answers

There are so many ways ...

You can look at stack languages ​​and Forth. This is not very useful when it comes to developing other languages, but it is something that can be done very quickly.

You can learn functional languages. Most of them are based on a few simple concepts and have simple parsing. And, nevertheless, they are very powerful.

And then traditional languages. They are the most difficult. You will need to study lexical analyzers, parsers, LALR grammars, LL grammars, EBNF and common languages ​​in order to pass the analysis.

Bytecode orientation is not just a good idea. Otherwise, the exercises will be crazy and mostly useless in the learning process.

Do yourself a favor and look at books and tutorials about compilers.

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

+3
source share

You can first read a book about compilers .

To really understand what is going on, you will most likely want to write your code in C.

Java would not be a bad choice if you want to write an interpreted language like Jython . But since it looks like you want to compile machine code, it might be easier in C.

+1
source share

I recommend reading the following books:

ANTLR

Language Design Templates

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

+1
source share

All Articles