yar3333 / antlr4-php-workspace

This repo is a root for antlr4 subrepo with a PHP target
4 stars 3 forks source link

Undefined offset to report FailedPredicateException #4

Closed amorimjuliana closed 5 years ago

amorimjuliana commented 5 years ago

@yar3333, I'm running some tests here with @marcospassos and sometimes some of the issues we find are not straight forward, so I'll send you them so you can take a look. Since you are familiar with the code, there is a chance you recognize the error faster than us. Meanwhile, we will keep investigating, and Marcos will provide PRs with the fixes we can do.

This one is related to the root context creation. In the example below, we have a simple expression that will never match.

Grammar

grammar DemoGrammar;

root: ({false}? 'foo') EOF ;

Test

$lexer = new DemoLexer(CharStreams::fromString('foo'));
$tokens = new CommonTokenStream($lexer);
$parser = new DemoParser($tokens);

$result = $parser->root();

Result

Undefined offset: -1
antlr4-php-workspace/antlr4/runtime/Php/Error/DefaultErrorStrategy.php:315
antlr4-php-workspace/antlr4/runtime/Php/Error/DefaultErrorStrategy.php:139
parser-antlr-php/generated/DemoGrammarParser.php:192

Again, please let us know if we can do something to help :)

marcospassos commented 5 years ago

Fixed by https://github.com/yar3333/antlr4/commit/f10e0d1ddc95a2d154e729457da9fb8b173e389b.

Thank you, @amorimjuliana!