How can I decode text simple?

Hey, So I am creating a little app which users can create simple but fun programs. Yes, I am creating a programming language in a programming language programmed with another programming language ;). The problem I am facing is that I cant think of a simple and effective way to decode the lines of code. For example, if the line is: print "Hello world!" I can’t just compare them with a line because a variable is in it. Does anyone know a simple and effective solution?

greetings, Ruben

Explain better…
print “Hello world!” , is there a variable ?
There is 1 command (which must exist in your command list)
There is 1 string ( which can be identified , perhaps , because there are 2 double quotes )

Yes so the code between “” is variable. And I wanna put real vars there too, But Those are different per user and per program so I cant have a set line

Yes in this case there is, but If I have something like set {var} to "This" Its already different because there is a var in between.

but what if you { } define that what is between them is a variable ?
Or I didn’t understand…:grin:
your command will be:
set varname to “hello”
or
set {varname} to “hello” ?

Yes, that’s correct but how can I simply do that effectively?

But how do you want to do this? In kodular blocks?:thinking:
Is it a prototype?:face_with_monocle:
You might have to set up your “new language” definition rules, which wouldn’t be very practical using blocks…🤷
But, I might not have understood your true idea.:grin:

I will explain it in a bit more detail. I wanna create a simple programming language to display text and get some inputs from text or sensors or someting. Just a fun to play app. The problem I am facing atm is how I can check if a line of code is really something that exists. If they for example say move {hey} to the left In this case {left} is a variable. My app has to understand that that line of code does not exists in the app so it creates an error. But it needs to work if its a line that does exist. The hard part is that I cant just compare the line of code with a string, because variables change. Is this more understandable? :slight_smile:

1 Like

You will have to create your list of rules (syntax) for each command.
Create routine so that there is only 1 space between the words of the command.

Search if the command exists (in the first 10 characters of the command line, for example)
move
right
left
up
down. ( Only 4 first chatacters )
if it exists start testing the rules ( syntax ) of that command…

It’s no AI :grin:

1 Like

I will try thanks!

1 Like