bool Matches(const Pire::NonrelocScanner& scanner, const char* ptr, size_t len)
{
return Pire::Runner(scanner)
.Begin() // '^'
.Run(ptr, len) // the text
.End(); // '$'
// implicitly cast to bool
}
Which one is correct?
If Begin() and End() are to be called, then patterns without ^ and $ match nothing:
When Begin() is called, it feeds scanner with special begin char, moving it to dead state 1.
Compare this graph with the graph produced for same pattern surrounded and optimised:
Does this mean that all patterns must begin with ^ and end with $? Are Begin() and End() calls required? It should be clarified and documented.
2 . pigrep
Program pigrep behaves as latter Matches, calling Begin() and End(). It also surrounds its patterns. I have removed surrounding (btw it would be useful option, grep has it as -x, --line-regexp) and get the following results:
Matches
.pire/run.h
:README
:Which one is correct?
If
Begin()
andEnd()
are to be called, then patterns without^
and$
match nothing:When
Begin()
is called, it feeds scanner with special begin char, moving it to dead state 1.Compare this graph with the graph produced for same pattern surrounded and optimised:
Does this mean that all patterns must begin with
^
and end with$
? AreBegin()
andEnd()
calls required? It should be clarified and documented.2 . pigrep
Program
pigrep
behaves as latterMatches
, callingBegin()
andEnd()
. It also surrounds its patterns. I have removed surrounding (btw it would be useful option, grep has it as-x, --line-regexp
) and get the following results:Summary of problems here:
Matches
pigrep
option equivalent togrep --line-regexp