2002-07-29 17:37:59 +02:00
|
|
|
/*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
* You may obtain a copy of the Licence at
|
|
|
|
* http://www.gnu.org/licences/lgpl.html
|
|
|
|
*
|
|
|
|
* This module is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU Lesser General Public Licence for more details.
|
|
|
|
*
|
|
|
|
* As a special exception the copyright holders of this source file
|
|
|
|
* also give you permission to include this file in a library with
|
|
|
|
* any other source code that has been released under an Open Source
|
|
|
|
* Initiative certificed licence. More information about OSI certification
|
|
|
|
* can be found at: http://www.opensource.org
|
|
|
|
*
|
|
|
|
* This module was created by members of the firebird development
|
|
|
|
* team. All individual contributions remain the Copyright (C) of
|
|
|
|
* those individuals and all rights are reserved. Contributors to
|
|
|
|
* this file are either listed below or can be obtained from a CVS
|
|
|
|
* history command.
|
|
|
|
*
|
|
|
|
* Created by: Mark O'Donohue <mark.odonohue@ludwig.edu.au>
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
*
|
|
|
|
*
|
2004-03-07 08:58:55 +01:00
|
|
|
* $Id: keywords.cpp,v 1.28 2004-03-07 07:58:27 robocop Exp $
|
2002-07-29 17:37:59 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include "firebird.h"
|
|
|
|
|
|
|
|
#ifdef HAVE_STRING_H
|
|
|
|
#include <string.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include "dsql.tab.h"
|
|
|
|
#include "keywords.h"
|
|
|
|
|
2003-11-28 07:48:34 +01:00
|
|
|
static const TOK tokens[] = {
|
2002-07-30 09:23:40 +02:00
|
|
|
{NOT_LSS, "!<", 1},
|
2002-07-29 17:37:59 +02:00
|
|
|
{NEQ, "!=", 1},
|
|
|
|
{NOT_GTR, "!>", 1},
|
|
|
|
{LPAREN, "(", 1},
|
2002-07-30 11:49:16 +02:00
|
|
|
{RPAREN, ")", 1},
|
2002-07-30 09:23:40 +02:00
|
|
|
{COMMA, ",", 1},
|
|
|
|
{LSS, "<", 1},
|
|
|
|
{LEQ, "<=", 1},
|
2004-03-07 08:58:55 +01:00
|
|
|
{NEQ, "<>", 1}, // Alias of !=
|
2002-07-29 17:37:59 +02:00
|
|
|
{EQL, "=", 1},
|
|
|
|
{GTR, ">", 1},
|
|
|
|
{GEQ, ">=", 1},
|
|
|
|
{ACTION, "ACTION", 1},
|
|
|
|
{ACTIVE, "ACTIVE", 1},
|
|
|
|
{ADD, "ADD", 1},
|
|
|
|
{ADMIN, "ADMIN", 1},
|
|
|
|
{AFTER, "AFTER", 1},
|
|
|
|
{ALL, "ALL", 1},
|
|
|
|
{ALTER, "ALTER", 1},
|
2002-07-30 09:23:40 +02:00
|
|
|
{AND, "AND", 1},
|
|
|
|
{ANY, "ANY", 1},
|
|
|
|
{AS, "AS", 1},
|
2003-11-28 07:48:34 +01:00
|
|
|
{ASC, "ASC", 1}, // Alias of ASCENDING
|
2002-07-29 17:37:59 +02:00
|
|
|
{ASC, "ASCENDING", 1},
|
|
|
|
{AT, "AT", 1},
|
|
|
|
{AUTO, "AUTO", 1},
|
|
|
|
{AVG, "AVG", 1},
|
2003-08-06 18:30:49 +02:00
|
|
|
{BACKUP, "BACKUP", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{BASENAME, "BASE_NAME", 1},
|
|
|
|
{BEFORE, "BEFORE", 1},
|
|
|
|
{BEGIN, "BEGIN", 1},
|
|
|
|
{BETWEEN, "BETWEEN", 1},
|
2002-08-11 10:04:54 +02:00
|
|
|
{BIGINT, "BIGINT", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{BLOB, "BLOB", 1},
|
2004-01-16 11:43:21 +01:00
|
|
|
{BLOCK, "BLOCK", 1},
|
2002-07-30 09:23:40 +02:00
|
|
|
{KW_BREAK, "BREAK", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{BY, "BY", 1},
|
|
|
|
{CACHE, "CACHE", 1},
|
|
|
|
{CASCADE, "CASCADE", 1},
|
2002-08-03 17:27:20 +02:00
|
|
|
{CASE, "CASE", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{CAST, "CAST", 1},
|
|
|
|
{KW_CHAR, "CHAR", 1},
|
|
|
|
{CHARACTER, "CHARACTER", 1},
|
|
|
|
{CHECK, "CHECK", 1},
|
|
|
|
{CHECK_POINT_LEN, "CHECK_POINT_LENGTH", 1},
|
2003-11-02 13:28:30 +01:00
|
|
|
{CLOSE, "CLOSE", 2},
|
2002-08-03 17:27:20 +02:00
|
|
|
{COALESCE, "COALESCE", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{COLLATE, "COLLATE", 1},
|
|
|
|
{COLUMN, "COLUMN", 2},
|
|
|
|
{COMMIT, "COMMIT", 1},
|
|
|
|
{COMMITTED, "COMMITTED", 1},
|
|
|
|
{COMPUTED, "COMPUTED", 1},
|
|
|
|
{CONDITIONAL, "CONDITIONAL", 1},
|
|
|
|
{CONSTRAINT, "CONSTRAINT", 1},
|
|
|
|
{CONTAINING, "CONTAINING", 1},
|
|
|
|
{COUNT, "COUNT", 1},
|
|
|
|
{CREATE, "CREATE", 1},
|
|
|
|
{CSTRING, "CSTRING", 1},
|
|
|
|
{CURRENT, "CURRENT", 1},
|
2003-04-06 13:20:24 +02:00
|
|
|
{CURRENT_CONNECTION, "CURRENT_CONNECTION", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{CURRENT_DATE, "CURRENT_DATE", 2},
|
2002-07-30 09:23:40 +02:00
|
|
|
{CURRENT_ROLE, "CURRENT_ROLE", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{CURRENT_TIME, "CURRENT_TIME", 2},
|
|
|
|
{CURRENT_TIMESTAMP, "CURRENT_TIMESTAMP", 2},
|
2003-04-06 13:20:24 +02:00
|
|
|
{CURRENT_TRANSACTION, "CURRENT_TRANSACTION", 2},
|
2002-07-30 09:23:40 +02:00
|
|
|
{CURRENT_USER, "CURRENT_USER", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{CURSOR, "CURSOR", 1},
|
|
|
|
{DATABASE, "DATABASE", 1},
|
|
|
|
{DATE, "DATE", 1},
|
|
|
|
{DAY, "DAY", 2},
|
|
|
|
{KW_DEBUG, "DEBUG", 1},
|
|
|
|
{KW_DEC, "DEC", 1},
|
|
|
|
{DECIMAL, "DECIMAL", 1},
|
|
|
|
{DECLARE, "DECLARE", 1},
|
2003-01-15 13:00:33 +01:00
|
|
|
{DEFAULT, "DEFAULT", 1},
|
2003-07-02 02:16:56 +02:00
|
|
|
{KW_DELETE, "DELETE", 1},
|
2003-01-15 13:00:33 +01:00
|
|
|
{DELETING, "DELETING", 2},
|
2003-11-28 07:48:34 +01:00
|
|
|
{DESC, "DESC", 1}, // Alias of DESCENDING
|
2002-07-29 17:37:59 +02:00
|
|
|
{DESC, "DESCENDING", 1},
|
2002-07-30 09:23:40 +02:00
|
|
|
{KW_DESCRIPTOR, "DESCRIPTOR", 2},
|
2003-08-06 22:21:40 +02:00
|
|
|
{KW_DIFFERENCE, "DIFFERENCE", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{DISTINCT, "DISTINCT", 1},
|
|
|
|
{DO, "DO", 1},
|
|
|
|
{DOMAIN, "DOMAIN", 1},
|
|
|
|
{KW_DOUBLE, "DOUBLE", 1},
|
|
|
|
{DROP, "DROP", 1},
|
|
|
|
{ELSE, "ELSE", 1},
|
|
|
|
{END, "END", 1},
|
|
|
|
{ENTRY_POINT, "ENTRY_POINT", 1},
|
|
|
|
{ESCAPE, "ESCAPE", 1},
|
|
|
|
{EXCEPTION, "EXCEPTION", 1},
|
|
|
|
{EXECUTE, "EXECUTE", 1},
|
|
|
|
{EXISTS, "EXISTS", 1},
|
|
|
|
{EXIT, "EXIT", 1},
|
|
|
|
{EXTERNAL, "EXTERNAL", 1},
|
|
|
|
{EXTRACT, "EXTRACT", 2},
|
2003-11-02 13:28:30 +01:00
|
|
|
{FETCH, "FETCH", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{KW_FILE, "FILE", 1},
|
|
|
|
{FILTER, "FILTER", 1},
|
2002-07-30 09:23:40 +02:00
|
|
|
{FIRST, "FIRST", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{KW_FLOAT, "FLOAT", 1},
|
|
|
|
{FOR, "FOR", 1},
|
|
|
|
{FOREIGN, "FOREIGN", 1},
|
|
|
|
{FREE_IT, "FREE_IT", 1},
|
|
|
|
{FROM, "FROM", 1},
|
|
|
|
{FULL, "FULL", 1},
|
|
|
|
{FUNCTION, "FUNCTION", 1},
|
|
|
|
{GDSCODE, "GDSCODE", 1},
|
|
|
|
{GENERATOR, "GENERATOR", 1},
|
|
|
|
{GEN_ID, "GEN_ID", 1},
|
|
|
|
{GRANT, "GRANT", 1},
|
|
|
|
{GROUP, "GROUP", 1},
|
|
|
|
{GROUP_COMMIT_WAIT, "GROUP_COMMIT_WAIT_TIME", 1},
|
|
|
|
{HAVING, "HAVING", 1},
|
|
|
|
{HOUR, "HOUR", 2},
|
|
|
|
{IF, "IF", 1},
|
2003-07-02 02:16:56 +02:00
|
|
|
{KW_IN, "IN", 1},
|
2002-07-29 17:37:59 +02:00
|
|
|
{INACTIVE, "INACTIVE", 1},
|
|
|
|
{INDEX, "INDEX", 1},
|
|
|
|
{INNER, "INNER", 1},
|
|
|
|
{INPUT_TYPE, "INPUT_TYPE", 1},
|
|
|
|
{INSERT, "INSERT", 1},
|
2003-01-15 13:00:33 +01:00
|
|
|
{INSERTING, "INSERTING", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{KW_INT, "INT", 1},
|
|
|
|
{INTEGER, "INTEGER", 1},
|
|
|
|
{INTO, "INTO", 1},
|
|
|
|
{IS, "IS", 1},
|
|
|
|
{ISOLATION, "ISOLATION", 1},
|
|
|
|
{JOIN, "JOIN", 1},
|
|
|
|
{KEY, "KEY", 1},
|
2002-09-10 20:28:23 +02:00
|
|
|
{LAST, "LAST", 2},
|
2002-12-18 16:01:50 +01:00
|
|
|
{LEAVE, "LEAVE", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{LEFT, "LEFT", 1},
|
|
|
|
{LENGTH, "LENGTH", 1},
|
|
|
|
{LEVEL, "LEVEL", 1},
|
|
|
|
{LIKE, "LIKE", 1},
|
|
|
|
{LOGFILE, "LOGFILE", 1},
|
|
|
|
{LOG_BUF_SIZE, "LOG_BUFFER_SIZE", 1},
|
|
|
|
{KW_LONG, "LONG", 1},
|
|
|
|
{MANUAL, "MANUAL", 1},
|
|
|
|
{MAXIMUM, "MAX", 1},
|
|
|
|
{MAX_SEGMENT, "MAXIMUM_SEGMENT", 1},
|
|
|
|
{MERGE, "MERGE", 1},
|
|
|
|
{MESSAGE, "MESSAGE", 1},
|
|
|
|
{MINIMUM, "MIN", 1},
|
|
|
|
{MINUTE, "MINUTE", 2},
|
|
|
|
{MODULE_NAME, "MODULE_NAME", 1},
|
|
|
|
{MONTH, "MONTH", 2},
|
|
|
|
{NAMES, "NAMES", 1},
|
|
|
|
{NATIONAL, "NATIONAL", 1},
|
|
|
|
{NATURAL, "NATURAL", 1},
|
|
|
|
{NCHAR, "NCHAR", 1},
|
|
|
|
{NO, "NO", 1},
|
|
|
|
{NOT, "NOT", 1},
|
2002-08-03 17:27:20 +02:00
|
|
|
{NULLIF, "NULLIF", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{KW_NULL, "NULL", 1},
|
2002-09-10 20:28:23 +02:00
|
|
|
{NULLS, "NULLS", 2},
|
2002-10-29 21:20:44 +01:00
|
|
|
{LOCK, "LOCK", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{KW_NUMERIC, "NUMERIC", 1},
|
|
|
|
{NUM_LOG_BUFS, "NUM_LOG_BUFFERS", 1},
|
|
|
|
{OF, "OF", 1},
|
|
|
|
{ON, "ON", 1},
|
|
|
|
{ONLY, "ONLY", 1},
|
2003-11-02 13:28:30 +01:00
|
|
|
{OPEN, "OPEN", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{OPTION, "OPTION", 1},
|
|
|
|
{OR, "OR", 1},
|
|
|
|
{ORDER, "ORDER", 1},
|
|
|
|
{OUTER, "OUTER", 1},
|
|
|
|
{OUTPUT_TYPE, "OUTPUT_TYPE", 1},
|
|
|
|
{OVERFLOW, "OVERFLOW", 1},
|
|
|
|
{PAGE, "PAGE", 1},
|
|
|
|
{PAGES, "PAGES", 1},
|
2004-01-26 08:06:37 +01:00
|
|
|
{KW_PAGE_SIZE, "PAGE_SIZE", 1},
|
2002-07-29 17:37:59 +02:00
|
|
|
{PARAMETER, "PARAMETER", 1},
|
|
|
|
{PASSWORD, "PASSWORD", 1},
|
|
|
|
{PLAN, "PLAN", 1},
|
|
|
|
{POSITION, "POSITION", 1},
|
|
|
|
{POST_EVENT, "POST_EVENT", 1},
|
|
|
|
{PRECISION, "PRECISION", 1},
|
|
|
|
{PRIMARY, "PRIMARY", 1},
|
|
|
|
{PRIVILEGES, "PRIVILEGES", 1},
|
|
|
|
{PROCEDURE, "PROCEDURE", 1},
|
|
|
|
{PROTECTED, "PROTECTED", 1},
|
|
|
|
{RAW_PARTITIONS, "RAW_PARTITIONS", 1},
|
|
|
|
{DB_KEY, "RDB$DB_KEY", 1},
|
|
|
|
{READ, "READ", 1},
|
|
|
|
{REAL, "REAL", 1},
|
|
|
|
{VERSION, "RECORD_VERSION", 1},
|
2002-07-30 09:23:40 +02:00
|
|
|
{RECREATE, "RECREATE", 2},
|
2003-06-10 15:40:19 +02:00
|
|
|
{REFERENCES, "REFERENCES", 1},
|
|
|
|
{RELEASE, "RELEASE", 2},
|
2003-11-28 07:48:34 +01:00
|
|
|
{RESERVING, "RESERV", 1}, // Alias of RESERVING
|
2002-07-29 17:37:59 +02:00
|
|
|
{RESERVING, "RESERVING", 1},
|
|
|
|
{RESTRICT, "RESTRICT", 1},
|
|
|
|
{RETAIN, "RETAIN", 1},
|
|
|
|
{RETURNING_VALUES, "RETURNING_VALUES", 1},
|
|
|
|
{RETURNS, "RETURNS", 1},
|
|
|
|
{REVOKE, "REVOKE", 1},
|
|
|
|
{RIGHT, "RIGHT", 1},
|
|
|
|
{ROLE, "ROLE", 1},
|
2002-07-30 09:23:40 +02:00
|
|
|
{ROLLBACK, "ROLLBACK", 1},
|
2003-04-06 13:20:24 +02:00
|
|
|
{ROW_COUNT, "ROW_COUNT", 2},
|
2003-11-07 15:10:16 +01:00
|
|
|
{ROWS, "ROWS", 2},
|
2002-10-29 21:20:44 +01:00
|
|
|
{SAVEPOINT, "SAVEPOINT", 2},
|
2003-11-28 07:48:34 +01:00
|
|
|
{DATABASE, "SCHEMA", 1}, // Alias of DATABASE
|
2002-07-29 17:37:59 +02:00
|
|
|
{SECOND, "SECOND", 2},
|
|
|
|
{SEGMENT, "SEGMENT", 1},
|
|
|
|
{SELECT, "SELECT", 1},
|
|
|
|
{SET, "SET", 1},
|
|
|
|
{SHADOW, "SHADOW", 1},
|
2003-07-02 02:16:56 +02:00
|
|
|
{KW_SHARED, "SHARED", 1},
|
2002-07-29 17:37:59 +02:00
|
|
|
{SINGULAR, "SINGULAR", 1},
|
2003-04-01 01:40:53 +02:00
|
|
|
{KW_SIZE, "SIZE", 1},
|
2002-07-30 09:23:40 +02:00
|
|
|
{SKIP, "SKIP", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{SMALLINT, "SMALLINT", 1},
|
|
|
|
{SNAPSHOT, "SNAPSHOT", 1},
|
|
|
|
{SOME, "SOME", 1},
|
|
|
|
{SORT, "SORT", 1},
|
|
|
|
{SQLCODE, "SQLCODE", 1},
|
|
|
|
{STABILITY, "STABILITY", 1},
|
2002-07-30 09:23:40 +02:00
|
|
|
{STARTING, "STARTING", 1},
|
2003-11-28 07:48:34 +01:00
|
|
|
{STARTING, "STARTS", 1}, // Alias of STARTING
|
2003-03-16 13:04:13 +01:00
|
|
|
{STATEMENT, "STATEMENT", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{STATISTICS, "STATISTICS", 1},
|
2002-07-30 09:23:40 +02:00
|
|
|
{SUBSTRING, "SUBSTRING", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{SUB_TYPE, "SUB_TYPE", 1},
|
|
|
|
{SUM, "SUM", 1},
|
|
|
|
{SUSPEND, "SUSPEND", 1},
|
|
|
|
{TABLE, "TABLE", 1},
|
|
|
|
{THEN, "THEN", 1},
|
|
|
|
{TIME, "TIME", 2},
|
|
|
|
{TIMESTAMP, "TIMESTAMP", 2},
|
|
|
|
{TO, "TO", 1},
|
|
|
|
{TRANSACTION, "TRANSACTION", 1},
|
|
|
|
{TRIGGER, "TRIGGER", 1},
|
|
|
|
{TYPE, "TYPE", 2},
|
|
|
|
{UNCOMMITTED, "UNCOMMITTED", 1},
|
|
|
|
{UNION, "UNION", 1},
|
|
|
|
{UNIQUE, "UNIQUE", 1},
|
|
|
|
{UPDATE, "UPDATE", 1},
|
2003-01-15 13:00:33 +01:00
|
|
|
{UPDATING, "UPDATING", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{KW_UPPER, "UPPER", 1},
|
|
|
|
{USER, "USER", 1},
|
2002-09-04 14:09:25 +02:00
|
|
|
{USING, "USING", 2},
|
2002-07-29 17:37:59 +02:00
|
|
|
{KW_VALUE, "VALUE", 1},
|
|
|
|
{VALUES, "VALUES", 1},
|
|
|
|
{VARCHAR, "VARCHAR", 1},
|
|
|
|
{VARIABLE, "VARIABLE", 1},
|
|
|
|
{VARYING, "VARYING", 1},
|
|
|
|
{VIEW, "VIEW", 1},
|
|
|
|
{WAIT, "WAIT", 1},
|
|
|
|
{WEEKDAY, "WEEKDAY", 2},
|
|
|
|
{WHEN, "WHEN", 1},
|
|
|
|
{WHERE, "WHERE", 1},
|
|
|
|
{WHILE, "WHILE", 1},
|
|
|
|
{WITH, "WITH", 1},
|
|
|
|
{WORK, "WORK", 1},
|
|
|
|
{WRITE, "WRITE", 1},
|
2002-07-30 09:23:40 +02:00
|
|
|
{YEAR, "YEAR", 2},
|
|
|
|
{YEARDAY, "YEARDAY", 2},
|
2004-03-07 08:58:55 +01:00
|
|
|
{NOT_LSS, "^<", 1}, // Alias of !<
|
|
|
|
{NEQ, "^=", 1}, // Alias of !=
|
|
|
|
{NOT_GTR, "^>", 1}, // Alias of !>
|
2002-07-29 17:37:59 +02:00
|
|
|
{CONCATENATE, "||", 1},
|
2004-03-07 08:58:55 +01:00
|
|
|
{NOT_LSS, "~<", 1}, // Alias of !<
|
|
|
|
{NEQ, "~=", 1}, // Alias of !=
|
|
|
|
{NOT_GTR, "~>", 1}, // Alias of !>
|
2002-07-30 09:23:40 +02:00
|
|
|
{0, 0, 0}
|
|
|
|
};
|
2002-07-29 17:37:59 +02:00
|
|
|
|
|
|
|
/* This method is currently used in isql/isql.epp to check if a
|
|
|
|
user field is a reserved word, and hence needs to be quoted.
|
|
|
|
Obviously a hash table would make this a little quicker.
|
|
|
|
|
|
|
|
MOD 29-June-2002
|
|
|
|
*/
|
|
|
|
|
2003-11-18 08:58:35 +01:00
|
|
|
bool KEYWORD_stringIsAToken(const char* in_str)
|
2002-07-29 17:37:59 +02:00
|
|
|
{
|
2003-11-18 08:58:35 +01:00
|
|
|
const TOK* tok_ptr = tokens;
|
|
|
|
while (tok_ptr->tok_string) {
|
|
|
|
if (!strcmp(tok_ptr->tok_string, in_str)) {
|
2002-07-29 17:37:59 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
++tok_ptr;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2003-02-13 10:33:26 +01:00
|
|
|
const TOK* KEYWORD_getTokens()
|
2002-07-29 17:37:59 +02:00
|
|
|
{
|
|
|
|
return tokens;
|
|
|
|
}
|
2003-11-18 08:58:35 +01:00
|
|
|
|