Location: PHPKode > projects > Pieforms > pieforms-php5-0.2.2/doc/geshi/geshi/languages/sql/sql.php
 * GeSHi - Generic Syntax Highlighter
 * <pre>
 *   File:   geshi/languages/sql/sql.php
 *   Author: Nigel McNie
 *   E-mail: hide@address.com
 * </pre>
 * For information on how to use GeSHi, please consult the documentation
 * found in the docs/ directory, or online at http://geshi.org/docs/
 * This program is part of GeSHi.
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  GNU General Public License for more details.
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 * @package    geshi
 * @subpackage lang
 * @author     Nigel McNie
 * @copyright  (C) 2006 Nigel McNie
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL
 * @version    $Id: sql.php 907 2007-02-18 00:59:23Z oracleshinoda $

// SQL:
//  Statements separated by ;
//  Statements contain tokens
//  Tokens can be:
//    - key word
//    - identifier (name)
//    - quoted identifier
//    - literal (constant)
//    - special character symbol
//  Keywords and identifiers have the same lexical structure!
// TODO:
//   Merge all keywords back into one array. The code parser will instead
//   be written to be much smarter about how it tells between an identifier
//   and a keyword.
function geshi_sql_sql (&$context)
    $context->addChild('quoted_identifier', 'string');
    $context->addChild('string', 'string');

        'ABORT', 'ABS', 'ABSOLUTE', 'ACCESS', 'ADA', 'ADD', 'ADMIN',
        'ANALYZE', 'AND', 'ANY', 'ARE', 'AS', 'ASC', 'ASENSITIVE',
        'BITVAR', 'BIT_LENGTH',
        'DISTINCT', 'DO', 'DOMAIN', 'DROP', 'DYNAMIC',
        'FALSE', 'FETCH', 'FINAL', 'FIRST', 'FOR', 'FORCE', 'FOREIGN',
        'LEFT', 'LENGTH', 'LESS', 'LEVEL', 'LIKE', 'LILMIT', 'LISTEN', 'LOAD',
        'NULLIF', 'OBJECT', 'OCTET_LENGTH', 'OF', 'OFF',
        'WITHOUT', 'WORK', 'WRITE', 'YEAR', 'ZONE' 
    ), 'keyword/reserved');

    // Need to take nonreserved keywords out of the above array and put here...
    // DEPTH, PATH and SEQUENCE are reserved in SQL99 but not in postgres
    // (so presumably not elsewhere)
    // ACTION, MODULE and SECTION are reserved in SQL92 and 99 but not in
    // postgres
    // TIME is reserved in SQL92 and 99 and especially restricted in postgres
    // @todo [blocking 1.2.0] codeparser for SQL should perhaps be smarter
    // where keywords/fieldnames are concerned...
    // e.g. detect CREATE TABLE rule, then make first stuff field names unless
    // it's ones like CONSTRAINT, PRIMARY etc...
    // @todo to add here:
    //  version, search, scale, data, year, rule, role, reads, 
    ), 'keyword/nonreserved');
    // This group contains datatypes, which are really keywords but we split
    // them out because people like them highlighted differently. For some
    // reason the postgres documentation I got these lists from did not list
    // "SERIAL" as a keyword...
        'ARRAY', 'BIGINT', 'BINARY', 'BIT', 'BLOB', 'BOOLEAN', 'CHAR',
        'VARCHAR', 'VARYING',
        // These types added but weren't listed in the postgres manual
        'INT8', 'SERIAL8', 'TEXT'
    ), 'type');
        ';', ':', '(', ')', '[', ']', ',', '.'
    ), 'symbol');
        '+', '-', '*', '/', '<', '>', '=', '~', '!', '@', '#', '%', '^', '&',
        '|', '`', '?'
    ), 'operator');
    $context->addRegexGroup('#(\$\d+)#', '$', array(
        1 => array('positional_parameter', false)

function geshi_sql_sql_quoted_identifier (&$context)
    $context->addDelimiters('"', '"');

function geshi_sql_sql_string (&$context)
    // This context starts with a ' and ends with one too
    $context->addDelimiters(array("'", '"'), array("'", '"'));

    // If a ' occurs it can escape. There's nothing else listed as escape
    // characters so it only escapes itself.

    // The backslash escape is not SQL standard but is used in many databases
    // regardless (e.g. mysql, postgresql)
    // This rule means that the backslash escapes the array given (inc. the regex)
    // As such, the definitions given here are perfectly in line with the new feature
    // The only other feature is that the escape char could actually be an array of them
    $context->addEscapeGroup('\\', array('b', 'f', 'n', 'r', 't', "'",

function geshi_sql_sql_bitstring (&$context)
    // @todo [blocking 1.2.0] use parser to detect that only 0 and 1 are in
    // the string
    $context->addDelimiters("B'", "'");

function geshi_sql_sql_hexstring (&$context)
    // @todo [blocking 1.2.0] use parser to detect that only 0 - F are in
    // the string
    $context->addDelimiters("X'", "'");

function geshi_sql_sql_single_comment (&$context)
    $context->addDelimiters('--', "\n");

function geshi_sql_sql_multi_comment (&$context)
    // @todo [blocking 1.1.5] sql multiline comments can be nested
    $context->addDelimiters('/*', '*/');
Return current item: Pieforms