rindPHI / grammar2regex

Conversion / approximation of context-free grammars to regular expressions (custom ADT types or z3 ReRefs)
GNU General Public License v3.0
6 stars 0 forks source link

How to achieve a usable regex string as output. #2

Open clache547 opened 2 months ago

clache547 commented 2 months ago

This is simply the concatenation operator :) It's part of the reflex syntax I chose. You can also have the output as a Z3 regex object if you prefer.

Originally posted by @rindPHI in https://github.com/rindPHI/grammar2regex/issues/1#issuecomment-2197480266

^ Regarding this: I see. If I would like to use an output that is a syntactically correct regex string, it seems just removing the concatenation operator wouldn't suffice. How would I be able to get that?

rindPHI commented 2 months ago

Hi @clache547,

First, what's usable depends on where you want to use the regex. There's no such thing as a globally accepted standard for regex syntaxes.

What you obtain from the conversion is a Regex object. I recommend you implement a recursive procedure converting the classes inheriting from that base class to a string in a case distinction. It's only five cases you'll need to distinguish. Have a look at how this is done in regex_to_z3.

Cheers, Dominic

clache547 commented 2 months ago

Sounds good, I'll look into this!