# touched this one up a bit.
#  should be pretty much up to speed with most recent implementations
#                                      jsvendsen-24-07-2001

colorize PASCAL {
    SyntaxParser       = 'SIMPLE';

    color {
        { 'Normal',        'Lang_Default' },
        { 'Number',        'Lang_DecimalNumber' },
        { 'HexNumber',     'Lang_HexNumber' },
        { 'Punctuation',   'Lang_Punctuation' },
        { 'String',        'Lang_String' },
        { 'Comment',       'Lang_Comment' },
        { 'Command',       'Lang_Assembler' }, # assembler
        { 'CPreprocessor', 'Lang_Preprocessor' },
    };

    keyword 'Editor_Keywords' {
        'program', 'const', 'type', 'var', 
        'begin', 'end', 'array', 'set', 'record', 'string', 
        'if', 'then', 'else', 'while', 'for', 'to', 'downto', 'do', 'with',
        'repeat', 'until', 'case', 'of', 'goto', 'exit', 'label',
        'procedure', 'function', 'nil', 'file', 'and', 'or', 'not', 'xor',
        'div', 'mod', 'unit', 'uses', 'implementation', 'interface', 
        'asm', 'inline', 'object', 'constructor', 'destructor', 'inherited', 
        'except', 'finally', 'initialization', 'out', 'property',
        'resourcestring', 'try', 'exports', 'library', 'packed',
        'raise', 'as', 'class', 'dispinterface', 'in', 'shl', 'shr',
        'threadvar', 'finalization', 'is', 'at', 'on',
        
        'private', 'protected', 'public', 'published', 'automated',
        'absolute', 'abstract', 'cdecl', 'contains', 'default', 'dispid',
        'dynamic', 'export', 'external', 'far', 'assembler', 'virtual', 
        'near', 'forward', 'implements', 'index', 'message', 'name',
        'nodefault', 'overload', 'override', 'package', 'pascal', 'read',
        'readonly', 'register', 'reintroduce', 'requires', 'resident',
        'safecall', 'stdcall', 'stored', 'write', 'writeonly',
        
        'integer', 'cardinal', 'shortint', 'smallint', 'longint', 'int64',
        'byte', 'word', 'longword', 'char', 'boolean', 'bytebool',
        'wordbool', 'longbool', 'true', 'false', 'real48', 'single',
        'double', 'extended', 'comp', 'currency', 'real',
        'shortstring', 'ansistring', 'widestring',
    };

    h_state 0 { 'Normal' }
    h_trans { 10, '<', '(*&', 'CPreprocessor' }    
    h_trans { 10, '<', '(*$', 'CPreprocessor' }
    h_trans { 9, '<', '{&', 'CPreprocessor' }    
    h_trans { 9, '<', '{$', 'CPreprocessor' }
    h_trans { 8, '', 'asm', 'Command' }
    h_trans { 5, '-s', 'a-zA-Z_', 'Normal' }
    h_trans { 11, '<', '//', 'Comment' }
    h_trans { 1, '<', '(*', 'Comment' }
    h_trans { 2, '<', '{', 'Comment' }
    h_trans { 3, '<', '"', 'String' }
    h_trans { 4, '<', '\'', 'String' }
    h_trans { 6, '<', '0x', 'HexNumber' }
    h_trans { 7, '<s', '0-9', 'Number' }
    h_trans { 0, 'S', '_a-zA-Z0-9', 'Punctuation' }

    h_state 1 { 'Comment' }
    h_trans { 0, '>', '*)', 'Comment' }

    h_state 2 { 'Comment' }
    h_trans { 0, '>', '}', 'Comment' }
    
    h_state 3 { 'String' }
    h_trans { 0, '>', '"', 'String' }
    h_trans { 0, '$', '', 'String' }

    h_state 4 { 'String' }
    h_trans { 0, '>', '\'', 'String' }
    h_trans { 0, '$', '', 'String' }

    h_state 5 { 'Normal' }
    h_trans { 0, '$', '', 'Normal' }
    h_wtype { 0, 0, 0, 'i', 'a-zA-Z0-9_' }

    h_state 6 { 'HexNumber' }
    h_trans { 0, '-S', '0-9A-Fa-f', 'Normal' }
    h_trans { 0, '$', '', 'Normal' }

    h_state 7 { 'Number' }
    h_trans { 0, '-S', '0-9', 'Normal' }
    h_trans { 0, '$', '', 'Normal' }

    h_state 8 { 'Command' }
    h_trans { 0, '', 'end', 'Command' }
    
    h_state 9 { 'CPreprocessor' }
    h_trans { 0, '>', '}', 'CPreprocessor' }
    
    h_state 10 { 'CPreprocessor' }
    h_trans { 0, '>', '*)', 'CPreprocessor' }
    
    h_state 11 { 'Comment' }
    h_trans { 0, '$', '', 'Comment' }
    
    
}

mode PASCAL: PLAIN {      # Pascal Mode
    FileNameRx          = /\.\cPAS$/;
    HilitOn             = 1;
    Colorizer           = 'PASCAL';
    AutoIndent          = 1;
    IndentMode          = 'PLAIN';
    MatchCase           = 0;
    Trim                = 1;
    MultiLineHilit      = 1;
    AutoHilitParen      = 1;

    SaveFolds           = 2;      # save fold info at end of line
    CommentStart        = ' (*';
    CommentEnd          = '*)';

    RoutineRegexp       = '^{procedure}|{function}';
}
