// SQL highlighter, reswrved words from ISO SQL 92, 99, 2003 + MySQL + PostgreSQL


// tokens
Token=tnone
Token=tstring
Token=tcomment
Token=tident
Token=tinteger
Token=tfloat
Token=tresword
Token=turl
Token=twhitespace


// states
State=snormal
State=sstring1
State=sstring2
State=scomment1
State=scomment2


//delims
Delimiters=;.,:'"{}[]()?!@#$%^&*-+=|\/

// reswords
snormal 'ABSOLUTE'              snormal tresword
snormal 'ABSOLUTE'              snormal tresword
snormal 'ACTION'                snormal tresword
snormal 'ADD'                   snormal tresword
snormal 'AFTER'                 snormal tresword
snormal 'ALL'                   snormal tresword
snormal 'ALLOCATE'              snormal tresword
snormal 'ALTER'                 snormal tresword
snormal 'ANALYSE'               snormal tresword
snormal 'ANALYZE'               snormal tresword
snormal 'AND'                   snormal tresword
snormal 'ANY'                   snormal tresword
snormal 'ARE'                   snormal tresword
snormal 'ARRAY'                 snormal tresword
snormal 'AS'                    snormal tresword
snormal 'ASC'                   snormal tresword
snormal 'ASENSITIVE'            snormal tresword
snormal 'ASSERTION'             snormal tresword
snormal 'ASYMMETRIC'            snormal tresword
snormal 'AT'                    snormal tresword
snormal 'ATOMIC'                snormal tresword
snormal 'AUTHORIZATION'         snormal tresword
snormal 'AVG'                   snormal tresword
snormal 'BEFORE'                snormal tresword
snormal 'BEGIN'                 snormal tresword
snormal 'BETWEEN'               snormal tresword
snormal 'BIGINT'                snormal tresword
snormal 'BINARY'                snormal tresword
snormal 'BIT'                   snormal tresword
snormal 'BIT_LENGTH'            snormal tresword
snormal 'BLOB'                  snormal tresword
snormal 'BOOLEAN'               snormal tresword
snormal 'BOTH'                  snormal tresword
snormal 'BREADTH'               snormal tresword
snormal 'BY'                    snormal tresword
snormal 'CALL'                  snormal tresword
snormal 'CALLED'                snormal tresword
snormal 'CASCADE'               snormal tresword
snormal 'CASCADED'              snormal tresword
snormal 'CASE'                  snormal tresword
snormal 'CAST'                  snormal tresword
snormal 'CATALOG'               snormal tresword
snormal 'CHANGE'                snormal tresword
snormal 'CHAR'                  snormal tresword
snormal 'CHAR_LENGTH'           snormal tresword
snormal 'CHARACTER'             snormal tresword
snormal 'CHARACTER_LENGTH'      snormal tresword
snormal 'CHECK'                 snormal tresword
snormal 'CLOB'                  snormal tresword
snormal 'CLOSE'                 snormal tresword
snormal 'COALESCE'              snormal tresword
snormal 'COLLATE'               snormal tresword
snormal 'COLLATION'             snormal tresword
snormal 'COLUMN'                snormal tresword
snormal 'COMMIT'                snormal tresword
snormal 'CONDITION'             snormal tresword
snormal 'CONNECT'               snormal tresword
snormal 'CONNECTION'            snormal tresword
snormal 'CONSTRAINT'            snormal tresword
snormal 'CONSTRAINTS'           snormal tresword
snormal 'CONSTRUCTOR'           snormal tresword
snormal 'CONTAINS'              snormal tresword
snormal 'CONTINUE'              snormal tresword
snormal 'CONVERT'               snormal tresword
snormal 'CORRESPONDING'         snormal tresword
snormal 'COUNT'                 snormal tresword
snormal 'CREATE'                snormal tresword
snormal 'CROSS'                 snormal tresword
snormal 'CUBE'                  snormal tresword
snormal 'CURRENT'               snormal tresword
snormal 'CURRENT_DATE'          snormal tresword
snormal 'CURRENT_DEFAULT_TRANSFORM_GROUP'   snormal tresword
snormal 'CURRENT_PATH'          snormal tresword
snormal 'CURRENT_ROLE'          snormal tresword
snormal 'CURRENT_TIME'          snormal tresword
snormal 'CURRENT_TIMESTAMP'     snormal tresword
snormal 'CURRENT_TRANSFORM_GROUP_FOR_TYPE'  snormal tresword
snormal 'CURRENT_USER'          snormal tresword
snormal 'CURSOR'                snormal tresword
snormal 'CYCLE'                 snormal tresword
snormal 'DATA'                  snormal tresword
snormal 'DATABASE'              snormal tresword
snormal 'DATABASES'             snormal tresword
snormal 'DATE'                  snormal tresword
snormal 'DAY'                   snormal tresword
snormal 'DAY_HOUR'              snormal tresword
snormal 'DAY_MICROSECOND'       snormal tresword
snormal 'DAY_MINUTE'            snormal tresword
snormal 'DAY_SECOND'            snormal tresword
snormal 'DEALLOCATE'            snormal tresword
snormal 'DEC'                   snormal tresword
snormal 'DECIMAL'               snormal tresword
snormal 'DECLARE'               snormal tresword
snormal 'DEFAULT'               snormal tresword
snormal 'DEFERRABLE'            snormal tresword
snormal 'DEFERRED'              snormal tresword
snormal 'DELAYED'               snormal tresword
snormal 'DELETE'                snormal tresword
snormal 'DEPTH'                 snormal tresword
snormal 'DEREF'                 snormal tresword
snormal 'DESC'                  snormal tresword
snormal 'DESCRIBE'              snormal tresword
snormal 'DESCRIPTOR'            snormal tresword
snormal 'DETERMINISTIC'         snormal tresword
snormal 'DIAGNOSTICS'           snormal tresword
snormal 'DISCONNECT'            snormal tresword
snormal 'DISTINCT'              snormal tresword
snormal 'DISTINCTROW'           snormal tresword
snormal 'DIV'                   snormal tresword
snormal 'DO'                    snormal tresword
snormal 'DOMAIN'                snormal tresword
snormal 'DOUBLE'                snormal tresword
snormal 'DROP'                  snormal tresword
snormal 'DUAL'                  snormal tresword
snormal 'DYNAMIC'               snormal tresword
snormal 'EACH'                  snormal tresword
snormal 'ELEMENT'               snormal tresword
snormal 'ELSE'                  snormal tresword
snormal 'ELSEIF'                snormal tresword
snormal 'ENCLOSED'              snormal tresword
snormal 'END'                   snormal tresword
snormal 'EQUALS'                snormal tresword
snormal 'ESCAPE'                snormal tresword
snormal 'ESCAPED'               snormal tresword
snormal 'EXCEPT'                snormal tresword
snormal 'EXCEPTION'             snormal tresword
snormal 'EXEC'                  snormal tresword
snormal 'EXECUTE'               snormal tresword
snormal 'EXISTS'                snormal tresword
snormal 'EXIT'                  snormal tresword
snormal 'EXPLAIN'               snormal tresword
snormal 'EXTERNAL'              snormal tresword
snormal 'EXTRACT'               snormal tresword
snormal 'FETCH'                 snormal tresword
snormal 'FILTER'                snormal tresword
snormal 'FIRST'                 snormal tresword
snormal 'FLOAT'                 snormal tresword
snormal 'FLOAT4'                snormal tresword
snormal 'FLOAT8'                snormal tresword
snormal 'FOR'                   snormal tresword
snormal 'FORCE'                 snormal tresword
snormal 'FOREIGN'               snormal tresword
snormal 'FOUND'                 snormal tresword
snormal 'FREE'                  snormal tresword
snormal 'FREEZE'                snormal tresword
snormal 'FROM'                  snormal tresword
snormal 'FULL'                  snormal tresword
snormal 'FULLTEXT'              snormal tresword
snormal 'FUNCTION'              snormal tresword
snormal 'GENERAL'               snormal tresword
snormal 'GET'                   snormal tresword
snormal 'GLOBAL'                snormal tresword
snormal 'GO'                    snormal tresword
snormal 'GOTO'                  snormal tresword
snormal 'GRANT'                 snormal tresword
snormal 'GROUP'                 snormal tresword
snormal 'GROUPING'              snormal tresword
snormal 'HANDLER'               snormal tresword
snormal 'HAVING'                snormal tresword
snormal 'HIGH_PRIORITY'         snormal tresword
snormal 'HOLD'                  snormal tresword
snormal 'HOUR'                  snormal tresword
snormal 'HOUR_MICROSECOND'      snormal tresword
snormal 'HOUR_MINUTE'           snormal tresword
snormal 'HOUR_SECOND'           snormal tresword
snormal 'IDENTITY'              snormal tresword
snormal 'IF'                    snormal tresword
snormal 'IGNORE'                snormal tresword
snormal 'ILIKE'                 snormal tresword
snormal 'IMMEDIATE'             snormal tresword
snormal 'IN'                    snormal tresword
snormal 'INDEX'                 snormal tresword
snormal 'INDICATOR'             snormal tresword
snormal 'INFILE'                snormal tresword
snormal 'INITIALLY'             snormal tresword
snormal 'INNER'                 snormal tresword
snormal 'INOUT'                 snormal tresword
snormal 'INPUT'                 snormal tresword
snormal 'INSENSITIVE'           snormal tresword
snormal 'INSERT'                snormal tresword
snormal 'INT'                   snormal tresword
snormal 'INT1'                  snormal tresword
snormal 'INT2'                  snormal tresword
snormal 'INT3'                  snormal tresword
snormal 'INT4'                  snormal tresword
snormal 'INT8'                  snormal tresword
snormal 'INTEGER'               snormal tresword
snormal 'INTERSECT'             snormal tresword
snormal 'INTERVAL'              snormal tresword
snormal 'INTO'                  snormal tresword
snormal 'IS'                    snormal tresword
snormal 'ISNULL'                snormal tresword
snormal 'ISOLATION'             snormal tresword
snormal 'ITERATE'               snormal tresword
snormal 'JOIN'                  snormal tresword
snormal 'KEY'                   snormal tresword
snormal 'KEYS'                  snormal tresword
snormal 'KILL'                  snormal tresword
snormal 'LABEL'                 snormal tresword
snormal 'LANGUAGE'              snormal tresword
snormal 'LARGE'                 snormal tresword
snormal 'LAST'                  snormal tresword
snormal 'LATERAL'               snormal tresword
snormal 'LEADING'               snormal tresword
snormal 'LEAVE'                 snormal tresword
snormal 'LEFT'                  snormal tresword
snormal 'LEVEL'                 snormal tresword
snormal 'LIKE'                  snormal tresword
snormal 'LIMIT'                 snormal tresword
snormal 'LINES'                 snormal tresword
snormal 'LOAD'                  snormal tresword
snormal 'LOCAL'                 snormal tresword
snormal 'LOCALTIME'             snormal tresword
snormal 'LOCALTIMESTAMP'        snormal tresword
snormal 'LOCATOR'               snormal tresword
snormal 'LOCK'                  snormal tresword
snormal 'LONG'                  snormal tresword
snormal 'LONGBLOB'              snormal tresword
snormal 'LONGTEXT'              snormal tresword
snormal 'LOOP'                  snormal tresword
snormal 'LOW_PRIORITY'          snormal tresword
snormal 'LOWER'                 snormal tresword
snormal 'MAP'                   snormal tresword
snormal 'MATCH'                 snormal tresword
snormal 'MAX'                   snormal tresword
snormal 'MEDIUMBLOB'            snormal tresword
snormal 'MEDIUMINT'             snormal tresword
snormal 'MEDIUMTEXT'            snormal tresword
snormal 'MEMBER'                snormal tresword
snormal 'MERGE'                 snormal tresword
snormal 'METHOD'                snormal tresword
snormal 'MIDDLEINT'             snormal tresword
snormal 'MIN'                   snormal tresword
snormal 'MINUTE'                snormal tresword
snormal 'MINUTE_MICROSECOND'    snormal tresword
snormal 'MINUTE_SECOND'         snormal tresword
snormal 'MOD'                   snormal tresword
snormal 'MODIFIES'              snormal tresword
snormal 'MODULE'                snormal tresword
snormal 'MONTH'                 snormal tresword
snormal 'MULTISET'              snormal tresword
snormal 'NAMES'                 snormal tresword
snormal 'NATIONAL'              snormal tresword
snormal 'NATURAL'               snormal tresword
snormal 'NCHAR'                 snormal tresword
snormal 'NCLOB'                 snormal tresword
snormal 'NEW'                   snormal tresword
snormal 'NEXT'                  snormal tresword
snormal 'NO'                    snormal tresword
snormal 'NO_WRITE_TO_BINLOG'    snormal tresword
snormal 'NONE'                  snormal tresword
snormal 'NOT'                   snormal tresword
snormal 'NOTNULL'               snormal tresword
snormal 'NULL'                  snormal tresword
snormal 'NULLIF'                snormal tresword
snormal 'NUMERIC'               snormal tresword
snormal 'OBJECT'                snormal tresword
snormal 'OCTET_LENGTH'          snormal tresword
snormal 'OF'                    snormal tresword
snormal 'OFF'                   snormal tresword
snormal 'OFFSET'                snormal tresword
snormal 'OLD'                   snormal tresword
snormal 'ON'                    snormal tresword
snormal 'ONLY'                  snormal tresword
snormal 'OPEN'                  snormal tresword
snormal 'OPTIMIZE'              snormal tresword
snormal 'OPTION'                snormal tresword
snormal 'OPTIONALLY'            snormal tresword
snormal 'OR'                    snormal tresword
snormal 'ORDER'                 snormal tresword
snormal 'ORDINALITY'            snormal tresword
snormal 'OUT'                   snormal tresword
snormal 'OUTER'                 snormal tresword
snormal 'OUTFILE'               snormal tresword
snormal 'OUTPUT'                snormal tresword
snormal 'OVER'                  snormal tresword
snormal 'OVERLAPS'              snormal tresword
snormal 'PAD'                   snormal tresword
snormal 'PARAMETER'             snormal tresword
snormal 'PARTIAL'               snormal tresword
snormal 'PARTITION'             snormal tresword
snormal 'PATH'                  snormal tresword
snormal 'PLACING'               snormal tresword
snormal 'POSITION'              snormal tresword
snormal 'PRECISION'             snormal tresword
snormal 'PREPARE'               snormal tresword
snormal 'PRESERVE'              snormal tresword
snormal 'PRIMARY'               snormal tresword
snormal 'PRIOR'                 snormal tresword
snormal 'PRIVILEGES'            snormal tresword
snormal 'PROCEDURE'             snormal tresword
snormal 'PUBLIC'                snormal tresword
snormal 'PURGE'                 snormal tresword
snormal 'RANGE'                 snormal tresword
snormal 'READ'                  snormal tresword
snormal 'READS'                 snormal tresword
snormal 'REAL'                  snormal tresword
snormal 'RECURSIVE'             snormal tresword
snormal 'REF'                   snormal tresword
snormal 'REFERENCES'            snormal tresword
snormal 'REFERENCING'           snormal tresword
snormal 'REGEXP'                snormal tresword
snormal 'RELATIVE'              snormal tresword
snormal 'RELEASE'               snormal tresword
snormal 'RENAME'                snormal tresword
snormal 'REPEAT'                snormal tresword
snormal 'REPLACE'               snormal tresword
snormal 'REQUIRE'               snormal tresword
snormal 'RESIGNAL'              snormal tresword
snormal 'RESTRICT'              snormal tresword
snormal 'RESULT'                snormal tresword
snormal 'RETURN'                snormal tresword
snormal 'RETURNS'               snormal tresword
snormal 'REVOKE'                snormal tresword
snormal 'RIGHT'                 snormal tresword
snormal 'RLIKE'                 snormal tresword
snormal 'ROLE'                  snormal tresword
snormal 'ROLLBACK'              snormal tresword
snormal 'ROLLUP'                snormal tresword
snormal 'ROUTINE'               snormal tresword
snormal 'ROW'                   snormal tresword
snormal 'ROWS'                  snormal tresword
snormal 'SAVEPOINT'             snormal tresword
snormal 'SCHEMA'                snormal tresword
snormal 'SCHEMAS'               snormal tresword
snormal 'SCOPE'                 snormal tresword
snormal 'SCROLL'                snormal tresword
snormal 'SEARCH'                snormal tresword
snormal 'SECOND'                snormal tresword
snormal 'SECOND_MICROSECOND'    snormal tresword
snormal 'SECTION'               snormal tresword
snormal 'SELECT'                snormal tresword
snormal 'SENSITIVE'             snormal tresword
snormal 'SEPARATOR'             snormal tresword
snormal 'SESSION'               snormal tresword
snormal 'SESSION_USER'          snormal tresword
snormal 'SET'                   snormal tresword
snormal 'SETS'                  snormal tresword
snormal 'SHOW'                  snormal tresword
snormal 'SIGNAL'                snormal tresword
snormal 'SIMILAR'               snormal tresword
snormal 'SIZE'                  snormal tresword
snormal 'SMALLINT'              snormal tresword
snormal 'SOME'                  snormal tresword
snormal 'SONAME'                snormal tresword
snormal 'SPACE'                 snormal tresword
snormal 'SPATIAL'               snormal tresword
snormal 'SPECIFIC'              snormal tresword
snormal 'SPECIFICTYPE'          snormal tresword
snormal 'SQL'                   snormal tresword
snormal 'SQL_BIG_RESULT'        snormal tresword
snormal 'SQL_CALC_FOUND_ROWS'   snormal tresword
snormal 'SQL_SMALL_RESULT'      snormal tresword
snormal 'SQLCODE'               snormal tresword
snormal 'SQLERROR'              snormal tresword
snormal 'SQLEXCEPTION'          snormal tresword
snormal 'SQLSTATE'              snormal tresword
snormal 'SQLWARNING'            snormal tresword
snormal 'SSL'                   snormal tresword
snormal 'START'                 snormal tresword
snormal 'STARTING'              snormal tresword
snormal 'STATE'                 snormal tresword
snormal 'STATIC'                snormal tresword
snormal 'STRAIGHT_JOIN'         snormal tresword
snormal 'SUBMULTISET'           snormal tresword
snormal 'SUBSTRING'             snormal tresword
snormal 'SUM'                   snormal tresword
snormal 'SYMMETRIC'             snormal tresword
snormal 'SYSTEM'                snormal tresword
snormal 'SYSTEM_USER'           snormal tresword
snormal 'TABLE'                 snormal tresword
snormal 'TABLESAMPLE'           snormal tresword
snormal 'TEMPORARY'             snormal tresword
snormal 'TERMINATED'            snormal tresword
snormal 'THEN'                  snormal tresword
snormal 'TIME'                  snormal tresword
snormal 'TIMESTAMP'             snormal tresword
snormal 'TIMEZONE_HOUR'         snormal tresword
snormal 'TIMEZONE_MINUTE'       snormal tresword
snormal 'TINYBLOB'              snormal tresword
snormal 'TINYINT'               snormal tresword
snormal 'TINYTEXT'              snormal tresword
snormal 'TO'                    snormal tresword
snormal 'TRAILING'              snormal tresword
snormal 'TRANSACTION'           snormal tresword
snormal 'TRANSLATE'             snormal tresword
snormal 'TRANSLATION'           snormal tresword
snormal 'TREAT'                 snormal tresword
snormal 'TRIGGER'               snormal tresword
snormal 'TRIM'                  snormal tresword
snormal 'UNDER'                 snormal tresword
snormal 'UNDO'                  snormal tresword
snormal 'UNION'                 snormal tresword
snormal 'UNIQUE'                snormal tresword
snormal 'UNKNOWN'               snormal tresword
snormal 'UNLOCK'                snormal tresword
snormal 'UNNEST'                snormal tresword
snormal 'UNSIGNED'              snormal tresword
snormal 'UNTIL'                 snormal tresword
snormal 'UPDATE'                snormal tresword
snormal 'UPGRADE'               snormal tresword
snormal 'UPPER'                 snormal tresword
snormal 'USAGE'                 snormal tresword
snormal 'USE'                   snormal tresword
snormal 'USER'                  snormal tresword
snormal 'USING'                 snormal tresword
snormal 'UTC_DATE'              snormal tresword
snormal 'UTC_TIME'              snormal tresword
snormal 'UTC_TIMESTAMP'         snormal tresword
snormal 'VALUE'                 snormal tresword
snormal 'VALUES'                snormal tresword
snormal 'VARBINARY'             snormal tresword
snormal 'VARCHAR'               snormal tresword
snormal 'VARCHARACTER'          snormal tresword
snormal 'VARYING'               snormal tresword
snormal 'VERBOSE'               snormal tresword
snormal 'VIEW'                  snormal tresword
snormal 'WHEN'                  snormal tresword
snormal 'WHENEVER'              snormal tresword
snormal 'WHERE'                 snormal tresword
snormal 'WHILE'                 snormal tresword
snormal 'WINDOW'                snormal tresword
snormal 'WITH'                  snormal tresword
snormal 'WITHIN'                snormal tresword
snormal 'WITHOUT'               snormal tresword
snormal 'WORK'                  snormal tresword
snormal 'WRITE'                 snormal tresword
snormal 'XOR'                   snormal tresword
snormal 'YEAR'                  snormal tresword
snormal 'YEAR_MONTH'            snormal tresword
snormal 'ZONE'                  snormal tresword
snormal 'FALSE'                 snormal tresword
snormal 'TRUE'                  snormal tresword


// numbers
snormal [0-9][0-9]*                            snormal  tinteger
snormal [1-9][0-9]*\.[0-9]*                    snormal  tfloat
snormal [1-9][0-9]*{\.[0-9]+}|e{[\+\-]}|[0-9]+ snormal  tfloat

//idents
snormal   [a-˙_A-Ż][%a-˙_A-Ż0-9]*  snormal   tident

//white space
//snormal #32*                      snormal    twhitespace

//comments
snormal   \#                      scomment1  tcomment
snormal    --                     scomment1  tcomment
scomment1  .*                     snormal    tcomment
scomment1 $                       snormal    tcomment
snormal   /\*                     scomment2  tcomment
scomment2 [^\*]*                  scomment2  tcomment
scomment2 \*[^/]                  scomment2  tcomment
scomment2 [\*]*/                  snormal    tcomment


//strings
snormal    \"                     sstring1   tstring
sstring1   [^\"]*                 sstring1   tstring
sstring1   \"                     snormal    tstring
sstring1   \"\"                   sstring1   tstring
sstring1   \\\\                   sstring1   tstring
sstring1   \\\"                   sstring1   tstring
sstring1   \\[^\\]                sstring1   tstring
//sstring1   $                    snormal    tstring

snormal    \'                     sstring2   tstring
sstring2   [^\']*                 sstring2   tstring
sstring2   \'                     snormal    tstring
sstring2   \'\'                   sstring2   tstring
sstring2   \\\\                   sstring2   tstring
sstring2   \\\'                   sstring2   tstring
sstring2   \\[^\\]                sstring2   tstring 
//sstring2   $                    snormal    tstring
