- There are two functions called
Matches.
bool Matches(const Scanner& scanner, const char* begin, const char* end)
{
return Runner(scanner).Run(begin, end);
}
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:
$ echo -n 'abc' | pigrep 'abc'
$ echo -n 'abc' | pigrep '^abc'
$ echo -n 'abc' | pigrep 'abc$'
$ echo -n 'abc' | pigrep '^abc$'
abc
Summary of problems here:
- pattern without ^ and $ matches nothing unless Surrounded
- two different functions called
Matches
- provide
pigrep option equivalent to grep --line-regexp
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
pigrepbehaves 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:
Matchespigrepoption equivalent togrep --line-regexp