Building blocks for using Regular Expressions (RegEx)

Regular Expressions (RegExes) can be thought of as simple computer programs, but they are just as capable of stumping beginners. Inspired by how block-based languages like Snap! made code more accessible to new programmers, I decided to try doing the same for RegEx patterns. This project provides a (hopefully) easy-to-understand set of blocks that let you build RegExes without worrying about the syntax.

Link: Regexp building blocks test by gregory8128 - Snap! Build Your Own Blocks (berkeley.edu)

I like this idea!

I think maybe you could improve the clarity of the presentation by reducing the number of blocks. For example:
Google Chrome001
instead of three separate blocks, to clarify that they're variants of the same idea.

But I was sad to look inside your blocks and see that you make Javascript do the work. Regular expression parsing and matching is something that can easily enough be done in Snap! itself, where the code is accessible to learners. Sort of like this: https://people.eecs.berkeley.edu/~bh/v3ch1/fsm.html

Thank you for taking a look at my project!

I did not know that you could do dropdowns in custom blocks! That is pretty cool.

The original intent of the project was to help teach how to put RegEx blocks together, so I figured that the JS engine would be fine. But you are right, it would be very good for people to be able to see how the actual engine works, even if it would take a bit of time to implement.

I can't work out how to run the fsm program to play game :frowning:

Oh. GAME calls FSM. You say, e.g., GAME 3 to play the third (of ten) games. FSM takes an arbitrary finite state machine and simulates it.

I mean more fundamental than that :slight_smile:

What do I physically run it in?

Oh! Berkeley Logo.

... and when you start Logo you can just say

cslsload "fsm

to load that program.

Getting there - managed to run game 1 :slight_smile:

image

But how do I quit game 1 without closing Logo environment (running on windows if that make any diff)

It does make a difference, because on my Mac you type option-C to stop the running program. But if you look on the menu bar there should be a menu named Logo and it'll have options "stop" and "pause" and you can look at the keyboard shortcut shown next to the "stop" one.

edit: Thank you for finding a Logo bug... those lines with the all-caps ACCEPT and REJECT should also be showing what you typed to get to those states.

That's my problem - when I click on stop - the whole Logo window closes

But I just want to quit the running game 1 program

Is this another bug? :slight_smile:

edit

BTW it works fine if I don't have a running program

image

Oh. Yes it is. I thought that was just on my Mac. I've filed a bug report.

Meanwhile, after loading the program, type

er "fsm1

and then paste this in:

to fsm1 :here
ifelse memberp :here :accept [accept] [reject]
fsm1 (fsmnext :here fsmcheckstop readchar)
end
  
to fsmcheckstop :char
if :char = "s [throw "toplevel]
op :char
end

And then you can type "s" (just plain s) to stop the game.