zeusdeux / re2

Automatically exported from code.google.com/p/re2
BSD 3-Clause "New" or "Revised" License
0 stars 0 forks source link

feature: incremental matching #30

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Hi.  I've read a bunch of the headers and implementation files, and haven't 
found any support for incremental matching with state-saving.  For instance, 
let's assume the following:

##
std::string a("Foo");
std::string b("Bar");
RE2 pat("FooBar");
##

Now, I want to do the following (making up the syntax):

###
result = RE2::IncrementalMatcher();
if(result.Match(a, pat))
{
  printf("Yay! Matched the 1st!\n")
}
if(result.Match(b, pat))
{
  printf("Yay! Matched the 2nd!\n")
}
###

This should print "Yay!  Matched the 2nd!", because the state of the DFA was 
saved between the Match calls, and was resumed upon the match call for string 
b.  

If this is obvious, and I'm just thick-headed, please let me know.  Otherwise, 
what would it take to implement this?  Is there currently a way to manually 
save Prog state and re-input it into a Match call?

This is particularly useful when reading a file one line at a time without 
reconstructing the entire thing in memory (slow).  I'm open to suggestions.  
Thanks for making such an awesome library!

Original issue reported on code.google.com by hardware...@gmail.com on 9 Sep 2010 at 8:20

GoogleCodeExporter commented 9 years ago
Unfortunately there's nothing like that.
If you wanted to build it, you could probably
start by looking at re2/dfa.cc, especially the
StateSaver.  You'd want to use something like
the StateSaver as the persistent representation
across calls, since the individual DFA states
are only cached and can be freed or reused 
between calls.

Original comment by rsc@swtch.com on 11 Sep 2010 at 10:25

GoogleCodeExporter commented 9 years ago
Hi, when I intall RE2 on the CentOS5.5(64bit), everything is OK except run 
"make testintall", the error information:

(cd obj && g++ -I/usr/local/include -L/usr/local/lib testinstall.cc -lre2 
-pthread -o testinstall)
/usr/bin/ld: skipping incompatible /usr/local/lib/libre2.so when searching for 
-lre2
/usr/bin/ld: skipping incompatible /usr/local/lib/libre2.a when searching for 
-lre2
/usr/bin/ld: skipping incompatible /usr/local/lib/libre2.so when searching for 
-lre2
/usr/bin/ld: skipping incompatible /usr/local/lib/libre2.a when searching for 
-lre2
/usr/bin/ld: cannot find -lre2

Are there 64-bit version? Thanks a lot!

Original comment by sky...@gmail.com on 18 Jan 2011 at 2:12

GoogleCodeExporter commented 9 years ago

Original comment by rsc@golang.org on 10 Jan 2014 at 3:17

GoogleCodeExporter commented 9 years ago
RE2 has moved to GitHub. I have not moved the issues over. If this issue is 
still important to you, please file a new one at 
https://github.com/google/re2/issues. Thank you.

Original comment by rsc@golang.org on 11 Dec 2014 at 4:45