I believe the first step would be to define arithmetic operators in your language, and have them to be recognized by the lexer and the parser. Remember to include a type system that can differentiate between strings and integers.
Bump because I still need help. Is there any guide here I can look at to create a programming language? I understand the lexer and tokenization now, but I don’t understand the parser.
About the parser… the parser will take the flat sequence of tokens and builds a tree structure that represents the grammatical structure of the input.
Being more direct, the parser will get the part of syntax checking, relationships and hierarchy, like, if you want to do 1+2 x 3, the proper order would be 3 x 2+1, and the parser will recognize that, etc.
In Resume:
The parser makes the computer understand the structure and meaning of the code.
There’s a good guide here (and what the author of the guide said):
Don’t worry. When I started this project 6 months ago, I had never built a compiler, nor had I used OCaml or C++ in any serious project. I’ll explain everything in due course.
In this series of posts we’ll be building a proper programming language. One of the gripes I had when seeing programming language tutorials that created a toy language with only operations like addition and multiplication, was: okay, but what about a real language like Java?
So that’s what this series aims to fix. The language Bolt I wrote as part of my third year disseration is a Java-style concurrent object-oriented language.