Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>This is actually pretty similar (identical?) to how a lexer/parser works. If you had a defined grammar then you could probably write a parser with not too much trouble. For instance, you could write something like this:</p> <pre><code>&lt;expression&gt; :: == &lt;rule&gt; | &lt;rule&gt; &lt;expression&gt; | &lt;rule&gt; " followed by " &lt;expression&gt; &lt;rule&gt; :: == &lt;val&gt; | &lt;qty&gt; &lt;val&gt; &lt;qty&gt; :: == "literal" | "one" | "one of" | "one or more of" | "zero or more of" &lt;val&gt; :: == "a" | "b" | "c" | "d" | ... | "Z" | </code></pre> <p>That's nowhere near a perfect description. For more info, take a look at <a href="http://www.rfoinc.com/docs/qnx/watcom/wd/regexp.html#RegularExpressionBNF" rel="nofollow noreferrer">this BNF of the regex language</a>. You could then look at <a href="http://en.wikipedia.org/wiki/Lexical_analysis" rel="nofollow noreferrer">lexing</a> and <a href="http://en.wikipedia.org/wiki/Parsing" rel="nofollow noreferrer">parsing</a> the expression.</p> <p>If you did it this way you could probably get a little closer to <a href="http://en.wikipedia.org/wiki/Natural_language_processing" rel="nofollow noreferrer">Natural Language</a>/English versions of regexes.</p> <hr> <p>I can see a tool like this being useful, but as was previously said, mainly for beginners. The main limitation to this approach would be in the amount of code you have to write to translate the language into regex (and/or vice versa). On the other hand, I think a two-way translation tool would actually be more ideal and see more use. Being able to take a regex and turn it into English might be a lot more helpful to spot errors.</p> <p>Of course it doesn't take too long to pickup regex as the syntax is usually terse and most of the meanings are pretty self explanatory, at least if you use | or || as <code>OR</code> in your language, and you think of * as multiplying by 0-N, + as adding 0-N.</p> <p>Though sometimes I wouldn't mind typing "find one or more 'a' followed by three digits or 'b' then 'c'"</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload