Rust: Finite State Machine

preview_player
Показать описание
We are going over the basics of building a Finite State Machine in Rust.

Links:

My Social Links:
Рекомендации по теме
Комментарии
Автор

never seen someone give a content warning for a Wikipedia page before. excellent videos!

RoamingAdhocrat
Автор

Great video, very informative. Particularly enjoyed your approach of walking through the formal definition and then jumping into your implementation.

Looking forward for more content. Subscribed!

aleksandermirowsky
Автор

This came to me at a great time. I was stuck at writing a arithmetic parser where if my tokenizer is an iterator, I just can't go back because iterator "next" changes the iterator. Now I might implement a state machine where in case I have an parentheses or if I am simply checking for operator precedence, I can code that into a state machine and check against it.

abhishekshah
Автор

Subscribed you because of you mentioned Chinese is your second language😆

haozhen
Автор

It's been a while since I used state machines! I enjoyed the refresher =) Your implementation was great! It was also cool to see you handle Chinese characters.
I do think you could have simplified the state machine to two states (e.g. InQuote and NotInQuote) rather than three. Something like this:
case
InQuote: if is_right_quote
then flush buffer and state -> NotInQuote
else add to buffer
NotInQuote: if is_left_quote
then state -> InQuote
else continue

RdRdRd
Автор

Well, I'm looking at re-implementing my parser from Go to Rust so I'm bit new to Rust. But video confused me. Why use bytes? I've seen you can convert string to char vectors. Isn't that better approach for handling different languages?

dyto
Автор

Took me a while to understand what right and left quote meant 😅
Left quote: sentence(s) ending quote
Right quote: sentence(s) starting quote
And in 'process' fn: you're pushing all the characters inside the quotes to buffer.


(Did I get it right?)

ahmedhafiz