Reputation: 791
I'm just getting started using ANTLR, and want to try test parsing some simple PL/SQL statements using the plsql.g4 grammar. I am following the format used in Getting Started with ANTLR v4.
The following commands execute without issue:
antlr4 plsql.g4
java org.antlr.v4.Tool plsql.g4
javac plsql*.java
In the getting started example, they run the following command:
grun Hello r -tree
Where 'Hello' is the name of the grammar and 'r' is one of its production rules. The grammar indicates that the 'sql_script' production rule consists of zero or more unit statements or sqlplus commands followed by the end of the input stream:
sql_script
: (unit_statement | sql_plus_command)* EOF
;
So I am trying to invoke the PL/SQL parser like so:
grun plsql sql_script -tree
But I get the following error:
Can't load plsql as lexer or parser
What is the correct way to invoke the parser for this grammar to generate a parse tree for a simple PL/SQL statement? I am using JDK 8 on a Windows machine. Here is a screenshot showing the contents of my terminal window.
Upvotes: 2
Views: 1539
Reputation: 791
The JVM is the culprit. It does not automatically check the working directory first before checking the system-wide %CLASSPATH% environment variable if it exists. Adding a '.' to the beginning of the %CLASSPATH% environment variable will fix the problem and allow the command to work as intended. Refer to this screenshot of the Edit Environment Variable tool in Windows 10 to see how it should look.
This tool can be accessed through Control Panel -> System and Security -> System, click on the item to the left that says "Advanced system settings", and then click on the button labeled "Environment Variables". Selecting a variable and then clicking the "Edit..." button will bring up the tool in the screenshot.
Upvotes: 1