I
I
Igor2020-08-19 10:57:41
Bots
Igor, 2020-08-19 10:57:41

How to write an interpreter for simple commands to a bot?

I welcome colleagues.

The question is still theoretical.

I am writing a universal bot. This task is quite easy to deal with.
Now I want to implement a feature (interpreter) so that my bot can download the program text and execute it.

Well, for example:
Bot, go there, do that, ask that.

My searches led me to keywords such as:

Лексический анализ, Интерпретатор, Token, Parser, AST


Throw a suitable article on the topic, which would move things a little off the ground.
Give advice.

Thank you.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor, 2020-09-27
@IgorPI

I was advised to look towards the state machine.
Indeed, this is what I needed to solve this problem.
Found a library
There was already an interpreter, and with sufficient potential.
What advantages I have identified for myself:
1. Changing the dialogue without changing the bot code.
2. Hot script reloading
3. Dialogue branching (most important)
And most importantly, I managed to implement a powerful bot with an action interpreter based on this library.
Now I just write scripts and enjoy.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question