Skip to content

Nothink

dprokoptsev edited this page Dec 15, 2010 · 3 revisions

Don't make me think!

A brief summary of changes needed for people to use Pire without reading any documentation :)

Easy syntax

  • Add a AnyScanner class to transform static Scanner polymorphism into dynamic one. Compilation into AnyScanner should try to determine FSM and produce a DFA; if failed, switch to NFA.
  • Wrap it into Regexp class, possessing bool Matches(const std::string&).
  • Add a holder for Feature and Encoding, possessing operator|().

These features enable new easy synatx:

Pire::Regexp re("(foo|bar)*ba[zr]", Pire::NOCASE | Pire::ANCHORED | Pire::UTF8);
if (re.Matches("foobar"))
    std::cout << "YARLY!" << std::endl;

TODO: what about scanners in extra/?

Surround

Detect patterns like /.*^foo/ and transform them into /^foo/, since people constantly Surround() thier patterns and heavily use anchors where they actually do not need any surrounding.

Clone this wiki locally