BNF for sqlgrammar.jj

TOKENS

<DEFAULT> SKIP : {
" "
| "\t"
| "\n"
| "\r"
}

   
<DEFAULT> MORE : {
"/*" : IN_BRACKETED_COMMENT
}

   
<IN_BRACKETED_COMMENT> MORE : {
"/*" : IN_NESTED_BRACKETED_COMMENT
}

   
<IN_BRACKETED_COMMENT> SKIP : {
"*/" : DEFAULT
}

   
<IN_NESTED_BRACKETED_COMMENT> MORE : {
"/*" : {
}

   
<IN_NESTED_BRACKETED_COMMENT> MORE : {
"*/" : {
}

   
<IN_BRACKETED_COMMENT,IN_NESTED_BRACKETED_COMMENT> MORE : {
<~[]>
}

   
<DEFAULT> SKIP : {
"--" : IN_COMMENT
}

   
<IN_COMMENT> SKIP : {
" "
| "\t"
}

   
/*
	Check if the comment characters -- are followed by DERBY-PROPERTIES
	token. 

	If yes, then this comment is providing user-supplied optimizer 
	overrides. There should be keyname=value [,keyname=value] pairs
	after -- DERBY-PROPERTIES otherwise throw an exception. These
	optimier overrides should be used in correct context only, 
	otherwise, the parser will throw an exception.

	If this comment does not start with DERBY-PROPERTOIES, then it is 
	just a regular comment. Skip the comment and move on to the next line.
 */
<IN_COMMENT> MORE [IGNORE_CASE] : {
"D" : LOOKFOR_DE
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_D: ~["D"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DE> MORE [IGNORE_CASE] : {
"E" : LOOKFOR_DER
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DE: ~["E"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DER> MORE [IGNORE_CASE] : {
"R" : LOOKFOR_DERB
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DER: ~["R"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DERB> MORE [IGNORE_CASE] : {
"B" : LOOKFOR_DERBY
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DERB: ~["B"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DERBY> MORE [IGNORE_CASE] : {
"Y" : LOOKFOR_DERBYDASH
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DERBY: ~["Y"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DERBYDASH> MORE [IGNORE_CASE] : {
"-" : LOOKFOR_DERBYDASHP
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DERBYDASH: ~["-"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DERBYDASHP> MORE [IGNORE_CASE] : {
"P" : LOOKFOR_DERBYDASHPR
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DERBYDASHP: ~["P"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DERBYDASHPR> MORE [IGNORE_CASE] : {
"R" : LOOKFOR_DERBYDASHPRO
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DERBYDASHPR: ~["R"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DERBYDASHPRO> MORE [IGNORE_CASE] : {
"O" : LOOKFOR_DERBYDASHPROP
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DERBYDASHPRO: ~["O"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DERBYDASHPROP> MORE [IGNORE_CASE] : {
"P" : LOOKFOR_DERBYDASHPROPE
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DERBYDASHPROP: ~["P"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DERBYDASHPROPE> MORE [IGNORE_CASE] : {
"E" : LOOKFOR_DERBYDASHPROPER
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DERBYDASHPROPE: ~["E"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DERBYDASHPROPER> MORE [IGNORE_CASE] : {
"R" : LOOKFOR_DERBYDASHPROPERT
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DERBYDASHPROPER: ~["R"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DERBYDASHPROPERT> MORE [IGNORE_CASE] : {
"T" : LOOKFOR_DERBYDASHPROPERTI
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DERBYDASHPROPERT: ~["T"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DERBYDASHPROPERTI> MORE [IGNORE_CASE] : {
"I" : LOOKFOR_DERBYDASHPROPERTIE
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DERBYDASHPROPERTI: ~["I"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DERBYDASHPROPERTIE> MORE [IGNORE_CASE] : {
"E" : LOOKFOR_DERBYDASHPROPERTIES
| <("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_DERBYDASHPROPERTIE: ~["E"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<LOOKFOR_DERBYDASHPROPERTIES> TOKEN [IGNORE_CASE] : {
<DERBYDASHPROPERTIES: "DERBYDASHPROPERTIES">
}

   
//once we find comment starting with -- DERBY-PROPERTIES, we want to switch 
//from SKIP mode to the TOKEN mode in the parser so the rest of the characters 
//on the comment line can be treated as part of one big token so we can get 
//keyname=value pairs from that token. The reason for treating them as one big
//token is that the existing code in parser allows newline characters between
//individual token but with optimizer overrides, all the properties have to
//be specified on the -- DERBY-PROPERTIES comment line. 
<LOOKFOR_DERBYDASHPROPERTIES> TOKEN [IGNORE_CASE] : {
"S" : PROPERTIES_LIST
}

   
//We found -- DERBY-PROPERTIE? where ? is a character other than S
//and hence we should the rest of the characters on this line as 
//a regular comment
<LOOKFOR_DERBYDASHPROPERTIES> SKIP : {
<("\n" | "\r" | "\r\n")?> : DEFAULT
| <NOT_PROPERTIES: ~["S","s"]> : IT_IS_NOT_DERBYPROPERTIES_COMMENT
}

   
<IT_IS_NOT_DERBYPROPERTIES_COMMENT> SKIP : {
<SINGLE_LINE_SQLCOMMENT: (~["\n","\r"])* ("\n" | "\r" | "\r\n")?> : DEFAULT
}

   
//found -- DERBY-PROPERTIES. Treat rest of the characters on the line
//as one big token and then fetch keyname=value pairs from that token.
<PROPERTIES_LIST> TOKEN : {
<CHECK_PROPERTIES: (~["\n","\r"])* ("\n" | "\r" | "\r\n")?> : DEFAULT
}

   
/*
	This list should contain only and all SQL92 keywords that are reserved.
	Reserved keywords can be used as identifiers in the language only
	as delimited identifiers.
 */
/* NOTE - If you add a keyword, then you must add it to reservedKeyword()
 *	      or nonReservedKeyword() as well!
 */
<DEFAULT> TOKEN [IGNORE_CASE] : {
<ADD: "add">
| <ALL: "all">
| <ALLOCATE: "allocate">
| <ALTER: "alter">
| <AND: "and">
| <ANY: "any">
| <ARE: "are">
| <AS: "as">
| <ASC: "asc">
| <ASSERTION: "assertion">
| <AT: "at">
| <AUTHORIZATION: "authorization">
| <AVG: "avg">
| <BEGIN: "begin">
| <BETWEEN: "between">
| <BINARY: "binary">
| <BIT: "bit">
| <BOTH: "both">
| <BY: "by">
| <CASCADE: "cascade">
| <CASCADED: "cascaded">
| <CASE: "case">
| <CAST: "cast">
| <CHAR: "char">
| <CHARACTER: "character">
| <CHARACTER_LENGTH: "character_length">
| <CHECK: "check">
| <CLOSE: "close">
| <COALESCE: "coalesce">
| <COLLATE: "collate">
| <COLLATION: "collation">
| <COLUMN: "column">
| <COMMIT: "commit">
| <CONNECT: "connect">
| <CONNECTION: "connection">
| <CONSTRAINT: "constraint">
| <CONSTRAINTS: "constraints">
| <CONTINUE: "continue">
| <CONVERT: "convert">
| <CORRESPONDING: "corresponding">
| <COUNT: "count">
| <CREATE: "create">
| <CROSS: "cross">
| <CURRENT: "current">
| <CURRENT_DATE: "current_date">
| <CURRENT_TIME: "current_time">
| <CURRENT_TIMESTAMP: "current_timestamp">
| <CURRENT_USER: "current_user">
| <CURSOR: "cursor">
| <D: "d">
| <DEALLOCATE: "deallocate">
| <DEC: "dec">
| <DECIMAL: "decimal">
| <DECLARE: "declare">
| <_DEFAULT: "default">
| <DEFERRABLE: "deferrable">
| <DEFERRED: "deferred">
| <DELETE: "delete">
| <DESC: "desc">
| <DESCRIBE: "describe">
| <DIAGNOSTICS: "diagnostics">
| <DISCONNECT: "disconnect">
| <DISTINCT: "distinct">
| <DOUBLE: "double">
| <DROP: "drop">
| <ELSE: "else">
| <END: "end">
| <ENDEXEC: "end-exec">
| <ESCAPE: "escape">
| <EXCEPT: "except">
| <EXCEPTION: "exception">
| <EXEC: "exec">
| <EXECUTE: "execute">
| <EXISTS: "exists">
| <EXTERNAL: "external">
| <FALSE: "false">
| <FETCH: "fetch">
| <FIRST: "first">
| <FLOAT: "float">
| <FOR: "for">
| <FOREIGN: "foreign">
| <FOUND: "found">
| <FROM: "from">
| <FULL: "full">
| <FUNCTION: "function">
| <GET: "get">
| <GLOBAL: "global">
| <GO: "go">
| <GOTO: "goto">
| <GRANT: "grant">
| <GROUP: "group">
| <HAVING: "having">
| <HOUR: "hour">
| <IDENTITY: "identity">
| <IMMEDIATE: "immediate">
| <IN: "in">
| <INDICATOR: "indicator">
| <INITIALLY: "initially">
| <INNER: "inner">
| <INPUT: "input">
| <INSENSITIVE: "insensitive">
| <INSERT: "insert">
| <INT: "int">
| <INTEGER: "integer">
| <INTERSECT: "intersect">
| <INTO: "into">
| <IS: "is">
| <ISOLATION: "isolation">
| <JOIN: "join">
| <KEY: "key">
| <LAST: "last">
| <LEADING: "leading">
| <LEFT: "left">
| <LIKE: "like">
| <LOWER: "lower">
| <MATCH: "match">
| <MAX: "max">
| <MIN: "min">
| <MINUTE: "minute">
| <MODULE: "module">
| <NATIONAL: "national">
| <NATURAL: "natural">
| <NCHAR: "nchar">
| <NEXT: "next">
| <NO: "no">
| <NOT: "not">
| <NULL: "null">
| <NULLIF: "nullif">
| <NUMERIC: "numeric">
| <OF: "of">
| <ON: "on">
| <ONLY: "only">
| <OPEN: "open">
| <OPTION: "option">
| <OR: "or">
| <ORDER: "order">
| <OUTER: "outer">
| <OUTPUT: "output">
| <OVERLAPS: "overlaps">
| <PAD: "pad">
| <PARTIAL: "partial">
| <PREPARE: "prepare">
| <PRESERVE: "preserve">
| <PRIMARY: "primary">
| <PRIOR: "prior">
| <PRIVILEGES: "privileges">
| <PROCEDURE: "procedure">
| <PUBLIC: "public">
| <READ: "read">
| <REAL: "real">
| <REFERENCES: "references">
| <RELATIVE: "relative">
| <RESTRICT: "restrict">
| <REVOKE: "revoke">
| <RIGHT: "right">
| <ROLLBACK: "rollback">
| <ROWS: "rows">
| <SCHEMA: "schema">
| <SCROLL: "scroll">
| <SECOND: "second">
| <SELECT: "select">
| <SESSION_USER: "session_user">
| <SET: "set">
| <SMALLINT: "smallint">
| <SOME: "some">
| <SPACE: "space">
| <SQL: "sql">
| <SQLCODE: "sqlcode">
| <SQLERROR: "sqlerror">
| <SQLSTATE: "sqlstate">
| <SUBSTRING: "substring">
| <SUM: "sum">
| <SYSTEM_USER: "system_user">
| <T: "t">
| <TABLE: "table">
| <TEMPORARY: "temporary">
| <TIMEZONE_HOUR: "timezone_hour">
| <TIMEZONE_MINUTE: "timezone_minute">
| <TO: "to">
| <TRANSACTION: "transaction">
| <TRANSLATE: "translate">
| <TRANSLATION: "translation">
| <TRAILING: "trailing">
| <TRIM: "trim">
| <TRUE: "true">
| <TS: "ts">
| <UNION: "union">
| <UNIQUE: "unique">
| <UNKNOWN: "unknown">
| <UPDATE: "update">
| <UPPER: "upper">
| <USER: "user">
| <USING: "using">
| <VALUE: "value">
| <VALUES: "values">
| <VARBINARY: "varbinary">
| <VARCHAR: "varchar">
| <VARYING: "varying">
| <VIEW: "view">
| <WHENEVER: "whenever">
| <WHERE: "where">
| <WINDOW: "window">
| <WITH: "with">
| <WORK: "work">
| <WRITE: "write">
| <YEAR: "year">
}

   
/*
	This list should contain only and all SQL92 keywords that are non-reserved.
	Non-reserved keywords can be used as identifiers in the language.
	To make that happen, the individual tokens have to be repeated in
	the nonReservedKeyword() rule -- unless there's some other JavaCC shorthand?

	NOTE: I've commented out most of these because we won't be using them
	right away and the grammar is taking forever to process.
 */
/* NOTE - If you add a keyword, then you must add it to reservedKeyword()
 *	      or nonReservedKeyword() as well!
 */
<DEFAULT> TOKEN [IGNORE_CASE] : {
<ABS: "abs">
| <ABSVAL: "absval">
| <ACTION: "action">
| <ALWAYS: "always">
| <BLOB: "blob">
| <C: "c">
| <CALLED: "called">
| <CLOB: "clob">
| <COBOL: "cobol">
| <COMMITTED: "committed">
| <CONCAT: "concat">
| <CONTAINS: "contains">
| <CYCLE: "cycle">
| <DATA: "data">
| <DATE: "date">
| <DAY: "day">
| <DEFINER: "definer">
| <DETERMINISTIC: "deterministic">
| <DYNAMIC: "dynamic">
| <ENFORCED: "enforced">
| <FORTRAN: "fortran">
| <GENERATED: "generated">
| <IDENTITY_VAL_LOCAL: "identity_val_local">
| <INCREMENT: "increment">
| <INITIAL: "initial">
| <INOUT: "inout">
| <INTERVAL: "interval">
| <INVOKER: "invoker">
| <LANGUAGE: "language">
| <LARGE: "large">
| <LENGTH: "length">
| <LEVEL: "level">
| <LIMIT: "limit">
| <LOCKS: "locks">
| <LOCKSIZE: "locksize">
| <LOGGED: "logged">
| <MATCHED: "matched">
| <MAXVALUE: "maxvalue">
| <MERGE: "merge">
| <MINVALUE: "minvalue">
| <MOD: "mod">
| <MODIFIES: "modifies">
| <MODIFY: "modify">
| <MONTH: "month">
| <_MORE: "more">
| <MUMPS: "mumps">
| <NAME: "name">
| <NCLOB: "nclob">
| <NULLABLE: "nullable">
| <NULLS: "nulls">
| <NUMBER: "number">
| <OBJECT: "object">
| <OFFSET: "offset">
| <PASCAL: "pascal">
| <PLI: "pli">
| <PRECISION: "precision">
| <RELEASE: "release">
| <REPEATABLE: "repeatable">
| <RESTART: "restart">
| <RETURNS: "returns">
| <ROLLUP: "rollup">
| <ROW: "row">
| <SAVEPOINT: "savepoint">
| <SCALE: "scale">
| <SECURITY: "security">
| <SERIALIZABLE: "serializable">
| <SQL_TSI_FRAC_SECOND: "sql_tsi_frac_second">
| <SQL_TSI_SECOND: "sql_tsi_second">
| <SQL_TSI_MINUTE: "sql_tsi_minute">
| <SQL_TSI_HOUR: "sql_tsi_hour">
| <SQL_TSI_DAY: "sql_tsi_day">
| <SQL_TSI_WEEK: "sql_tsi_week">
| <SQL_TSI_MONTH: "sql_tsi_month">
| <SQL_TSI_QUARTER: "sql_tsi_quarter">
| <SQL_TSI_YEAR: "sql_tsi_year">
| <START: "start">
| <STATEMENT: "statement">
| <SYNONYM: "synonym">
| <THEN: "then">
| <TIME: "time">
| <TIMESTAMP: "timestamp">
| <TIMESTAMPADD: "timestampadd">
| <TIMESTAMPDIFF: "timestampdiff">
| <TRUNCATE: "truncate">
| <TYPE: "type">
| <UNCOMMITTED: "uncommitted">
| <USAGE: "usage">
| <WHEN: "when">
| <DERBYPLAN: "--derbyplan">
}

   
/*
	The next lists should contain non-SQL92 keywords, and should
	specify whether their keywords are reserved or non-reserved.
	If they are non-reserved, they need to be added to the identifier() rule.

	NOTE: XML, XMLPARSE, XMLSERIALIZE, and XMLEXISTS are considered reserved
	words to comply with the SQL/XML (2003) standard, section 5.1.  Similarly,
	XMLQUERY is a reserved word per SQL/XML (2006).
 */

/* NOTE - If you add a keyword, then you must add it to reservedKeyword()
 *	      or nonReservedKeyword() as well!
 */
<DEFAULT> TOKEN [IGNORE_CASE] : {
<BOOLEAN: "boolean">
| <CALL: "call">
| <CURDATE: "curdate">
| <CURRENT_ROLE: "current_role">
| <CURTIME: "curtime">
| <DATABASE: "database">
| <GET_CURRENT_CONNECTION: "getCurrentConnection">
| <EXPLAIN: "explain">
| <BIGINT: "bigint">
| <LONG: "long">
| <LTRIM: "ltrim">
| <NONE: "none">
| <OVER: "over">
| <ROLE: "role">
| <ROWNUMBER: "row_number">
| <RTRIM: "rtrim">
| <SUBSTR: "substr">
| <XML: "xml">
| <XMLEXISTS: "xmlexists">
| <XMLPARSE: "xmlparse">
| <XMLQUERY: "xmlquery">
| <XMLSERIALIZE: "xmlserialize">
}

   
/* NOTE - If you add a keyword, then you must add it to reservedKeyword()
 *	      or nonReservedKeyword() as well!
 *
 * NOTE: CONTENT, DOCUMENT, STRIP, WHITESPACE and PASSING are considered NON-
 * reserved words to comply with the SQL/XML (2003) standard, section 5.1.
 * Similarly, EMPTY, RETURNING, and SEQUENCE are all considered NON-reserved
 * words per SQL/XML (2006).  PRESERVE is also listed as non-reserved in the
 * SQL/XML spec, but since that word is already reserved, we leave it alone.
 */
<DEFAULT> TOKEN [IGNORE_CASE] : {
<AFTER: "after">
| <AGGREGATE: "aggregate">
| <BEFORE: "before">
| <CLASS: "class">
| <COMPRESS: "compress">
| <CONTENT: "content">
| <CS: "cs">
| <CURSORS: "cursors">
| <DB2SQL: "db2sql">
| <DERBY: "derby">
| <DERBY_JDBC_RESULT_SET: "derby_jdbc_result_set">
| <DEFRAGMENT: "defragment">
| <DIRTY: "dirty">
| <DOCUMENT: "document">
| <EACH: "each">
| <EMPTY: "empty">
| <EXCLUSIVE: "exclusive">
| <FN: "fn">
| <INDEX: "index">
| <INPLACE: "inplace">
| <JAVA: "java">
| <LCASE: "lcase">
| <LOCATE: "locate">
| <LOCK: "lock">
| <MESSAGE_LOCALE: "message_locale">
| <METHOD: "method">
| <MODE: "mode">
| <NEW: "new">
| <NEW_TABLE: "new_table">
| <NVARCHAR: "nvarchar">
| <OJ: "oj">
| <OFF: "off">
| <OLD: "old">
| <OLD_TABLE: "old_table">
| <OUT: "out">
| <PARAMETER: "parameter">
| <PASSING: "passing">
| <PROPERTIES: "properties">
| <PURGE: "purge">
| <READS: "reads">
| <REF: "ref">
| <REFERENCING: "referencing">
| <RENAME: "rename">
| <RESET: "reset">
| <RESULT: "result">
| <RETAIN: "retain">
| <RETURNING: "returning">
| <RR: "rr">
| <RS: "rs">
| <STATISTICS: "statistics">
| <SEQUENCE: "sequence">
| <SEQUENTIAL: "sequential">
| <SETS: "sets">
| <SHARE: "share">
| <SQLID: "sqlid">
| <SPECIFIC: "specific">
| <SQRT: "sqrt">
| <STABILITY: "stability">
| <STRIP: "strip">
| <STYLE: "style">
| <TRIGGER: "trigger">
| <TRUNCATE_END: "truncate_end">
| <UCASE: "ucase">
| <UR: "ur">
| <WHITESPACE: "whitespace">
}

   
<DEFAULT> TOKEN : {
<DOUBLE_QUOTE: "\"">
| <PERCENT: "%">
| <AMPERSAND: "&">
| <QUOTE: "\'">
| <LEFT_BRACE: "{">
| <RIGHT_BRACE: "}">
| <LEFT_PAREN: "(">
| <RIGHT_PAREN: ")">
| <ASTERISK: "*">
| <HASH: "#">
| <PLUS_SIGN: "+">
| <COMMA: ",">
| <MINUS_SIGN: "-">
| <PERIOD: ".">
| <SOLIDUS: "/">
| <COLON: ":">
| <DOUBLE_COLON: "::">
| <SEMICOLON: ";">
| <LESS_THAN_OPERATOR: "<">
| <LESS_THAN_OR_EQUALS_OPERATOR: "<=">
| <EQUALS_OPERATOR: "=">
| <NOT_EQUALS_OPERATOR: "<>">
| <NOT_EQUALS_OPERATOR2: "!=">
| <GREATER_THAN_OPERATOR: ">">
| <GREATER_THAN_OR_EQUALS_OPERATOR: ">=">
| <QUESTION_MARK: "?">
| <UNDERSCORE: "_">
| <VERTICAL_BAR: "|">
| <LEFT_BRACKET: "[">
| <RIGHT_BRACKET: "]">
| <CONCATENATION_OPERATOR: "||">
| <FIELD_REFERENCE: "->">
| <ELLIPSIS: "...">
}

   
<DEFAULT> TOKEN : {
<IDENTIFIER: <LETTER> (<LETTER> | "_" | <DIGIT>)*>
}

   
<DEFAULT> TOKEN : {
<K: "K">
}

   
<DEFAULT> TOKEN : {
<M: "M">
}

   
<DEFAULT> TOKEN : {
<G: "G">
}

   
<DEFAULT> TOKEN : {
<#LETTER: ["a"-"z","A"-"Z","\u00aa","\u00b5","\u00ba","\u00c0"-"\u00d6","\u00d8"-"\u00f6","\u00f8"-"\u01f5","\u01fa"-"\u0217","\u0250"-"\u02a8","\u02b0"-"\u02b8","\u02bb"-"\u02c1","\u02d0"-"\u02d1","\u02e0"-"\u02e4","\u037a","\u0386","\u0388"-"\u038a","\u038c","\u038e"-"\u03a1","\u03a3"-"\u03ce","\u03d0"-"\u03d6","\u03da","\u03dc","\u03de","\u03e0","\u03e2"-"\u03f3","\u0401"-"\u040c","\u040e"-"\u044f","\u0451"-"\u045c","\u045e"-"\u0481","\u0490"-"\u04c4","\u04c7"-"\u04c8","\u04cb"-"\u04cc","\u04d0"-"\u04eb","\u04ee"-"\u04f5","\u04f8"-"\u04f9","\u0531"-"\u0556","\u0559","\u0561"-"\u0587","\u05d0"-"\u05ea","\u05f0"-"\u05f2","\u0621"-"\u063a","\u0640"-"\u064a","\u0671"-"\u06b7","\u06ba"-"\u06be","\u06c0"-"\u06ce","\u06d0"-"\u06d3","\u06d5","\u06e5"-"\u06e6","\u0905"-"\u0939","\u093d","\u0958"-"\u0961","\u0985"-"\u098c","\u098f"-"\u0990","\u0993"-"\u09a8","\u09aa"-"\u09b0","\u09b2","\u09b6"-"\u09b9","\u09dc"-"\u09dd","\u09df"-"\u09e1","\u09f0"-"\u09f1","\u0a05"-"\u0a0a","\u0a0f"-"\u0a10","\u0a13"-"\u0a28","\u0a2a"-"\u0a30","\u0a32"-"\u0a33","\u0a35"-"\u0a36","\u0a38"-"\u0a39","\u0a59"-"\u0a5c","\u0a5e","\u0a72"-"\u0a74","\u0a85"-"\u0a8b","\u0a8d","\u0a8f"-"\u0a91","\u0a93"-"\u0aa8","\u0aaa"-"\u0ab0","\u0ab2"-"\u0ab3","\u0ab5"-"\u0ab9","\u0abd","\u0ae0","\u0b05"-"\u0b0c","\u0b0f"-"\u0b10","\u0b13"-"\u0b28","\u0b2a"-"\u0b30","\u0b32"-"\u0b33","\u0b36"-"\u0b39","\u0b3d","\u0b5c"-"\u0b5d","\u0b5f"-"\u0b61","\u0b85"-"\u0b8a","\u0b8e"-"\u0b90","\u0b92"-"\u0b95","\u0b99"-"\u0b9a","\u0b9c","\u0b9e"-"\u0b9f","\u0ba3"-"\u0ba4","\u0ba8"-"\u0baa","\u0bae"-"\u0bb5","\u0bb7"-"\u0bb9","\u0c05"-"\u0c0c","\u0c0e"-"\u0c10","\u0c12"-"\u0c28","\u0c2a"-"\u0c33","\u0c35"-"\u0c39","\u0c60"-"\u0c61","\u0c85"-"\u0c8c","\u0c8e"-"\u0c90","\u0c92"-"\u0ca8","\u0caa"-"\u0cb3","\u0cb5"-"\u0cb9","\u0cde","\u0ce0"-"\u0ce1","\u0d05"-"\u0d0c","\u0d0e"-"\u0d10","\u0d12"-"\u0d28","\u0d2a"-"\u0d39","\u0d60"-"\u0d61","\u0e01"-"\u0e2e","\u0e30","\u0e32"-"\u0e33","\u0e40"-"\u0e46","\u0e81"-"\u0e82","\u0e84","\u0e87"-"\u0e88","\u0e8a","\u0e8d","\u0e94"-"\u0e97","\u0e99"-"\u0e9f","\u0ea1"-"\u0ea3","\u0ea5","\u0ea7","\u0eaa"-"\u0eab","\u0ead"-"\u0eae","\u0eb0","\u0eb2"-"\u0eb3","\u0ebd","\u0ec0"-"\u0ec4","\u0ec6","\u0edc"-"\u0edd","\u0f40"-"\u0f47","\u0f49"-"\u0f69","\u10a0"-"\u10c5","\u10d0"-"\u10f6","\u1100"-"\u1159","\u115f"-"\u11a2","\u11a8"-"\u11f9","\u1e00"-"\u1e9b","\u1ea0"-"\u1ef9","\u1f00"-"\u1f15","\u1f18"-"\u1f1d","\u1f20"-"\u1f45","\u1f48"-"\u1f4d","\u1f50"-"\u1f57","\u1f59","\u1f5b","\u1f5d","\u1f5f"-"\u1f7d","\u1f80"-"\u1fb4","\u1fb6"-"\u1fbc","\u1fbe","\u1fc2"-"\u1fc4","\u1fc6"-"\u1fcc","\u1fd0"-"\u1fd3","\u1fd6"-"\u1fdb","\u1fe0"-"\u1fec","\u1ff2"-"\u1ff4","\u1ff6"-"\u1ffc","\u207f","\u2102","\u2107","\u210a"-"\u2113","\u2115","\u2118"-"\u211d","\u2124","\u2126","\u2128","\u212a"-"\u2131","\u2133"-"\u2138","\u3005","\u3031"-"\u3035","\u3041"-"\u3094","\u309b"-"\u309e","\u30a1"-"\u30fa","\u30fc"-"\u30fe","\u3105"-"\u312c","\u3131"-"\u318e","\u4e00"-"\u9fa5","\uac00"-"\ud7a3","\uf900"-"\ufa2d","\ufb00"-"\ufb06","\ufb13"-"\ufb17","\ufb1f"-"\ufb28","\ufb2a"-"\ufb36","\ufb38"-"\ufb3c","\ufb3e","\ufb40"-"\ufb41","\ufb43"-"\ufb44","\ufb46"-"\ufbb1","\ufbd3"-"\ufd3d","\ufd50"-"\ufd8f","\ufd92"-"\ufdc7","\ufdf0"-"\ufdfb","\ufe70"-"\ufe72","\ufe74","\ufe76"-"\ufefc","\uff21"-"\uff3a","\uff41"-"\uff5a","\uff66"-"\uffbe","\uffc2"-"\uffc7","\uffca"-"\uffcf","\uffd2"-"\uffd7","\uffda"-"\uffdc"]>
}

   
<DEFAULT> TOKEN : {
<#DIGIT: ["0"-"9","\u0660"-"\u0669","\u06f0"-"\u06f9","\u0966"-"\u096f","\u09e6"-"\u09ef","\u0a66"-"\u0a6f","\u0ae6"-"\u0aef","\u0b66"-"\u0b6f","\u0be7"-"\u0bef","\u0c66"-"\u0c6f","\u0ce6"-"\u0cef","\u0d66"-"\u0d6f","\u0e50"-"\u0e59","\u0ed0"-"\u0ed9","\u0f20"-"\u0f29","\uff10"-"\uff19"]>
}

   
<DEFAULT> TOKEN : {
<DELIMITED_IDENTIFIER: "\"" ("\"\"" | ~["\""])+ "\"">
}

   
<DEFAULT> TOKEN : {
<EXACT_NUMERIC: <UINT> ("." (<UINT>)?)? | "." <UINT>>
| <UINT: (["0"-"9"])+>
| <LENGTH_MODIFIER: <UINT> ["K","M","G","k","m","g"]>
| <STRING: "\'" ("\'\'" | ~["\'"])* "\'">
| <HEX_STRING: ["X","x"] "\'" (["0"-"9","a"-"f","A"-"F"])* "\'">
| <APPROXIMATE_NUMERIC: <EXACT_NUMERIC> ["e","E"] ("+" | "-")? (["0"-"9"])+>
| <INTERVAL_LITERAL: "INTERVAL" "\'" (["+","-"])? <INTERVAL_STRING> <INTERVAL_QUALIFIER>>
| <#INTERVAL_STRING: "\'" (<YEAR_MONTH_LITERAL> | <DAY_TIME_LITERAL>) "\'">
| <#INTERVAL_QUALIFIER: <SINGLE_DATETIME_FIELD> | <START_FIELD> <TO> <END_FIELD>>
| <#SINGLE_DATETIME_FIELD: <NON_SECOND_DATETIME_FIELD> (<LEFT_PAREN> <UINT> <RIGHT_PAREN>)?>
| <#START_FIELD: <NON_SECOND_DATETIME_FIELD> (<LEFT_PAREN> <UINT> <RIGHT_PAREN>)?>
| <#END_FIELD: <NON_SECOND_DATETIME_FIELD>>
| <#NON_SECOND_DATETIME_FIELD: <YEAR> | <MONTH> | <DAY> | <HOUR> | <MINUTE>>
| <#YEAR_MONTH_LITERAL: (<UINT> | <UINT> "-")? <UINT>>
| <#DAY_TIME_LITERAL: <DAY_TIME_INTERVAL> | <TIME_INTERVAL>>
| <#DAY_TIME_INTERVAL: <UINT> (" " <UINT> (":" <UINT> (":" <SECONDS_VALUE>)?)?)?>
| <#SECONDS_VALUE: <UINT> ("." (<UINT>)?)?>
| <#TIME_INTERVAL: <UINT> (":" <UINT> (":" <SECONDS_VALUE>)?)? | <UINT> (":" <SECONDS_VALUE>)? | <SECONDS_VALUE>>
}

   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   
   

NON-TERMINALS

/*
 * Statement
 */
Statement
Statement ::= StatementPart <EOF>

/**
 * Parse a search condition.
 *
 * @param sqlFragment a fragment of an SQL statement, representing a
 *                    search condition
 * @return a {@code ValueNode} representing the search condition
 */
SearchCondition
SearchCondition ::= valueExpression <EOF>

proceduralStatement
proceduralStatement ::= ( insertStatement | preparableUpdateStatement | preparableDeleteStatement | preparableSelectStatement | mergeStatement | callStatement )

/*
 * StatementPart
 * 
 * @param tokenHolder returns the token that starts
 * the statement.  If null, ignored.
 */
StatementPart
StatementPart ::= ( spsRenameStatement | lockStatement )
| ( createStatements | dropStatements | spsAlterStatement | globalTemporaryTableDeclaration | preparableSQLDataStatement | spsSetStatement | truncateTableStatement | grantStatement | revokeStatement | execStatement )

/*
 * spsCreateStatement
 */
createStatements
createStatements ::= <CREATE> ( ( schemaDefinition | viewDefinition | triggerDefinition | synonymDefinition | roleDefinition | sequenceDefinition ) | tableDefinition | procedureDefinition | functionDefinition | aggregateDefinition | udtDefinition | indexDefinition )

/*
 * spsDropStatement
 */
dropStatements
dropStatements ::= <DROP> ( dropSchemaStatement | dropTableStatement | dropIndexStatement | dropAliasStatement | dropViewStatement | dropTriggerStatement | dropRoleStatement | dropSequenceStatement )

/*
 * spsAlterStatement
 */
spsAlterStatement
spsAlterStatement ::= <ALTER> ( alterTableStatement )

/*
 * spsSetStatement
 */
spsSetStatement
spsSetStatement ::= <SET> ( setIsolationStatement | setSchemaStatement | setMessageLocaleStatement | setRoleStatement | setConstraintsStatement )
| <SET> ( setSchemaStatement | setIsolationStatement )

/**
 * constraintsReference
 */
constraintsReference
constraintsReference ::= qualifiedName

/**
 * setConstraintsStatement
 */
setConstraintsStatement
setConstraintsStatement ::= <CONSTRAINTS> ( constraintsReference ( <COMMA> constraintsReference )* | <ALL> ) ( <DEFERRED> | <IMMEDIATE> )

/*
 * preparableSQLDataStatement
 *
 * preparableSQLDataStatement differs from
 * directSQLDataStatement in that it
 * supports positioned update and delete
 * and a preparable select (with FOR UPDATE)
 * instead of a direct select (without FOR UPDATE)
 */
preparableSQLDataStatement
preparableSQLDataStatement ::= preparableDeleteStatement
| preparableSelectStatement
| insertStatement
| mergeStatement
| preparableUpdateStatement
| callStatement
| savepointStatement

/*
 * preparableDeleteStatement
 *
 *	This may be a search or positioned delete statement.
 */
preparableDeleteStatement
preparableDeleteStatement ::= <DELETE> deleteBody

deleteBody
deleteBody ::= <FROM> newInvocation ( <WHERE> whereClause )?
| <FROM> qualifiedName ( ( <AS> )? identifier )? ( propertyList <CHECK_PROPERTIES> )? ( <WHERE> ( currentOfClause | whereClause ) )?

/*
 * currentOfClause
 */
currentOfClause
currentOfClause ::= <CURRENT> <OF> identifier

/*
 * preparableSelectStatement
 *
 *
 *	The preparable select statement is a superset of
 *	the directSelectStatementMultipleRows in that it
 *	allows both the preparable single row select statement
 *	(a query expression that returns one row, although it
 *	is also handled like a cursor) and the preparable
 *	multiple row select statement, which allows not only
 *	an order by clause but also a for update clause.
 */
preparableSelectStatement
preparableSelectStatement ::= queryExpression ( orderByClause )? offsetFetchFirstClause ( <FOR> forUpdateClause )? ( atIsolationLevel )?

/*
 * insertStatement
 */
insertStatement
insertStatement ::= <INSERT> <INTO> targetTable insertColumnsAndSource

targetTable
targetTable ::= newInvocation
| qualifiedName

/*
 * preparableUpdateStatement
 */
preparableUpdateStatement
preparableUpdateStatement ::= <UPDATE> updateBody

tableOrIndex
tableOrIndex ::= <TABLE>
| <INDEX>

updateBody
updateBody ::= newInvocation <SET> setClauseList ( <WHERE> whereClause )?
| qualifiedName ( ( <AS> )? identifier )? ( propertyList <CHECK_PROPERTIES> )? <SET> setClauseList ( <WHERE> ( whereClause | currentOfClause ) )?

/*
 * callStatement
 */
callStatement
callStatement ::= ( bareCallStatement | <LEFT_BRACE> bareCallStatement <RIGHT_BRACE> )

/*
 * baseCallStatement
 */
bareCallStatement
bareCallStatement ::= <CALL> primaryExpression
| dynamicParameterSpecification <EQUALS_OPERATOR> <CALL> rowValueConstructor

/*
 * mergeStatement
 */
mergeStatement
mergeStatement ::= <MERGE> <INTO> tableFactor <USING> tableFactor joinCondition matchingClauseList

/*
 * matchingClauseList
 */
matchingClauseList
matchingClauseList ::= matchingClause ( matchingClause )*

/*
 * matchingClause
 */
matchingClause
matchingClause ::= <WHEN> <MATCHED> ( <AND> valueExpression )? <THEN> ( <DELETE> | <UPDATE> <SET> setClauseList )
| <WHEN> <NOT> <MATCHED> ( <AND> valueExpression )? <THEN> <INSERT> ( <LEFT_PAREN> insertColumnList <RIGHT_PAREN> )? <VALUES> <LEFT_PAREN> rowValueConstructorList <RIGHT_PAREN>

/*
 * primaryExpression
 */
primaryExpression
primaryExpression ::= routineInvocation
| primaryExpressionXX

/* 
 * savepointStatement

	savepointStatementClauses contains the UNIQUE, ON ROLLBACK RETAIN LOCKS, ON ROLLBACK RETAIN CURSORS clauses.

	0 - Boolean - UNIQUE clause
	1 - Boolean - ON ROLLBACK RETAIN LOCKS clause
	2 - Boolean - ON ROLLBACK RETAIN CURSORS clause
 */
savepointStatement
savepointStatement ::= ( <SAVEPOINT> identifier ( savepointStatementClause )+ | <ROLLBACK> ( <WORK> )? <TO> <SAVEPOINT> ( identifier )? | <RELEASE> ( <TO> )? <SAVEPOINT> identifier )

savepointStatementClause
savepointStatementClause ::= ( <UNIQUE> | <ON> <ROLLBACK> <RETAIN> ( LocksOrCursors ) )

/*
 * LocksOrCursors
 */
LocksOrCursors
LocksOrCursors ::= <LOCKS>
| <CURSORS>

/* 
 * globalTemporaryTableDeclaration

	declareTableClauses contains the NOT LOGGED, on commit and on rollback clauses.

	0 - Boolean - NOT LOGGED clause
	1 - Boolean - on commit behavior
	2 - Boolean - on rollback behavior
 */
globalTemporaryTableDeclaration
globalTemporaryTableDeclaration ::= <DECLARE> <GLOBAL> <TEMPORARY> <TABLE> qualifiedName tableElementList ( declareTableClause )+

declareTableClause
declareTableClause ::= ( <NOT> <LOGGED> | <ON> <COMMIT> ( onCommit ) <ROWS> | <ON> <ROLLBACK> <DELETE> <ROWS> )

/*
 * onCommit
 */
onCommit
onCommit ::= <PRESERVE>
| <DELETE>

/*
 * tableElementList
 */
tableElementList
tableElementList ::= <LEFT_PAREN> tableElement ( <COMMA> tableElement )* <RIGHT_PAREN>

/*
 * tableElement
 */
tableElement
tableElement ::= columnDefinition
| tableConstraintDefinition

/*
 * columnDefinition
 */
columnDefinition
columnDefinition ::= identifier ( ( dataTypeDDL ) )? ( defaultAndConstraints )?

/*
 * defaultAndConstraints
 */
defaultAndConstraints
defaultAndConstraints ::= columnConstraintDefinition ( columnConstraintDefinition )* ( defaultClause ( columnConstraintDefinition )* )?
| defaultClause ( columnConstraintDefinition )*

/*
 * dataTypeDDL
 */
dataTypeDDL
dataTypeDDL ::= dataTypeCommon
| javaType

/**
   Returns  a dataTypeDDL() as a catalog type, ie.
   the Java interface TypeDescriptor.
*/
catalogType
catalogType ::= dataTypeDDL

/*
 * dataTypeCast
 */
dataTypeCast
dataTypeCast ::= dataTypeCommon
| javaType

/*
 * dataTypeCommon
 */
dataTypeCommon
dataTypeCommon ::= ( ( characterStringType ) | ( nationalCharacterStringType ) | numericType | datetimeType | <BOOLEAN> | longType | LOBType | XMLType )

/*
 * characterStringType
 */
characterStringType
characterStringType ::= ( ( <VARCHAR> charLength ) | charOrCharacter ( <VARYING> charLength | ( charLength )? ) ) ( forBitData )?

/*
 * charOrCharacter
 */
charOrCharacter
charOrCharacter ::= <CHAR>
| <CHARACTER>

/*
 * charType
 */
charLength
charLength ::= <LEFT_PAREN> length <RIGHT_PAREN>

/*
** forBitData
*/
forBitData
forBitData ::= <FOR> <BIT> <DATA>

/*
 * nationalCharacterStringType
 */
nationalCharacterStringType
nationalCharacterStringType ::= ( <NATIONAL> charOrCharacter ( <VARYING> charLength | ( charLength )? ) | <NCHAR> ( <VARYING> charLength | ( charLength )? ) | <NVARCHAR> ( charLength ) )

/*
 * lobType
 */
LOBType
LOBType ::= ( <BLOB> ( lengthAndModifier )? | <CLOB> ( lengthAndModifier )? | <NCLOB> lengthAndModifier | <BINARY> <LARGE> <OBJECT> ( lengthAndModifier )? | charOrCharacter <LARGE> <OBJECT> ( lengthAndModifier )? | <NATIONAL> <CHARACTER> <LARGE> <OBJECT> lengthAndModifier )

/*
 * numericType
 */
numericType
numericType ::= exactNumericType
| approximateNumericType

/*
 * exactNumericType
 */
exactNumericType
exactNumericType ::= ( <NUMERIC> | <DECIMAL> | <DEC> ) ( <LEFT_PAREN> precision ( <COMMA> scale )? <RIGHT_PAREN> )?
| exactIntegerType

/*
 * exactNumericType
 */
exactIntegerType
exactIntegerType ::= ( <INTEGER> | <INT> )
| <SMALLINT>
| <BIGINT>

/*
 * approximateNumericType
 */
approximateNumericType
approximateNumericType ::= <FLOAT> ( <LEFT_PAREN> precision <RIGHT_PAREN> )?
| <REAL>
| doubleType

/*
 * doubleType
 */
doubleType
doubleType ::= ( <DOUBLE> <PRECISION> | <DOUBLE> )

/*
 * longType
 */
longType
longType ::= <LONG> longSubType

longSubType
longSubType ::= <VARCHAR> ( forBitData )?
| <NVARCHAR>

/*
 * XMLType
 */
XMLType
XMLType ::= <XML>

/*
 * xmlDocOrContent
 *
 * Parse the XML keywords DOCUMENT and CONTENT.  We don't
 * support CONTENT yet, so we throw an appropriate error
 * if we see it.
 *
 */
xmlDocOrContent
xmlDocOrContent ::=
| <CONTENT>
| <DOCUMENT>

/*
 * javaType
 */
javaType
javaType ::= qualifiedName

/*
 * javaDSL
 *
 * A Java dot-separated list.
 */
javaDSL
javaDSL ::= caseSensitiveIdentifierPlusReservedWords ( javaDSLNameExtender )*

/*
 * javaClassName
 */
javaClassName
javaClassName ::= javaDSL

/*
 * javaDSLNameExtender
 */
javaDSLNameExtender
javaDSLNameExtender ::= <PERIOD> caseSensitiveIdentifierPlusReservedWords

/*
 * lengthAndModifier
 */
lengthAndModifier
lengthAndModifier ::= <LEFT_PAREN> ( <LENGTH_MODIFIER> | <EXACT_NUMERIC> ( <IDENTIFIER> )? ) <RIGHT_PAREN>

/*
 * length
 */
length
length ::= <EXACT_NUMERIC>

/*
 * exactNumber
*/
exactNumber
exactNumber ::= ( sign )? <EXACT_NUMERIC>

/*
 * precision
 */
precision
precision ::= uint_value

/*
 * uint_value
 */
uint_value
uint_value ::= <EXACT_NUMERIC>

/*
 * scale
 */
scale
scale ::= uint_value

/*
 * datetimeType
 */
datetimeType
datetimeType ::= <DATE>
| <TIME>
| <TIMESTAMP>

/*
 * qualifiedName
 */
qualifiedName
qualifiedName ::= identifier ( <PERIOD> identifier )?

/*
 * queryExpression
 *
 * We have to be carefull to get the associativity correct. According to the SQL spec
 *    ::=
 *     
 *    |  UNION [ ALL ] 
 *    |  EXCEPT [ ALL ] 
 * Meaning that
 *   t1 UNION ALL t2 UNION t3
 * is equivalent to
 *   (t1 UNION ALL t2) UNION t3
 * However recursive descent parsers want recursion to be on the right, so this kind of associativity is unnatural
 * for our parser. The queryExpression method must know whether it is being called as the right hand side of a
 * set operator to produce a query tree with the correct associativity.
 */
queryExpression
queryExpression ::= nonJoinQueryTerm ( unionOrExcept )?

/*
 * unionOrExcept
 */
unionOrExcept
unionOrExcept ::= <UNION> ( <ALL> | <DISTINCT> )? queryExpression
| <EXCEPT> ( <ALL> | <DISTINCT> )? queryExpression

/*
 * nonJoinQueryTerm
 *
 * Be careful with the associativity of INTERSECT. According to the SQL spec
 *   t1 INTERSECT t2 INTERSECT ALL t3
 * is equivalent to
 *   (t1 INTERSECT t2) INTERSECT ALL t3
 * which is not the same as
 *   t1 INTERSECT (t2 INTERSECT ALL t3)
 * See the comment on queryExpression.
 */
nonJoinQueryTerm
nonJoinQueryTerm ::= nonJoinQueryPrimary ( intersect )?

/*
 * intersect
 */
intersect
intersect ::= <INTERSECT> ( <ALL> | <DISTINCT> )? nonJoinQueryTerm

/*
 * nonJoinQueryPrimary
 */
nonJoinQueryPrimary
nonJoinQueryPrimary ::= simpleTable
| <LEFT_PAREN> queryExpression ( orderByClause )? offsetFetchFirstClause <RIGHT_PAREN>

/*
 * simpleTable
 */
simpleTable
simpleTable ::= querySpecification
| tableValueConstructor

/*
 * querySpecification
 */
querySpecification
querySpecification ::= <SELECT> ( setQuantifier )? selectList tableExpression

/*
 * setQuantifier
 */
setQuantifier
setQuantifier ::= <DISTINCT>
| <ALL>

/*
 * selectList
 */
selectList
selectList ::= <ASTERISK>
| selectColumnList

selectColumnList
selectColumnList ::= selectSublist ( <COMMA> selectSublist )*

/*
 * selectSublist
 */
selectSublist
selectSublist ::= qualifiedName <PERIOD> <ASTERISK>
| derivedColumn

/*
 * derivedColumn
 */
derivedColumn
derivedColumn ::= valueExpression ( asClause )?

/*
 * asClause
 */
asClause
asClause ::= ( <AS> )? identifier

/*
 * valueExpression
 */
valueExpression
valueExpression ::= orExpression ( <OR> orExpression )*

/*
 * orExpression
 */
orExpression
orExpression ::= andExpression ( <AND> andExpression )*

/*
 * andExpression
 */
andExpression
andExpression ::= ( <NOT> )? isSearchCondition

/*
 * isSearchCondition
 */
isSearchCondition
isSearchCondition ::= booleanPrimary

/*
 * booleanPrimary
 */
booleanPrimary
booleanPrimary ::= predicate

/*
 * predicate
 */
predicate
predicate ::= ( additiveExpression | existsExpression ) ( remainingPredicate )*

/*
 * remainingPredicates
 */
remainingPredicate
remainingPredicate ::= remainingNonNegatablePredicate
| ( <NOT> )? remainingNegatablePredicate

/*
 * remainingNonNegatablePredicate
 */
remainingNonNegatablePredicate
remainingNonNegatablePredicate ::= compOp ( ( quantifier <LEFT_PAREN> tableSubquery <RIGHT_PAREN> ) | ( additiveExpression ) )

/*
 * remainingNegatablePredicate
 */
remainingNegatablePredicate
remainingNegatablePredicate ::= <IN> inPredicateValue
| <IS> ( <NOT> )? <NULL>
| <LIKE> additiveExpression ( <ESCAPE> additiveExpression | <LEFT_BRACE> <ESCAPE> additiveExpression <RIGHT_BRACE> )?
| <BETWEEN> additiveExpression <AND> additiveExpression

/*
 * compOp
 */
compOp
compOp ::= <EQUALS_OPERATOR>
| <NOT_EQUALS_OPERATOR>
| <NOT_EQUALS_OPERATOR2>
| <LESS_THAN_OPERATOR>
| <GREATER_THAN_OPERATOR>
| <LESS_THAN_OR_EQUALS_OPERATOR>
| <GREATER_THAN_OR_EQUALS_OPERATOR>

/*
 * additiveExpression
 */
additiveExpression
additiveExpression ::= multiplicativeExpression ( additiveOperator multiplicativeExpression )*

/*
 * additiveOperator
 */
additiveOperator
additiveOperator ::= <PLUS_SIGN>
| <MINUS_SIGN>

/*
 * multiplicativeExpression
 */
multiplicativeExpression
multiplicativeExpression ::= unaryExpression ( multiplicativeOperator unaryExpression )*

/*
 * multiplicativeOperator
 */
multiplicativeOperator
multiplicativeOperator ::= <ASTERISK>
| <SOLIDUS>
| <CONCATENATION_OPERATOR>

/*
 * unaryExpression
 */
unaryExpression
unaryExpression ::= ( sign )? primaryExpression

/*
 * sign
 */
sign
sign ::= <PLUS_SIGN>
| <MINUS_SIGN>

/*
 * primaryExpressionXX
 */
primaryExpressionXX
primaryExpressionXX ::= primary ( nonStaticMethodCallOrFieldAccess )*

nonStaticMethodCallOrFieldAccess
nonStaticMethodCallOrFieldAccess ::= nonStaticMethodInvocation

/*
 * nonStaticMethodInvocation
 */
nonStaticMethodInvocation
nonStaticMethodInvocation ::= ( <FIELD_REFERENCE> | <PERIOD> ) methodName methodCallParameterList
| <PERIOD> methodName

/*
 * methodName
 */
methodName
methodName ::= caseSensitiveIdentifierPlusReservedWords

/*
 * staticMethodName
 */
staticMethodName
staticMethodName ::= caseSensitiveIdentifierPlusReservedWords

/*
 * methodParameter
 */
methodParameter
methodParameter ::= valueExpression
| nullSpecification

/*
 * primary
 */
primary
primary ::= staticClassReference
| valueExpressionPrimary

/*
 * staticClassReference
 */
staticClassReference
staticClassReference ::= javaClass <DOUBLE_COLON> staticClassReferenceType

/*
 * staticClassReferenceType
 */
staticClassReferenceType
staticClassReferenceType ::= staticMethodInvocation
| staticClassFieldReference

/*
 * staticClassFieldReference
 */
staticClassFieldReference
staticClassFieldReference ::= caseSensitiveIdentifierPlusReservedWords

/*
 * nonSecondDatetimeField
 */
nonSecondDatetimeField
nonSecondDatetimeField ::= <YEAR>
| <MONTH>
| <DAY>
| <HOUR>
| <MINUTE>

escapedValueFunction
escapedValueFunction ::= miscBuiltinsCore
| <SUBSTRING> <LEFT_PAREN> additiveExpression <COMMA> additiveExpression ( <COMMA> additiveExpression )? <RIGHT_PAREN>
| <CURDATE> <LEFT_PAREN> <RIGHT_PAREN>
| <CURTIME> <LEFT_PAREN> <RIGHT_PAREN>
| <CONCAT> <LEFT_PAREN> additiveExpression <COMMA> additiveExpression <RIGHT_PAREN>
| userNode <LEFT_PAREN> <RIGHT_PAREN>
| timestampArithmeticFuncion
| escapedSYSFUNFunction

/*
 * numericValueFunction
 */
escapedSYSFUNFunction
escapedSYSFUNFunction ::= <IDENTIFIER> methodCallParameterList

/*
 * timestampArithmeticFuncion
 */
timestampArithmeticFuncion
timestampArithmeticFuncion ::= <TIMESTAMPADD> <LEFT_PAREN> jdbcIntervalType <COMMA> additiveExpression <COMMA> additiveExpression <RIGHT_PAREN>
| <TIMESTAMPDIFF> <LEFT_PAREN> jdbcIntervalType <COMMA> additiveExpression <COMMA> additiveExpression <RIGHT_PAREN>

/*
 * jdbcIntervalType
 */
jdbcIntervalType
jdbcIntervalType ::= <SQL_TSI_FRAC_SECOND>
| <SQL_TSI_SECOND>
| <SQL_TSI_MINUTE>
| <SQL_TSI_HOUR>
| <SQL_TSI_DAY>
| <SQL_TSI_WEEK>
| <SQL_TSI_MONTH>
| <SQL_TSI_QUARTER>
| <SQL_TSI_YEAR>

/*
 * numericValueFunction
 */
numericValueFunction
numericValueFunction ::= <ABS> absFunction
| <ABSVAL> absFunction
| <SQRT> <LEFT_PAREN> additiveExpression <RIGHT_PAREN>
| <MOD> modFunction
| <IDENTITY_VAL_LOCAL> <LEFT_PAREN> <RIGHT_PAREN>

/*
 * coalesceFunction
 */
coalesceFunction
coalesceFunction ::= <LEFT_PAREN> coalesceExpression ( <COMMA> coalesceExpression )* <RIGHT_PAREN>

/*
 * coalesceExpression
 */
coalesceExpression
coalesceExpression ::= additiveExpression

/*
 * absFunction
 */
absFunction
absFunction ::= <LEFT_PAREN> additiveExpression <RIGHT_PAREN>

/*
 * modFunction
 */
modFunction
modFunction ::= <LEFT_PAREN> additiveExpression <COMMA> additiveExpression <RIGHT_PAREN>

/*
 * datetimeField
 */
datetimeField
datetimeField ::= nonSecondDatetimeField
| <SECOND>

characterValueFunction
characterValueFunction ::= <SUBSTR> <LEFT_PAREN> additiveExpression <COMMA> additiveExpression ( <COMMA> additiveExpression )? <RIGHT_PAREN>
| ( <UPPER> | <LOWER> ) <LEFT_PAREN> additiveExpression <RIGHT_PAREN>
| ( <UCASE> | <LCASE> ) <LEFT_PAREN> additiveExpression <RIGHT_PAREN>
| trimFunction
| <LOCATE> <LEFT_PAREN> additiveExpression <COMMA> additiveExpression ( <COMMA> additiveExpression )? <RIGHT_PAREN>

trimFunction
trimFunction ::= trimType <LEFT_PAREN> additiveExpression <RIGHT_PAREN>
| <TRIM> ansiTrim

ansiTrim
ansiTrim ::= <LEFT_PAREN> ansiTrimSpec ( <FROM> additiveExpression <RIGHT_PAREN> | additiveExpression <FROM> additiveExpression <RIGHT_PAREN> )
| <LEFT_PAREN> additiveExpression ( <FROM> additiveExpression <RIGHT_PAREN> | <RIGHT_PAREN> )

ansiTrimSpec
ansiTrimSpec ::= <TRAILING>
| <LEADING>
| <BOTH>

trimType
trimType ::= <RTRIM>
| <LTRIM>

/*
 * valueExpressionPrimary
 */
valueExpressionPrimary
valueExpressionPrimary ::= <LEFT_BRACE> <FN> escapedValueFunction <RIGHT_BRACE>
| <CURRENT> ( <SCHEMA> | <SQLID> )
| <CURRENT> <ISOLATION>
| valueSpecification
| newInvocation
| windowOrAggregateFunctionNode
| miscBuiltins
| columnReference
| <LEFT_PAREN> ( subquery | valueExpression ) <RIGHT_PAREN>
| castSpecification
| nextValueExpression

/*
 * miscBuiltins
 */
miscBuiltins
miscBuiltins ::= miscBuiltinsCore
| datetimeValueFunction
| routineInvocation

miscBuiltinsCore
miscBuiltinsCore ::= <GET_CURRENT_CONNECTION> <LEFT_PAREN> <RIGHT_PAREN>
| numericValueFunction
| characterValueFunction
| dataTypeScalarFunction
| <COALESCE> coalesceFunction
| <VALUE> coalesceFunction
| <LENGTH> <LEFT_PAREN> additiveExpression <RIGHT_PAREN>
| xmlFunction

/*
 * dataTypeScalarFunction
 */
dataTypeScalarFunction
dataTypeScalarFunction ::= dateTimeScalarFunction
| numericFunctionType <LEFT_PAREN> additiveExpression <RIGHT_PAREN>
| charOrVarchar <LEFT_PAREN> additiveExpression ( <COMMA> length )? <RIGHT_PAREN>

/*
 * xmlFunction
 *
 * This method parses the built-in functions used with
 * the XML datatype.
 *
 */
xmlFunction
xmlFunction ::= <XMLPARSE> <LEFT_PAREN> xmlDocOrContent xmlParseValue <RIGHT_PAREN>
| <XMLSERIALIZE> <LEFT_PAREN> xmlSerializeValue <RIGHT_PAREN>
| <XMLEXISTS> <LEFT_PAREN> xmlQueryValue <RIGHT_PAREN>
| <XMLQUERY> <LEFT_PAREN> xmlQueryValue <RIGHT_PAREN>

/*
 * xmlParseValue
 *
 * Syntax is as follows:
 *
 *     XMLPARSE( DOCUMENT  PRESERVE WHITESPACE )
 *
 * The result of this operation will be an XML value, which can either
 * be used transiently or else can be stored persistently in a table that
 * has an XML column.  For example:
 *
 * ij> CREATE TABLE x_table (id INT, xdoc XML);
 * 0 rows inserted/updated/deleted
 * ij> INSERT INTO x_table VALUES (1, XMLPARSE(DOCUMENT ' doc '
 * PRESERVE WHITESPACE));
 * 1 row inserted/updated/deleted
 *
 * We only allow XML documents (as opposed to XML content) to be
 * parsed into XML values.  Note that we require the "PRESERVE WHITESPACE"
 * keyword to be explicit; this is because the SQL/XML (2003) spec says that
 * if no whitespace option is given, the default is "STRIP WHITESPACE", which
 * we don't support (yet).
 *
 * By the time we get to this method, the "DOCUMENT" keyword has already
 * been parsed.
 *
 */
xmlParseValue
xmlParseValue ::= additiveExpression xmlPreserveWhitespace

/*
 * xmlPreserveWhitespace
 *
 * For now, we only support the PRESERVE WHITESPACE option.
 *
 */
xmlPreserveWhitespace
xmlPreserveWhitespace ::=
| <STRIP> <WHITESPACE>
| <PRESERVE> <WHITESPACE>

/*
 * xmlSerializeValue
 *
 * Syntax is as follows:
 *
 *   XMLSERIALIZE(  AS  )
 *
 * The result of this operation will be a string value with the type specified
 * by the user.  For example:
 *
 * ij> SELECT id, XMLSERIALIZE(xdoc AS varchar(30)) FROM x_table;
 * ID         |2
 * ------------------------------------------
 * 1          | doc 
 *
 */
xmlSerializeValue
xmlSerializeValue ::= additiveExpression xmlSerializeTargetType

/*
 * xmlSerializeTargetType
 *
 * Parse the target type of an XMLSERIALIZE operation.
 *
 */
xmlSerializeTargetType
xmlSerializeTargetType ::=
| <AS> dataTypeDDL

/*
 * xmlQueryValue
 *
 * This method is used for parsing the XMLEXISTS and XMLQUERY operators
 * (which operator depends on the received boolean parameter).
 *
 * For XMLEXISTS, the syntax is as follows:
 *
 *   XMLEXISTS(  PASSING BY REF  )
 *
 * The result of this operation will be a boolean true/false/unknown value:
 *   -- Unknown if either  or  is null;
 *   -- True if evaluation of the given query expression against the
 *      given xml-value returns at least one node.
 *   -- False otherwise.
 *
 * For example:
 *
 * ij> SELECT id FROM x_table WHERE XMLEXISTS('/simple' PASSING BY REF xdoc);
 * ID
 * -----------
 * 1
 *
 * ====
 *
 * For XMLQUERY, the syntax is as follows:
 *
 *   XMLQUERY( 
 *      PASSING BY REF 
 *      [ RETURNING SEQUENCE [ BY REF ] ]
 *      EMPTY ON EMPTY
 *   )
 *
 * The result of this operation will be an XMLDataValue.
 *
 * For example:
 *
 * ij> SELECT XMLSERIALIZE(
 *       XMLQUERY('/simple' PASSING BY REF xdoc EMPTY ON EMPTY) AS CHAR(100));
 * ID
 * -----------
 *  doc 
 *
 */
xmlQueryValue
xmlQueryValue ::= additiveExpression <PASSING> xmlPassingMechanism xqVarList ( ( xqReturningClause ( xmlPassingMechanism )? )? xqEmptyHandlingClause | )

/**
 * xqVarList
 *
 * Parse a list of XML query variables, which can include at most one
 * XML value to be used as the "context item" for the query.  If
 * such a context item was found, return that item; for all other
 * variable declarations we currently throw a "not supported" error
 * because Xalan doesn't allowing binding of variables.
 */
xqVarList
xqVarList ::= xqVariable ( <COMMA> xqVariable )*

/**
 * xqVariable
 *
 * Parse an XML query variable.  If the argument is an XML value
 * to be used as the "context item" for a query, then store the
 * value in the first slot of the received ValueNode array;
 * otherwise, throw a "not supported" errror (for now).
 */
xqVariable
xqVariable ::= additiveExpression ( <AS> identifier )? ( ( xmlPassingMechanism )? )

/*
 * xmlPassingMechanism
 *
 * For now, we only support the BY REF option because
 * that gives us better performance (allows us to avoid
 * performing potentially deep copies of XML nodes).  This
 * means that if the same XML value is passed BY REF into
 * two different XML arguments for a single operator, then
 * every node in the first XML argument must have an
 * identical node in the second XML argument, and the
 * ids for both nodes must be the same.  That said,
 * since we don't support variable binding yet, this
 * becomes a non-issue because we can't pass XML values.
 * In the future, though, we may choose to support the
 * passing/binding of variables (the only reason we
 * don't now is because Xalan doesn't support it) and
 * if we do, BY REF should provide better performance
 * due to lack of deep copying.
 */
xmlPassingMechanism
xmlPassingMechanism ::= <BY> <REF>
| <BY> <VALUE>

/*
 * xqReturningClause
 *
 * For now we only support "RETURNING SEQUENCE".  The reason
 * is that this applies to the XMLQUERY operator and the
 * results of evaluating a query expression in Xalan against
 * an XML value can be an arbritary sequence of items--including
 * atomic values.  For simplicity we just return the values
 * as they are, without doing any further work.  SQL/XML[2006]
 * says that if we supported RETURNING CONTENT then we'd have
 * to construct an XQuery document from the results--but we don't
 * do that extra work for now, so we just say that we return
 * SEQUENCE.
 *
 * NOTE: This means that we may not be able to store the results
 * of an XMLQUERY operation into a Derby XML column.  Right now
 * an XML column can only hold valid DOCUMENT nodes, which we
 * we define as an XML value whose serialized form can be parsed
 * by a JAXP DocumentBuilder (because that's what Derby's XMLPARSE
 * operator uses and the result is always a Document node).
 * Internally this means that we can only store a sequence if it
 * contains exactly one org.w3c.dom.Node that is an instance of
 * org.w3c.dom.Document.  If the result of an XMLQUERY operation
 * does not fit this criteria then it will *not* be storable into
 * Derby XML columns.
 */
xqReturningClause
xqReturningClause ::= <RETURNING> <SEQUENCE>
| <RETURNING> <CONTENT>

/*
 * xqEmptyHandlingClause
 *
 * Defines what the behavior should be when an XMLQUERY operator
 * results in an empty sequence.  For now we just return the
 * empty sequence.
 */
xqEmptyHandlingClause
xqEmptyHandlingClause ::= <EMPTY> <ON> <EMPTY>
| <NULL> <ON> <EMPTY>

/*
 * numericFunctionType
 */
numericFunctionType
numericFunctionType ::= doubleType
| exactIntegerType

/*
 * dateTimeScalarFunction
 */
dateTimeScalarFunction
dateTimeScalarFunction ::= <TIME> <LEFT_PAREN> additiveExpression <RIGHT_PAREN>
| <DATE> <LEFT_PAREN> additiveExpression <RIGHT_PAREN>
| <TIMESTAMP> <LEFT_PAREN> additiveExpression timestampFunctionCompletion
| datetimeField <LEFT_PAREN> additiveExpression <RIGHT_PAREN>

/*
 * timestampFunctionCompletion
 */
timestampFunctionCompletion
timestampFunctionCompletion ::= <RIGHT_PAREN>
| <COMMA> additiveExpression <RIGHT_PAREN>

/*
 * booleanLiteral
 */
booleanLiteral
booleanLiteral ::= <TRUE>
| <FALSE>

/*
 * generalValueSpecification
 */
generalValueSpecification
generalValueSpecification ::= dynamicParameterSpecification
| userNode
| currentRoleNode

userNode
userNode ::= <USER>
| <CURRENT_USER>
| <SESSION_USER>

/*
 * currentRoleNode
 */
currentRoleNode
currentRoleNode ::= <CURRENT_ROLE>

/*
 * newInvocation
 */
newInvocation
newInvocation ::= <NEW> javaClassName methodCallParameterList

/*
 * vtiTableConstruct
 *
 * Parse a TABLE() constructor that corresponds to an internal
 * VTI invocation.  For example:
 *
 *    TABLE (  (arg1, arg2, ...) )
 *
 * where  is a table name that Derby will map internally
 * to a VTI (ex. "SYSCS_DIAG.SPACE_TABLE").  The list of arguments
 * will then be passed to the VTI when it is invoked (DERBY-2152).
 *
 * An example query where this might occur is as follows:
 *
 *   SELECT * FROM TABLE(SYSCS_DIAG.SPACE_TABLE('APP', 'T1')) x
 *
 * in which case SYSCS_DIAG.SPACE_TABLE will be mapped (internally)
 * to the "org.apache.derby.diag.SpaceTable" diagnostic VTI.  Thus
 * the equivalent call prior to DERBY-2152 would have been:
 *
 *   SELECT * FROM NEW org.apache.derby.diag.SpaceTable('APP', 'T1')) x
 *
 * Note that this latter syntax is still supported.
 */
vtiTableConstruct
vtiTableConstruct ::= <TABLE> <LEFT_PAREN> qualifiedName methodCallParameterList <RIGHT_PAREN>

/*
 * staticMethodInvocation
 */
staticMethodInvocation
staticMethodInvocation ::= staticMethodName methodCallParameterList

/**
 * methodCallParameterList
*/
methodCallParameterList
methodCallParameterList ::= <LEFT_PAREN> ( methodParameter ( <COMMA> methodParameter )* )? <RIGHT_PAREN>

/*
 * routineInvocation
 */
routineInvocation
routineInvocation ::= routineExpression
| distinctUDA

/*
 * routineExpression
 */
routineExpression
routineExpression ::= qualifiedName methodCallParameterList

/*
 * distinctUDA
 */
distinctUDA
distinctUDA ::= qualifiedName <LEFT_PAREN> <DISTINCT> additiveExpression <RIGHT_PAREN>

/*
 * javaClass
 */
javaClass
javaClass ::= javaClassName

/*
 * columnMethodInvocation
 */
columnMethodInvocation
columnMethodInvocation ::= columnNameForInvocation nonStaticMethodInvocation

/*
 * columnNameForInvocation
 */
columnNameForInvocation
columnNameForInvocation ::= identifier ( <PERIOD> identifier ( <PERIOD> identifier )? )?

/*
 * columnReference
 */
columnReference
columnReference ::= identifier ( <PERIOD> identifier ( <PERIOD> identifier )? )?

/*
void
columnReference() throws StandardException :
{}
{
	/*
	**
	** I re-wrote the above rule because it caused a grammar ambiguitity.
	** The problem is that we are parsing a dot-separated list of identifiers,
	** and the grammar doesn't know what the identifiers stand for, but the
	** syntax assumed that it did.  For example, in schema.table.column,
	** the grammar doesn't know when it parses the first identifier whether
	** it will be a catalog name, schema name, table name, or column name.
	**
	** I think this problem could be solved by increasing the lookahead.
	** I will try that solution next.  I like that solution better because,
	** if it works, it will be easier for the grammar to figure out what
	** each identifier stands for.
	**

	[    |
	  [ [ [   ]   ]   ]
	]
	
}
*/
orderByClause
orderByClause ::= <ORDER> <BY> sortSpecificationList

atIsolationLevel
atIsolationLevel ::= <WITH> isolationLevelDB2Abbrev

sortSpecificationList
sortSpecificationList ::= sortSpecification ( <COMMA> sortSpecification )*

sortSpecification
sortSpecification ::= sortKey ( orderingSpecification )? ( nullOrdering )?

sortKey
sortKey ::= additiveExpression

orderingSpecification
orderingSpecification ::= <ASC>
| <DESC>

/*
 * The data type comparison functions need to know whether NULL values
 * should sort higher than non-NULL values, or lower. The answer to this
 * depends on whether the user specified ASCending or DESCending, and on
 * whether the user specified NULLS FIRST, or NULLS LAST, as follows:
 *
 * +===============+========+========+
 * | ORDER BY says | ASC    | DESC   |
 * +===============+========+========+
 * | NULLS FIRST   | less   | greater|
 * +===============+========+========+
 * | NULLS LAST    | greater| less   |
 * +===============+========+========+
 */
nullOrdering
nullOrdering ::= <NULLS> <LAST>
| <NULLS> <FIRST>

/*
 * offsetFetchFirstClause
 */
offsetFetchFirstClause
offsetFetchFirstClause ::= sqlStandardOffsetFetchFirst
| ( jdbcLimitOffset )?

/*
 * sqlStandardOffsetFetchFirst
 */
sqlStandardOffsetFetchFirst
sqlStandardOffsetFetchFirst ::= ( offsetClause )? ( fetchFirstClause )?

/*
 * jdbcLimitOffset
 */
jdbcLimitOffset
jdbcLimitOffset ::= <LEFT_BRACE> <LIMIT> ( intLiteral | dynamicParameterSpecification ) ( <OFFSET> ( intLiteral | dynamicParameterSpecification ) )? <RIGHT_BRACE>

/*
 * offsetClause
 */
offsetClause
offsetClause ::= <OFFSET> ( intLiteral | dynamicParameterSpecification ) ( <ROW> | <ROWS> )

/*
 * fetchFirstClause
 */
fetchFirstClause
fetchFirstClause ::= <FETCH> ( <FIRST> | <NEXT> ) ( intLiteral | dynamicParameterSpecification )? ( <ROW> | <ROWS> ) <ONLY>

/*
 * forUpdateClause
 */
forUpdateClause
forUpdateClause ::= <UPDATE> ( <OF> forUpdateColumnList )?
| <READ> <ONLY>
| <FETCH> <ONLY>

/*
 * forUpdateColumnList
 */
forUpdateColumnList
forUpdateColumnList ::= forUpdateColumn ( <COMMA> forUpdateColumn )*

/*
 * forUpdateColumn
 */
forUpdateColumn
forUpdateColumn ::= identifier

/*
 * setClauseList
 */
setClauseList
setClauseList ::= setClause ( <COMMA> setClause )*

/*
 * setClause
 */
setClause
setClause ::= columnReference <EQUALS_OPERATOR> updateSource

/*
 * updateSource
 */
updateSource
updateSource ::= valueExpression
| nullSpecification
| <_DEFAULT>

/*
 * nullSpecification
 */
nullSpecification
nullSpecification ::= <NULL>

/*
 * insertColumnsAndSource
 */
insertColumnsAndSource
insertColumnsAndSource ::= ( <LEFT_PAREN> insertColumnList <RIGHT_PAREN> )? ( propertyList <CHECK_PROPERTIES> )? queryExpression ( orderByClause )? offsetFetchFirstClause

/*
 * insertColumnList
 */
insertColumnList
insertColumnList ::= columnQualifiedNameList

/*
 * columnQualifiedNameList
 */
columnQualifiedNameList
columnQualifiedNameList ::= columnQualifiedNameItem ( <COMMA> columnQualifiedNameItem )*

/*
 * columnQualifiedNameItem
 */
columnQualifiedNameItem
columnQualifiedNameItem ::= columnReference

/*
 * rowValueConstructor
 */
rowValueConstructor
rowValueConstructor ::= <LEFT_PAREN> rowValueConstructorList <RIGHT_PAREN>
| rowValueConstructorElement

/*
 * rowValueConstructorElement
 */
rowValueConstructorElement
rowValueConstructorElement ::= valueExpression
| nullSpecification
| <_DEFAULT>
|

/*
 * rowValueConstructorList
 */
rowValueConstructorList
rowValueConstructorList ::= rowValueConstructorElement ( <COMMA> rowValueConstructorElement )*

/*
 * tableSubquery
 */
tableSubquery
tableSubquery ::= subquery

/*
 * subquery
 */
subquery
subquery ::= queryExpression ( orderByClause )? offsetFetchFirstClause

/*
 * inPredicateValue
 */
inPredicateValue
inPredicateValue ::= <LEFT_PAREN> ( tableSubquery | inValueList ) <RIGHT_PAREN>

/*
 * inValueList
 */
inValueList
inValueList ::= inElement ( <COMMA> inElement )*

/*
 * inElement
 */
inElement
inElement ::= additiveExpression

/*
 * quantifier
 */
quantifier
quantifier ::= <ALL>
| some

/*
 * some
 */
some
some ::= <SOME>
| <ANY>

/*
 * existsExpression
 */
existsExpression
existsExpression ::= <EXISTS> <LEFT_PAREN> tableSubquery <RIGHT_PAREN>

/*
 * tableExpression
 */
tableExpression
tableExpression ::= fromClause ( <WHERE> whereClause )? ( groupByClause )? ( havingClause )? ( windowClause )? ( optimizerOverridePlan )?

/*
 * fromClause
 */
fromClause
fromClause ::= <FROM> ( fromListProperties )? dummyTableReferenceRule ( <COMMA> dummyTableReferenceRule )*

/*
 * fromListProperties
 */
fromListProperties
fromListProperties ::= propertyList <CHECK_PROPERTIES>

/* This rule created simply as a way to add the result of tableReference()
 * to the fromList.
 */
dummyTableReferenceRule
dummyTableReferenceRule ::= <TABLE> tableReferenceTypes
| tableReferenceTypes

tableReferenceTypes
tableReferenceTypes ::= tableReference
| <LEFT_BRACE> <OJ> tableReference <RIGHT_BRACE>

optionalTableClauses
optionalTableClauses ::= optionalTableProperties
| ( ( <AS> )? identifier ( <LEFT_PAREN> derivedColumnList <RIGHT_PAREN> )? ( propertyList <CHECK_PROPERTIES> )? )?

optionalTableProperties
optionalTableProperties ::= propertyList <CHECK_PROPERTIES>

/*
 * tableReference
 */
tableReference
tableReference ::= tableFactor ( joinedTableExpression )*

tableFactor
tableFactor ::= ( newInvocation | vtiTableConstruct ) ( <AS> )? identifier ( <LEFT_PAREN> derivedColumnList <RIGHT_PAREN> )? ( optionalTableProperties )?
| qualifiedName optionalTableClauses
| derivedTable ( <AS> )? identifier ( <LEFT_PAREN> derivedColumnList <RIGHT_PAREN> )? ( optionalTableProperties )?
| <LEFT_PAREN> tableReferenceTypes <RIGHT_PAREN>

/*
 * derivedColumnList
 */
derivedColumnList
derivedColumnList ::= columnNameList

/*
 * columnNameList
 */
columnNameList
columnNameList ::= columnNameItem ( <COMMA> columnNameItem )*

/*
 * columnNameItem
 */
columnNameItem
columnNameItem ::= identifier

/*
 * indexColumnList
 */
indexColumnList
indexColumnList ::= indexColumnItem ( <COMMA> indexColumnItem )*

/*
 * indexColumnItem
 */
indexColumnItem
indexColumnItem ::= identifier ( <ASC> | <DESC> )?

/*
 * derivedTable
 */
derivedTable
derivedTable ::= <LEFT_PAREN> tableSubquery <RIGHT_PAREN>

joinedTableExpression
joinedTableExpression ::= crossJoin
| qualifiedJoin
| naturalJoin

crossJoin
crossJoin ::= <CROSS> <JOIN> tableFactor

qualifiedJoin
qualifiedJoin ::= ( joinType )? <JOIN> tableReferenceTypes joinSpecification

naturalJoin
naturalJoin ::= <NATURAL> ( joinType )? <JOIN> tableFactor

joinType
joinType ::= <INNER>
| outerJoinType ( <OUTER> )?

outerJoinType
outerJoinType ::= <LEFT>
| <RIGHT>

joinSpecification
joinSpecification ::= joinCondition
| namedColumnsJoin

joinCondition
joinCondition ::= <ON> valueExpression

namedColumnsJoin
namedColumnsJoin ::= <USING> <LEFT_PAREN> columnNameList <RIGHT_PAREN>

/*
 * tableValueConstructor
 */
tableValueConstructor
tableValueConstructor ::= <VALUES> tableValueConstructorList

/*
 * tableValueConstructorList
 */
tableValueConstructorList
tableValueConstructorList ::= rowValueConstructor ( <COMMA> rowValueConstructor )*

/*
 * explicitTable
 */

/*
 * datetimeValueFunction
 */
datetimeValueFunction
datetimeValueFunction ::= <CURRENT> <DATE>
| <CURRENT_DATE>
| <CURRENT> <TIME>
| <CURRENT_TIME>
| <CURRENT> <TIMESTAMP>
| <CURRENT_TIMESTAMP>

/*
** Note that set function and aggregate are used
** interchangeably in the parser.  The tree has
** aggregate nodes.
*/
windowOrAggregateFunctionNode
windowOrAggregateFunctionNode ::= <COUNT> <LEFT_PAREN> ( <ASTERISK> | aggregateExpression ) <RIGHT_PAREN> ( overClause )?
| generalAggregate ( overClause )?
| <ROWNUMBER> <LEFT_PAREN> <RIGHT_PAREN> overClause

overClause
overClause ::= <OVER> ( <LEFT_PAREN> ( orderByClause )? <RIGHT_PAREN> | identifier )

aggregateExpression
aggregateExpression ::= ( setQuantifier )? additiveExpression

generalAggregate
generalAggregate ::= builtInAggregateType <LEFT_PAREN> aggregateExpression <RIGHT_PAREN>

/*
** All built in aggregates are pretty similar to user
** defined aggregates, except we know what to map to
** without looking up the class name.
**
** NOTE: COUNT is omitted here because the COUNT aggregate is
** factored into a different rule, to distinguish between
** COUNT(*) and COUNT().
*/
builtInAggregateType
builtInAggregateType ::= ( <MAX> | <AVG> | <MIN> | <SUM> )

castSpecification
castSpecification ::= <CAST> <LEFT_PAREN> castOperand <AS> dataTypeCast <RIGHT_PAREN>

/**
 * Next value from a sequence object
 */
nextValueExpression
nextValueExpression ::= <NEXT> <VALUE> <FOR> qualifiedName

/*
 * charOrVarchar
 */
charOrVarchar
charOrVarchar ::= <CHAR>
| <VARCHAR>

castOperand
castOperand ::= additiveExpression
| <NULL>

/*
 * dynamicParameterSpecification
 */
dynamicParameterSpecification
dynamicParameterSpecification ::= <QUESTION_MARK>

/*
 * whereClause
 */
whereClause
whereClause ::= valueExpression

groupByClause
groupByClause ::= <GROUP> <BY> ( <ROLLUP> <LEFT_PAREN> groupingColumnReferenceList <RIGHT_PAREN> | groupingColumnReferenceList )

groupingColumnReferenceList
groupingColumnReferenceList ::= groupingColumnReference ( <COMMA> groupingColumnReference )*

groupingColumnReference
groupingColumnReference ::= additiveExpression

havingClause
havingClause ::= <HAVING> valueExpression

windowClause
windowClause ::= <WINDOW> windowDefinition ( <COMMA> windowDefinition )*

windowDefinition
windowDefinition ::= identifier <AS> <LEFT_PAREN> ( orderByClause )? <RIGHT_PAREN>

/*
 * optimizerOverridePlan
 */
optimizerOverridePlan
optimizerOverridePlan ::= <DERBYPLAN> optimizerPlan

/*
 * optimizerPlan
 */
optimizerPlan
optimizerPlan ::= optimizerJoin
| optimizerRowSource

/*
 * optimizerJoin
 */
optimizerJoin
optimizerJoin ::= <LEFT_PAREN> optimizerPlan joinStrategy optimizerPlan <RIGHT_PAREN>

/*
 * joinStrategy
 */
joinStrategy
joinStrategy ::= <ASTERISK>
| <HASH>

/*
 * optimizerRowSource
 */
optimizerRowSource
optimizerRowSource ::= qualifiedName ( <LEFT_PAREN> <RIGHT_PAREN> )?

schemaDefinition
schemaDefinition ::= <SCHEMA> ( identifier ( <AUTHORIZATION> identifier )? | <AUTHORIZATION> identifier )

/*
 * roleDefinition
 */
roleDefinition
roleDefinition ::= <ROLE> identifier

/*
 * sequenceDefinition
 */
sequenceDefinition
sequenceDefinition ::= <SEQUENCE> qualifiedName ( sequenceGeneratorOption )*

/*
 * sequenceGeneratorOption
 */
sequenceGeneratorOption
sequenceGeneratorOption ::= ( <AS> exactIntegerType | <START> <WITH> exactIntegerObject | <INCREMENT> <BY> exactIntegerObject | ( ( <MAXVALUE> exactIntegerObject ) | ( <NO> <MAXVALUE> ) ) | ( ( <MINVALUE> exactIntegerObject ) | ( <NO> <MINVALUE> ) ) | cycleClause )

/*
 * cycleClause
 */
cycleClause
cycleClause ::= <CYCLE>
| <NO> <CYCLE>

/*
 * exactNumberObject
 */
exactIntegerObject
exactIntegerObject ::= exactNumber

/*
 * stepValue
 */
stepValue
stepValue ::= <INCREMENT> <BY> exactNumber

/*
 * dropSequenceStatement
 */
dropSequenceStatement
dropSequenceStatement ::= <SEQUENCE> qualifiedName <RESTRICT>

/*
 * tableDefinition
 */
tableDefinition
tableDefinition ::= <TABLE> qualifiedName ( tableElementList ( propertyList <CHECK_PROPERTIES> )? | ( <LEFT_PAREN> tableColumnList <RIGHT_PAREN> )? <AS> queryExpression <WITH> ( <NO> )? <DATA> )

tableColumnList
tableColumnList ::= columnNameList

/*
 * This method is called when a comment starting with "--derby-properties" is
 * found.  Such a comment is a special directive to Derby and allows an SQL
 * statement to pass optimizer overrides. Derby looks for
 *
 *     propertyName = value* [, propertyName = value]*
 *
 * after "--derby-properties" and returns these properties in a Properties
 * object as a return value of this method.  If the parameter
 * "propertiesUseAllowed" is true, it indicates that users are allowed to
 * specify optimizer overrides in the given context.  False means optimizer
 * overrides in the given context are allowed internally only, e.g. by the
 * class org.apache.derby.impl.load.Import specifies the property
 * "insertMode=replace/bulkInsert" in the INSERT statement. This same property
 * will not be acceptable from an INSERT statement from a user SQL statement.
 */
propertyList
propertyList ::= <DERBYDASHPROPERTIES>

/*
 * DB2lockGranularityClause
 */
DB2lockGranularityClause
DB2lockGranularityClause ::= <LOCKSIZE> lockGranularity

/*
 * lockGranularity
 */
lockGranularity
lockGranularity ::= <TABLE>
| <ROW>

/*
 * indexDefinition
 */
indexDefinition
indexDefinition ::= ( unique )? <INDEX> qualifiedName <ON> qualifiedName <LEFT_PAREN> indexColumnList <RIGHT_PAREN> ( propertyList <CHECK_PROPERTIES> )?

/*
 * unique
 */
unique
unique ::= <UNIQUE>

/**
	CREATE PROCEDURE

	procedureElements contains the description of the procedure.
	(CREATE FUNCTIONS shares this lyout), see functionDefinition

	0 - Object[] 3 element array for parameters
	1 - TableName - specific name
	2 - Integer - dynamic result set count
	3 - String language (always java) - ignore
	4 - String external name (also passed directly to create alias node - ignore
	5 - Short parameter style (always java) - ignore 
	6 - Short - SQL allowed.
	7 - Boolean - CALLED ON NULL INPUT (always TRUE for procedures)
	8 - TypeDescriptor - return type (always NULL for procedures)
*/
procedureDefinition
procedureDefinition ::= <PROCEDURE> qualifiedName procedureParameterList ( routineElement )+

routineElement
routineElement ::= ( <SPECIFIC> qualifiedName | ( <DYNAMIC> )? <RESULT> <SETS> uint_value | <LANGUAGE> <JAVA> | <DETERMINISTIC> | <NOT> <DETERMINISTIC> | <EXTERNAL> ( <NAME> string | <SECURITY> ) | <PARAMETER> <STYLE> parameterStyle | <NO> <SQL> | <CONTAINS> <SQL> | <READS> <SQL> <DATA> | <MODIFIES> <SQL> <DATA> | calledOnNullInput )

calledOnNullInput
calledOnNullInput ::= ( <CALLED> | <RETURNS> <NULL> ) <ON> <NULL> <INPUT>

routineSecurityClause
routineSecurityClause ::= ( <INVOKER> | <DEFINER> )

parameterStyle
parameterStyle ::= <JAVA>
| <DERBY_JDBC_RESULT_SET>
| <DERBY>

procedureParameterList
procedureParameterList ::= <LEFT_PAREN> ( procedureParameterDefinition ( <COMMA> procedureParameterDefinition )* ( ellipsis )? )? <RIGHT_PAREN>

/*
 * procedureParameterDefinition
 */
procedureParameterDefinition
procedureParameterDefinition ::= inoutParameter ( identifier )? dataTypeDDL

inoutParameter
inoutParameter ::= ( <IN> | <OUT> | <INOUT> )?

/**
	CREATE FUNCTION

	functionElements contains the description of the function.

	0 - Object[] 3 element array for parameters
	1 - TableName - specific name
	2 - Integer - dynamic result set count - always 0
	3 - String language (always java) - required to be set
	4 - String external name (also passed directly to create alias node - ignore
	5 - Short parameter style (always java) - required to be set 
	6 - Short - SQL allowed.
	7 - Boolean - CALLED ON NULL INPUT
	8 - TypeDescriptor - return type
*/
functionDefinition
functionDefinition ::= <FUNCTION> qualifiedName functionParameterList <RETURNS> functionReturnDataType ( routineElement )+

functionParameterList
functionParameterList ::= <LEFT_PAREN> ( functionParameterDefinition ( <COMMA> functionParameterDefinition )* ( ellipsis )? )? <RIGHT_PAREN>

ellipsis
ellipsis ::= <ELLIPSIS>

/*
 * functionParameterDefinition
 */
functionParameterDefinition
functionParameterDefinition ::= ( identifier )? dataTypeDDL

/*
 * functionReturnDataType
 */
functionReturnDataType
functionReturnDataType ::= ( catalogType | functionTableType )

/*
 * functionTableType
 */
functionTableType
functionTableType ::= <TABLE> <LEFT_PAREN> functionTableReturnColumn ( <COMMA> functionTableReturnColumn )* <RIGHT_PAREN>

/*
 * functionTableReturnColumn
 */
functionTableReturnColumn
functionTableReturnColumn ::= identifier dataTypeDDL

/**
	CREATE TYPE
*/
udtDefinition
udtDefinition ::= <TYPE> qualifiedName <EXTERNAL> <NAME> string <LANGUAGE> <JAVA>

aggregateDefinition
aggregateDefinition ::= <DERBY> <AGGREGATE> qualifiedName <FOR> dataTypeDDL ( <RETURNS> dataTypeDDL )? <EXTERNAL> <NAME> string

viewDefinition
viewDefinition ::= <VIEW> qualifiedName ( <LEFT_PAREN> viewColumnList <RIGHT_PAREN> )? <AS> queryExpression ( orderByClause )? offsetFetchFirstClause

viewColumnList
viewColumnList ::= columnNameList

triggerDefinition
triggerDefinition ::= <TRIGGER> qualifiedName beforeOrAfter triggerEvent <ON> qualifiedName ( triggerReferencingClause )? ( <FOR> <EACH> rowOrStatement )? ( <MODE> <DB2SQL> )? ( <WHEN> <LEFT_PAREN> valueExpression <RIGHT_PAREN> )? proceduralStatement

synonymDefinition
synonymDefinition ::= <SYNONYM> qualifiedName <FOR> qualifiedName

beforeOrAfter
beforeOrAfter ::= <NO> <CASCADE> <BEFORE>
| <AFTER>

triggerEvent
triggerEvent ::= <INSERT>
| <DELETE>
| <UPDATE> ( <OF> columnNameList )?

rowOrStatement
rowOrStatement ::= <ROW>
| <STATEMENT>

triggerReferencingClause
triggerReferencingClause ::= <REFERENCING> triggerReferencingExpression ( triggerReferencingExpression )*

triggerReferencingExpression
triggerReferencingExpression ::= ( <NEW> ( <ROW> | <TABLE> )? | <OLD> ( <ROW> | <TABLE> )? | <NEW_TABLE> | <OLD_TABLE> ) <AS> identifier

/*
 * defaultClause
 */
defaultClause
defaultClause ::= ( <WITH> )? <_DEFAULT> defaultOption
| generatedColumnOption

/*
 * defaultNullOnlyClause
 */
defaultNullOnlyClause
defaultNullOnlyClause ::= <_DEFAULT> <NULL>

/*
 * generatedColumnOption
 */

//ToCleanUp
//A specific class not such long[] should exists for autoIncrementInfo ...
generatedColumnOption
generatedColumnOption ::= <GENERATED> ( generatedAlways | generatedByDefault )

/*
 * generatedAlways
 */
generatedAlways
generatedAlways ::= <ALWAYS> ( asIdentity | generationClause )

/*
 * generatedByDefault
 */
generatedByDefault
generatedByDefault ::= <BY> <_DEFAULT> asIdentity

/*
 * asIdentity
 */
asIdentity
asIdentity ::= <AS> <IDENTITY> ( <LEFT_PAREN> autoIncrementBeginEnd <RIGHT_PAREN> )?

/*
 * generationClause
 */
generationClause
generationClause ::= <AS> <LEFT_PAREN> valueExpression <RIGHT_PAREN>

/*
 * autoIncrementBeginEnd
 */
autoIncrementBeginEnd
autoIncrementBeginEnd ::= ( ( identityColumnOption )* )

/*
 * identityColumnOption
 */
identityColumnOption
identityColumnOption ::= ( <START> <WITH> exactNumber | <INCREMENT> <BY> exactNumber | <CYCLE> whetherCycle | <COMMA> ( | ) )

/*
 * whetherCycle
 */
whetherCycle
whetherCycle ::=

/*
 * defaultOption
 */
defaultOption
defaultOption ::= <NULL>
| DB2DefaultOption

/*
 * DB2DefaultOption
 */
DB2DefaultOption
DB2DefaultOption ::= <CURRENT> ( <SCHEMA> | <SQLID> )
| userNode
| currentRoleNode
| miscBuiltins
| miscBuiltins
| datetimeValueFunction
| literal

/*
 * literal
 */
literal
literal ::= ( sign )? numericLiteral
| stringLiteral
| hexLiteral
| dateTimeLiteral
| booleanLiteral

/*
 * intLiteral
 */
intLiteral
intLiteral ::= ( sign )? <EXACT_NUMERIC>

/*
 * numericLiteral
 */
numericLiteral
numericLiteral ::= <EXACT_NUMERIC>
| <APPROXIMATE_NUMERIC>

/*
 * dateTimeLiteral
 */
dateTimeLiteral
dateTimeLiteral ::= ( ( <LEFT_BRACE> escapedDateTimeLiteral <RIGHT_BRACE> ) )

/*
 * escapedDateTimeLiteral
 */
escapedDateTimeLiteral
escapedDateTimeLiteral ::= <D> bareDateLiteral
| <T> bareTimeLiteral
| <TS> bareTimestampLiteral

/*
 * bareDateLiteral
 */
bareDateLiteral
bareDateLiteral ::= string

/*
 * bareTimeLiteral
 */
bareTimeLiteral
bareTimeLiteral ::= string

/*
 * bareTimestampLiteral
 */
bareTimestampLiteral
bareTimestampLiteral ::= string

/*
 * string
 */
string
string ::= <STRING>

/*
 * stringLiteral
 */
stringLiteral
stringLiteral ::= <STRING>

/*
 * hexLiteral
 */
hexLiteral
hexLiteral ::= <HEX_STRING>

constraintNameDefinition
constraintNameDefinition ::= <CONSTRAINT> qualifiedName

/*
 * DB2 requires column check constraints to refer to only that column. Derby
 * doesn't care if check constraints are column level or table level. For DB2 compatibility
 * check that column check constraints only refer to that column.
 */
checkConstraintDefinition
checkConstraintDefinition ::= <CHECK> <LEFT_PAREN> valueExpression <RIGHT_PAREN>

/*
 * spsRenameStatement
 */
spsRenameStatement
spsRenameStatement ::= <RENAME> ( renameTableStatement | renameIndexStatement | renameColumnStatement )

/*
 * renameTableStatement
 */
renameTableStatement
renameTableStatement ::= <TABLE> qualifiedName <TO> identifier

/*
 * renameIndexStatement
 */
renameIndexStatement
renameIndexStatement ::= <INDEX> identifier <TO> identifier

renameColumnStatement
renameColumnStatement ::= <COLUMN> columnReference <TO> identifier

lockStatement
lockStatement ::= <LOCK> <TABLE> qualifiedName <IN> lockMode <MODE>

lockMode
lockMode ::= <EXCLUSIVE>
| <SHARE>

execStatement
execStatement ::= <EXECUTE> <STATEMENT> qualifiedName

setIsolationStatement
setIsolationStatement ::= setIsolationHeader ( ( <EQUALS_OPERATOR> | <TO> ) )? transactionMode

setIsolationHeader
setIsolationHeader ::= <ISOLATION>
| <CURRENT> <ISOLATION>

transactionMode
transactionMode ::= isolationLevelDB2OrReset

isolationLevelDB2OrReset
isolationLevelDB2OrReset ::= ( <RESET> | isolationLevelDB2 )

isolationLevelDB2
isolationLevelDB2 ::= ( isolationLevelDB2Abbrev | ( ( <REPEATABLE> <READ> ) | <SERIALIZABLE> ) | <CURSOR> <STABILITY> | <DIRTY> <READ> | <READ> <COMMITTED> | <READ> <UNCOMMITTED> )

isolationLevelDB2Abbrev
isolationLevelDB2Abbrev ::= ( <RR> | <RS> | <CS> | <UR> )

isolationLevel
isolationLevel ::= <ISOLATION> <LEVEL> levelOfIsolation

levelOfIsolation
levelOfIsolation ::= <READ>
| <REPEATABLE> <READ>
| <SERIALIZABLE>

levelOfIsolationRead
levelOfIsolationRead ::= <UNCOMMITTED>
| <COMMITTED>

/*
 * simpleValueSpecification
 */
simpleValueSpecification
simpleValueSpecification ::= literal

/*
 * setRoleStatement
 */
setRoleStatement
setRoleStatement ::= <ROLE> setRoleSpecification

/*
 * setRoleSpecification
 */
setRoleSpecification
setRoleSpecification ::= <NONE>
| identifier
| dynamicParameterSpecification
| string

setSchemaStatement
setSchemaStatement ::= setSchemaHeader ( <EQUALS_OPERATOR> )? setSchemaValues

setSchemaHeader
setSchemaHeader ::= <SCHEMA>
| <CURRENT> ( <SCHEMA> | <SQLID> )

setSchemaValues
setSchemaValues ::= identifier
| <USER>
| dynamicParameterSpecification
| string

// Set the locale for messages coming from the database system. This
// is for support only, so we can get messages in our preferred language
// (usually English). I didn't want to create all the execution wiring
// to do this, so this command executes in the parser
setMessageLocaleStatement
setMessageLocaleStatement ::= <MESSAGE_LOCALE> string

/*
 * valueSpecification
 */
valueSpecification
valueSpecification ::= literal
| generalValueSpecification
| <NULLIF> <LEFT_PAREN> valueExpression <COMMA> valueExpression <RIGHT_PAREN>
| <CASE> searchedCaseExpression
| <CASE> valueExpression simpleCaseExpression

searchedCaseExpression
searchedCaseExpression ::= ( whenThenExpression )+ ( <ELSE> thenElseExpression )? <END>

/*
 * whenThenExpression
 */
whenThenExpression
whenThenExpression ::= <WHEN> valueExpression <THEN> thenElseExpression

/*
 * thenElseExpression
 */
thenElseExpression
thenElseExpression ::= <NULL>
| valueExpression

simpleCaseExpression
simpleCaseExpression ::= ( simpleWhenClause )+ ( <ELSE> thenElseExpression )? <END>

simpleWhenClause
simpleWhenClause ::= <WHEN> whenOperandList <THEN> thenElseExpression

whenOperandList
whenOperandList ::= whenOperand ( <COMMA> whenOperandList )?

whenOperand
whenOperand ::= remainingPredicate
| valueExpression

tableConstraintDefinition
tableConstraintDefinition ::= ( constraintNameDefinition )? tableConstraint ( propertyList <CHECK_PROPERTIES> )?

tableConstraint
tableConstraint ::= ( uniqueConstraintDefinition | referentialConstraintDefinition | checkConstraintDefinition ) ( constraintCharacteristics )?

uniqueConstraintDefinition
uniqueConstraintDefinition ::= uniqueSpecification <LEFT_PAREN> uniqueColumnList <RIGHT_PAREN>

//the second parameter to the following method will always be null for a table level
//constraint but not for a column level constraint
uniqueSpecification
uniqueSpecification ::= <UNIQUE>
| <PRIMARY> <KEY>

uniqueColumnList
uniqueColumnList ::= columnNameList

referentialConstraintDefinition
referentialConstraintDefinition ::= <FOREIGN> <KEY> <LEFT_PAREN> columnNameList <RIGHT_PAREN> referencesSpecification

referencesSpecification
referencesSpecification ::= <REFERENCES> referencedTableAndColumns ( <ON> referentialTriggeredAction )?

referencedTableAndColumns
referencedTableAndColumns ::= qualifiedName ( <LEFT_PAREN> columnNameList <RIGHT_PAREN> )?

referentialTriggeredAction
referentialTriggeredAction ::= ( updateRule ( <ON> deleteRule )? | deleteRule ( <ON> updateRule )? )

updateRule
updateRule ::= <UPDATE> updateReferentialAction

deleteRule
deleteRule ::= <DELETE> deleteReferentialAction

updateReferentialAction
updateReferentialAction ::= <RESTRICT>
| <NO> <ACTION>

deleteReferentialAction
deleteReferentialAction ::= <CASCADE>
| <RESTRICT>
| <NO> <ACTION>
| <SET> ( <NULL> | <_DEFAULT> )

/*
 * constraintCharacteristics
 */
constraintCharacteristics
constraintCharacteristics ::= ( ( initiallyDeferred ) ( deferrable )? ( constraintEnforcement )? | ( deferrable ) ( initiallyDeferred )? ( constraintEnforcement )? | constraintEnforcement )

/*
 * initiallyDeferred
 */
initiallyDeferred
initiallyDeferred ::= <INITIALLY> ( <IMMEDIATE> | <DEFERRED> )

/*
 * deferrable
 */
deferrable
deferrable ::= ( <NOT> )? <DEFERRABLE>

/*
 * constraintEnforcement
 */
constraintEnforcement
constraintEnforcement ::= ( <NOT> )? <ENFORCED>

/*
 * columnConstraintDefinition
 */
columnConstraintDefinition
columnConstraintDefinition ::= ( constraintNameDefinition )? columnConstraint ( constraintCharacteristics )?

/*
 * columnConstraint
 */
columnConstraint
columnConstraint ::= <NOT> <NULL>
| uniqueSpecification ( propertyList <CHECK_PROPERTIES> )?
| referencesSpecification ( propertyList <CHECK_PROPERTIES> )?
| checkConstraintDefinition

/*
 * dropRoleStatement
 */
dropRoleStatement
dropRoleStatement ::= <ROLE> identifier

dropSchemaStatement
dropSchemaStatement ::= <SCHEMA> identifier <RESTRICT>

alterTableStatement
alterTableStatement ::= <TABLE> qualifiedName alterTableBody

alterTableBody
alterTableBody ::= <COMPRESS> ( inplaceCompress | sequentialCompress )
| <ALL> ( dropStatistics | updateStatistics )
| <UPDATE> <STATISTICS> ( identifier )
| <STATISTICS> <DROP> ( identifier )
| <DROP> ( dropColumnDefinition | dropTableConstraintDefinitionCore )
| alterTableAction

/*
 * Called for ALTER TABLE ALL DROP STATISTICS. This is an internal
 *  syntax and can't be invoked by a user directly. DERBY-4115. This
 *  will drop all the statistics for the given table name
 *
 * By the time we get here, we've parsed
 *    ALTER TABLE tablename ALL 
 * and here we parse DROP STATISTICS clause
 */
dropStatistics
dropStatistics ::= <DROP> <STATISTICS>

/*
 * Called for ALTER TABLE ALL UPDATE STATISTICS. This is an internal
 *  syntax and can't be invoked by a user directly. DERBY-269. This
 *  will update all the statistics for the given table name
 *
 * By the time we get here, we've parsed
 *    ALTER TABLE tablename ALL 
 * and here we parse UPDATE STATISTICS clause
 */
updateStatistics
updateStatistics ::= <UPDATE> <STATISTICS>

inplaceCompress
inplaceCompress ::= <INPLACE> ( ( <PURGE> )? ( <DEFRAGMENT> )? ( <TRUNCATE_END> )? )

sequentialCompress
sequentialCompress ::= ( <SEQUENTIAL> )?

/*
 * alterTableRenameTableStatement
 */
/*
StatementNode
alterTableRenameTableStatement(TableName tableName) throws StandardException :
{
	String newTableName;
}
{
	 newTableName = identifier(Limits.MAX_IDENTIFIER_LENGTH, true)
	{
        return new RenameNode(
							null,
							newTableName,
                            true,
                            StatementType.RENAME_TABLE,
							getContextManager());
	}
}
*/

/*
 * alterTableRenameColumnStatement
 */
/*
StatementNode
alterTableRenameColumnStatement(TableName tableName) throws StandardException :
{
	String oldColumnName;
	String newColumnName;
}
{
	oldColumnName = identifier(Limits.MAX_IDENTIFIER_LENGTH, true)  newColumnName = identifier(Limits.MAX_IDENTIFIER_LENGTH, true)
	{
        return new RenameNode(
							tableName,
							oldColumnName,
							newColumnName,
                            true,
                            StatementType.RENAME_COLUMN,
							getContextManager());
	}
}
*/
alterTableAction
alterTableAction ::= <ADD> ( addColumnDefinition | tableConstraintDefinition )
| <ALTER> ( <COLUMN> )? identifier columnAlterClause
| <ALTER> constraintNameDefinition constraintEnforcement
| DB2lockGranularityClause

/*
 * Handle
 *
 *    ALTER TABLE tablename DROP [ COLUMN ] columnname [ CASCADE | RESTRICT ]
 */
dropColumnDefinition
dropColumnDefinition ::= ( <COLUMN> )? identifier dropColumnReferentialAction

dropColumnReferentialAction
dropColumnReferentialAction ::= ( <CASCADE> | <RESTRICT> )?

addColumnDefinition
addColumnDefinition ::= ( <COLUMN> )? columnDefinition

/*
 * Various variants of the ALTER TABLE ALTER COLUMN statement.
 *
 * By the time we get here, we've parsed
 *    ALTER TABLE tablename ALTER [COLUMN] columnname
 * and here we parse the remainder of the ALTER COLUMN clause, one of:
 *		SET DATA TYPE data_type
 *		SET INCREMENT BY increment_value
 *		RESTART WITH increment_restart_value
 *		[SET | WITH] DEFAULT default_value
 *      DROP DEFAULT
 *      SET NOT NULL
 *      DROP NOT NULL
 *      [NOT] NULL
 */
columnAlterClause
columnAlterClause ::= <SET> <DATA> <TYPE> dataTypeDDL
| <SET> <GENERATED> alterGeneratedColumn
| <SET> <INCREMENT> <BY> exactNumber
| <RESTART> <WITH> exactNumber
| ( <SET> )? defaultClause
| <DROP> <_DEFAULT>
| ( <NULL> | <DROP> <NOT> <NULL> )
| ( <NOT> <NULL> | <SET> <NOT> <NULL> )

/*
 * Various variants of the ALTER TABLE ALTER COLUMN SET GENERATED statement.
 *
 * By the time we get here, we've parsed
 *    ALTER TABLE ALTER COLUMN SET GENERATED
 */
alterGeneratedColumn
alterGeneratedColumn ::= <BY> <_DEFAULT>
| <ALWAYS>

dropTableConstraintDefinitionCore
dropTableConstraintDefinitionCore ::= dropTableConstraintDefinition

dropTableConstraintDefinition
dropTableConstraintDefinition ::= <CONSTRAINT> qualifiedName
| <PRIMARY> <KEY>
| <FOREIGN> <KEY> qualifiedName
| <UNIQUE> qualifiedName
| <CHECK> qualifiedName

/*
 * dropTableStatement
 */
dropTableStatement
dropTableStatement ::= <TABLE> qualifiedName

/*
 * dropIndexStatement
 */
dropIndexStatement
dropIndexStatement ::= <INDEX> qualifiedName

/*
 * dropAliasStatement
 */
dropAliasStatement
dropAliasStatement ::= <PROCEDURE> qualifiedName
| <FUNCTION> qualifiedName
| <SYNONYM> qualifiedName
| <TYPE> qualifiedName <RESTRICT>
| <DERBY> <AGGREGATE> qualifiedName <RESTRICT>

dropViewStatement
dropViewStatement ::= <VIEW> qualifiedName

dropTriggerStatement
dropTriggerStatement ::= <TRIGGER> qualifiedName

truncateTableStatement
truncateTableStatement ::= <TRUNCATE> <TABLE> qualifiedName

/*
 * grantStatement
 */
grantStatement
grantStatement ::= <GRANT> ( tableGrantStatement | routineGrantStatement | usageGrantStatement )
| <GRANT> ( roleGrantStatement )

/*
 * tableGrantStatement
 */
tableGrantStatement
tableGrantStatement ::= tablePrivileges <TO> granteeList

// end of tableGrantStatement

/*
 * tablePrivileges
 */
tablePrivileges
tablePrivileges ::= tableActions <ON> ( <TABLE> )? qualifiedName

// end of   tablePrivilege                               

/*
 * tableActions
 */
tableActions
tableActions ::= <ALL> <PRIVILEGES>
| tableAction ( <COMMA> tableAction )*

// end of tableActions

/*
 * routineGrantStatement
 */
routineGrantStatement
routineGrantStatement ::= <EXECUTE> <ON> routineDesignator <TO> granteeList

// end of routineGrantStatement

/*
 * usageGrantStatement
 */
usageGrantStatement
usageGrantStatement ::= <USAGE> <ON> usableObjects qualifiedName <TO> granteeList

// end of usageGrantStatement

/*
 * usableObjects
 */
usableObjects
usableObjects ::= <DERBY> <AGGREGATE>
| <SEQUENCE>
| <TYPE>

// end of routineGrantStatement

/*
 * routineAlias
 */
routineDesignator
routineDesignator ::= ( <FUNCTION> | <PROCEDURE> ) qualifiedName ( <LEFT_PAREN> parameterTypeList <RIGHT_PAREN> )?

// end of routineDesignator


/*
 * parameterTypeList
 */
parameterTypeList
parameterTypeList ::= ( catalogType ( <COMMA> catalogType )* )?

// end of parameterTypeList


/*
 * tableAction
 */
tableAction
tableAction ::= <SELECT> ( privilegeColumnList )?
| <DELETE>
| <INSERT>
| <UPDATE> ( privilegeColumnList )?
| <REFERENCES> ( privilegeColumnList )?
| <TRIGGER>

// end of tableAction

/*
 * privilegeColumnList
 */
privilegeColumnList
privilegeColumnList ::= <LEFT_PAREN> columnNameList <RIGHT_PAREN>

// end of privilegeColumnList

/*
 * granteeList
 */
granteeList
granteeList ::= grantee ( <COMMA> grantee )*

grantee
grantee ::= identifier
| <PUBLIC>

/*
 * roleGrantStatement
 */
roleGrantStatement
roleGrantStatement ::= roleList <TO> granteeList

/*
 * roleList
 */
roleList
roleList ::= roleElement ( <COMMA> roleElement )*

/*
 * roleElement
 */
roleElement
roleElement ::= identifier

/*
 * revokeStatement
 */
revokeStatement
revokeStatement ::= <REVOKE> ( tableRevokeStatement | routineRevokeStatement | usageRevokeStatement )
| <REVOKE> ( roleRevokeStatement )

/*
 * tableRevokeStatement
 */
tableRevokeStatement
tableRevokeStatement ::= tablePrivileges <FROM> granteeList

// end of tableRevokeStatement

/*
 * routineRevokeStatement
 */
routineRevokeStatement
routineRevokeStatement ::= <EXECUTE> <ON> routineDesignator <FROM> granteeList <RESTRICT>

// end of routineRevokeStatement

/*
 * usageRevokeStatement
 */
usageRevokeStatement
usageRevokeStatement ::= <USAGE> <ON> usableObjects qualifiedName <FROM> granteeList <RESTRICT>

// end of usageRevokeStatement


/*
 * roleRevokeStatement
 */
roleRevokeStatement
roleRevokeStatement ::= roleList <FROM> granteeList

/*
 * identifier
 */
internalIdentifier
internalIdentifier ::= <IDENTIFIER>
| delimitedIdentifier
| nonReservedKeyword

identifier
identifier ::= internalIdentifier

/*
 * delimitedIdentifier
 */
delimitedIdentifier
delimitedIdentifier ::= <DELIMITED_IDENTIFIER>

/*
 * reservedKeyword
 */
reservedKeyword
reservedKeyword ::= ( <ADD> | <ALL> | <ALLOCATE> | <ALTER> | <AND> | <ANY> | <ARE> | <AS> | <ASC> | <ASSERTION> | <AT> | <AUTHORIZATION> | <AVG> | <BEGIN> | <BETWEEN> | <BIT> | <BOTH> | <BY> | <CASCADE> | <CASCADED> | <CASE> | <CAST> | <CHAR> | <CHARACTER> | <CHECK> | <CLOSE> | <COLLATE> | <COLLATION> | <COLUMN> | <COMMIT> | <CONNECT> | <CONNECTION> | <CONSTRAINT> | <CONSTRAINTS> | <CONTINUE> | <CONVERT> | <CORRESPONDING> | <CREATE> | <CROSS> | <CURRENT> | <CURRENT_DATE> | <CURRENT_TIME> | <CURRENT_TIMESTAMP> | <CURRENT_USER> | <CURSOR> | <DEALLOCATE> | <DEC> | <DECIMAL> | <DECLARE> | <_DEFAULT> | <DEFERRABLE> | <DEFERRED> | <DELETE> | <DESC> | <DESCRIBE> | <DIAGNOSTICS> | <DISCONNECT> | <DISTINCT> | <DOUBLE> | <DROP> | <ELSE> | <END> | <ENDEXEC> | <ESCAPE> | <EXCEPT> | <EXCEPTION> | <EXEC> | <EXECUTE> | <EXISTS> | <EXTERNAL> | <FALSE> | <FETCH> | <FIRST> | <FLOAT> | <FOR> | <FOREIGN> | <FOUND> | <FROM> | <FULL> | <FUNCTION> | <GET> | <GET_CURRENT_CONNECTION> | <GLOBAL> | <GO> | <GOTO> | <GRANT> | <GROUP> | <HAVING> | <HOUR> | <IDENTITY> | <IMMEDIATE> | <IN> | <INDICATOR> | <INITIALLY> | <INNER> | <INOUT> | <INPUT> | <INSENSITIVE> | <INSERT> | <INT> | <INTEGER> | <INTERSECT> | <INTO> | <IS> | <ISOLATION> | <JOIN> | <KEY> | <LAST> | <LEADING> | <LEFT> | <LIKE> | <LOWER> | <MATCH> | <MAX> | <MIN> | <MINUTE> | <NATIONAL> | <NATURAL> | <NCHAR> | <NVARCHAR> | <NEXT> | <NO> | <NONE> | <NOT> | <NULL> | <NULLIF> | <NUMERIC> | <OF> | <ON> | <ONLY> | <OPEN> | <OPTION> | <OR> | <ORDER> | <OUT> | <OUTER> | <OUTPUT> | <OVERLAPS> | <PAD> | <PARTIAL> | <PREPARE> | <PRESERVE> | <PRIMARY> | <PRIOR> | <PRIVILEGES> | <PROCEDURE> | <PUBLIC> | <READ> | <REAL> | <REFERENCES> | <RELATIVE> | <RESTRICT> | <REVOKE> | <RIGHT> | <ROLLBACK> | <ROWS> | <SCHEMA> | <SCROLL> | <SECOND> | <SELECT> | <SESSION_USER> | <SET> | <SMALLINT> | <SOME> | <SPACE> | <SQL> | <SQLCODE> | <SQLERROR> | <SQLSTATE> | <SUBSTRING> | <SUM> | <SYSTEM_USER> | <TABLE> | <TEMPORARY> | <TIMEZONE_HOUR> | <TIMEZONE_MINUTE> | <TO> | <TRAILING> | <TRANSACTION> | <TRANSLATE> | <TRANSLATION> | <TRUE> | <UNION> | <UNIQUE> | <UNKNOWN> | <UPDATE> | <UPPER> | <USER> | <USING> | <VALUES> | <VARCHAR> | <VARYING> | <VIEW> | <WHENEVER> | <WHERE> | <WITH> | <WORK> | <WRITE> | <YEAR> | <BOOLEAN> | <CALL> | <CURRENT_ROLE> | <EXPLAIN> | <BIGINT> | <LTRIM> | <RTRIM> | <TRIM> | <SUBSTR> | <XML> | <XMLPARSE> | <XMLSERIALIZE> | <XMLEXISTS> | <XMLQUERY> )

/*
 * nonReservedKeyword
 */
nonReservedKeyword
nonReservedKeyword ::= ( <ABS> | <ABSVAL> | <ACTION> | <AFTER> | <AGGREGATE> | <ALWAYS> | <BEFORE> | <BINARY> | <BLOB> | <C> | <CALLED> | <CLASS> | <CLOB> | <COALESCE> | <COBOL> | <COMMITTED> | <COMPRESS> | <CONCAT> | <CONTAINS> | <CONTENT> | <COUNT> | <CS> | <CURDATE> | <CURTIME> | <CYCLE> | <D> | <DATA> | <DATE> | <DAY> | <DEFRAGMENT> | <DIRTY> | <DYNAMIC> | <DATABASE> | <DB2SQL> | <DERBY> | <DERBY_JDBC_RESULT_SET> | <DOCUMENT> | <ENFORCED> | <EACH> | <EMPTY> | <EXCLUSIVE> | <FN> | <FORTRAN> | <GENERATED> | <IDENTITY_VAL_LOCAL> | <INCREMENT> | <INDEX> | <INITIAL> | <INPLACE> | <INTERVAL> | <JAVA> | <LANGUAGE> | <LARGE> | <LCASE> | <LENGTH> | <LEVEL> | <LIMIT> | <LOCATE> | <LOCK> | <LOCKS> | <LOCKSIZE> | <LOGGED> | <LONG> | <MATCHED> | <MAXVALUE> | <MERGE> | <MINVALUE> | <MESSAGE_LOCALE> | <METHOD> | <MOD> | <MODE> | <MODIFIES> | <MODIFY> | <MODULE> | <MONTH> | <_MORE> | <MUMPS> | <NAME> | <NCLOB> | <NEW> | <NEW_TABLE> | <NULLABLE> | <NULLS> | <NUMBER> | <OBJECT> | <OFF> | <OFFSET> | <OLD> | <OLD_TABLE> | <OJ> | <OVER> | <PASCAL> | <PASSING> | <PLI> | <PRECISION> | <PROPERTIES> | <PURGE> | <READS> | <REF> | <RELEASE> | <RENAME> | <REPEATABLE> | <REFERENCING> | <RESET> | <RESTART> | <RESULT> | <RETAIN> | <RETURNING> | <RETURNS> | <ROLE> | <ROLLUP> | <ROW> | <ROWNUMBER> | <RR> | <RS> | <SCALE> | <SAVEPOINT> | <SECURITY> | <SEQUENCE> | <SEQUENTIAL> | <SERIALIZABLE> | <SETS> | <SHARE> | <SPECIFIC> | <SQLID> | <SQL_TSI_FRAC_SECOND> | <SQL_TSI_SECOND> | <SQL_TSI_MINUTE> | <SQL_TSI_HOUR> | <SQL_TSI_DAY> | <SQL_TSI_WEEK> | <SQL_TSI_MONTH> | <SQL_TSI_QUARTER> | <SQL_TSI_YEAR> | <SQRT> | <STABILITY> | <START> | <STATEMENT> | <STATISTICS> | <STRIP> | <SYNONYM> | <STYLE> | <T> | <THEN> | <TIME> | <TIMESTAMP> | <TIMESTAMPADD> | <TIMESTAMPDIFF> | <TRIGGER> | <TRUNCATE> | <TRUNCATE_END> | <TS> | <TYPE> | <UCASE> | <UNCOMMITTED> | <UR> | <USAGE> | <VALUE> | <VARBINARY> | <PARAMETER> | <WHEN> | <WHITESPACE> )

/*
 * caseSensitiveIdentifierPlusReservedWords
 */
caseSensitiveIdentifierPlusReservedWords
caseSensitiveIdentifierPlusReservedWords ::= caseSensitiveIdentifier
| reservedKeyword

/*
 * caseInsensitiveIdentifierPlusReservedWords
 */
caseInsensitiveIdentifierPlusReservedWords
caseInsensitiveIdentifierPlusReservedWords ::= identifier
| reservedKeyword

/*
 * caseSensitiveIdentifier
 */
caseSensitiveIdentifier
caseSensitiveIdentifier ::= <IDENTIFIER>
| delimitedIdentifier
| nonReservedKeyword