ANTLR3 c目标:当规则失败时,操作仍然执行,我可以';我不明白

ANTLR3 c目标:当规则失败时,操作仍然执行,我可以';我不明白,antlr,antlr3,Antlr,Antlr3,当规则失败时,操作仍然执行,为什么? 这是我的测试: grammar Test; options{ language = C; } @parser::includes { #include <iostream> } @lexer::includes { #include <iostream> } rScript : INT LR RR{std::cout << "Action Run...\n";}; INT :

当规则失败时,操作仍然执行,为什么? 这是我的测试:

grammar Test;
options{
    language = C;   
}
@parser::includes
{
    #include <iostream>
}
@lexer::includes
{
    #include <iostream>
}

rScript
    :   INT LR RR{std::cout << "Action Run...\n";};

INT :
    ('0'..'9')+;
LR  :   '{';
RR  :   '}';
语法测试;
选择权{
语言=C;
}
@解析器::包含
{
#包括
}
@lexer::includes
{
#包括
}
rScript
:INT LR RR{std::cout rScript(psr);
int parserrorcount=psr->pParser->rec->state->errorCount;
int-lexerrorcount=Lex->pLexer->rec->state->errorCount;

std::cout[offtopic]为什么使用ANTLR3而不是ANTLR4?
int main()
{
    char teststr1[] = "111dd}";
    pANTLR3_INPUT_STREAM    input;
    input = antlr3StringStreamNew((pANTLR3_UINT8)teststr1, ANTLR3_ENC_8BIT, sizeof(teststr1) - 1, (pANTLR3_UINT8)"-memory-");

    pTestLexer Lex = TestLexerNew(input);
    pANTLR3_COMMON_TOKEN_STREAM tstream = antlr3CommonTokenStreamSourceNew(
        ANTLR3_SIZE_HINT, TOKENSOURCE(Lex));
    pTestParser psr = TestParserNew(tstream);
    psr->rScript(psr);

    int ParserErrorCount = psr->pParser->rec->state->errorCount;
    int LexerErrorCount = Lex->pLexer->rec->state->errorCount;
    std::cout << "Parser Error Count: " << ParserErrorCount << "\n";
    std::cout << "Lexer Error Count: " << LexerErrorCount << "\n";
    getchar();
    return 0;
}
-memory-(1) : lexer error 3 :
         at offset 4, near 'd' :
        dd}
-memory-(1) : lexer error 3 :
         at offset 5, near 'd' :
        d}
-memory-(1)  : error 10 : org.antlr.runtime.MissingTokenException, at offset 5
    near [Index: 0 (Start: 0-Stop: 0) ='<missing LR>', type<5> Line: 1 LinePos:5]
     : Missing LR
Action Run...
Parser Error Count: 1
Lexer Error Count: 2