pire icon indicating copy to clipboard operation
pire copied to clipboard

Lexer.Parse called multiple times results in errors

Open starius opened this issue 9 years ago • 2 comments

#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

starius avatar Jul 28 '15 15:07 starius