#How to make a simple Programming Language

70 messages ยท Page 1 of 1 (latest)

soft tusk
#

Hello Everyone,
So I want to make a simple Programming Language in Go, but I am not able to find any blog that can help me make one, I found some, but not able to understand what to do, first of all I just want to able to do simple maths like addition subtraction multiplication and division.

royal forum
soft tusk
smoky fiber
#

I suggest you find it

stone current
#

lmao

dapper narwhal
sour gorge
#

Free book

#

Not in Go

azure tartan
#

^ 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

soft tusk
soft tusk
royal minnow
royal minnow
unreal belfry
#

Well it's easy to create an interpreted language. I suggest using text/scanner to tokenize your input

soft tusk
#

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

unreal belfry
#

hmm could u show me your code base?

#

@soft tusk

soft tusk
unreal belfry
#

so you want to make go functions and execute them in your language?

soft tusk
unreal belfry
unreal belfry
#

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

soft tusk
unreal belfry
#

well first you need to know how the lexer works and be able to modify it with no problems

soft tusk
#

I can modify all the code in the project

unreal belfry
soft tusk
unreal belfry
#

yes i know about the lexer but first we need the syntax for the import keyword

soft tusk
#
use "filename.extension"
unreal belfry
#

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>

soft tusk
#

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?

unreal belfry
#

Yea that could work

soft tusk
#

alright ๐Ÿ˜„

unreal belfry
#

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

unreal belfry
#

For example in here in my programming language

soft tusk
#

i have to go somewhere I'll do it after I come back

unreal belfry
#

Ok

soft tusk
#

if you got what I meant

unreal belfry
#

Yes I got it I'll take a look into the lexer code

soft tusk
#

alright

unreal belfry
#

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

soft tusk
grave spindle
sour gorge
#

It's possible to get a Turing Complete language in 5 days if you're familiar with all of the steps.

unreal belfry
soft tusk
grave spindle
soft tusk
unreal belfry
grave spindle
soft tusk
grave spindle
#

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

teal fern
soft tusk
soft tusk
unreal belfry