/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtXmlPatterns module of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and The Qt Company. For licensing terms
** and conditions see https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU Lesser General Public License Usage
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 3 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL3 included in the
** packaging of this file. Please review the following information to
** ensure the GNU Lesser General Public License version 3 requirements
** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 2.0 or (at your option) the GNU General
** Public license version 3 or any later version approved by the KDE Free
** Qt Foundation. The licenses are as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-2.0.html and
** https://www.gnu.org/licenses/gpl-3.0.html.
**
** $QT_END_LICENSE$
**
****************************************************************************/

/**
 * @file qtokenlookup.cpp
 * @short This file is generated from TokenLookup.gperf and contains
 * TokenLookup, a class housing a perfect hash function class for XQuery's keywords.
 * @author Frans Englich <frans.englich@nokia.com>
 */

/**
 * @class QPatternist::TokenLookup
 * @short Contains a perfect hash function for XQuery's keywords.
 */

/**
 * @fn QPatternist::TokenLookup::value(const QString &keyword)
 * Looks up @p keyword and returns a pointer to the corresponding value.
 *
 * If @p keyword is not contained in the hash, a null pointer is returned.
 */

/**
 * @file
 * @short This file is the @c gperf declaration for generating TokenLookup.cpp.
 *
 * You generate TokenLookup.cpp by running:
 *
 * @code
 * gperf TokenLookup.gperf --output-file=../src/parser/TokenLookup.cpp
 * @endcode
 *
 * @c gperf generates a perfect hash function, which the tokenizer, src/parser/qxquerytokenizer.cpp,
 * uses for looking up XQuery keywords.
 *
 * @see <a href="http://en.wikipedia.org/wiki/Perfect_hash_function">Perfect hash function, Wikipedia</a>
 * @see <a href="http://www.gnu.org/software/gperf/manual/gperf.html">Perfect Hash Function Generator</a>
 */

%language=C++

/* Declare data const such that the compiler can put them
 * in the read-only section. */
%readonly-tables

/* Yes, for crisps sake, we want enums instead of macros. */
%enum

/* Rename in_word_set to value, such that it's more
 * like QHash::value(). */
%define lookup-function-name value

/* Rename Perfect_Hash to TokenLookup. More Qt/Patternist'ish. */
%define class-name TokenLookup

/* Output initializers for the TokenMap struct. Note the lack
 * of a space between the comma and ERROR. Anything else is
 * a syntax error to gperf. Rocket science. */
%define initializer-suffix ,T_ERROR

%struct-type

struct TokenMap
{
    const char *name;
    const Tokenizer::TokenType token;
}

%{

QT_BEGIN_NAMESPACE

namespace QPatternist
{

%}

/* The strings below are in UTF-16 encoding. Subsequently, each ASCII
 * character is stored as the ASCII character, followed by a null byte.
 * Sorted alphabetically. */
%%
"ancestor",                 T_ANCESTOR
"ancestor-or-self",         T_ANCESTOR_OR_SELF
"and",                      T_AND
"as",                       T_AS
"ascending",                T_ASCENDING
"assign",                   T_ASSIGN
"at",                       T_AT
"attribute",                T_ATTRIBUTE
"base-uri",                 T_BASEURI
"boundary-space",           T_BOUNDARY_SPACE
"by",                       T_BY
"case",                     T_CASE
"castable",                 T_CASTABLE
"cast",                     T_CAST
"child",                    T_CHILD
"collation",                T_COLLATION
"comment",                  T_COMMENT
"construction",             T_CONSTRUCTION
"copy-namespaces",          T_COPY_NAMESPACES
"declare",                  T_DECLARE
"default",                  T_DEFAULT
"descendant",               T_DESCENDANT
"descendant-or-self",       T_DESCENDANT_OR_SELF
"descending",               T_DESCENDING
"div",                      T_DIV
"document",                 T_DOCUMENT
"document-node",            T_DOCUMENT_NODE
"element",                  T_ELEMENT
"else",                     T_ELSE
"empty",                    T_EMPTY
"empty-sequence",           T_EMPTY_SEQUENCE
"encoding",                 T_ENCODING
"eq",                       T_EQ
"every",                    T_EVERY
"except",                   T_EXCEPT
"external",                 T_EXTERNAL
"following",                T_FOLLOWING
"following-sibling",        T_FOLLOWING_SIBLING
"follows",                  T_FOLLOWS
"for",                      T_FOR
"function",                 T_FUNCTION
"ge",                       T_GE
"greatest",                 T_GREATEST
"gt",                       T_GT
"idiv",                     T_IDIV
"if",                       T_IF
"import",                   T_IMPORT
"inherit",                  T_INHERIT
"in",                       T_IN
"instance",                 T_INSTANCE
"intersect",                T_INTERSECT
"is",                       T_IS
"item",                     T_ITEM
"lax",                      T_LAX
"least",                    T_LEAST
"le",                       T_LE
"let",                      T_LET
"lt",                       T_LT
"mod",                      T_MOD
"module",                   T_MODULE
"namespace",                T_NAMESPACE
"ne",                       T_NE
"node",                     T_NODE
"no-inherit",               T_NO_INHERIT
"no-preserve",              T_NO_PRESERVE
"of",                       T_OF
"option",                   T_OPTION
"ordered",                  T_ORDERED
"ordering",                 T_ORDERING
"order",                    T_ORDER
"or",                       T_OR
"parent",                   T_PARENT
"precedes",                 T_PRECEDES
"preceding",                T_PRECEDING
"preceding-sibling",        T_PRECEDING_SIBLING
"preserve",                 T_PRESERVE
"processing-instruction",   T_PROCESSING_INSTRUCTION
"return",                   T_RETURN
"satisfies",                T_SATISFIES
"schema-attribute",         T_SCHEMA_ATTRIBUTE
"schema-element",           T_SCHEMA_ELEMENT
"schema",                   T_SCHEMA
"self",                     T_SELF
"some",                     T_SOME
"stable",                   T_STABLE
"strict",                   T_STRICT
"strip",                    T_STRIP
"text",                     T_TEXT
"then",                     T_THEN
"to",                       T_TO
"treat",                    T_TREAT
"typeswitch",               T_TYPESWITCH
"union",                    T_UNION
"unordered",                T_UNORDERED
"validate",                 T_VALIDATE
"variable",                 T_VARIABLE
"version",                  T_VERSION
"where",                    T_WHERE
"xquery",                   T_XQUERY
%%

} /* Close the QPatternist namespace. */

QT_END_NAMESPACE
