pire
pire copied to clipboard
Lexer.Parse called multiple times results in errors
#include <pire/pire.h>
int main() {
Pire::Lexer lexer("abc");
Pire::Scanner s1 = lexer.Parse().Compile<Pire::Scanner>();
Pire::Scanner s2 = lexer.Parse().Compile<Pire::Scanner>();
const char* text = "abc";
std::cout << "abc "
<< Pire::Matches(s1, text, text + 3) << ' '
<< Pire::Matches(s2, text, text + 3) << std::endl;
std::cout << "ab "
<< Pire::Matches(s1, text, text + 2) << ' '
<< Pire::Matches(s2, text, text + 2) << std::endl;
std::cout << " "
<< Pire::Matches(s1, text, text + 0) << ' '
<< Pire::Matches(s2, text, text + 0) << std::endl;
}
Output:
abc 1 0
ab 0 0
0 1
Expected output:
abc 1 1
ab 0 0
0 0