//
// Macro definitions. Parameters may be specified and the replacement text terminates with the end of
// line (watch trailing blanks).
//
#define st_DEFAULT          0
#define st_COMMENT          1
#define st_IDENTIFIER       2
#define st_STRING           3
#define st_NUMBER           4
#define st_SYMBOL           5
#define st_RESERVED         6
#define st_COMMENT_LINE     7
#define st_COMMENT_STAR     8

#define st_CUSTOM           10

#define st_CUST_KEYWORD     11
#define st_CUST_COMMENT     12
#define st_CUST_STRING      13
#define st_CUST_NUMBER      14
#define st_CUST_SYMBOL      15


#define _non_alpha_         '[^_A-Za-z0-9\xFF]'
#define _all_chars_         '[\x00-\xFF]'
#define _no_chars_          '[]'
#define _dont_care_         _all_chars_

%%language
Name                        = 'PLSQL'
Gutter                      = _DEFAULT_GUTTER

EditableStyles              ('Reserved word', st_RESERVED),
                            ('Comment',       st_COMMENT),
                            ('Identifier',    st_IDENTIFIER),
                            ('String',        st_STRING),
                            ('Number',        st_NUMBER),
                            ('Symbols',       st_SYMBOL),
                            ('Default',       st_DEFAULT)

%%words
'--'              _dont_care_       st_COMMENT_LINE
'/*'              _dont_care_       st_COMMENT_STAR
'!'               _dont_care_       st_SYMBOL
'*'               _dont_care_       st_SYMBOL
'('               _dont_care_       st_SYMBOL
')'               _dont_care_       st_SYMBOL
'-'               _dont_care_       st_SYMBOL
'='               _dont_care_       st_SYMBOL
'+'               _dont_care_       st_SYMBOL
';'               _dont_care_       st_SYMBOL
':'               _dont_care_       st_SYMBOL
'@'               _dont_care_       st_SYMBOL
'<'               _dont_care_       st_SYMBOL
'>'               _dont_care_       st_SYMBOL
','               _dont_care_       st_SYMBOL
'/'               _dont_care_       st_SYMBOL
'%'               _dont_care_       st_SYMBOL
'||'              _dont_care_       st_SYMBOL
'.'               _dont_care_       st_IDENTIFIER
// Multi-line strings
'\x27'            _dont_care_       st_STRING

'AFTER' _non_alpha_ st_RESERVED
'AGENT' _non_alpha_ st_RESERVED
'AGGREGATE' _non_alpha_ st_RESERVED
'ALL' _non_alpha_ st_RESERVED
'ALTER' _non_alpha_ st_RESERVED
'AND' _non_alpha_ st_RESERVED
'ANY' _non_alpha_ st_RESERVED
'ARRAY' _non_alpha_ st_RESERVED
'AS' _non_alpha_ st_RESERVED
'ASC' _non_alpha_ st_RESERVED
'AUTHID' _non_alpha_ st_RESERVED
'AUTONOMOUS_TRANSACTION' _non_alpha_ st_RESERVED
'AVG' _non_alpha_ st_RESERVED
'BEFORE' _non_alpha_ st_RESERVED
'BEGIN' _non_alpha_ st_RESERVED
'BETWEEN' _non_alpha_ st_RESERVED
'BFILE' _non_alpha_ st_RESERVED
'BINARY_INTEGER' _non_alpha_ st_RESERVED
'BLOB' _non_alpha_ st_RESERVED
'BLOCK' _non_alpha_ st_RESERVED
'BODY' _non_alpha_ st_RESERVED
'BOOLEAN' _non_alpha_ st_RESERVED
'BULK' _non_alpha_ st_RESERVED
'BULK_EXCEPTIONS' _non_alpha_ st_RESERVED
'BULK_ROWCOUNT' _non_alpha_ st_RESERVED
'BY' _non_alpha_ st_RESERVED
'BYTE' _non_alpha_ st_RESERVED
'CALL' _non_alpha_ st_RESERVED
'CALLING' _non_alpha_ st_RESERVED
'CASE' _non_alpha_ st_RESERVED
'CAST' _non_alpha_ st_RESERVED
'CHAR' _non_alpha_ st_RESERVED
'CHARACTER' _non_alpha_ st_RESERVED
'CHECK' _non_alpha_ st_RESERVED
'CLASS' _non_alpha_ st_RESERVED
'CLOB' _non_alpha_ st_RESERVED
'CLOSE' _non_alpha_ st_RESERVED
'CLUSTER' _non_alpha_ st_RESERVED
'COLLECT' _non_alpha_ st_RESERVED
'COMMENT' _non_alpha_ st_RESERVED
'COMMIT' _non_alpha_ st_RESERVED
'COMMITTED' _non_alpha_ st_RESERVED
'COMPILE' _non_alpha_ st_RESERVED
'CONNECT' _non_alpha_ st_RESERVED
'CONSTANT' _non_alpha_ st_RESERVED
'CONSTRAINT' _non_alpha_ st_RESERVED
'CONSTRUCTOR' _non_alpha_ st_RESERVED
'CONTEXT' _non_alpha_ st_RESERVED
'COUNT' _non_alpha_ st_RESERVED
'CREATE' _non_alpha_ st_RESERVED
'CROSS' _non_alpha_ st_RESERVED
'CUBE' _non_alpha_ st_RESERVED
'CURRENT' _non_alpha_ st_RESERVED
'CURRENT_USER' _non_alpha_ st_RESERVED
'CURRVAL' _non_alpha_ st_RESERVED
'CURSOR' _non_alpha_ st_RESERVED
'DATABASE' _non_alpha_ st_RESERVED
'DATE' _non_alpha_ st_RESERVED
'DAY' _non_alpha_ st_RESERVED
'DEC' _non_alpha_ st_RESERVED
'DECIMAL' _non_alpha_ st_RESERVED
'DECLARE' _non_alpha_ st_RESERVED
'DEFAULT' _non_alpha_ st_RESERVED
'DEFINER' _non_alpha_ st_RESERVED
'DELETE' _non_alpha_ st_RESERVED
'DEREF' _non_alpha_ st_RESERVED
'DESC' _non_alpha_ st_RESERVED
'DETERMINISTIC' _non_alpha_ st_RESERVED
'DISTINCT' _non_alpha_ st_RESERVED
'DOUBLE' _non_alpha_ st_RESERVED
'EACH' _non_alpha_ st_RESERVED
'ELSE' _non_alpha_ st_RESERVED
'ELSIF' _non_alpha_ st_RESERVED
'END' _non_alpha_ st_RESERVED
'ERROR_CODE' _non_alpha_ st_RESERVED
'ERROR_INDEX' _non_alpha_ st_RESERVED
'ESCAPE' _non_alpha_ st_RESERVED
'EXCEPTION' _non_alpha_ st_RESERVED
'EXCEPTION_INIT' _non_alpha_ st_RESERVED
'EXCEPTIONS' _non_alpha_ st_RESERVED
'EXCLUSIVE' _non_alpha_ st_RESERVED
'EXECUTE' _non_alpha_ st_RESERVED
'EXISTS' _non_alpha_ st_RESERVED
'EXIT' _non_alpha_ st_RESERVED
'EXTEND' _non_alpha_ st_RESERVED
'EXTERNAL' _non_alpha_ st_RESERVED
'FALSE' _non_alpha_ st_RESERVED
'FETCH' _non_alpha_ st_RESERVED
'FINAL' _non_alpha_ st_RESERVED
'FIRST' _non_alpha_ st_RESERVED
'FLOAT' _non_alpha_ st_RESERVED
'FOR' _non_alpha_ st_RESERVED
'FORALL' _non_alpha_ st_RESERVED
'FOUND' _non_alpha_ st_RESERVED
'FROM' _non_alpha_ st_RESERVED
'FULL' _non_alpha_ st_RESERVED
'FUNCTION' _non_alpha_ st_RESERVED
'GOTO' _non_alpha_ st_RESERVED
'GROUP' _non_alpha_ st_RESERVED
'GROUPING' _non_alpha_ st_RESERVED
'HASH' _non_alpha_ st_RESERVED
'HAVING' _non_alpha_ st_RESERVED
'IF' _non_alpha_ st_RESERVED
'IMMEDIATE' _non_alpha_ st_RESERVED
'IN' _non_alpha_ st_RESERVED
'INDEX' _non_alpha_ st_RESERVED
'INDICES' _non_alpha_ st_RESERVED
'INNER' _non_alpha_ st_RESERVED
'INSERT' _non_alpha_ st_RESERVED
'INSTANTIABLE' _non_alpha_ st_RESERVED
'INSTEAD' _non_alpha_ st_RESERVED
'INT' _non_alpha_ st_RESERVED
'INTEGER' _non_alpha_ st_RESERVED
'INTERSECT' _non_alpha_ st_RESERVED
'INTERVAL' _non_alpha_ st_RESERVED
'INTO' _non_alpha_ st_RESERVED
'IS' _non_alpha_ st_RESERVED
'ISOLATION' _non_alpha_ st_RESERVED
'ISOPEN' _non_alpha_ st_RESERVED
'JAVA' _non_alpha_ st_RESERVED
'JOIN' _non_alpha_ st_RESERVED
'LANGUAGE' _non_alpha_ st_RESERVED
'LAST' _non_alpha_ st_RESERVED
'LEFT' _non_alpha_ st_RESERVED
'LEVEL' _non_alpha_ st_RESERVED
'LIBRARY' _non_alpha_ st_RESERVED
'LIKE' _non_alpha_ st_RESERVED
'LIMIT' _non_alpha_ st_RESERVED
'LOCAL' _non_alpha_ st_RESERVED
'LOCK' _non_alpha_ st_RESERVED
'LONG' _non_alpha_ st_RESERVED
'LOOP' _non_alpha_ st_RESERVED
'MAP' _non_alpha_ st_RESERVED
'MATCHED' _non_alpha_ st_RESERVED
'MAX' _non_alpha_ st_RESERVED
'MEMBER' _non_alpha_ st_RESERVED
'MERGE' _non_alpha_ st_RESERVED
'MIN' _non_alpha_ st_RESERVED
'MINUS' _non_alpha_ st_RESERVED
'MLSLABEL' _non_alpha_ st_RESERVED
'MOD' _non_alpha_ st_RESERVED
'MODE' _non_alpha_ st_RESERVED
'MONTH' _non_alpha_ st_RESERVED
'MULTISET' _non_alpha_ st_RESERVED
'NAME' _non_alpha_ st_RESERVED
'NAMED' _non_alpha_ st_RESERVED
'NATURAL' _non_alpha_ st_RESERVED
'NATURALN' _non_alpha_ st_RESERVED
'NCHAR' _non_alpha_ st_RESERVED
'NCLOB' _non_alpha_ st_RESERVED
'NESTED' _non_alpha_ st_RESERVED
'NEW' _non_alpha_ st_RESERVED
'NEXT' _non_alpha_ st_RESERVED
'NEXTVAL' _non_alpha_ st_RESERVED
'NOCOPY' _non_alpha_ st_RESERVED
'NOFORCE' _non_alpha_ st_RESERVED
'NOT' _non_alpha_ st_RESERVED
'NOTFOUND' _non_alpha_ st_RESERVED
'NOWAIT' _non_alpha_ st_RESERVED
'NULL' _non_alpha_ st_RESERVED
'NULLS' _non_alpha_ st_RESERVED
'NUMBER' _non_alpha_ st_RESERVED
'NUMERIC' _non_alpha_ st_RESERVED
'NVARCHAR2' _non_alpha_ st_RESERVED
'OBJECT' _non_alpha_ st_RESERVED
'OF' _non_alpha_ st_RESERVED
'OID' _non_alpha_ st_RESERVED
'OLD' _non_alpha_ st_RESERVED
'ON' _non_alpha_ st_RESERVED
'ONLY' _non_alpha_ st_RESERVED
'OPEN' _non_alpha_ st_RESERVED
'OPTION' _non_alpha_ st_RESERVED
'OR' _non_alpha_ st_RESERVED
'ORDER' _non_alpha_ st_RESERVED
'OTHERS' _non_alpha_ st_RESERVED
'OUT' _non_alpha_ st_RESERVED
'OUTER' _non_alpha_ st_RESERVED
'OVERRIDING' _non_alpha_ st_RESERVED
'PACKAGE' _non_alpha_ st_RESERVED
'PARALLEL_ENABLE' _non_alpha_ st_RESERVED
'PARAMETERS' _non_alpha_ st_RESERVED
'PARENT' _non_alpha_ st_RESERVED
'PARTITION' _non_alpha_ st_RESERVED
'PIPE' _non_alpha_ st_RESERVED
'PIPELINED' _non_alpha_ st_RESERVED
'PLS_INTEGER' _non_alpha_ st_RESERVED
'POSITIVE' _non_alpha_ st_RESERVED
'POSITIVEN' _non_alpha_ st_RESERVED
'PRAGMA' _non_alpha_ st_RESERVED
'PRAGMA_RESTRICT_REFERENCES' _non_alpha_ st_RESERVED
'PRECISION' _non_alpha_ st_RESERVED
'PRIOR' _non_alpha_ st_RESERVED
'PROCEDURE' _non_alpha_ st_RESERVED
'RAISE' _non_alpha_ st_RESERVED
'RANGE' _non_alpha_ st_RESERVED
'RAW' _non_alpha_ st_RESERVED
'READ' _non_alpha_ st_RESERVED
'REAL' _non_alpha_ st_RESERVED
'RECORD' _non_alpha_ st_RESERVED
'REF' _non_alpha_ st_RESERVED
'REFERENCING' _non_alpha_ st_RESERVED
'REPLACE' _non_alpha_ st_RESERVED
'RESOLVE' _non_alpha_ st_RESERVED
'RESOLVER' _non_alpha_ st_RESERVED
'RESOURCE' _non_alpha_ st_RESERVED
'RESTRICT_REFERENCES' _non_alpha_ st_RESERVED
'RESULT' _non_alpha_ st_RESERVED
'RETURN' _non_alpha_ st_RESERVED
'RETURNING' _non_alpha_ st_RESERVED
'REVERSE' _non_alpha_ st_RESERVED
'RIGHT' _non_alpha_ st_RESERVED
'RNDS' _non_alpha_ st_RESERVED
'RNPS' _non_alpha_ st_RESERVED
'ROLLBACK' _non_alpha_ st_RESERVED
'ROLLUP' _non_alpha_ st_RESERVED
'ROW' _non_alpha_ st_RESERVED
'ROWCOUNT' _non_alpha_ st_RESERVED
'ROWID' _non_alpha_ st_RESERVED
'ROWTYPE' _non_alpha_ st_RESERVED
'SAMPLE' _non_alpha_ st_RESERVED
'SAVE' _non_alpha_ st_RESERVED
'SAVEPOINT' _non_alpha_ st_RESERVED
'SCHEMA' _non_alpha_ st_RESERVED
'SECOND' _non_alpha_ st_RESERVED
'SEGMENT' _non_alpha_ st_RESERVED
'SELECT' _non_alpha_ st_RESERVED
'SELF' _non_alpha_ st_RESERVED
'SERIALIZABLE' _non_alpha_ st_RESERVED
'SERIALLY_REUSABLE' _non_alpha_ st_RESERVED
'SET' _non_alpha_ st_RESERVED
'SETS' _non_alpha_ st_RESERVED
'SHARE' _non_alpha_ st_RESERVED
'SIBLINGS' _non_alpha_ st_RESERVED
'SIGNTYPE' _non_alpha_ st_RESERVED
'SMALLINT' _non_alpha_ st_RESERVED
'SOURCE' _non_alpha_ st_RESERVED
'SQL' _non_alpha_ st_RESERVED
'SQLCODE' _non_alpha_ st_RESERVED
'SQLERRM' _non_alpha_ st_RESERVED
'STANDARD' _non_alpha_ st_RESERVED
'START' _non_alpha_ st_RESERVED
'STATEMENT' _non_alpha_ st_RESERVED
'STATIC' _non_alpha_ st_RESERVED
'STDDEV' _non_alpha_ st_RESERVED
'STRING' _non_alpha_ st_RESERVED
'SUBPARTITION' _non_alpha_ st_RESERVED
'SUBTYPE' _non_alpha_ st_RESERVED
'SUM' _non_alpha_ st_RESERVED
'SYSDATE' _non_alpha_ st_RESERVED
'TABLE' _non_alpha_ st_RESERVED
'THE' _non_alpha_ st_RESERVED
'THEN' _non_alpha_ st_RESERVED
'TIME' _non_alpha_ st_RESERVED
'TIMESTAMP' _non_alpha_ st_RESERVED
'TO' _non_alpha_ st_RESERVED
'TRANSACTION' _non_alpha_ st_RESERVED
'TRIGGER' _non_alpha_ st_RESERVED
'TRIM' _non_alpha_ st_RESERVED
'TRUE' _non_alpha_ st_RESERVED
'TRUST' _non_alpha_ st_RESERVED
'TYPE' _non_alpha_ st_RESERVED
'UNDER' _non_alpha_ st_RESERVED
'UNION' _non_alpha_ st_RESERVED
'UNIQUE' _non_alpha_ st_RESERVED
'UPDATE' _non_alpha_ st_RESERVED
'UROWID' _non_alpha_ st_RESERVED
'USE' _non_alpha_ st_RESERVED
'USER' _non_alpha_ st_RESERVED
'USING' _non_alpha_ st_RESERVED
'VALUE' _non_alpha_ st_RESERVED
'VALUES' _non_alpha_ st_RESERVED
'VARCHAR' _non_alpha_ st_RESERVED
'VARCHAR2' _non_alpha_ st_RESERVED
'VARIABLE' _non_alpha_ st_RESERVED
'VARIANCE' _non_alpha_ st_RESERVED
'VARRAY' _non_alpha_ st_RESERVED
'VARYING' _non_alpha_ st_RESERVED
'WHEN' _non_alpha_ st_RESERVED
'WHERE' _non_alpha_ st_RESERVED
'WHILE' _non_alpha_ st_RESERVED
'WITH' _non_alpha_ st_RESERVED
'WNDS' _non_alpha_ st_RESERVED
'WNPS' _non_alpha_ st_RESERVED
'WORK' _non_alpha_ st_RESERVED
'WRITE' _non_alpha_ st_RESERVED
'XOR' _non_alpha_ st_RESERVED
'YEAR' _non_alpha_ st_RESERVED
'ZONE' _non_alpha_ st_RESERVED

%%handler
st_COMMENT_LINE         '[^\n]'?                    '\n'           _discard_
st_COMMENT_STAR         _all_chars_?                '*/'           _use_
// Multi-line strings
st_STRING               _all_chars_?                '\x27'         _use_

%%tokens
st_STRING               __STD_PASCALSTRING
st_DEFAULT              __STD_C_STRING
st_NUMBER               __STD_NUMBER_OR_FP
st_IDENTIFIER           '[a-zA-Z_$#\xFF]' '[a-zA-Z_$#0-9\xFF]'? '[^a-zA-Z_$#0-9\xFF]' _discard_

%%map
st_DEFAULT         st_DEFAULT
st_IDENTIFIER      st_IDENTIFIER
st_STRING          st_STRING
st_COMMENT         st_COMMENT
st_COMMENT_LINE    st_COMMENT
st_COMMENT_STAR    st_COMMENT
st_RESERVED        st_RESERVED
st_SYMBOL          st_SYMBOL
st_NUMBER          st_NUMBER

st_CUSTOM          st_CUSTOM

st_CUST_KEYWORD    st_RESERVED
st_CUST_COMMENT    st_COMMENT
st_CUST_STRING     st_STRING
st_CUST_NUMBER     st_NUMBER
st_CUST_SYMBOL     st_SYMBOL

