diff --git a/babel/src/main/codegen/config.fmpp b/babel/src/main/codegen/config.fmpp index 95a930797868..bb31a72b2720 100644 --- a/babel/src/main/codegen/config.fmpp +++ b/babel/src/main/codegen/config.fmpp @@ -14,12 +14,18 @@ # limitations under the License. data: { + # Data declarations for this parser. + # + # Default declarations are in default_config.fmpp; if you do not include a + # declaration ('imports' or 'nonReservedKeywords', for example) in this file, + # FMPP will use the declaration from default_config.fmpp. parser: { # Generated parser implementation class package and name package: "org.apache.calcite.sql.parser.babel", class: "SqlBabelParserImpl", - # List of import statements. + # List of additional classes and packages to import. + # Example: "org.apache.calcite.sql.*", "java.util.List". imports: [ "org.apache.calcite.sql.SqlCreate", "org.apache.calcite.sql.babel.SqlBabelCreateTable", @@ -27,326 +33,14 @@ data: { "org.apache.calcite.sql.ddl.SqlDdlNodes", ] - # List of keywords. + # List of new keywords. Example: "DATABASES", "TABLES". If the keyword is + # not a reserved keyword, add it to the 'nonReservedKeywords' section. keywords: [ "IF" "SEMI" "VOLATILE" ] - # List of keywords from "keywords" section that are not reserved. - nonReservedKeywords: [ - "A" - "ABSENT" - "ABSOLUTE" - "ACTION" - "ADA" - "ADD" - "ADMIN" - "AFTER" - "ALWAYS" - "APPLY" - "ASC" - "ASSERTION" - "ASSIGNMENT" - "ATTRIBUTE" - "ATTRIBUTES" - "BEFORE" - "BERNOULLI" - "BREADTH" - "C" - "CASCADE" - "CATALOG" - "CATALOG_NAME" - "CENTURY" - "CHAIN" - "CHARACTERISTICS" - "CHARACTERS" - "CHARACTER_SET_CATALOG" - "CHARACTER_SET_NAME" - "CHARACTER_SET_SCHEMA" - "CLASS_ORIGIN" - "COBOL" - "COLLATION" - "COLLATION_CATALOG" - "COLLATION_NAME" - "COLLATION_SCHEMA" - "COLUMN_NAME" - "COMMAND_FUNCTION" - "COMMAND_FUNCTION_CODE" - "COMMITTED" - "CONDITIONAL" - "CONDITION_NUMBER" - "CONNECTION" - "CONNECTION_NAME" - "CONSTRAINT_CATALOG" - "CONSTRAINT_NAME" - "CONSTRAINTS" - "CONSTRAINT_SCHEMA" - "CONSTRUCTOR" - "CONTINUE" - "CURSOR_NAME" - "DATA" - "DATABASE" - "DATETIME_INTERVAL_CODE" - "DATETIME_INTERVAL_PRECISION" - "DAYS" - "DECADE" - "DEFAULTS" - "DEFERRABLE" - "DEFERRED" - "DEFINED" - "DEFINER" - "DEGREE" - "DEPTH" - "DERIVED" - "DESC" - "DESCRIPTION" - "DESCRIPTOR" - "DIAGNOSTICS" - "DISPATCH" - "DOMAIN" - "DOW" - "DOY" - "DYNAMIC_FUNCTION" - "DYNAMIC_FUNCTION_CODE" - "ENCODING" - "EPOCH" - "ERROR" - "EXCEPTION" - "EXCLUDE" - "EXCLUDING" - "FINAL" - "FIRST" - "FOLLOWING" - "FORMAT" - "FORTRAN" - "FOUND" - "FRAC_SECOND" - "G" - "GENERAL" - "GENERATED" - "GEOMETRY" - "GO" - "GOTO" - "GRANTED" - "HIERARCHY" - "HOURS" - "IGNORE" - "IMMEDIATE" - "IMMEDIATELY" - "IMPLEMENTATION" - "INCLUDING" - "INCREMENT" - "INITIALLY" - "INPUT" - "INSTANCE" - "INSTANTIABLE" - "INVOKER" - "ISODOW" - "ISOLATION" - "ISOYEAR" - "JAVA" - "JSON" - "K" - "KEY" - "KEY_MEMBER" - "KEY_TYPE" - "LABEL" - "LAST" - "LENGTH" - "LEVEL" - "LIBRARY" - "LOCATOR" - "M" - "MAP" - "MATCHED" - "MAXVALUE" - "MESSAGE_LENGTH" - "MESSAGE_OCTET_LENGTH" - "MESSAGE_TEXT" - "MICROSECOND" - "MILLENNIUM" - "MILLISECOND" - "MINUTES" - "MINVALUE" - "MONTHS" - "MORE_" - "MUMPS" - "NAME" - "NAMES" - "NANOSECOND" - "NESTING" - "NORMALIZED" - "NULLABLE" - "NULLS" - "NUMBER" - "OBJECT" - "OCTETS" - "OPTION" - "OPTIONS" - "ORDERING" - "ORDINALITY" - "OTHERS" - "OUTPUT" - "OVERRIDING" - "PAD" - "PARAMETER_MODE" - "PARAMETER_NAME" - "PARAMETER_ORDINAL_POSITION" - "PARAMETER_SPECIFIC_CATALOG" - "PARAMETER_SPECIFIC_NAME" - "PARAMETER_SPECIFIC_SCHEMA" - "PARTIAL" - "PASCAL" - "PASSING" - "PASSTHROUGH" - "PAST" - "PATH" - "PLACING" - "PLAN" - "PLI" - "PRECEDING" - "PRESERVE" - "PRIOR" - "PRIVILEGES" - "PUBLIC" - "QUARTER" - "READ" - "RELATIVE" - "REPEATABLE" - "REPLACE" - "RESPECT" - "RESTART" - "RESTRICT" - "RETURNED_CARDINALITY" - "RETURNED_LENGTH" - "RETURNED_OCTET_LENGTH" - "RETURNED_SQLSTATE" - "RETURNING" - "ROLE" - "ROUTINE" - "ROUTINE_CATALOG" - "ROUTINE_NAME" - "ROUTINE_SCHEMA" - "ROW_COUNT" - "SCALAR" - "SCALE" - "SCHEMA" - "SCHEMA_NAME" - "SCOPE_CATALOGS" - "SCOPE_NAME" - "SCOPE_SCHEMA" - "SECONDS" - "SECTION" - "SECURITY" - "SELF" - "SEQUENCE" - "SERIALIZABLE" - "SERVER" - "SERVER_NAME" - "SESSION" - "SETS" - "SIMPLE" - "SIZE" - "SOURCE" - "SPACE" - "SPECIFIC_NAME" - "SQL_BIGINT" - "SQL_BINARY" - "SQL_BIT" - "SQL_BLOB" - "SQL_BOOLEAN" - "SQL_CHAR" - "SQL_CLOB" - "SQL_DATE" - "SQL_DECIMAL" - "SQL_DOUBLE" - "SQL_FLOAT" - "SQL_INTEGER" - "SQL_INTERVAL_DAY" - "SQL_INTERVAL_DAY_TO_HOUR" - "SQL_INTERVAL_DAY_TO_MINUTE" - "SQL_INTERVAL_DAY_TO_SECOND" - "SQL_INTERVAL_HOUR" - "SQL_INTERVAL_HOUR_TO_MINUTE" - "SQL_INTERVAL_HOUR_TO_SECOND" - "SQL_INTERVAL_MINUTE" - "SQL_INTERVAL_MINUTE_TO_SECOND" - "SQL_INTERVAL_MONTH" - "SQL_INTERVAL_SECOND" - "SQL_INTERVAL_YEAR" - "SQL_INTERVAL_YEAR_TO_MONTH" - "SQL_LONGVARBINARY" - "SQL_LONGVARCHAR" - "SQL_LONGVARNCHAR" - "SQL_NCHAR" - "SQL_NCLOB" - "SQL_NUMERIC" - "SQL_NVARCHAR" - "SQL_REAL" - "SQL_SMALLINT" - "SQL_TIME" - "SQL_TIMESTAMP" - "SQL_TINYINT" - "SQL_TSI_DAY" - "SQL_TSI_FRAC_SECOND" - "SQL_TSI_HOUR" - "SQL_TSI_MICROSECOND" - "SQL_TSI_MINUTE" - "SQL_TSI_MONTH" - "SQL_TSI_QUARTER" - "SQL_TSI_SECOND" - "SQL_TSI_WEEK" - "SQL_TSI_YEAR" - "SQL_VARBINARY" - "SQL_VARCHAR" - "STATE" - "STATEMENT" - "STRUCTURE" - "STYLE" - "SUBCLASS_ORIGIN" - "SUBSTITUTE" - "TABLE_NAME" - "TEMPORARY" - "TIES" - "TIMESTAMPADD" - "TIMESTAMPDIFF" - "TOP_LEVEL_COUNT" - "TRANSACTION" - "TRANSACTIONS_ACTIVE" - "TRANSACTIONS_COMMITTED" - "TRANSACTIONS_ROLLED_BACK" - "TRANSFORM" - "TRANSFORMS" - "TRIGGER_CATALOG" - "TRIGGER_NAME" - "TRIGGER_SCHEMA" - "TYPE" - "UNBOUNDED" - "UNCOMMITTED" - "UNCONDITIONAL" - "UNDER" - "UNNAMED" - "USAGE" - "USER_DEFINED_TYPE_CATALOG" - "USER_DEFINED_TYPE_CODE" - "USER_DEFINED_TYPE_NAME" - "USER_DEFINED_TYPE_SCHEMA" - "UTF16" - "UTF32" - "UTF8" - "VERSION" - "VIEW" - "WEEK" - "WORK" - "WRAPPER" - "WRITE" - "XML" - "YEARS" - "ZONE" - ] - # List of non-reserved keywords to add; # items in this list become non-reserved nonReservedKeywordsToAdd: [ @@ -824,63 +518,35 @@ data: { "ZONE" ] - # List of non-reserved keywords to remove; - # items in this list become reserved - nonReservedKeywordsToRemove: [ - ] - # List of additional join types. Each is a method with no arguments. - # Example: LeftSemiJoin() + # Example: "LeftSemiJoin". joinTypes: [ "LeftSemiJoin" ] - # List of methods for parsing custom SQL statements. - statementParserMethods: [ - ] - - # List of methods for parsing custom literals. - # Return type of method implementation should be "SqlNode". - # Example: ParseJsonLiteral(). - literalParserMethods: [ - ] - - # List of methods for parsing custom data types. - # Return type of method implementation should be "SqlTypeNameSpec". - # Example: SqlParseTimeStampZ(). - dataTypeParserMethods: [ - ] - # List of methods for parsing builtin function calls. # Return type of method implementation should be "SqlNode". - # Example: DateFunctionCall(). + # Example: "DateFunctionCall()". builtinFunctionCallMethods: [ "DateFunctionCall()" "DateaddFunctionCall()" ] - # List of methods for parsing extensions to "ALTER " calls. - # Each must accept arguments "(SqlParserPos pos, String scope)". - alterStatementParserMethods: [ - ] - # List of methods for parsing extensions to "CREATE [OR REPLACE]" calls. # Each must accept arguments "(SqlParserPos pos, boolean replace)". + # Example: "SqlCreateForeignSchema". createStatementParserMethods: [ "SqlCreateTable" ] - # List of methods for parsing extensions to "DROP" calls. - # Each must accept arguments "(SqlParserPos pos)". - dropStatementParserMethods: [ - ] - - # Binary operators tokens + # Binary operators tokens. + # Example: "< INFIX_CAST: \"::\" >". binaryOperatorsTokens: [ "< INFIX_CAST: \"::\" >" ] - # Binary operators initialization + # Binary operators initialization. + # Example: "InfixCast". extraBinaryExpressions: [ "InfixCast" ] @@ -889,14 +555,12 @@ data: { # implementations for parsing custom SQL statements, literals or types # given as part of "statementParserMethods", "literalParserMethods" or # "dataTypeParserMethods". + # Example: "parserImpls.ftl". implementationFiles: [ "parserImpls.ftl" ] includePosixOperators: true - includeCompoundIdentifier: true - includeBraces: true - includeAdditionalDeclarations: false } } diff --git a/buildSrc/subprojects/fmpp/src/main/kotlin/org/apache/calcite/buildtools/fmpp/FmppTask.kt b/buildSrc/subprojects/fmpp/src/main/kotlin/org/apache/calcite/buildtools/fmpp/FmppTask.kt index f51117b2e398..b9680920645c 100644 --- a/buildSrc/subprojects/fmpp/src/main/kotlin/org/apache/calcite/buildtools/fmpp/FmppTask.kt +++ b/buildSrc/subprojects/fmpp/src/main/kotlin/org/apache/calcite/buildtools/fmpp/FmppTask.kt @@ -62,7 +62,9 @@ open class FmppTask @Inject constructor( "fmpp"( "configuration" to config.get(), "sourceRoot" to templates.get().asFile, - "outputRoot" to output.get().asFile + "outputRoot" to output.get().asFile, + "data" to "tdd(" + config.get() + "), " + + "default: tdd(" + templates.get().asFile + "/../default_config.fmpp)" ) } } diff --git a/core/src/main/codegen/config.fmpp b/core/src/main/codegen/config.fmpp index ecf6dcf176c9..7aae3ee16314 100644 --- a/core/src/main/codegen/config.fmpp +++ b/core/src/main/codegen/config.fmpp @@ -33,399 +33,16 @@ # part of the calcite-core-.jar under "codegen" directory. data: { + # Data declarations for this parser. + # + # Default declarations are in default_config.fmpp; if you do not include a + # declaration ('imports' or 'nonReservedKeywords', for example) in this file, + # FMPP will use the declaration from default_config.fmpp. parser: { # Generated parser implementation package and class name. package: "org.apache.calcite.sql.parser.impl", class: "SqlParserImpl", - # List of additional classes and packages to import. - # Example. "org.apache.calcite.sql.*", "java.util.List". - imports: [ - ] - - # List of new keywords. Example: "DATABASES", "TABLES". If the keyword is not a reserved - # keyword add it to 'nonReservedKeywords' section. - keywords: [ - ] - - # List of keywords from "keywords" section that are not reserved. - nonReservedKeywords: [ - "A" - "ABSENT" - "ABSOLUTE" - "ACTION" - "ADA" - "ADD" - "ADMIN" - "AFTER" - "ALWAYS" - "APPLY" - "ASC" - "ASSERTION" - "ASSIGNMENT" - "ATTRIBUTE" - "ATTRIBUTES" - "BEFORE" - "BERNOULLI" - "BREADTH" - "C" - "CASCADE" - "CATALOG" - "CATALOG_NAME" - "CENTURY" - "CHAIN" - "CHARACTERISTICS" - "CHARACTERS" - "CHARACTER_SET_CATALOG" - "CHARACTER_SET_NAME" - "CHARACTER_SET_SCHEMA" - "CLASS_ORIGIN" - "COBOL" - "COLLATION" - "COLLATION_CATALOG" - "COLLATION_NAME" - "COLLATION_SCHEMA" - "COLUMN_NAME" - "COMMAND_FUNCTION" - "COMMAND_FUNCTION_CODE" - "COMMITTED" - "CONDITIONAL" - "CONDITION_NUMBER" - "CONNECTION" - "CONNECTION_NAME" - "CONSTRAINT_CATALOG" - "CONSTRAINT_NAME" - "CONSTRAINTS" - "CONSTRAINT_SCHEMA" - "CONSTRUCTOR" - "CONTINUE" - "CURSOR_NAME" - "DATA" - "DATABASE" - "DATETIME_INTERVAL_CODE" - "DATETIME_INTERVAL_PRECISION" - "DAYS" - "DECADE" - "DEFAULTS" - "DEFERRABLE" - "DEFERRED" - "DEFINED" - "DEFINER" - "DEGREE" - "DEPTH" - "DERIVED" - "DESC" - "DESCRIPTION" - "DESCRIPTOR" - "DIAGNOSTICS" - "DISPATCH" - "DOMAIN" - "DOW" - "DOY" - "DYNAMIC_FUNCTION" - "DYNAMIC_FUNCTION_CODE" - "ENCODING" - "EPOCH" - "ERROR" - "EXCEPTION" - "EXCLUDE" - "EXCLUDING" - "FINAL" - "FIRST" - "FOLLOWING" - "FORMAT" - "FORTRAN" - "FOUND" - "FRAC_SECOND" - "G" - "GENERAL" - "GENERATED" - "GEOMETRY" - "GO" - "GOTO" - "GRANTED" - "HIERARCHY" - "HOP" - "HOURS" - "IGNORE" - "IMMEDIATE" - "IMMEDIATELY" - "IMPLEMENTATION" - "INCLUDING" - "INCREMENT" - "INITIALLY" - "INPUT" - "INSTANCE" - "INSTANTIABLE" - "INVOKER" - "ISODOW" - "ISOLATION" - "ISOYEAR" - "JAVA" - "JSON" - "K" - "KEY" - "KEY_MEMBER" - "KEY_TYPE" - "LABEL" - "LAST" - "LENGTH" - "LEVEL" - "LIBRARY" - "LOCATOR" - "M" - "MAP" - "MATCHED" - "MAXVALUE" - "MESSAGE_LENGTH" - "MESSAGE_OCTET_LENGTH" - "MESSAGE_TEXT" - "MICROSECOND" - "MILLENNIUM" - "MILLISECOND" - "MINUTES" - "MINVALUE" - "MONTHS" - "MORE_" - "MUMPS" - "NAME" - "NAMES" - "NANOSECOND" - "NESTING" - "NORMALIZED" - "NULLABLE" - "NULLS" - "NUMBER" - "OBJECT" - "OCTETS" - "OPTION" - "OPTIONS" - "ORDERING" - "ORDINALITY" - "OTHERS" - "OUTPUT" - "OVERRIDING" - "PAD" - "PARAMETER_MODE" - "PARAMETER_NAME" - "PARAMETER_ORDINAL_POSITION" - "PARAMETER_SPECIFIC_CATALOG" - "PARAMETER_SPECIFIC_NAME" - "PARAMETER_SPECIFIC_SCHEMA" - "PARTIAL" - "PASCAL" - "PASSING" - "PASSTHROUGH" - "PAST" - "PATH" - "PLACING" - "PLAN" - "PLI" - "PRECEDING" - "PRESERVE" - "PRIOR" - "PRIVILEGES" - "PUBLIC" - "QUARTER" - "READ" - "RELATIVE" - "REPEATABLE" - "REPLACE" - "RESPECT" - "RESTART" - "RESTRICT" - "RETURNED_CARDINALITY" - "RETURNED_LENGTH" - "RETURNED_OCTET_LENGTH" - "RETURNED_SQLSTATE" - "RETURNING" - "ROLE" - "ROUTINE" - "ROUTINE_CATALOG" - "ROUTINE_NAME" - "ROUTINE_SCHEMA" - "ROW_COUNT" - "SCALAR" - "SCALE" - "SCHEMA" - "SCHEMA_NAME" - "SCOPE_CATALOGS" - "SCOPE_NAME" - "SCOPE_SCHEMA" - "SECONDS" - "SECTION" - "SECURITY" - "SELF" - "SEQUENCE" - "SERIALIZABLE" - "SERVER" - "SERVER_NAME" - "SESSION" - "SETS" - "SIMPLE" - "SIZE" - "SOURCE" - "SPACE" - "SPECIFIC_NAME" - "SQL_BIGINT" - "SQL_BINARY" - "SQL_BIT" - "SQL_BLOB" - "SQL_BOOLEAN" - "SQL_CHAR" - "SQL_CLOB" - "SQL_DATE" - "SQL_DECIMAL" - "SQL_DOUBLE" - "SQL_FLOAT" - "SQL_INTEGER" - "SQL_INTERVAL_DAY" - "SQL_INTERVAL_DAY_TO_HOUR" - "SQL_INTERVAL_DAY_TO_MINUTE" - "SQL_INTERVAL_DAY_TO_SECOND" - "SQL_INTERVAL_HOUR" - "SQL_INTERVAL_HOUR_TO_MINUTE" - "SQL_INTERVAL_HOUR_TO_SECOND" - "SQL_INTERVAL_MINUTE" - "SQL_INTERVAL_MINUTE_TO_SECOND" - "SQL_INTERVAL_MONTH" - "SQL_INTERVAL_SECOND" - "SQL_INTERVAL_YEAR" - "SQL_INTERVAL_YEAR_TO_MONTH" - "SQL_LONGVARBINARY" - "SQL_LONGVARCHAR" - "SQL_LONGVARNCHAR" - "SQL_NCHAR" - "SQL_NCLOB" - "SQL_NUMERIC" - "SQL_NVARCHAR" - "SQL_REAL" - "SQL_SMALLINT" - "SQL_TIME" - "SQL_TIMESTAMP" - "SQL_TINYINT" - "SQL_TSI_DAY" - "SQL_TSI_FRAC_SECOND" - "SQL_TSI_HOUR" - "SQL_TSI_MICROSECOND" - "SQL_TSI_MINUTE" - "SQL_TSI_MONTH" - "SQL_TSI_QUARTER" - "SQL_TSI_SECOND" - "SQL_TSI_WEEK" - "SQL_TSI_YEAR" - "SQL_VARBINARY" - "SQL_VARCHAR" - "STATE" - "STATEMENT" - "STRUCTURE" - "STYLE" - "SUBCLASS_ORIGIN" - "SUBSTITUTE" - "TABLE_NAME" - "TEMPORARY" - "TIES" - "TIMESTAMPADD" - "TIMESTAMPDIFF" - "TOP_LEVEL_COUNT" - "TRANSACTION" - "TRANSACTIONS_ACTIVE" - "TRANSACTIONS_COMMITTED" - "TRANSACTIONS_ROLLED_BACK" - "TRANSFORM" - "TRANSFORMS" - "TRIGGER_CATALOG" - "TRIGGER_NAME" - "TRIGGER_SCHEMA" - "TUMBLE" - "TYPE" - "UNBOUNDED" - "UNCOMMITTED" - "UNCONDITIONAL" - "UNDER" - "UNNAMED" - "USAGE" - "USER_DEFINED_TYPE_CATALOG" - "USER_DEFINED_TYPE_CODE" - "USER_DEFINED_TYPE_NAME" - "USER_DEFINED_TYPE_SCHEMA" - "UTF16" - "UTF32" - "UTF8" - "VERSION" - "VIEW" - "WEEK" - "WORK" - "WRAPPER" - "WRITE" - "XML" - "YEARS" - "ZONE" - ] - - # List of non-reserved keywords to add; - # items in this list become non-reserved - nonReservedKeywordsToAdd: [ - ] - - # List of non-reserved keywords to remove; - # items in this list become reserved - nonReservedKeywordsToRemove: [ - ] - - # List of additional join types. Each is a method with no arguments. - # Example: LeftSemiJoin() - joinTypes: [ - ] - - # List of methods for parsing custom SQL statements. - # Return type of method implementation should be 'SqlNode'. - # Example: SqlShowDatabases(), SqlShowTables(). - statementParserMethods: [ - ] - - # List of methods for parsing custom literals. - # Return type of method implementation should be "SqlNode". - # Example: ParseJsonLiteral(). - literalParserMethods: [ - ] - - # List of methods for parsing custom data types. - # Return type of method implementation should be "SqlTypeNameSpec". - # Example: SqlParseTimeStampZ(). - dataTypeParserMethods: [ - ] - - # List of methods for parsing builtin function calls. - # Return type of method implementation should be "SqlNode". - # Example: DateFunctionCall(). - builtinFunctionCallMethods: [ - ] - - # List of methods for parsing extensions to "ALTER " calls. - # Each must accept arguments "(SqlParserPos pos, String scope)". - # Example: "SqlUploadJarNode" - alterStatementParserMethods: [ - ] - - # List of methods for parsing extensions to "CREATE [OR REPLACE]" calls. - # Each must accept arguments "(SqlParserPos pos, boolean replace)". - createStatementParserMethods: [ - ] - - # List of methods for parsing extensions to "DROP" calls. - # Each must accept arguments "(SqlParserPos pos)". - dropStatementParserMethods: [ - ] - - # Binary operators tokens - binaryOperatorsTokens: [ - ] - - # Binary operators initialization - extraBinaryExpressions: [ - ] - # List of files in @includes directory that have parser method # implementations for parsing custom SQL statements, literals or types # given as part of "statementParserMethods", "literalParserMethods" or @@ -433,11 +50,6 @@ data: { implementationFiles: [ "parserImpls.ftl" ] - - includePosixOperators: false - includeCompoundIdentifier: true - includeBraces: true - includeAdditionalDeclarations: false } } diff --git a/core/src/main/codegen/default_config.fmpp b/core/src/main/codegen/default_config.fmpp new file mode 100644 index 000000000000..0ed5a1bfe186 --- /dev/null +++ b/core/src/main/codegen/default_config.fmpp @@ -0,0 +1,424 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to you under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Default data declarations for parsers. +# Each of these may be overridden in a parser's config.fmpp file. +# In addition, each parser must define "package" and "class". +parser: { + # List of additional classes and packages to import. + # Example: "org.apache.calcite.sql.*", "java.util.List". + imports: [ + ] + + # List of new keywords. Example: "DATABASES", "TABLES". If the keyword is + # not a reserved keyword, add it to the 'nonReservedKeywords' section. + keywords: [ + ] + + # List of keywords from "keywords" section that are not reserved. + nonReservedKeywords: [ + "A" + "ABSENT" + "ABSOLUTE" + "ACTION" + "ADA" + "ADD" + "ADMIN" + "AFTER" + "ALWAYS" + "APPLY" + "ASC" + "ASSERTION" + "ASSIGNMENT" + "ATTRIBUTE" + "ATTRIBUTES" + "BEFORE" + "BERNOULLI" + "BREADTH" + "C" + "CASCADE" + "CATALOG" + "CATALOG_NAME" + "CENTURY" + "CHAIN" + "CHARACTERISTICS" + "CHARACTERS" + "CHARACTER_SET_CATALOG" + "CHARACTER_SET_NAME" + "CHARACTER_SET_SCHEMA" + "CLASS_ORIGIN" + "COBOL" + "COLLATION" + "COLLATION_CATALOG" + "COLLATION_NAME" + "COLLATION_SCHEMA" + "COLUMN_NAME" + "COMMAND_FUNCTION" + "COMMAND_FUNCTION_CODE" + "COMMITTED" + "CONDITIONAL" + "CONDITION_NUMBER" + "CONNECTION" + "CONNECTION_NAME" + "CONSTRAINT_CATALOG" + "CONSTRAINT_NAME" + "CONSTRAINTS" + "CONSTRAINT_SCHEMA" + "CONSTRUCTOR" + "CONTINUE" + "CURSOR_NAME" + "DATA" + "DATABASE" + "DATETIME_INTERVAL_CODE" + "DATETIME_INTERVAL_PRECISION" + "DAYS" + "DECADE" + "DEFAULTS" + "DEFERRABLE" + "DEFERRED" + "DEFINED" + "DEFINER" + "DEGREE" + "DEPTH" + "DERIVED" + "DESC" + "DESCRIPTION" + "DESCRIPTOR" + "DIAGNOSTICS" + "DISPATCH" + "DOMAIN" + "DOW" + "DOY" + "DYNAMIC_FUNCTION" + "DYNAMIC_FUNCTION_CODE" + "ENCODING" + "EPOCH" + "ERROR" + "EXCEPTION" + "EXCLUDE" + "EXCLUDING" + "FINAL" + "FIRST" + "FOLLOWING" + "FORMAT" + "FORTRAN" + "FOUND" + "FRAC_SECOND" + "G" + "GENERAL" + "GENERATED" + "GEOMETRY" + "GO" + "GOTO" + "GRANTED" + "HIERARCHY" + "HOP" + "HOURS" + "IGNORE" + "IMMEDIATE" + "IMMEDIATELY" + "IMPLEMENTATION" + "INCLUDING" + "INCREMENT" + "INITIALLY" + "INPUT" + "INSTANCE" + "INSTANTIABLE" + "INVOKER" + "ISODOW" + "ISOLATION" + "ISOYEAR" + "JAVA" + "JSON" + "K" + "KEY" + "KEY_MEMBER" + "KEY_TYPE" + "LABEL" + "LAST" + "LENGTH" + "LEVEL" + "LIBRARY" + "LOCATOR" + "M" + "MAP" + "MATCHED" + "MAXVALUE" + "MESSAGE_LENGTH" + "MESSAGE_OCTET_LENGTH" + "MESSAGE_TEXT" + "MICROSECOND" + "MILLENNIUM" + "MILLISECOND" + "MINUTES" + "MINVALUE" + "MONTHS" + "MORE_" + "MUMPS" + "NAME" + "NAMES" + "NANOSECOND" + "NESTING" + "NORMALIZED" + "NULLABLE" + "NULLS" + "NUMBER" + "OBJECT" + "OCTETS" + "OPTION" + "OPTIONS" + "ORDERING" + "ORDINALITY" + "OTHERS" + "OUTPUT" + "OVERRIDING" + "PAD" + "PARAMETER_MODE" + "PARAMETER_NAME" + "PARAMETER_ORDINAL_POSITION" + "PARAMETER_SPECIFIC_CATALOG" + "PARAMETER_SPECIFIC_NAME" + "PARAMETER_SPECIFIC_SCHEMA" + "PARTIAL" + "PASCAL" + "PASSING" + "PASSTHROUGH" + "PAST" + "PATH" + "PLACING" + "PLAN" + "PLI" + "PRECEDING" + "PRESERVE" + "PRIOR" + "PRIVILEGES" + "PUBLIC" + "QUARTER" + "READ" + "RELATIVE" + "REPEATABLE" + "REPLACE" + "RESPECT" + "RESTART" + "RESTRICT" + "RETURNED_CARDINALITY" + "RETURNED_LENGTH" + "RETURNED_OCTET_LENGTH" + "RETURNED_SQLSTATE" + "RETURNING" + "ROLE" + "ROUTINE" + "ROUTINE_CATALOG" + "ROUTINE_NAME" + "ROUTINE_SCHEMA" + "ROW_COUNT" + "SCALAR" + "SCALE" + "SCHEMA" + "SCHEMA_NAME" + "SCOPE_CATALOGS" + "SCOPE_NAME" + "SCOPE_SCHEMA" + "SECONDS" + "SECTION" + "SECURITY" + "SELF" + "SEQUENCE" + "SERIALIZABLE" + "SERVER" + "SERVER_NAME" + "SESSION" + "SETS" + "SIMPLE" + "SIZE" + "SOURCE" + "SPACE" + "SPECIFIC_NAME" + "SQL_BIGINT" + "SQL_BINARY" + "SQL_BIT" + "SQL_BLOB" + "SQL_BOOLEAN" + "SQL_CHAR" + "SQL_CLOB" + "SQL_DATE" + "SQL_DECIMAL" + "SQL_DOUBLE" + "SQL_FLOAT" + "SQL_INTEGER" + "SQL_INTERVAL_DAY" + "SQL_INTERVAL_DAY_TO_HOUR" + "SQL_INTERVAL_DAY_TO_MINUTE" + "SQL_INTERVAL_DAY_TO_SECOND" + "SQL_INTERVAL_HOUR" + "SQL_INTERVAL_HOUR_TO_MINUTE" + "SQL_INTERVAL_HOUR_TO_SECOND" + "SQL_INTERVAL_MINUTE" + "SQL_INTERVAL_MINUTE_TO_SECOND" + "SQL_INTERVAL_MONTH" + "SQL_INTERVAL_SECOND" + "SQL_INTERVAL_YEAR" + "SQL_INTERVAL_YEAR_TO_MONTH" + "SQL_LONGVARBINARY" + "SQL_LONGVARCHAR" + "SQL_LONGVARNCHAR" + "SQL_NCHAR" + "SQL_NCLOB" + "SQL_NUMERIC" + "SQL_NVARCHAR" + "SQL_REAL" + "SQL_SMALLINT" + "SQL_TIME" + "SQL_TIMESTAMP" + "SQL_TINYINT" + "SQL_TSI_DAY" + "SQL_TSI_FRAC_SECOND" + "SQL_TSI_HOUR" + "SQL_TSI_MICROSECOND" + "SQL_TSI_MINUTE" + "SQL_TSI_MONTH" + "SQL_TSI_QUARTER" + "SQL_TSI_SECOND" + "SQL_TSI_WEEK" + "SQL_TSI_YEAR" + "SQL_VARBINARY" + "SQL_VARCHAR" + "STATE" + "STATEMENT" + "STRUCTURE" + "STYLE" + "SUBCLASS_ORIGIN" + "SUBSTITUTE" + "TABLE_NAME" + "TEMPORARY" + "TIES" + "TIMESTAMPADD" + "TIMESTAMPDIFF" + "TOP_LEVEL_COUNT" + "TRANSACTION" + "TRANSACTIONS_ACTIVE" + "TRANSACTIONS_COMMITTED" + "TRANSACTIONS_ROLLED_BACK" + "TRANSFORM" + "TRANSFORMS" + "TRIGGER_CATALOG" + "TRIGGER_NAME" + "TRIGGER_SCHEMA" + "TUMBLE" + "TYPE" + "UNBOUNDED" + "UNCOMMITTED" + "UNCONDITIONAL" + "UNDER" + "UNNAMED" + "USAGE" + "USER_DEFINED_TYPE_CATALOG" + "USER_DEFINED_TYPE_CODE" + "USER_DEFINED_TYPE_NAME" + "USER_DEFINED_TYPE_SCHEMA" + "UTF16" + "UTF32" + "UTF8" + "VERSION" + "VIEW" + "WEEK" + "WORK" + "WRAPPER" + "WRITE" + "XML" + "YEARS" + "ZONE" + ] + + # List of non-reserved keywords to add; + # items in this list become non-reserved. + nonReservedKeywordsToAdd: [ + ] + + # List of non-reserved keywords to remove; + # items in this list become reserved. + nonReservedKeywordsToRemove: [ + ] + + # List of additional join types. Each is a method with no arguments. + # Example: "LeftSemiJoin". + joinTypes: [ + ] + + # List of methods for parsing custom SQL statements. + # Return type of method implementation should be 'SqlNode'. + # Example: "SqlShowDatabases()", "SqlShowTables()". + statementParserMethods: [ + ] + + # List of methods for parsing custom literals. + # Return type of method implementation should be "SqlNode". + # Example: ParseJsonLiteral(). + literalParserMethods: [ + ] + + # List of methods for parsing custom data types. + # Return type of method implementation should be "SqlTypeNameSpec". + # Example: SqlParseTimeStampZ(). + dataTypeParserMethods: [ + ] + + # List of methods for parsing builtin function calls. + # Return type of method implementation should be "SqlNode". + # Example: "DateFunctionCall()". + builtinFunctionCallMethods: [ + ] + + # List of methods for parsing extensions to "ALTER " calls. + # Each must accept arguments "(SqlParserPos pos, String scope)". + # Example: "SqlAlterTable". + alterStatementParserMethods: [ + ] + + # List of methods for parsing extensions to "CREATE [OR REPLACE]" calls. + # Each must accept arguments "(SqlParserPos pos, boolean replace)". + # Example: "SqlCreateForeignSchema". + createStatementParserMethods: [ + ] + + # List of methods for parsing extensions to "DROP" calls. + # Each must accept arguments "(SqlParserPos pos)". + # Example: "SqlDropSchema". + dropStatementParserMethods: [ + ] + + # Binary operators tokens. + # Example: "< INFIX_CAST: \"::\" >". + binaryOperatorsTokens: [ + ] + + # Binary operators initialization. + # Example: "InfixCast". + extraBinaryExpressions: [ + ] + + # List of files in @includes directory that have parser method + # implementations for parsing custom SQL statements, literals or types + # given as part of "statementParserMethods", "literalParserMethods" or + # "dataTypeParserMethods". + # Example: "parserImpls.ftl". + implementationFiles: [ + ] + + includePosixOperators: false + includeCompoundIdentifier: true + includeBraces: true + includeAdditionalDeclarations: false +} diff --git a/core/src/main/codegen/templates/Parser.jj b/core/src/main/codegen/templates/Parser.jj index 861304ebd2f4..18ef06fc9e45 100644 --- a/core/src/main/codegen/templates/Parser.jj +++ b/core/src/main/codegen/templates/Parser.jj @@ -29,7 +29,7 @@ PARSER_BEGIN(${parser.class}) package ${parser.package}; -<#list parser.imports as importStr> +<#list (parser.imports!default.parser.imports) as importStr> import ${importStr}; @@ -1025,7 +1025,7 @@ SqlNode SqlStmt() : { ( <#-- Add methods to parse additional statements here --> -<#list parser.statementParserMethods as method> +<#list (parser.statementParserMethods!default.parser.statementParserMethods) as method> LOOKAHEAD(2) stmt = ${method} | @@ -1033,11 +1033,11 @@ SqlNode SqlStmt() : | stmt = SqlAlter() | -<#if parser.createStatementParserMethods?size != 0> +<#if (parser.createStatementParserMethods!default.parser.createStatementParserMethods)?size != 0> stmt = SqlCreate() | -<#if parser.dropStatementParserMethods?size != 0> +<#if (parser.dropStatementParserMethods!default.parser.dropStatementParserMethods)?size != 0> stmt = SqlDrop() | @@ -1077,7 +1077,7 @@ SqlNode SqlStmtEof() : } <#-- Add implementations of additional parser statement calls here --> -<#list parser.implementationFiles as file> +<#list (parser.implementationFiles!default.parser.implementationFiles) as file> <#include "/@includes/"+file /> @@ -1880,7 +1880,7 @@ SqlLiteral JoinType() : { ( LOOKAHEAD(3) // required for "LEFT SEMI JOIN" in Babel -<#list parser.joinTypes as method> +<#list (parser.joinTypes!default.parser.joinTypes) as method> joinType = ${method}() | @@ -3467,7 +3467,7 @@ List Expression2(ExprContext exprContext) : | { op = SqlStdOperatorTable.SIMILAR_TO; } ) - <#if parser.includePosixOperators> + <#if (parser.includePosixOperators!default.parser.includePosixOperators)> | { op = SqlStdOperatorTable.NEGATED_POSIX_REGEX_CASE_SENSITIVE; } [ { op = SqlStdOperatorTable.NEGATED_POSIX_REGEX_CASE_INSENSITIVE; } ] @@ -3491,7 +3491,7 @@ List Expression2(ExprContext exprContext) : } ] | - <#list parser.extraBinaryExpressions as extra > + <#list (parser.extraBinaryExpressions!default.parser.extraBinaryExpressions) as extra > ${extra}(list, exprContext, s) | @@ -3930,7 +3930,7 @@ SqlAlter SqlAlter() : scope = Scope() ( <#-- additional literal parser methods are included here --> -<#list parser.alterStatementParserMethods as method> +<#list (parser.alterStatementParserMethods!default.parser.alterStatementParserMethods) as method> alterNode = ${method}(s, scope) | @@ -3949,7 +3949,7 @@ String Scope() : ( | ) { return token.image.toUpperCase(Locale.ROOT); } } -<#if parser.createStatementParserMethods?size != 0> +<#if (parser.createStatementParserMethods!default.parser.createStatementParserMethods)?size != 0> /** * Parses a CREATE statement. */ @@ -3968,7 +3968,7 @@ SqlCreate SqlCreate() : ] ( <#-- additional literal parser methods are included here --> -<#list parser.createStatementParserMethods as method> +<#list (parser.createStatementParserMethods!default.parser.createStatementParserMethods) as method> create = ${method}(s, replace) <#sep>| LOOKAHEAD(2) @@ -3979,7 +3979,7 @@ SqlCreate SqlCreate() : } -<#if parser.dropStatementParserMethods?size != 0> +<#if (parser.dropStatementParserMethods!default.parser.dropStatementParserMethods)?size != 0> /** * Parses a DROP statement. */ @@ -3993,7 +3993,7 @@ SqlDrop SqlDrop() : { s = span(); } ( <#-- additional literal parser methods are included here --> -<#list parser.dropStatementParserMethods as method> +<#list (parser.dropStatementParserMethods!default.parser.dropStatementParserMethods) as method> drop = ${method}(s, replace) <#sep>| @@ -4042,7 +4042,7 @@ SqlNode NonIntervalLiteral() : | e = DateTimeLiteral() <#-- additional literal parser methods are included here --> -<#list parser.literalParserMethods as method> +<#list (parser.literalParserMethods!default.parser.literalParserMethods) as method> | e = ${method} @@ -4914,7 +4914,7 @@ SqlNodeList ParenthesizedSimpleIdentifierList() : } } -<#if parser.includeCompoundIdentifier > +<#if (parser.includeCompoundIdentifier!default.parser.includeCompoundIdentifier) > /** * Parses a compound identifier. */ @@ -5097,7 +5097,7 @@ SqlTypeNameSpec TypeName() : ( <#-- additional types are included here --> <#-- put custom data types in front of Calcite core data types --> -<#list parser.dataTypeParserMethods as method> +<#list (parser.dataTypeParserMethods!default.parser.dataTypeParserMethods) as method> LOOKAHEAD(2) typeNameSpec = ${method} | @@ -5707,7 +5707,7 @@ SqlNode BuiltinFunctionCall() : | node = TimestampDiffFunctionCall() { return node; } | -<#list parser.builtinFunctionCallMethods as method> +<#list (parser.builtinFunctionCallMethods!default.parser.builtinFunctionCallMethods) as method> node = ${method} { return node; } | @@ -7660,7 +7660,7 @@ SqlPostfixOperator PostfixRowOperator() : | < YEARS: "YEARS" > | < ZONE: "ZONE" > <#-- additional parser keywords are included here --> -<#list parser.keywords as keyword> +<#list (parser.keywords!default.parser.keywords) as keyword> | < ${keyword}: "${keyword}" > } @@ -7699,7 +7699,7 @@ void NonReservedKeyWord0of3() : } { ( -<#list parser.nonReservedKeywords + parser.nonReservedKeywordsToAdd as keyword> +<#list (parser.nonReservedKeywords!default.parser.nonReservedKeywords) + (parser.nonReservedKeywordsToAdd!default.parser.nonReservedKeywordsToAdd) as keyword> <#if keyword?index == 0> <${keyword}> <#elseif keyword?index % 3 == 0> @@ -7715,7 +7715,7 @@ void NonReservedKeyWord1of3() : } { ( -<#list parser.nonReservedKeywords + parser.nonReservedKeywordsToAdd as keyword> +<#list (parser.nonReservedKeywords!default.parser.nonReservedKeywords) + (parser.nonReservedKeywordsToAdd!default.parser.nonReservedKeywordsToAdd) as keyword> <#if keyword?index == 1> <${keyword}> <#elseif keyword?index % 3 == 1> @@ -7731,7 +7731,7 @@ void NonReservedKeyWord2of3() : } { ( -<#list parser.nonReservedKeywords + parser.nonReservedKeywordsToAdd as keyword> +<#list (parser.nonReservedKeywords!default.parser.nonReservedKeywords) + (parser.nonReservedKeywordsToAdd!default.parser.nonReservedKeywordsToAdd) as keyword> <#if keyword?index == 2> <${keyword}> <#elseif keyword?index % 3 == 2> @@ -7813,7 +7813,7 @@ void NonReservedKeyWord2of3() : { < LPAREN: "("> | < RPAREN: ")"> -<#if parser.includeBraces > +<#if (parser.includeBraces!default.parser.includeBraces) > | < LBRACE_D: "{" (" ")* ["d","D"] > | < LBRACE_T: "{" (" ")* ["t","T"] > | < LBRACE_TS: "{" (" ")* ["t","T"] ["s","S"] > @@ -7856,7 +7856,7 @@ void NonReservedKeyWord2of3() : | < VERTICAL_BAR: "|" > | < CARET: "^" > | < DOLLAR: "$" > -<#list parser.binaryOperatorsTokens as operator> +<#list (parser.binaryOperatorsTokens!default.parser.binaryOperatorsTokens) as operator> | ${operator} } @@ -7890,7 +7890,7 @@ TOKEN_MGR_DECLS : { } } -<#if parser.includeAdditionalDeclarations> +<#if (parser.includeAdditionalDeclarations!default.parser.includeAdditionalDeclarations)> <#include "/@includes/tokenManagerDeclarations.ftl" /> } diff --git a/core/src/test/codegen/config.fmpp b/core/src/test/codegen/config.fmpp index 0667110bb01c..ee74320d5742 100644 --- a/core/src/test/codegen/config.fmpp +++ b/core/src/test/codegen/config.fmpp @@ -14,400 +14,52 @@ # limitations under the License. data: { + # Data declarations for this parser. + # + # Default declarations are in default_config.fmpp; if you do not include a + # declaration ('imports' or 'nonReservedKeywords', for example) in this file, + # FMPP will use the declaration from default_config.fmpp. parser: { # Generated parser implementation class package and name package: "org.apache.calcite.sql.parser.parserextensiontesting", class: "ExtensionSqlParserImpl", - # List of import statements. + # List of additional classes and packages to import. + # Example: "org.apache.calcite.sql.*", "java.util.List". imports: [ "org.apache.calcite.sql.SqlCreate", "org.apache.calcite.sql.parser.parserextensiontesting.SqlCreateTable", "org.apache.calcite.sql.parser.parserextensiontesting.SqlUploadJarNode" ] - # List of keywords. + # List of new keywords. Example: "DATABASES", "TABLES". If the keyword is + # not a reserved keyword, add it to the 'nonReservedKeywords' section. keywords: [ "UPLOAD" "JAR" ] - # List of keywords from "keywords" section that are not reserved. - nonReservedKeywords: [ - "A" - "ABSENT" - "ABSOLUTE" - "ACTION" - "ADA" - "ADD" - "ADMIN" - "AFTER" - "ALWAYS" - "APPLY" - "ASC" - "ASSERTION" - "ASSIGNMENT" - "ATTRIBUTE" - "ATTRIBUTES" - "BEFORE" - "BERNOULLI" - "BREADTH" - "C" - "CASCADE" - "CATALOG" - "CATALOG_NAME" - "CENTURY" - "CHAIN" - "CHARACTERISTICS" - "CHARACTERS" - "CHARACTER_SET_CATALOG" - "CHARACTER_SET_NAME" - "CHARACTER_SET_SCHEMA" - "CLASS_ORIGIN" - "COBOL" - "COLLATION" - "COLLATION_CATALOG" - "COLLATION_NAME" - "COLLATION_SCHEMA" - "COLUMN_NAME" - "COMMAND_FUNCTION" - "COMMAND_FUNCTION_CODE" - "COMMITTED" - "CONDITIONAL" - "CONDITION_NUMBER" - "CONNECTION" - "CONNECTION_NAME" - "CONSTRAINT_CATALOG" - "CONSTRAINT_NAME" - "CONSTRAINTS" - "CONSTRAINT_SCHEMA" - "CONSTRUCTOR" - "CONTINUE" - "CURSOR_NAME" - "DATA" - "DATABASE" - "DATETIME_INTERVAL_CODE" - "DATETIME_INTERVAL_PRECISION" - "DAYS" - "DECADE" - "DEFAULTS" - "DEFERRABLE" - "DEFERRED" - "DEFINED" - "DEFINER" - "DEGREE" - "DEPTH" - "DERIVED" - "DESC" - "DESCRIPTION" - "DESCRIPTOR" - "DIAGNOSTICS" - "DISPATCH" - "DOMAIN" - "DOW" - "DOY" - "DYNAMIC_FUNCTION" - "DYNAMIC_FUNCTION_CODE" - "ENCODING" - "EPOCH" - "ERROR" - "EXCEPTION" - "EXCLUDE" - "EXCLUDING" - "FINAL" - "FIRST" - "FOLLOWING" - "FORMAT" - "FORTRAN" - "FOUND" - "FRAC_SECOND" - "G" - "GENERAL" - "GENERATED" - "GEOMETRY" - "GO" - "GOTO" - "GRANTED" - "HIERARCHY" - "HOURS" - "IGNORE" - "IMMEDIATE" - "IMMEDIATELY" - "IMPLEMENTATION" - "INCLUDING" - "INCREMENT" - "INITIALLY" - "INPUT" - "INSTANCE" - "INSTANTIABLE" - "INVOKER" - "ISODOW" - "ISOLATION" - "ISOYEAR" - "JAVA" - "JSON" - "K" - "KEY" - "KEY_MEMBER" - "KEY_TYPE" - "LABEL" - "LAST" - "LENGTH" - "LEVEL" - "LIBRARY" - "LOCATOR" - "M" - "MAP" - "MATCHED" - "MAXVALUE" - "MESSAGE_LENGTH" - "MESSAGE_OCTET_LENGTH" - "MESSAGE_TEXT" - "MICROSECOND" - "MILLENNIUM" - "MILLISECOND" - "MINUTES" - "MINVALUE" - "MONTHS" - "MORE_" - "MUMPS" - "NAME" - "NAMES" - "NANOSECOND" - "NESTING" - "NORMALIZED" - "NULLABLE" - "NULLS" - "NUMBER" - "OBJECT" - "OCTETS" - "OPTION" - "OPTIONS" - "ORDERING" - "ORDINALITY" - "OTHERS" - "OUTPUT" - "OVERRIDING" - "PAD" - "PARAMETER_MODE" - "PARAMETER_NAME" - "PARAMETER_ORDINAL_POSITION" - "PARAMETER_SPECIFIC_CATALOG" - "PARAMETER_SPECIFIC_NAME" - "PARAMETER_SPECIFIC_SCHEMA" - "PARTIAL" - "PASCAL" - "PASSING" - "PASSTHROUGH" - "PAST" - "PATH" - "PLACING" - "PLAN" - "PLI" - "PRECEDING" - "PRESERVE" - "PRIOR" - "PRIVILEGES" - "PUBLIC" - "QUARTER" - "READ" - "RELATIVE" - "REPEATABLE" - "REPLACE" - "RESPECT" - "RESTART" - "RESTRICT" - "RETURNED_CARDINALITY" - "RETURNED_LENGTH" - "RETURNED_OCTET_LENGTH" - "RETURNED_SQLSTATE" - "RETURNING" - "ROLE" - "ROUTINE" - "ROUTINE_CATALOG" - "ROUTINE_NAME" - "ROUTINE_SCHEMA" - "ROW_COUNT" - "SCALAR" - "SCALE" - "SCHEMA" - "SCHEMA_NAME" - "SCOPE_CATALOGS" - "SCOPE_NAME" - "SCOPE_SCHEMA" - "SECONDS" - "SECTION" - "SECURITY" - "SELF" - "SEQUENCE" - "SERIALIZABLE" - "SERVER" - "SERVER_NAME" - "SESSION" - "SETS" - "SIMPLE" - "SIZE" - "SOURCE" - "SPACE" - "SPECIFIC_NAME" - "SQL_BIGINT" - "SQL_BINARY" - "SQL_BIT" - "SQL_BLOB" - "SQL_BOOLEAN" - "SQL_CHAR" - "SQL_CLOB" - "SQL_DATE" - "SQL_DECIMAL" - "SQL_DOUBLE" - "SQL_FLOAT" - "SQL_INTEGER" - "SQL_INTERVAL_DAY" - "SQL_INTERVAL_DAY_TO_HOUR" - "SQL_INTERVAL_DAY_TO_MINUTE" - "SQL_INTERVAL_DAY_TO_SECOND" - "SQL_INTERVAL_HOUR" - "SQL_INTERVAL_HOUR_TO_MINUTE" - "SQL_INTERVAL_HOUR_TO_SECOND" - "SQL_INTERVAL_MINUTE" - "SQL_INTERVAL_MINUTE_TO_SECOND" - "SQL_INTERVAL_MONTH" - "SQL_INTERVAL_SECOND" - "SQL_INTERVAL_YEAR" - "SQL_INTERVAL_YEAR_TO_MONTH" - "SQL_LONGVARBINARY" - "SQL_LONGVARCHAR" - "SQL_LONGVARNCHAR" - "SQL_NCHAR" - "SQL_NCLOB" - "SQL_NUMERIC" - "SQL_NVARCHAR" - "SQL_REAL" - "SQL_SMALLINT" - "SQL_TIME" - "SQL_TIMESTAMP" - "SQL_TINYINT" - "SQL_TSI_DAY" - "SQL_TSI_FRAC_SECOND" - "SQL_TSI_HOUR" - "SQL_TSI_MICROSECOND" - "SQL_TSI_MINUTE" - "SQL_TSI_MONTH" - "SQL_TSI_QUARTER" - "SQL_TSI_SECOND" - "SQL_TSI_WEEK" - "SQL_TSI_YEAR" - "SQL_VARBINARY" - "SQL_VARCHAR" - "STATE" - "STATEMENT" - "STRUCTURE" - "STYLE" - "SUBCLASS_ORIGIN" - "SUBSTITUTE" - "TABLE_NAME" - "TEMPORARY" - "TIES" - "TIMESTAMPADD" - "TIMESTAMPDIFF" - "TOP_LEVEL_COUNT" - "TRANSACTION" - "TRANSACTIONS_ACTIVE" - "TRANSACTIONS_COMMITTED" - "TRANSACTIONS_ROLLED_BACK" - "TRANSFORM" - "TRANSFORMS" - "TRIGGER_CATALOG" - "TRIGGER_NAME" - "TRIGGER_SCHEMA" - "TYPE" - "UNBOUNDED" - "UNCOMMITTED" - "UNCONDITIONAL" - "UNDER" - "UNNAMED" - "USAGE" - "USER_DEFINED_TYPE_CATALOG" - "USER_DEFINED_TYPE_CODE" - "USER_DEFINED_TYPE_NAME" - "USER_DEFINED_TYPE_SCHEMA" - "UTF16" - "UTF32" - "UTF8" - "VERSION" - "VIEW" - "WEEK" - "WORK" - "WRAPPER" - "WRITE" - "XML" - "YEARS" - "ZONE" - ] - - # List of non-reserved keywords to add; - # items in this list become non-reserved - nonReservedKeywordsToAdd: [ - ] - - # List of non-reserved keywords to remove; - # items in this list become reserved - nonReservedKeywordsToRemove: [ - ] - - # List of additional join types. Each is a method with no arguments. - # Example: LeftSemiJoin() - joinTypes: [ - ] - # List of methods for parsing custom SQL statements. + # Return type of method implementation should be 'SqlNode'. + # Example: "SqlShowDatabases()", "SqlShowTables()". statementParserMethods: [ "SqlDescribeSpacePower()" ] - # List of methods for parsing custom literals. - # Return type of method implementation should be "SqlNode". - # Example: ParseJsonLiteral(). - literalParserMethods: [ - ] - - # List of methods for parsing custom data types. - # Return type of method implementation should be "SqlTypeNameSpec". - # Example: SqlParseTimeStampZ(). - dataTypeParserMethods: [ - ] - - # List of methods for parsing builtin function calls. - # Return type of method implementation should be "SqlNode". - # Example: DateFunctionCall(). - builtinFunctionCallMethods: [ - ] - # List of methods for parsing extensions to "ALTER " calls. # Each must accept arguments "(SqlParserPos pos, String scope)". + # Example: "SqlAlterTable". alterStatementParserMethods: [ "SqlUploadJarNode" ] # List of methods for parsing extensions to "CREATE [OR REPLACE]" calls. # Each must accept arguments "(SqlParserPos pos, boolean replace)". + # Example: "SqlCreateForeignSchema". createStatementParserMethods: [ "SqlCreateTable" ] - # List of methods for parsing extensions to "DROP" calls. - # Each must accept arguments "(SqlParserPos pos)". - dropStatementParserMethods: [ - ] - - # Binary operators tokens - binaryOperatorsTokens: [ - ] - - # Binary operators initialization - extraBinaryExpressions: [ - ] - # List of files in @includes directory that have parser method # implementations for parsing custom SQL statements, literals or types # given as part of "statementParserMethods", "literalParserMethods" or @@ -415,11 +67,6 @@ data: { implementationFiles: [ "parserImpls.ftl" ] - - includePosixOperators: false - includeCompoundIdentifier: true - includeBraces: true - includeAdditionalDeclarations: false } } diff --git a/server/src/main/codegen/config.fmpp b/server/src/main/codegen/config.fmpp index cbdfa74a464a..58d2bdf3ecad 100644 --- a/server/src/main/codegen/config.fmpp +++ b/server/src/main/codegen/config.fmpp @@ -14,6 +14,11 @@ # limitations under the License. data: { + # Data declarations for this parser. + # + # Default declarations are in default_config.fmpp; if you do not include a + # declaration ('imports' or 'nonReservedKeywords', for example) in this file, + # FMPP will use the declaration from default_config.fmpp. parser: { # Generated parser implementation class package and name package: "org.apache.calcite.sql.parser.ddl", @@ -29,7 +34,8 @@ data: { "java.util.HashMap" ] - # List of keywords. + # List of new keywords. Example: "DATABASES", "TABLES". If the keyword is + # not a reserved keyword, add it to the 'nonReservedKeywords' section. keywords: [ "IF" "MATERIALIZED" @@ -40,319 +46,6 @@ data: { "ARCHIVE" ] - # List of keywords from "keywords" section that are not reserved. - nonReservedKeywords: [ - "A" - "ABSENT" - "ABSOLUTE" - "ACTION" - "ADA" - "ADD" - "ADMIN" - "AFTER" - "ALWAYS" - "APPLY" - "ASC" - "ASSERTION" - "ASSIGNMENT" - "ATTRIBUTE" - "ATTRIBUTES" - "BEFORE" - "BERNOULLI" - "BREADTH" - "C" - "CASCADE" - "CATALOG" - "CATALOG_NAME" - "CENTURY" - "CHAIN" - "CHARACTERISTICS" - "CHARACTERS" - "CHARACTER_SET_CATALOG" - "CHARACTER_SET_NAME" - "CHARACTER_SET_SCHEMA" - "CLASS_ORIGIN" - "COBOL" - "COLLATION" - "COLLATION_CATALOG" - "COLLATION_NAME" - "COLLATION_SCHEMA" - "COLUMN_NAME" - "COMMAND_FUNCTION" - "COMMAND_FUNCTION_CODE" - "COMMITTED" - "CONDITIONAL" - "CONDITION_NUMBER" - "CONNECTION" - "CONNECTION_NAME" - "CONSTRAINT_CATALOG" - "CONSTRAINT_NAME" - "CONSTRAINTS" - "CONSTRAINT_SCHEMA" - "CONSTRUCTOR" - "CONTINUE" - "CURSOR_NAME" - "DATA" - "DATABASE" - "DATETIME_INTERVAL_CODE" - "DATETIME_INTERVAL_PRECISION" - "DAYS" - "DECADE" - "DEFAULTS" - "DEFERRABLE" - "DEFERRED" - "DEFINED" - "DEFINER" - "DEGREE" - "DEPTH" - "DERIVED" - "DESC" - "DESCRIPTION" - "DESCRIPTOR" - "DIAGNOSTICS" - "DISPATCH" - "DOMAIN" - "DOW" - "DOY" - "DYNAMIC_FUNCTION" - "DYNAMIC_FUNCTION_CODE" - "ENCODING" - "EPOCH" - "ERROR" - "EXCEPTION" - "EXCLUDE" - "EXCLUDING" - "FINAL" - "FIRST" - "FOLLOWING" - "FORMAT" - "FORTRAN" - "FOUND" - "FRAC_SECOND" - "G" - "GENERAL" - "GENERATED" - "GEOMETRY" - "GO" - "GOTO" - "GRANTED" - "HIERARCHY" - "HOURS" - "IGNORE" - "IMMEDIATE" - "IMMEDIATELY" - "IMPLEMENTATION" - "INCLUDING" - "INCREMENT" - "INITIALLY" - "INPUT" - "INSTANCE" - "INSTANTIABLE" - "INVOKER" - "ISODOW" - "ISOLATION" - "ISOYEAR" - "JAVA" - "JSON" - "K" - "KEY" - "KEY_MEMBER" - "KEY_TYPE" - "LABEL" - "LAST" - "LENGTH" - "LEVEL" - "LIBRARY" - "LOCATOR" - "M" - "MAP" - "MATCHED" - "MAXVALUE" - "MESSAGE_LENGTH" - "MESSAGE_OCTET_LENGTH" - "MESSAGE_TEXT" - "MICROSECOND" - "MILLENNIUM" - "MILLISECOND" - "MINUTES" - "MINVALUE" - "MONTHS" - "MORE_" - "MUMPS" - "NAME" - "NAMES" - "NANOSECOND" - "NESTING" - "NORMALIZED" - "NULLABLE" - "NULLS" - "NUMBER" - "OBJECT" - "OCTETS" - "OPTION" - "OPTIONS" - "ORDERING" - "ORDINALITY" - "OTHERS" - "OUTPUT" - "OVERRIDING" - "PAD" - "PARAMETER_MODE" - "PARAMETER_NAME" - "PARAMETER_ORDINAL_POSITION" - "PARAMETER_SPECIFIC_CATALOG" - "PARAMETER_SPECIFIC_NAME" - "PARAMETER_SPECIFIC_SCHEMA" - "PARTIAL" - "PASCAL" - "PASSING" - "PASSTHROUGH" - "PAST" - "PATH" - "PLACING" - "PLAN" - "PLI" - "PRECEDING" - "PRESERVE" - "PRIOR" - "PRIVILEGES" - "PUBLIC" - "QUARTER" - "READ" - "RELATIVE" - "REPEATABLE" - "REPLACE" - "RESPECT" - "RESTART" - "RESTRICT" - "RETURNED_CARDINALITY" - "RETURNED_LENGTH" - "RETURNED_OCTET_LENGTH" - "RETURNED_SQLSTATE" - "RETURNING" - "ROLE" - "ROUTINE" - "ROUTINE_CATALOG" - "ROUTINE_NAME" - "ROUTINE_SCHEMA" - "ROW_COUNT" - "SCALAR" - "SCALE" - "SCHEMA" - "SCHEMA_NAME" - "SCOPE_CATALOGS" - "SCOPE_NAME" - "SCOPE_SCHEMA" - "SECONDS" - "SECTION" - "SECURITY" - "SELF" - "SEQUENCE" - "SERIALIZABLE" - "SERVER" - "SERVER_NAME" - "SESSION" - "SETS" - "SIMPLE" - "SIZE" - "SOURCE" - "SPACE" - "SPECIFIC_NAME" - "SQL_BIGINT" - "SQL_BINARY" - "SQL_BIT" - "SQL_BLOB" - "SQL_BOOLEAN" - "SQL_CHAR" - "SQL_CLOB" - "SQL_DATE" - "SQL_DECIMAL" - "SQL_DOUBLE" - "SQL_FLOAT" - "SQL_INTEGER" - "SQL_INTERVAL_DAY" - "SQL_INTERVAL_DAY_TO_HOUR" - "SQL_INTERVAL_DAY_TO_MINUTE" - "SQL_INTERVAL_DAY_TO_SECOND" - "SQL_INTERVAL_HOUR" - "SQL_INTERVAL_HOUR_TO_MINUTE" - "SQL_INTERVAL_HOUR_TO_SECOND" - "SQL_INTERVAL_MINUTE" - "SQL_INTERVAL_MINUTE_TO_SECOND" - "SQL_INTERVAL_MONTH" - "SQL_INTERVAL_SECOND" - "SQL_INTERVAL_YEAR" - "SQL_INTERVAL_YEAR_TO_MONTH" - "SQL_LONGVARBINARY" - "SQL_LONGVARCHAR" - "SQL_LONGVARNCHAR" - "SQL_NCHAR" - "SQL_NCLOB" - "SQL_NUMERIC" - "SQL_NVARCHAR" - "SQL_REAL" - "SQL_SMALLINT" - "SQL_TIME" - "SQL_TIMESTAMP" - "SQL_TINYINT" - "SQL_TSI_DAY" - "SQL_TSI_FRAC_SECOND" - "SQL_TSI_HOUR" - "SQL_TSI_MICROSECOND" - "SQL_TSI_MINUTE" - "SQL_TSI_MONTH" - "SQL_TSI_QUARTER" - "SQL_TSI_SECOND" - "SQL_TSI_WEEK" - "SQL_TSI_YEAR" - "SQL_VARBINARY" - "SQL_VARCHAR" - "STATE" - "STATEMENT" - "STRUCTURE" - "STYLE" - "SUBCLASS_ORIGIN" - "SUBSTITUTE" - "TABLE_NAME" - "TEMPORARY" - "TIES" - "TIMESTAMPADD" - "TIMESTAMPDIFF" - "TOP_LEVEL_COUNT" - "TRANSACTION" - "TRANSACTIONS_ACTIVE" - "TRANSACTIONS_COMMITTED" - "TRANSACTIONS_ROLLED_BACK" - "TRANSFORM" - "TRANSFORMS" - "TRIGGER_CATALOG" - "TRIGGER_NAME" - "TRIGGER_SCHEMA" - "TYPE" - "UNBOUNDED" - "UNCOMMITTED" - "UNCONDITIONAL" - "UNDER" - "UNNAMED" - "USAGE" - "USER_DEFINED_TYPE_CATALOG" - "USER_DEFINED_TYPE_CODE" - "USER_DEFINED_TYPE_NAME" - "USER_DEFINED_TYPE_SCHEMA" - "UTF16" - "UTF32" - "UTF8" - "VERSION" - "VIEW" - "WEEK" - "WORK" - "WRAPPER" - "WRITE" - "XML" - "YEARS" - "ZONE" - ] - # List of non-reserved keywords to add; # items in this list become non-reserved nonReservedKeywordsToAdd: [ @@ -366,45 +59,9 @@ data: { "ARCHIVE" ] - # List of non-reserved keywords to remove; - # items in this list become reserved - nonReservedKeywordsToRemove: [ - ] - - # List of additional join types. Each is a method with no arguments. - # Example: LeftSemiJoin() - joinTypes: [ - ] - - # List of methods for parsing custom SQL statements. - statementParserMethods: [ - ] - - # List of methods for parsing custom literals. - # Return type of method implementation should be "SqlNode". - # Example: ParseJsonLiteral(). - literalParserMethods: [ - ] - - # List of methods for parsing custom data types. - # Return type of method implementation should be "SqlTypeNameSpec". - # Example: SqlParseTimeStampZ(). - dataTypeParserMethods: [ - ] - - # List of methods for parsing builtin function calls. - # Return type of method implementation should be "SqlNode". - # Example: DateFunctionCall(). - builtinFunctionCallMethods: [ - ] - - # List of methods for parsing extensions to "ALTER " calls. - # Each must accept arguments "(SqlParserPos pos, String scope)". - alterStatementParserMethods: [ - ] - # List of methods for parsing extensions to "CREATE [OR REPLACE]" calls. # Each must accept arguments "(SqlParserPos pos, boolean replace)". + # Example: "SqlCreateForeignSchema". createStatementParserMethods: [ "SqlCreateForeignSchema" "SqlCreateMaterializedView" @@ -417,6 +74,7 @@ data: { # List of methods for parsing extensions to "DROP" calls. # Each must accept arguments "(SqlParserPos pos)". + # Example: "SqlDropSchema". dropStatementParserMethods: [ "SqlDropMaterializedView" "SqlDropSchema" @@ -426,26 +84,14 @@ data: { "SqlDropFunction" ] - # Binary operators tokens - binaryOperatorsTokens: [ - ] - - # Binary operators initialization - extraBinaryExpressions: [ - ] - # List of files in @includes directory that have parser method # implementations for parsing custom SQL statements, literals or types # given as part of "statementParserMethods", "literalParserMethods" or # "dataTypeParserMethods". + # Example: "parserImpls.ftl". implementationFiles: [ "parserImpls.ftl" ] - - includePosixOperators: false - includeCompoundIdentifier: true - includeBraces: true - includeAdditionalDeclarations: false } }