Answer the question
In order to leave comments, you need to log in
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
Answer the question
In order to leave comments, you need to log in
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 questionAsk a Question
731 491 924 answers to any question