The goal of the project – create Oracle PL/SQL parser, which operates the same syntactic blocks, which are described in Oracle documentation. This means that the parse tree produced by the parser has the same structure (or at least very close) as the one presented in Oracle docs. Also parser rules are named after the Oracle docs (with some exceptions) to keep straightforward mapping.
Oracle docs used:
To test the grammar execute mvn test or mvn clean test.
- Literals
- Numeric
- Character (e.g. string)
- Boolean
- Comments
- Single-line
- Multi-line (see "Known issues" for exceptions).
- PL/SQL block
- Declarations
- Definitions
- Type definition
- Subtype
- Collection type
- Associative array
- Varray
- Nested table
- Record type
- Ref cursor type
- Type definition
- Exception handler
Comments Comments can be only outside statements and expressions. This makes parser rules and eventually parser easier.
-- Valid comment.
declare
/* Valid multi-line
comment. */
/* This is also valid.*/
-- This is valid.
my_const constant number := 10; -- Valid comment
my_var /* This will cause parser to fail */ varchar2(100);
begin
-- Valid comment
/* Also valid. */
end;Making the parser find comment everywhere will slow it down while bringing almost no value.