antlr / antlr-php-runtime

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

trying to execute the example #29

Closed matthewmorrone closed 1 year ago

matthewmorrone commented 2 years ago

🐞 Bug report

I'm trying to set up antlr in PHP as per the readme, and come across these issues:

`PHP Fatal error: Uncaught Error: Interface "Antlr\Antlr4\Runtime\Tree\ParseTreeListener" not found in C:\xampp\htdocs\diachron-db\parser\json.php:14 Stack trace:

0 {main}

thrown in C:\xampp\htdocs\diachron-db\parser\json.php on line 14`

In VSCode, I'm getting these errors from intelephense:

Undefined type 'JsonParser\JSONLexer'.intelephense(1009) Undefined type 'JsonParser\JSONParser'.intelephense(1009)

Steps to reproduce

  1. antlr4 -Dlanguage=PHP JSON.g4
  2. php json.php example.json

Screenshots

image

Additional Context

According to the example in the readme, antlr4 -Dlanguage=PHP JSON.g4 generates all of its files in a folder called "parser", but in fact it generates all of them in the working directory. antlr4 -Dlanguage=PHP JSON.g4 -o parser does this.

marcospassos commented 1 year ago

@matthewmorrone, did you set up the autoloader?