#How to make a simple Programming Language
70 messages ยท Page 1 of 1 (latest)
i would love to buy it, but my mother wont allow me to buy about something she doesnt understands
I suggest you find it
the most boomer thing ive seen
lmao
this seems so cool, boutta yoink that asap
^ you can try that also, it's fully free online
it's not in go but it should share the broader concepts
and should be enough for what you need to get started
Grow up faster ๐
i got the book dont worry ๐
also what do you expect from a 15 y/o kid....?
Nice!
It was rather a joke, as I know the feeling myself from few years ago haha
ok then ๐
Well it's easy to create an interpreted language. I suggest using text/scanner to tokenize your input
alright so... I have made a language with the book, now... can anyone help me, I cant seem to find a way to add std lib for it, like math, etc
so you want to make go functions and execute them in your language?
no, like functions written in the custom lang
so you want to write the std in your own language or write them in go and be able to call them in your language?
in my own lang
well if you have function decleration in your language you can do just add your own code into the file that the user wants to execute or make files in your own language then import them into the file that user wants to execute, i would just write the std in golang and make it available in the language
hmm, alright I can make the std in golang, but what if the users want to make there custom library and want to import it in the main file? how will I achieve that?
well first you need to know how the lexer works and be able to modify it with no problems
that I can do
I can modify all the code in the project
ok thats good, first in here https://github.com/Jonak-Adipta-Kalita/JAK-Programming-Language/blob/main/token/token.go add a new keyword like import
then send me your import keyword syntax
you want me to just add the keyword? no lexer parser?
yes i know about the lexer but first we need the syntax for the import keyword
use "filename.extension"
done
so how would u use it
like
you would do like golang import
use file "filename.extension"
and then with
file you can access functions
like file.<Method>
which one do you think is better? (none is better ig, then which do you think is easier?)
lets do use "file.ext" as file?
Yea that could work
alright ๐
Then in token.go you need to define use and as keywords and file would be an identifier, in lexer you need to detect "use", to detect the use and as keyword at first it would be an identifier and if it matches use or as then its type is use or as
hmm ok
For example in here in my programming language
i have to go somewhere I'll do it after I come back
Ok
btw I just had to say, if we make a token and keyword in token.go it automatically gets lexed as a identifier
if you got what I meant
Yes I got it I'll take a look into the lexer code
alright
I think I have 2 approaches, make an export statement
Or
Read the file find variable/function decelerations and add them to a map and then use them
i didnt really understood....
by export statement, what do you mean? where should the export statement be?
u created a programming lang in 5 days ๐คจ?
It's possible to get a Turing Complete language in 5 days if you're familiar with all of the steps.
ok in import statement u need to execute that files code then take all refrences and then add them to a map and allow to use it in the file with import statement
In 3 days, I was following the book, so it was pretty easy
Hmm ok..... I understand now
ok so u r just pasting
kinda
its still possible to create a simple programming language in few days
@soft tusk cheeck out the super-tiny-compiler written in Go: https://github.com/hazbo/the-super-tiny-compiler, it is written only in ~250 LOC (excluding comments), so should be super easy to get started with
i dont want a compiler and I am happy with the interpreter I have made
Compilers and interpreters do share the a lot of components in the beginning stage like tokenizer, parser, etc
Since the codebase is extremely small, you should be able to swap and modify the parts you don't need
This might also be a good starting point:
https://github.com/alecthomas/participle/blob/master/_examples/expr/main.go
thanks a lot bro, it now works ๐
hey buddy, how is going, I need another help.... so I am trying to add elif statements to my lang... I am not able to think of how I can do....
When I made if/else/else if statements when I check for else and next token is if then I skip 1 turn and then read it as an if statement