Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I have begun working on a <a href="https://github.com/KendallHopkins/FormalTheory" rel="nofollow">solution on Github</a>. It can already lex most examples and give the solution set for finite regex.</p> <p>It currently passes the following unit tests.</p> <pre><code>&lt;?php class RegexCompiler_Tests_MatchTest extends PHPUnit_Framework_TestCase { function dataProviderForTestSimpleRead() { return array( array( "^ab$", array( "ab" ) ), array( "^(ab)$", array( "ab" ) ), array( "^(ab|ba)$", array( "ab", "ba" ) ), array( "^(ab|(b|c)a)$", array( "ab", "ba", "ca" ) ), array( "^(ab|ba){0,2}$", array( "", "ab", "ba", "abab", "abba", "baab", "baba" ) ), array( "^(ab|ba){1,2}$", array( "ab", "ba", "abab", "abba", "baab", "baba" ) ), array( "^(ab|ba){2}$", array( "abab", "abba", "baab", "baba" ) ), array( "^hello?$", array( "hell", "hello" ) ), array( "^(0|1){3}$", array( "000", "001", "010", "011", "100", "101", "110", "111" ) ), array( "^[1-9][0-9]{0,1}$", array_map( function( $input ) { return (string)$input; }, range( 1, 99 ) ) ), array( '^\n$', array( "\n" ) ), array( '^\r$', array( "\r" ) ), array( '^\t$', array( "\t" ) ), array( '^[\\\\\\]a\\-]$', array( "\\", "]", "a", "-" ) ), //the regex is actually '^[\\\]a\-]$' after PHP string parsing array( '^[\\n-\\r]$', array( chr( 10 ), chr( 11 ), chr( 12 ), chr( 13 ) ) ), ); } /** * @dataProvider dataProviderForTestSimpleRead */ function testSimpleRead( $regex_string, $expected_matches_array ) { $lexer = new RegexCompiler_Lexer(); $actualy_matches_array = $lexer-&gt;lex( $regex_string )-&gt;getMatches(); sort( $actualy_matches_array ); sort( $expected_matches_array ); $this-&gt;assertSame( $expected_matches_array, $actualy_matches_array ); } } ?&gt; </code></pre> <p>I would like to build an <code>MatchIterator</code> class that could handle infinite lists as well as one that would randomly generate matches from the regex. I'd also like to look into building regex from a match set as a way of optimizing lookups or compressing data.</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