Need help with integers

Hello this is my first post.
I was wondering:
How would I add a way for my programming language to print integers and be able to do math with them?

PS:
My programming language currently has: a way to output string values, create variables with string values, and print those variables out.

Hi @VALUEX and welcome to the community!

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.

8 Likes

Thank you!

Is there a guide that can help me make my programmign language more realistic?

what is ur language i can show u some code

if u dont specify what language i will be unable to help you- i teach computer science at oxford btw

It sounds like they’re making their own programming language.

1 Like

I am building the programming language using Node.js.

Can you send the link to your Repl?

1 Like

Here:
https://replit.com/@VALUEX/TEPL#index.js

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.

4 Likes