/* Copyright (C) 2002-2012 Albert Tumanov All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. * Neither the name of the nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ /** * Added ASTIsOfTypeCondition node, added support for USING IN|OUT|IN_OUT * See PMD Bug #1520 * * Andreas Dangel 11/2016 *==================================================================== * Adjusted ProgramUnit() to allow Pragma(), even though this is not * valid syntax. See PMD Bug #1527. * * Andreas Dangel 11/2016 */ /** * Added ASTIsNullCondition node * * Sergey Yanzin 11/2016 */ // options { DEBUG_PARSER = false ; DEBUG_TOKEN_MANAGER = false; DEBUG_LOOKAHEAD = false; IGNORE_CASE = true; STATIC = false; LOOKAHEAD = 1; // set the ambiguity checks to higher values, if you need more extensive checks of the grammar // this however make the parser generation very slow, so should only be done once after // modifying the grammar to make sure there are no grammar errors. // Default value is 2. CHOICE_AMBIGUITY_CHECK = 2; OTHER_AMBIGUITY_CHECK = 1; ERROR_REPORTING = true; JAVA_UNICODE_ESCAPE = false; //true UNICODE_INPUT = true; USER_TOKEN_MANAGER = false; USER_CHAR_STREAM = false; BUILD_PARSER = true; BUILD_TOKEN_MANAGER = true; SANITY_CHECK = true; FORCE_LA_CHECK = false; CACHE_TOKENS = true; MULTI = true; VISITOR = true; NODE_USES_PARSER = true; NODE_PACKAGE="net.sourceforge.pmd.lang.plsql.ast"; NODE_CLASS = "net.sourceforge.pmd.lang.plsql.ast.AbstractPLSQLNode"; } PARSER_BEGIN(PLSQLParser) /* Copyright (C) 2002 Albert Tumanov This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ package net.sourceforge.pmd.lang.plsql.ast; import java.io.*; import net.sourceforge.pmd.lang.ast.Node; import net.sourceforge.pmd.lang.ast.SimpleCharStream; import net.sourceforge.pmd.lang.ast.TokenMgrError; public class PLSQLParser { /** * main method, for testing only. * @param args */ public static void main(String[] args) throws ParseException { PLSQLParser parser = new PLSQLParser(System.in); PLSQLNode node = parser.Input(); String s; s = "qwerty"; // System.err.println(s + " -> " + parser.purifyIdentifier(s)); s = "\"qwerty\""; // System.err.println(s + " -> " + parser.purifyIdentifier(s)); s = "\"qwerty\".uiop"; // System.err.println(s + " -> " + parser.purifyIdentifier(s)); s = "\"qwerty\".\"uiop\""; // System.err.println(s + " -> " + parser.purifyIdentifier(s)); } /** Return canonical version of the Oracle */ public static String canonicalName(String name) { StringBuilder s = null ; if (null == name) { return name; } else if (-1 == name.indexOf('"') ) { name = name.toUpperCase(); s = new StringBuilder(name.trim()); } else { StringBuilder oldString = new StringBuilder( name.trim().length()); s = new StringBuilder(name.trim()); boolean quotedCharacter = false ; for (int i=0; i|||||||||) SkipPastNextTokenOccurrence(SQLPLUS_TERMINATOR) //Ignore SQL statements in scripts ) ("/")* )* { return jjtThis ; } } ASTDDLCommand DDLCommand() : { PLSQLNode simpleNode = null ; } { ( simpleNode = DDLEvent() SkipPastNextTokenOccurrence(SQLPLUS_TERMINATOR) ) { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTSqlPlusCommand SqlPlusCommand() : { StringBuilder sb = new StringBuilder() ; } { ( // e.g. SHOW ERRORS, GRANT EXECUTE ON ... TO ... // SQLPLUS commands ( "@" | | | | | | | | | | | | | | | | | | | | // DDL that might be encountered | | | | | // Attach Library | "." ) { sb.append(token.image) ; sb.append(" ...") ; } Skip2NextTokenOccurrence(EOL) //Tracker Issue 1433480 skip until next EOL Special Token //[";" | "-"] ) { jjtThis.setImage(sb.toString()) ; return jjtThis ; } } /* SRT 2011-04-17 This syntax breaks the parser when fields of record.attach* are referenced in PL/SQL void attachLibrary() : {} { <".attach"> } */ /** * All global definitions of triggers, functions and procedures are evaluated here. * Every occurence goes under a new PACKAGE-Node in the XML document. * This happens, cause a global "block" does not have a definied start and end token * like a package specification or a package body. * Thats why every construct is handled like a new part of the global package. * To overcome this problem, I could use an infinity lookahead - which should solve the problem * and slow down the whole parsing. * Another idea would be to lookahead the next tokens and decide wether they belong to a package definition or not. * Then I could decide to stay in this global parsing state. By now lookahead gives the parser a hint to * choose the correct way on a given base. So we can't negate it easily. * On the other hand I could also hold the global state in a global variable. * But this does not seems the correct way to solve the problem, I think. * * 2006-05-17 - Matthias Hendler - added */ ASTGlobal Global() : { } { /* Remove triggers from global processing because their schema may be defined in the trigger code itself Still wrap the trigger in a fake package but make the package name dependent on the actual schema defaulting to the globalPackageName if it cannot be found */ (LOOKAHEAD ( ( Label() )* [ DeclarativeSection()] ) ( Label() )* Block() ";" | LOOKAHEAD (4) ProgramUnit() ) { return jjtThis ; } } ASTBlock Block() : { } { // Included as part of statement() [ DeclarativeSection() ] (Statement())* (ExceptionHandler())? [ ] // Optional END Identifier has to match the label { return jjtThis ; } } ASTPackageSpecification PackageSpecification() : { PLSQLNode simpleNode = null ; } { ( [ [ ] [ | ] ] simpleNode = ObjectNameDeclaration() ( ( ( | )) | AccessibleByClause() )* ( ( WrappedObject() ) | ( ( | ) DeclarativeSection() [ID()] ";" ) ) ) { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTPackageBody PackageBody() : { PLSQLNode simpleNode = null ; } { ( [ [ ] [ | ] ] ( | ) simpleNode = ObjectNameDeclaration() ( ( WrappedObject() ) | ( ( | ) DeclarativeSection() //SRT 20110524 Allow PLDOc in Type Bodies [ (Statement())* (ExceptionHandler())? ] [ID()] ";" ) ) ) { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTDeclarativeUnit DeclarativeUnit() : {} { ( Pragma() | LOOKAHEAD(2) ExceptionDeclaration() | LOOKAHEAD((|) QualifiedID() ( | ) ) //SRT 20110616 - make sue soen't break object type SubTypeDefinition() | LOOKAHEAD((|) QualifiedID() ) //SRT 20111117 - Special case of parameterless methods:choose method in preference to variable ProgramUnit() | LOOKAHEAD(4) VariableOrConstantDeclaration() | LOOKAHEAD(2) CursorSpecification() | CursorBody() | CollectionDeclaration() | //ProgramUnit() //|TypeMethod() MethodDeclaration() |CompilationDeclarationFragment() ) { return jjtThis ; } } ASTDeclarativeSection DeclarativeSection() : {} { ( DeclarativeUnit() )* { return jjtThis ; } } ASTCompilationDeclarationFragment CompilationDeclarationFragment() : { } { ( //SRT 20110601 ConditionalOrExpression() (DeclarativeUnit() | Expression() )* ( ConditionalOrExpression() (DeclarativeUnit() | Expression() )* )* ( (DeclarativeUnit() | Expression() )* )* ) { return jjtThis ; } } /** * 2006-05-22 - Matthias Hendler - Printing of custom tag "@deprecated" removed. * Printing of any custom tag added. Now user can define his own * custom tags which he can evaluate in the XSLT. * This methode also documents global functions/procedures. */ ASTProgramUnit ProgramUnit() : { } { ( [ [ ] [ | ] ] MethodDeclarator() ( WrappedObject() | /* //SRT 20110516 Cope with AUTHID for schema level functions and procedures (tokenIsAs= ( | ))? */ ( ( ( | ) ) | | AccessibleByClause() | [ ParallelClause() ] [ ID() ["." ID()] ] | [ ( ID() ["." ID()] ) | //20110531 (( | ) [ID()] "(" ID() ( "," ID() )* ")" ) ] // drvparx.IndexMapDocuments | [ "(" ID() ["." ID()] ( "," ID() ["." ID()])* ")" ] ) * [ ID() ] // body [ ( | ) //SRT ( | ) ( LOOKAHEAD(2) CallSpecTail() //{ System.err.println("Found CallSpecTail") ; } | ( DeclarativeSection() [Pragma()] // See PMD Bug #1527 (Statement())* (ExceptionHandler())? [ID()] ) ) ] ";" //SRT 20110416 { System.err.println("Found terminating semi-colon") ; } ) //UnwrappedCode ) { return jjtThis ; } } ASTObjectNameDeclaration ObjectNameDeclaration() : {PLSQLNode schemaName = null, objectName = null ; } { [ LOOKAHEAD(2) schemaName = ID() "." ] objectName = ID() { jjtThis.setImage( (null == schemaName) ? objectName.getImage() : (schemaName.getImage() + "." + objectName.getImage() ) ) ; } { return jjtThis ; } } ASTFormalParameter FormalParameter() : { PLSQLNode simpleNode = null ; } { ( simpleNode = ID() // the order of outer "|" is important ! ( LOOKAHEAD(2) ( LOOKAHEAD(2) ( (|( )) (LOOKAHEAD(2) )? ) | ) )? ("..." | Datatype()) ( (":" "="|<_DEFAULT>) Expression() )? ) { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTMethodDeclaration MethodDeclaration() : {} { ( ProgramUnit() | TypeMethod() ) { return jjtThis ; } } ASTMethodDeclarator MethodDeclarator() : { PLSQLNode simpleNode = null ; } { ( simpleNode = ObjectNameDeclaration() ( [ FormalParameters() ] { Token nextToken; nextToken = getToken(1); //ReadAhead if (!nextToken.image.equalsIgnoreCase("WRAPPED") && !nextToken.image.equalsIgnoreCase("RETURN") ) { throw new ParseException("FUNCTION must RETURN a value or must be WRAPPED : found \"" + nextToken.image + "\" at line "+nextToken.beginLine + ", column "+nextToken.beginColumn ); } } // There is no RETURN for a WRAPPED object [ Datatype() ] ) | simpleNode = ObjectNameDeclaration() ( [ FormalParameters() ] ) ) { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTFormalParameters FormalParameters() : { PLSQLNode simpleNode = null ; StringBuilder sb = new StringBuilder(); } { ( "(" {sb.append("(");} [ simpleNode = FormalParameter() { sb.append(simpleNode.getImage());} ( "," simpleNode = FormalParameter() { sb.append(","+simpleNode.getImage());} )* ] ")"{sb.append(")");} ) { jjtThis.setImage(sb.toString()) ; return jjtThis ; } } ASTVariableOrConstantDeclarator VariableOrConstantDeclarator() : { PLSQLNode simpleNode = null ; StringBuilder sb = new StringBuilder(); } { ( simpleNode = VariableOrConstantDeclaratorId() { sb.append(simpleNode.getImage());} [LOOKAHEAD(2) {sb.append(" " + token.image);} ] simpleNode = Datatype() { sb.append(" " + simpleNode.getImage());} [[ {sb.append(" " + token.image);} ] {sb.append(" " + token.image);} ] [ ( ":" "=" {sb.append(" :=");}| <_DEFAULT> {sb.append(" " + token.image);}) simpleNode = VariableOrConstantInitializer() { sb.append(" " + simpleNode.getImage());} ] ) { jjtThis.setImage(sb.toString()) ; return jjtThis ; } } ASTVariableOrConstantDeclaratorId VariableOrConstantDeclaratorId() : { PLSQLNode simpleNode = null ; } { simpleNode = ID() { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTVariableOrConstantInitializer VariableOrConstantInitializer() : { PLSQLNode simpleNode = null ; } { simpleNode = Expression() { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTDatatype Datatype() : { PLSQLNode simpleNode = null ; StringBuilder sb = new StringBuilder(); } { ( // this should be first simpleNode = CompilationDataType() {sb.append(simpleNode.getImage());} | LOOKAHEAD(2) simpleNode = ScalarDataTypeName() {sb.append(simpleNode.getImage());} | ( ( [LOOKAHEAD(2) {sb.append(token.image);} ] simpleNode = QualifiedName() {sb.append(simpleNode.getImage());} //Bug 35352414 - datatype may include dblink ["@" simpleNode = QualifiedName() {sb.append("@"+simpleNode.getImage());} ] ["%" (|){sb.append("%"+token.image);} ] ) ) ) { jjtThis.setImage(sb.toString()) ; return jjtThis; } } ASTCompilationDataType CompilationDataType() : { PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { ( {sb.append(" "); sb.append(token.image) ; } simpleNode= ConditionalOrExpression() {sb.append(" "); sb.append(simpleNode.getImage()); } {sb.append(" "); sb.append(token.image); } simpleNode = Datatype() {sb.append(" "); sb.append(simpleNode.getImage()); } ( {sb.append(" "); sb.append(token.image); } simpleNode = ConditionalOrExpression() {sb.append(" "); sb.append(simpleNode.getImage()); } {sb.append(" "); sb.append(token.image); } simpleNode = Datatype() {sb.append(" "); sb.append(simpleNode.getImage()); } )* ( {sb.append(" "); sb.append(token.image); } simpleNode = Datatype() {sb.append(" "); sb.append(simpleNode.getImage()); } )* {sb.append(" "); sb.append(token.image); } ) { jjtThis.setImage(sb.toString()) ; return jjtThis; } } ASTCollectionTypeName CollectionTypeName() : { PLSQLNode size=null, precision=null; StringBuilder sb = new StringBuilder(); } { ( // Collection types
| | ( {sb.append( "VARYING ARRAY") ;}) ) { if (sb.length() == 0) { sb.append(token.toString()); } } (LOOKAHEAD(2) "(" size=NumericLiteral() {sb.append( "(" + size);} ["," precision=NumericLiteral() {sb.append( "," + precision);}] [ {sb.append( " CHAR") ;}] [ {sb.append( " BYTE") ;}] ")" {sb.append( ")");})? { jjtThis.setImage(sb.toString()) ; return jjtThis; } } ASTScalarDataTypeName ScalarDataTypeName() : { PLSQLNode size=null, precision=null ; StringBuilder name = new StringBuilder(); PLSQLNode characterSet = null; } { ( //Base types used in SYS.STANDARD | | | | | | // scalar types - numeric: | | | ( {name.append("DOUBLE PRECISION");}) | | | | | | | | | | | | | | // scalar types - character: ( ( | //SRT | LOOKAHEAD(2) ( {name = "LONG RAW";}) | LOOKAHEAD(2) | | LOOKAHEAD(2) ( {name.append("LONG RAW");}) | | | | | | | | | | | ) ) | // scalar types - boolean: | // composite types //SRT 20090531
| | ( {name = "VARYING ARRAY";}) | // - defined elsewhere // LOB types | | // reference types | //SRT Added to support pre-defined weak REF CURSOR ( {name.append("REF CURSOR");}) | // object_type - defined elsewhere // scalar types - date/time: | LOOKAHEAD(2) ( {name.append("INTERVAL YEAR");}) | LOOKAHEAD(2) ( {name.append("INTERVAL DAY");}) |
||) Skip2NextTerminator(initiator,terminator) { return jjtThis ; } } /** * 2011-05-15 - SRT - Added to cope with wrapped objects A wrapped function looks like this (always terminated by one or more equals signs "="):-
  "  CREATE OR REPLACE FUNCTION "TESTUSER"."GET_DATE_STRING"
/ ** Return SYSDATE formatted using the provided template.
 *
 *
 *  @param p_date_format normal TO_CHARE/TO_DATE date template
 *  @return formatted datestring
 *  @see http://www.oracle-base.com/articles/10g/WrapAndDBMS_DDL_10gR2.php#dbms_ddl
 * /
wrapped
a000000
369
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
abcd
8
89 b6
/SBrhM8+1iUO4QAih+qD2SK8kSowg8eZgcfLCNL+XlquYvSuoVah8JbRPpdHDLHn479SdFLw
v04omzJ0zOfHdMAzuHQlw+fAsr2ym9YI8I521pRTbnFVAHOOUw4JqPkIyj7wj4VwyL17nhYb
3qPVuL6SvhZTmEBnRtaErHpzaDuIpqZ0G4s=
  "
  
*/ void WrappedObject() : {} { { Token nextToken; nextToken = getToken(1); //ReadAhead while ( null != nextToken && nextToken.kind!=EOF ) { nextToken = getNextToken(); //Execute manual readahead nextToken = getToken(1); //ReadAhead 1 Token } return; } } // ============================================================================ // S T A T E M E N T S // ============================================================================ /** * 2006-05-24 - Matthias Hendler - added MERGE, EXECUTE choice and LOOKAHEAD at <LOOP> */ ASTUnlabelledStatement UnlabelledStatement() : {} { ( LOOKAHEAD(["("]
||) SqlStatement(null,";") [";"] | LOOKAHEAD(3) ContinueStatement() ";" // CONTINUE keyword was added in 11G, so Oracle compilation supports CONTINUE as a variable name | CaseStatement() ";" | IfStatement() ";" | ForStatement() ";" | ForAllStatement() ";" | LoopStatement() ";" | WhileStatement() ";" | GotoStatement() ";" | ReturnStatement() ";" | ExitStatement() ";" | RaiseStatement() ";" | CloseStatement() ";" | OpenStatement() ";" | FetchStatement() ";" | Block() ";" | EmbeddedSqlStatement() ";" | PipelineStatement() ";" | ConditionalCompilationStatement() // Conditional Compilation works outside the normal parsing rules | InlinePragma() ";" | Expression() ";" ) { return jjtThis ; } } ASTStatement Statement() : {} { ( //SQL Developer compiler allows 0, 1 or many labels immediately before a statement //SQL Developer compiler requires a statement after a sequence of labels LabelledStatement() | UnlabelledStatement() ) { return jjtThis ; } } /* LabelledStatement created solely to conform with PMD Java AST (for PMD DataFlow Analysis - DFA) N.B. equivalent Java AST* class is ASTLabeledStatement (single "l" rather than double "ll") */ ASTLabelledStatement LabelledStatement() : { PLSQLNode simpleNode = null; } { ( //SQL Developer compiler allows 0, 1 or many labels immediately before a statement //SQL Developer compiler requires a statement after a sequence of labels //Use the last label (simpleNode = Label() )+ UnlabelledStatement() ) { jjtThis.setImage( simpleNode.getImage() ) ; return jjtThis ; } } ASTCaseStatement CaseStatement() : {} { ( ( Expression() )? ( CaseWhenClause() )* [ ElseClause() ] [] ) { return jjtThis ; } } ASTCaseWhenClause CaseWhenClause() : {} { Expression() (Statement())+ { return jjtThis ; } } ASTElseClause ElseClause() : {} { (Statement())+ { return jjtThis ; } } ASTElsifClause ElsifClause() : {} { Expression() (Statement())+ { return jjtThis ; } } ASTLoopStatement LoopStatement() : {} { (Statement())+ [] { return jjtThis ; } } /** Scope rule: the loop index only exists within the Loop */ ASTForStatement ForStatement() : {} { ForIndex() [] Expression()[".."Expression()] (Statement())+ [] { return jjtThis ; } } ASTWhileStatement WhileStatement() : {} { Expression() (Statement())+ [] { return jjtThis ; } } ASTIfStatement IfStatement() : {} { Expression() (Statement())+ ( ElsifClause() {jjtThis.setHasElse();} )* [ ElseClause() {jjtThis.setHasElse();} ] { return jjtThis ; } } /** Scope rule: the loop index only exists within the statement */ /** ForIndex is declared implicitly, unlike most variables or constants. */ ASTForIndex ForIndex() : { PLSQLNode simpleNode = null ; } { simpleNode = ID() { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } /** ForAllIndex is declared implicitly, unlike most variables or constants. */ ASTForAllIndex ForAllIndex() : { PLSQLNode simpleNode = null; } { simpleNode = ID() { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTForAllStatement ForAllStatement() : {} { ForAllIndex() ( ( | ) Expression() // Add support for sparse collections | Expression() [".." Expression()] ) [ ] SqlStatement(null,";") { return jjtThis ; } } ASTGotoStatement GotoStatement() : { PLSQLNode label = null; } { label = QualifiedName() { jjtThis.setImage(label.getImage()) ; return jjtThis ; } } ASTReturnStatement ReturnStatement() : {} { [Expression()] { return jjtThis ; } } ASTContinueStatement ContinueStatement() : { PLSQLNode label = null; } { [ label = UnqualifiedID() ] [ Expression() ] { if (null != label) { jjtThis.setImage(label.getImage()) ; } return jjtThis ; } } ASTExitStatement ExitStatement() : { PLSQLNode label = null; } { [ label = UnqualifiedID() ] [ Expression() ] { if (null != label) { jjtThis.setImage(label.getImage()) ; } return jjtThis ; } } ASTRaiseStatement RaiseStatement() : {PLSQLNode exception = null ; } { [exception = QualifiedName()] { if (null != exception) { jjtThis.setImage(exception.getImage()) ; } return jjtThis ; } } ASTCloseStatement CloseStatement() : {PLSQLNode cursor = null ; } { cursor = QualifiedName() { jjtThis.setImage(cursor.getImage()) ; return jjtThis ; } } ASTOpenStatement OpenStatement() : {} { [Expression()] //[LOOKAHEAD(functionCall()) functionCall() | QualifiedName()] [ Expression() [ ( | | )? Expression() ("," ( | | )? Expression())*]] { return jjtThis ; } } ASTFetchStatement FetchStatement() : {} { QualifiedName() [ ] //MMUE 04/08/2005 (LOOKAHEAD(functionCall()) functionCall() | QualifiedName()) ("," (LOOKAHEAD(functionCall()) functionCall() | QualifiedName()))* ";" Expression() ("," Expression())* [ Expression()] // { return jjtThis ; } } ASTEmbeddedSqlStatement EmbeddedSqlStatement() : {} { Expression() // StringLiteral() /* */ //SRT 20110429 | StringExpression() [ Expression() ("," Expression())*] ";" //SRT 20121126 | StringExpression() [ Name() ("," Name())* ] [ [ [ ] | ] Expression() ("," [ [ ] | ] Expression())* ] [ ( | ) Expression() ("," Expression())*] ";" // PIPELINED FUNCTION OUTPUT { return jjtThis ; } } ASTPipelineStatement PipelineStatement() : {} { Expression() { return jjtThis ; } } ASTConditionalCompilationStatement ConditionalCompilationStatement() : {} { ( ConditionalOrExpression() (Statement())* ( ConditionalOrExpression() (Statement())+ )* ( (Statement())+ )* | Expression() ) { return jjtThis ; } } ASTSubTypeDefinition SubTypeDefinition() : { Token start, subtype_name=null, constraint=null, base_type=null; Token collection = null, collection2 = null; PLSQLNode name = null; PLSQLNode startElement = null, endElement = null; PLSQLNode baseType = null, returnType = null, indexBy = null ; int lastField = 0; } { ( ( name = QualifiedID() // SRT 20110605 to Parse SYS.standard need to allow normally reserved words which are low-level types Datatype() [ ( "(" ")") // SRT 20110604 [ ] | ( UnaryExpression(true) ".." UnaryExpression(true) ) // In "RANGE -1 .. 31" -1 is a unary Expression ] [ ] //SRT 20110604 ) | ( name = QualifiedID() // SRT 20110605 to Parse SYS.standars ned to allow nprmally reserved words which are low-level types (|) ( LOOKAHEAD(2) ( | | | | | ) | //SRT 20110606 SYS.STANDRD ( "(" FieldDeclaration() ("," FieldDeclaration())* ")" ) | ( "(" FieldDeclaration() ("," FieldDeclaration())* ")" ) | ((
| | )["(" NumericLiteral() ")"] Datatype() ( )? ( Datatype())?) | [ Datatype()] //Enumeration | ( "(" Expression() ( "," Expression() )* ")" ) //Alias for existing type | Datatype() ) ) ) ";" { jjtThis.setImage(name.getImage()) ; return jjtThis ; } } ASTFieldDeclaration FieldDeclaration() : { PLSQLNode name; PLSQLNode dataType; PLSQLNode defaultValue = null; } { name = ID() Datatype() [[] ] [ (":" "=" | <_DEFAULT>) Expression() ] { jjtThis.setImage(name.getImage()) ; return jjtThis ; } } ASTCollectionTypeDefinition CollectionTypeDefinition() : {Token t = null ; } { t = { jjtThis.setImage(t.image) ; return jjtThis ; } } ASTCollectionDeclaration CollectionDeclaration() : {Token t = null ; } { t = { jjtThis.setImage(t.image) ; return jjtThis ; } } ASTObjectDeclaration ObjectDeclaration() : {Token t = null ; } { t = { jjtThis.setImage(t.image) ; return jjtThis ; } } /** Java stored procedure, external function*/ ASTCallSpecTail CallSpecTail() : { } { // /* (/*"C"*/ | ) ( ( | (/*"C"*/ | ) )//SRT 20110516 { System.err.println("Found EXTERNAL or LANG ") ; } //These can appear in any order .... ( ( ( | | StringLiteral() ) [ "." ( | | StringLiteral() ) ] ) | ( ( | /* C */| StringLiteral() /* JAVA */ ) ) //SRT 20110517 Need to cope with CallSpecTails in ObjectTypes // Skip2NextTerminator(null,";") //SkipPastNextOccurrence(")") // Read until we have eaten the closing bracket ")" | ( ) | ( SkipPastNextOccurrence(")") // Read until we have eaten the closing bracket ")" ) )* ) /* ### or: library_name [NAME c_string_literal_name] [WITH CONTEXT] [PARAMETERS (external_parameter[, external_parameter]...)]; Where library_name is the name of your alias library, c_string_literal_name is the name of your external C procedure, and external_parameter stands for: { CONTEXT | SELF [{TDO | property}] | {parameter_name | RETURN} [property] [BY REFERENCE] [external_datatype] } where property stands for: {INDICATOR [{STRUCT | TDO}] | LENGTH | MAXLEN | CHARSETID | CHARSETFORM} ( [ | ] | | | | ) */ /* " ( ( | ( | ) ) [ ] [ "(" ( "," ( [ | [ ( [ | ] ) | | | | ] ] | ( ( | ) [ | [ ( [ | ] ) | | | | ] ] [ ] [ ] ) ) )* ")" ] ) { return; } */ { return jjtThis ; } } /** Cursor (common part of specification and body) */ ASTCursorUnit CursorUnit() : { PLSQLNode simpleNode = null ; } { ( simpleNode = ID() [ FormalParameters() ] [ Datatype() ] ) [ ("(")* SqlStatement(null,";")] ";" { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTCursorSpecification CursorSpecification() : {} { CursorUnit() { return jjtThis ; } } ASTCursorBody CursorBody() : {} { CursorUnit() // /**/ { return jjtThis ; } } // ============================================================================ // E X P R E S S I O N S // ============================================================================ /* String expression() : {} { "test" { return ""; } } */ ASTExpression Expression() : { PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { // Need syntactic lookahead to discriminate between Assignment and a procedure call ( LOOKAHEAD( PrimaryExpression() ":" "=" ) (simpleNode = Assignment()) {sb.append(simpleNode.getImage()); } | (simpleNode = ConditionalOrExpression() ) {sb.append(simpleNode.getImage()); } | (simpleNode = CompilationExpression() ) {sb.append(simpleNode.getImage()); } ) { jjtThis.setImage(sb.toString()); return jjtThis; } } ASTCompilationExpression CompilationExpression() : { PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { ( {sb.append(" "); sb.append(token.image) ; } simpleNode = ConditionalOrExpression() {sb.append(" "); sb.append(simpleNode.getImage()); } {sb.append(" "); sb.append(token.image); } simpleNode = Expression() {sb.append(" "); sb.append(simpleNode.getImage()); } ( {sb.append(" "); sb.append(token.image); } simpleNode = ConditionalOrExpression() {sb.append(" "); sb.append(simpleNode.getImage()); } {sb.append(" "); sb.append(token.image); } simpleNode = Expression() {sb.append(" "); sb.append(simpleNode.getImage()); } )* ( {sb.append(" "); sb.append(token.image); } simpleNode = Expression() {sb.append(" "); sb.append(simpleNode.getImage()); } )* {sb.append(" "); sb.append(token.image); } ) { jjtThis.setImage(sb.toString()); return jjtThis; } } ASTAssignment Assignment() : { PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { ( (simpleNode = PrimaryExpression() ) {sb.append(simpleNode.getImage());} (":" "=" ) {sb.append(" := ");} (simpleNode = Expression()) {sb.append(simpleNode.getImage());} ) { jjtThis.setImage(sb.toString()); return jjtThis; } } ASTCaseExpression CaseExpression() : { Token thisToken; PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { ( thisToken = { sb.append(thisToken.image);} ( simpleNode = Expression() { sb.append(" "); sb.append(simpleNode.getImage()); } )? ( thisToken = { sb.append(" "); sb.append(thisToken.image); } simpleNode = Expression() { sb.append(" "); sb.append(simpleNode.getImage()); } thisToken = { sb.append(" "); sb.append(thisToken.image); } Expression() { sb.append(" "); sb.append(simpleNode.getImage()); } )+ [ thisToken = { sb.append(" "); sb.append(thisToken.image);} Expression() { sb.append(" "); sb.append(simpleNode.getImage()); } ] thisToken = { sb.append(" "); sb.append(thisToken.image);} ) { jjtThis.setImage(sb.toString()); return jjtThis; } } /* LIKE ( Expression ) [ */ ASTLikeExpression LikeExpression() : { Token thisToken; PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { ( simpleNode = PrimaryExpression() { sb.append(" "); sb.append(simpleNode.getImage()); } (thisToken = ) { sb.append(thisToken.image);} //["(" { sb.append("(");} ] ( simpleNode = StringExpression() { sb.append(" "); sb.append(simpleNode.getImage()); } ) //[ ")" { sb.append(")");} ] [ { sb.append(" ESCAPE ");} ( { sb.append(" "); sb.append(token.toString()); } | simpleNode = StringLiteral() { sb.append(" "); sb.append(simpleNode.getImage()); } ) ] ) ( "." simpleNode = Expression() { sb.append("."); sb.append(simpleNode.getImage()); } )* { jjtThis.setImage(sb.toString()); return jjtThis; } } ASTTrimExpression TrimExpression() : { Token thisToken; PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { ( (thisToken = ) { sb.append(thisToken.image);} "(" { sb.append("(");} [ ( | | ){ sb.append(" "); sb.append(token.toString()); } ] [ simpleNode = StringExpression() { sb.append(" "); sb.append(simpleNode.getImage()); } ] ( ) { sb.append(thisToken.image);} simpleNode = StringExpression() { sb.append(" "); sb.append(simpleNode.getImage()); } ")" { sb.append(")");} ) { jjtThis.setImage(sb.toString()); return jjtThis; } } /* TREAT ( Expression AS datatype) CAST ( Expression AS datatype) */ ASTObjectExpression ObjectExpression() : { Token thisToken; PLSQLNode simpleNode = null; StringBuilder sb = new StringBuilder() ; } { ( (thisToken = | thisToken = ) { sb.append(thisToken.image);} "(" { sb.append("(");} ( simpleNode = Expression() { sb.append(" "); sb.append(simpleNode.getImage()); } ) [
ObjectNameDeclaration() "(" TableColumn() ("," TableColumn())* ")" [LOOKAHEAD(2) ( | ) ] //### [physicalProperties()] //### [tableProperties()] [";"] { return jjtThis ; } } ASTTableColumn TableColumn() : { } { ID() Datatype() [<_DEFAULT> Expression()] [[ ] ] { return jjtThis ; } } ASTView View() : { PLSQLNode simpleNode = null; } { [ ] [[] ] simpleNode = ObjectNameDeclaration() ["(" ViewColumn() ("," ViewColumn())* ")"] //### OF ... WITH OBJECT IDENTIFIER... Statement() //SRT select() //### WITH ... (";" | "/") { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTSynonym Synonym() : { PLSQLNode simpleNode = null; } { [ ] [] simpleNode = ObjectNameDeclaration() ObjectNameDeclaration() (";" | "/") { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTDirectory Directory() : { PLSQLNode simpleNode = null; } { [ ] simpleNode = ObjectNameDeclaration() StringLiteral() (";" | "/") { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTDatabaseLink DatabaseLink() : { PLSQLNode simpleNode = null; } { [ ] [ ] simpleNode = ObjectNameDeclaration() ( ( ( ) | ( UnqualifiedID() UnqualifiedID() UnqualifiedID() UnqualifiedID() ) ) | UnqualifiedID() UnqualifiedID() ) [ StringLiteral() ] (";" | "/") { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTViewColumn ViewColumn() : { } { ID() { return jjtThis ; } } ASTComment Comment() : { } { ( ((
| | ) [LOOKAHEAD(2) ID()"."] ID()) | ( [LOOKAHEAD(ID()"."ID()"."ID()) ID()"."] ID() "." ID()) ) [";"] { return jjtThis ; } } // SRT * / ASTTypeMethod TypeMethod() : { } { //inheritance CLAUSE { getToken(1); //System.err.println("typeMethod: Result of getToken(1) is \"" + startToken.toString() + "\"" ); } //SRT added to check Token List walking ( [ ] ( | | ) )* //[ MAP | ORDER ] //[ [] ] [ [] ] [ | ] ( | | ) MethodDeclarator() [] [] [] [] // Java or C function wrapped with PL/SQL wrapper declaration [ ( | ) ( CallSpecTail() [ ";" ] // This only exists in the type body | // SRT 20110524 Not really a Declaration any more ... ( DeclarativeSection() (Statement())* (ExceptionHandler())? [ID()] ";" // This only exists in the type body ) ) ] { return jjtThis ; } } ASTTypeSpecification TypeSpecification() : { PLSQLNode simpleNode = null; } { [ [ ] [ | ] ] simpleNode = ObjectNameDeclaration() [ ] // incomplete_type_spec (empty) // object_type_spec // varray_type_spec // nested_table_type [ LOOKAHEAD(2) ] ( LOOKAHEAD(2) // ( | ) ( ( ( | )) | AccessibleByClause() ) )* //(tokenIsAsUnder= | tokenIsAs= ) //{ // // possibly, package comment is here // processPackageComment(tokenIsAsUnder); //} [ ( ObjectNameDeclaration() //SUBTYPE | LOOKAHEAD(2) ( | ) // OBJECT TYPE | LOOKAHEAD(2) ( | ) "(*)" // OPAQUE TYPE ( | | StringLiteral() ) [ "." ( | | StringLiteral() ) ] | LOOKAHEAD(2) ( | ) CollectionTypeName() Datatype() ) ] // [ LOOKAHEAD(8) //tokenIsAsUnder= // "NAME" //JavaInterfaceClass() //( | | ) //JavaInterfaceClass() //( | | ) ] [ WrappedObject() ] // //incomplete OBJECT TYPE and COLLECTION TYPEs will not have this [ ("(" ) //Try matching against keywords first to allow FINCTION and procedure as a fallback (LOOKAHEAD(2) TypeMethod() | AttributeDeclaration() | PragmaClause() )* //SRT 20111125 This part may be completely empty if is a subtype which is effectively an alias for the supertype ( "," ( TypeMethod() | LOOKAHEAD(2) AttributeDeclaration() | PragmaClause() ) )* ")" ] ( [ ] ( /*OBJECTS TYPES ONLY */ | //OBJECT TYPES ONLY | //COLLECTION TYPES ONLY ) )* //Original Type Specification may be followed by a series of modifications ( AlterTypeSpec() ) * [ (";" | "/" ) ( AlterTypeSpec() ( "/" | ";" ) )* //SRT 20110529 There may be more after the first terminator ] { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTAlterTypeSpec AlterTypeSpec() : { PLSQLNode simpleNode = null; } { simpleNode = QualifiedName() // REPLACE invoker_rights_clause AS OBJECT //alter_method_spec //(tokenAlterType = |tokenAlterType = |tokenAlterType = |tokenAlterType = ) //SRT 20110529 Each ALTER TYPE statement may contaon 0 or more ADD or DROP clause //When more than one clause exists, each clause is separated by comma "," ( [","] ( ( | ) ( // Move typeMethidMatching above attribure matvhing becausse FUNCTION is a valid attribute name ( (TypeMethod() ) //( "," ( typeMethod(,typeVersion, tokenAlterTypeString) ) )* ) | ( ( "(" )* (AttributeDeclaration() ) ( "," ( AttributeDeclaration() ) )* ( ")" )* ) | ( NumericLiteral() ) | ( Datatype() ) )+ ) | ( () ( ( ( "(" )* (Attribute() ) ( "," ( Attribute() ) )* ( ")" )* ) | ( (TypeMethod() ) //( "," ( typeMethod(,typeVersion, tokenAlterTypeString) ) )* ) )+ ) )* /* ) { System.err.println("Alter Type is " + tokenAlterType.toString()); } | ( ( (TypeMethod() ) ( "," ( TypeMethod() ) )* ) | ( [ "(" ] (QualifiedName() ) ( "," ( QualifiedName() ) )* [ ")" ] ) ) | //alter_collection_clause ( ( tokenCollectionSize = NumericLiteral() ) | ( baseType = Datatype() ) ) | */ [ ( LOOKAHEAD(2) // ( | ) ( ( ( | )) | AccessibleByClause() ) )* ( ( | ) // OBJECT TYPE ) ("(" ) (LOOKAHEAD(2) TypeMethod() | AttributeDeclaration() ) ( "," ( LOOKAHEAD(2) TypeMethod() | AttributeDeclaration() ) )* ")" ] /* */ ( [ ] ( /*OBJECTS TYPES ONLY */ | //OBJECT TYPES ONLY | //COLLECTION TYPES ONLY ) )* //DEPENDENT HANDLING CLAUSE [ ( ) | ( ( ( [ ]
) | ( ) )* [ [ ] QualifiedName() ] ) ] { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } /* ASTTypeBody TypeBody() : { Token name=null; } { [ [ ]] (LOOKAHEAD(2) ID()".")? name=ID() ( ( WrappedObject() ) | ( ( | ) DeclarativeSection() //SRT 20110524 Allow PLDOc in Type Bodies [ (Statement())* (ExceptionHandler())? ] [ID()] ";" ) ) } */ /** * Method **/ ASTAttributeDeclaration AttributeDeclaration() : { PLSQLNode simpleNode = null; } { simpleNode = ID() Datatype() { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTAttribute Attribute() : { PLSQLNode simpleNode = null; } { simpleNode = ID() { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } /* This was quick cut from PRAGMA */ ASTPragmaClause PragmaClause() : { } { ( | | "(" (ID() /*| <_DEFAULT>*/) ("," (ID() | StringLiteral() /* 20110526 */) )+ ")" | "(" "," ["+"|"-"] NumericLiteral() ")" | "(" "," "," NumericLiteral() ")" ) { return jjtThis ; } } /** * Trigger * Triggers are always outside of a package. * * 2006-05-17 - Matthias Hendler - added */ /* 11g Trigger Syntax create_trigger : CREATE [OR REPLACE] TRIGGER [schema.]trigger ( simple_dml_trigger | compound_dml_trigger | non_dml_trigger ) [ FOLLOWS ( [schema.]trigger) ( , [schema.]trigger)* ] [ ENABLE | DISABLE ] ( WHEN ( trigger_condition ) trigger_body simple_dml_trigger : (BEFORE |AFTER | INSTEAD OF) dml_event_clause [ referencing_clause ] [ FOR EACH ROW ] compound_dml_trigger : FOR dml_event_clause [ referencing_clause ] non_dml_trigger : (BEFORE> | ) (DDLEvent | database_event) ( OR (DDLEvent | database_event))* ON (DATABASE | [schema.]SCHEMA trigger_body : (plsql_block | compound_trigger_block | CALL routine_clause) dml_event_clause: ( DELETE | INSERT | UPDATE [ OF column (, column ) ] ) ON ( (schema.table | NESTED TABLE nested_table_column OF [schema.]view ) referencing_clause: REFERENCING (OLD AS old_alias | NEW AS new_alias | PARENT AS parent_alias )* compound_trigger_block : COMPOUND TRIGGER declare_section (timing_point_section)+ END [trigger_name] ; timing_point_section: ( BEFORE STATEMENT IS tps_body END BEFORE STATEMENT |BEFORE EACH ROW IS tps_body END BEFORE EACH ROW |AFTER STATEMENT IS tps_body END AFTER STATEMENT |AFTER EACH ROW IS tps_body END AFTER EACH ROW ) tps_body: (statement)+ (EXCEPTION exception_handler )* */ ASTTriggerUnit TriggerUnit() : { PLSQLNode simpleNode = null ; } { [ [ ] [ | ] ] () simpleNode = ObjectNameDeclaration() // simple_dml_trigger | compound_dml_trigger | non_dml_trigger // simple_dml_trigger : ( | | | // Incorporate 11G Compound DML Trigger ) //dml_event_clause ( (( | | ) [LOOKAHEAD(6) ID() ("," ID() )*] ) | NonDMLEvent() ) ( ( (( | | ) [LOOKAHEAD(6) ID() ("," ID() )* ] ) | NonDMLEvent() ) )* ( //11G non_dml_trigger |LOOKAHEAD(2)
ID() [LOOKAHEAD(2) ID()"."] ID() |[LOOKAHEAD(2) ID()"."] ID() //includes 11g schema. table === ) // referencing_clause - there may be ZERO subclauses [ (( | | ) ID())*] [] // end of simple_dml_trigger (incorporating compound_dml_trigger ) [ [|] ] // 11G Syntax to specify Cross Edition Trigger [ (|) ( [LOOKAHEAD(2) ID() "."] ID() ) ( "," ( [ LOOKAHEAD(2) ID() "."] ID() ) )* ] // 11G Syntax to specify trigger firing order [ | ] // 11G Syntax can create the trigger enabled or disabled explcitly [ "(" ConditionalOrExpression() ")" ] //Trigger Body follows : //plsql_block | compound_trigger_block | routine ( PrimaryExpression() ";" //compound_trigger_block | CompoundTriggerBlock() |//plsql_block Block() ";" //| // routine ) { jjtThis.setImage(simpleNode.getImage()) ; return jjtThis ; } } ASTTriggerTimingPointSection TriggerTimingPointSection() : { StringBuilder sb = new StringBuilder(); } { ( ( | | ) { sb.append(token.image) ; } ( | ) {sb.append(" "); sb.append(token.image) ; } (Statement())+ ( | | ) ( | ) ";" ) { //Add a TRIGGER ENTRY for each timing point section } { jjtThis.setImage(sb.toString()) ; return jjtThis ; } } ASTCompoundTriggerBlock CompoundTriggerBlock() : { } { ( //Problems making the declaration optional //DeclarativeSection() //(TriggerTimingPointSection())+ ( TriggerTimingPointSection()| Pragma() | LOOKAHEAD(2) ExceptionDeclaration() | LOOKAHEAD(2) SubTypeDefinition() | LOOKAHEAD(4) VariableOrConstantDeclaration() | LOOKAHEAD(2) CursorSpecification() | CursorBody() | CollectionDeclaration() | ProgramUnit() )* ) [ID()] ";" { return jjtThis ; } } /* non_dml_trigger : (BEFORE> | ) (DDLEvent | database_event) ( OR (DDLEvent | database_event))* ON (DATABASE | [schema.]SCHEMA */ ASTNonDMLTrigger NonDMLTrigger() : { } { ( | ) ( DDLEvent() | DatabaseEvent() ) ( ( DDLEvent() | DatabaseEvent() ) )* ( | [LOOKAHEAD(2) ID()"."] ) { return jjtThis ; } } ASTDDLEvent DDLEvent(): {} { ( | | | | | | | | | | | | | ) { jjtThis.setImage(token.toString()) ; jjtThis.value = token ; return jjtThis ; } } ASTDatabaseEvent DatabaseEvent(): {} { ( | | | | | ) { jjtThis.setImage(token.toString()) ; jjtThis.value = token ; return jjtThis ; } } ASTNonDMLEvent NonDMLEvent(): {} { (DDLEvent() | DatabaseEvent()) { return jjtThis; } } /* When DBMS_METADATA.GET_DDL returns a trigger, it can come in 2 DDL statements. The first is the CREATE OR REPLACE TRIGER statement; the second is an ALTER TRIGGER statement, enabling or disabling the trigger. Unlike the ALTER TYPE, it does not seem to alter the structure of the object. */ void AlterTrigger() : {} { Skip2NextTerminator(null,";") ";" { return; } } // Copyright (C) 2002 Albert Tumanov /* WHITE SPACE */ SKIP : { //Tracker Issue 1433480 - Skip2 and SkipPast need to be able to check for EOL - so the characters //cannot be SKIPped //" " | "\t" | "\n" | "\r" | "\f" " " | "\t" | "\f" } /* COMMENTS */ MORE : { <"/**" ~["/"]> : IN_FORMAL_COMMENT | "/*" : IN_MULTI_LINE_COMMENT } SPECIAL_TOKEN : { //Remove terminating EOL from Single Comment Token definition: it causes failurs if no other newline exists before next production } //Tracker Issue 1433480 - Skip2 and SkipPast need to be able to check for EOL - so it cannot be SKIPped SPECIAL_TOKEN : { } SPECIAL_TOKEN : { : DEFAULT } SPECIAL_TOKEN : { : DEFAULT } /* SKIP : { : DEFAULT } */ MORE : { < ~[] > } /* PSEUDO-RESERVED WORDS */ TOKEN [IGNORE_CASE]: { | | | | | | | | // PRAGMA INLINE } /* PL/SQL RESERVED WORDS */ /** * 2006-05-20 - Matthias Hendler - Removed: * Added: , , , * , , , * , * 2016-11-04 - Andreas Dangel - Added , */ TOKEN [IGNORE_CASE]: { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | <_DEFAULT: "DEFAULT"> | | | | | // Needed for 11G Trigger Syntax | | | | | | | | // Needed for 11G Trigger Syntax | | | | | | | | | | // | | | | | | | | | | | | | | | | //SRT 2011-04-17 | | | | | //SRT 2011-04-17 | | | | | | | | | | | | | | | | | | | | // | | | | | | | | | | | | | | | | | | | | | | | | | | | //SRT 2011-04-17 | | | | | | | | | // | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | // | // Mark the start of a Q-quoted string, e.g. Q'[ This string contains a single-quote(') ]' | | | | | | | | | //SRT 2011-04-17 | //SRT 2011-04-17 | | | | | | //SRT 2011-04-17 | | | | | | | | | | | | | | //SRT 2011-04-17 | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | //SRT 2011-04-17 | | //SRT 2011-04-17 | | //SRT 2011-04-17 | | //SRT 2011-04-17 | | // are they reserved or not ? // most are not reserved, but cannot use just "WHERE" etc instead - resolves as identifier ! // | // | // | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //11G Trigger Syntax | //XE testing | //XE testing | //XE testing non-PLSQL functions | //XE testing non-PLSQL functions | //XE testing non-PLSQL functions | //XE testing non-PLSQL functions | //XE testing non-PLSQL functions | //XE testing non-PLSQL functions | //XE testing non-PLSQL functions | //XE testing non-PLSQL functions | //XE testing non-PLSQL functions //SQLPlus Commands | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | } /** * 2006-05-20 - Matthias Hendler - Added #GERMAN_SPECIAL_CHARACTERS and #SPECIAL_CHARACTERS. * Added ":" to */ TOKEN : { < #GERMAN_SPECIAL_CHARACTERS: "Ä" | "Ö" | "Ü" | "ä" | "ü" | "ö" | "ß" > | < #LETTER: ["A"-"Z"] | ["a"-"z"] | > | < #DIGIT: ["0"-"9"]> | < #_CHARACTER: <_CHARACTER_WO_ASTERISK> | "'" > | < #_CHARACTER_WO_ASTERISK: | | "(" | ")" | "+" | "-" | "*" | "/" | "<" | ">" | "=" | "!" | "~" | "^" | ";" | ":" | "." | "@" | "%" | "," | "\"" | "#" | "$" | "&" | "_" | "|" | "{" | "}" | "?" | "[" | "]" | " " | "\t" > | < #SPECIAL_CHARACTERS: "á" | "Ž" | "™" | "š" | "„" | "”" | "ý" | "²" | "€" | "³" | "µ"> | < #DELIMITER: "+" | "%" | "'" | "\"" | "." | "/" | "(" | ")" | ":" | "," | "*" | "=" | "<" | ">" | "@" | ";" | "-"> | < IDENTIFIER: ( ("$" | ":" | ) ( | | "$" | "_" | "#" )* ) // 2006-05-17 - Matthias Hendler - Bind variablen werden nun als Identifier akzeptiert. //SRT Does NOT seem to like identifiers 2 or fewer characters( ( ) ) //( ( ) ) //( ( "$" ) ) //( ( "_" ) ) //( ( "#" ) ) | ( ( | "$" ) ( | | "$" | "_" | "#" )* ) | //SRT ( "\"" (<_CHARACTER_WO_ASTERISK>)* "\"" ) ( "\"" ( | | "$" | "_" | "#" )* "\"" ) > | < UNSIGNED_NUMERIC_LITERAL: ( ["e","E"] (["-","+"])? )? (["f","F","d","D"])? > | < #FLOAT_LITERAL: ( "." )? | "." > | < #INTEGER_LITERAL: ( )+ > | < #_WHATEVER_CHARACTER_WO_ASTERISK: (~["'"]) > | < CHARACTER_LITERAL: "'" (<_WHATEVER_CHARACTER_WO_ASTERISK> | )? "'" > //|< STRING_LITERAL: // (["q","Q"])* "'" (<_WHATEVER_CHARACTER_WO_ASTERISK> | | "''")* "'" //> //Cope with Q-quoted stringswithout single quotes in them |< STRING_LITERAL: // Hard-code the most likely q-quote strings "'" (<_WHATEVER_CHARACTER_WO_ASTERISK> | | "''")* "'" |(["n","N"]) "'" (<_WHATEVER_CHARACTER_WO_ASTERISK> | | "''")* "'" //National Character Set String |(["q","Q"]) "'" (<_WHATEVER_CHARACTER_WO_ASTERISK> | | "''")* "'" // Bug 160632 |(["q","Q"]) "'[" (~["[","]"])* "]'" |(["q","Q"]) "'{" (~["{","}"])* "}'" |(["q","Q"]) "'<" (~["<",">"])* ">'" |(["q","Q"]) "'(" (~["(",")"])* ")'" |(["q","Q"]) "'/" (~["/"])* "/'" |(["q","Q"]) "'!" (~["!"])* "!'" |(["q","Q"]) "'#" (~["#"])* "#'" > //Cope with Q-quoted stringswithout single quotes in them | < #_WHATEVER_CHARACTER_WO_QUOTE: (~["\""]) > | < QUOTED_LITERAL: "\"" (<_WHATEVER_CHARACTER_WO_QUOTE> | | "\\\"")* "\"" > | < SQLDATA_CLASS: "SQLData" > | < CUSTOMDATUM_CLASS: "CustomDatum" > | < ORADATA_CLASS: "OraData" > | < JAVA_INTERFACE_CLASS: ( "SQLData" | "CustomDatum" | "OraData" ) > //| //< #BOOLEAN_LITERAL: "TRUE" | "FALSE" > | } //SRT 2011-04-17 - START ASTKEYWORD_RESERVED KEYWORD_RESERVED (): {} { // PL/SQL RESERVED WORDS - V$RESERVED.RESERVED='Y' ( | | | | | | | | | | | | | | | | <_DEFAULT> | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | |
| | | | | | | | | | | | ) { jjtThis.setImage(token.toString()) ; jjtThis.value = token ; return jjtThis ; } } ASTKEYWORD_UNRESERVED KEYWORD_UNRESERVED (): {} { // PL/SQL UNRESERVED KEYWORDS - V$RESERVED.RESERVED='N' ( | | //| | //| //| test_unreserved_keyword.pks //| //| | //| test_unreserved_keyword.pks //| //| //| //| | | //| //| //| //| //| | //| //| //| //| //| //| //| //| test_unreserved_keyword.pks | | | | //PLDoc Bug 3512149 test_unreserved_keyword.pks //| | | //| | //| //| //| //| //| //| //| //| //| | //| //| test_unreserved_keyword.pks //| | //-test_unreserved_keyword.pks //| //| //| //| //| //| //| //| //| //| //| //| | //| //| //| //| //| | //| //| //| //| test_unreserved_keyword.pks //| //| | //| //| //| // RESERVED WORD !!! | //test_unreserved_keyword.pks //| //| //| //| | //| //| | //| | //| //| //| //| //| | | | | //| //| //| //| //| //| //| | //| | //| //| | //| | | //| //| //| | | //| //| //| //| //| //| | //| //| //| //| //| //| //| //| //| //| //| //| | //| //| //| | | //| | | //| //| //| //| //| //| //| //| //| | //| //| //| //| | | //| //| //| //| | | //| //| //| //| | //| //| //| //| | | //| //| | //| //| //| //| //| | // SQL*Plus command //| | //| //| //| //| //| //| //| //| //| //| //| | | //| | | //| //| //| //| //| //| //| //| //| //| //| | //| //| //| //| //| //| //| | | //| //| //| | | //| //| //| //| //| //| //| //| //| //| //| //| | //| //| //| //| | | | //| //| //| //| //| //| //| //| //| //| | //| //| | //| | //| //| //| //| //| //| //| //| //| //| | //| //| //| //| //| //| //| //| //| | | //| //| //| //| //| //| //| | //| //| //| //| //| | //| //| //| //| //| //| //| //| //| | //| //| //| //|
| //| //| //| //| | | //| //| //| //| //| //| //| //| //| //| | //| //| //| //| //| //| //| //| //| //| //| //| //| //| //| //| //| //| //| //| //| //| //| //| //| | //| | | // FORALL i I INDICES OF collection - SPARSE COLLECTIONS //| //| //| //| //| //| //| //| //| //| //| | //| //| //| //| //| //| //| | | | //| //| //| | //| //| //| //| //| //| //| //| //| //| | //| //| //| //| //| //| | | | //| | //| | //| //| //| //| | | //| //| | //| //| //| //| //| //| //| //| //| //| //| //| | | //| //|
//| //| //| //| | // Bug 3512150 //| //| //| //| //| | //| //| //| //| //| | //| //| //| //| //| //| //| | //| | //| //| //| //| //| | //| //| //| //| | //| //| | //| //| //| //| //| //| //| //| | //| | //| //| //| | //| | //| //| //| //| //| | //|