antlr / antlr-php-runtime

PHP Runtime for ANTLR4
BSD 3-Clause "New" or "Revised" License
81 stars 19 forks source link

Updating ANTLR version results in Could not deserialize ATN with version 3 expected 4) #19

Closed valmoz closed 2 years ago

valmoz commented 2 years ago

I have a small grammar that works without problems using Antlr 4.9.2 and runtime version 0.5.1.

I tried to update Antlr to 4.9.3 and runtime to 0.6.0 and then regenerate the grammar, and it seemed to work correctly.

The problem is that when I execute my unit tests, I receive the following error: `InvalidArgumentException: Could not deserialize ATN with version 3 (expected 4).

/Users/maurovalota/fatture-in-cloud/api-filter/vendor/antlr/antlr4-php-runtime/src/Atn/ATNDeserializer.php:128 /Users/maurovalota/fatture-in-cloud/api-filter/vendor/antlr/antlr4-php-runtime/src/Atn/ATNDeserializer.php:74`

marcospassos commented 2 years ago

@KvanTTT, could you please take a look at this?

KvanTTT commented 2 years ago

@marcospassos you have to switch the default branch from dev to master as we have in ANTLR repository: https://github.com/antlr/antlr4 And reset master to this commit: https://github.com/antlr/antlr-php-runtime/commit/b56cfb9a798e68fec39b9a14162f2456840f2126 (the version before changing serialization format)

@Valmoz you have to use a stable PHP runtime version from master.

marcospassos commented 2 years ago

@KvanTTT, he's using a specific version and not the master. It should work unless ANTLR 4.9.3 doesn't include the new serialization format. Can you confirm it, pls?

KvanTTT commented 2 years ago

I don't completely understand how it works (maybe it just download PHP runtime from the repository?) but ANTLR 4.9.3 uses 3 serialization version but not 4.

tu6ge commented 2 years ago

The problem has not been fixed

thekryz commented 2 years ago

I'm also still experiencing this problem (installation via pip). I reverted to 4.8 to solve this.

marcospassos commented 2 years ago

Guys, I'm running the 4.10 on production without problems. Can you provide a reproduction repo?

valmoz commented 2 years ago

I just tried Antlr 4.10.1 + runtime 0.7.0 and it seems to work on PHP 8 (unfortunately my system uses PHP 7.4 at this moment, so I'll keep the old versions for now).

valmoz commented 2 years ago

@marcospassos you can try https://github.com/fattureincloud/api-filter/commit/515d9312d0fa37b5847d6405f4bab104a22f99e9

I used the docker-compose file to generate the classes, and the "validate" github action to launch the validation steps.

The action execution can be found here (I don't know if you have access): https://github.com/fattureincloud/api-filter/actions/runs/1893725924

marcospassos commented 2 years ago

@valmoz, sorry, what is it? Didn't you confirm it's working on 4.10.1?

valmoz commented 2 years ago

@valmoz, sorry, what is it? Didn't you confirm it's working on 4.10.1?

Yes, it works on 4.10.1, I shared the previous commit (4.9.3 with 0.6.0) that created the issue in this discussion