#From: Richard Glidden <rrglidden@uwaterloo.ca>
#
#  I just spent an hour or so configuring FTE to recognize Modula-3. 
#This file is almost complete (there are two minor bugs - Keywords
#immediately following punctuation don't highlight correctly, and
#RoutineRegexp isn't set to recognize Procedures unless they start at
#column 1), but I thought you'd like a copy of it anyway to include with
#FTE.

colorize MODULA3 {
    SyntaxParser       = 'SIMPLE';

    color {
        { 'Normal',      'Editor_Default' },
        { 'Number',      'Lang_DecimalNumber' },
        { 'HexNumber',   'Lang_HexNumber' },
        { 'Punctuation', 'Lang_Punctuation' },
        { 'String',      'Lang_String' },
        { 'Comment',     'Lang_Comment' },
        { 'Command',     'Lang_Assembler' }, # Pragma
    };

    keyword 'Editor_Keywords' {
        'ABS', 'ADDRESS', 'ADR', 'ADRSIZE', 'AND', 'ANY', 'ARRAY', 'AS',
        'BEGIN', 'BITS', 'BITSIZE', 'BOOLEAN', 'BRANDED', 'BY', 'BYTESIZE',
        'CARDINAL', 'CASE', 'CEILING', 'CHAR', 'CONST',
        'DEC', 'DISPOSE', 'DIV', 'DO',
        'ELSE', 'ELSIF', 'END', 'EVAL', 'EXCEPT', 'EXCEPTION', 'EXIT',
        'EXPORTS', 'EXTENDED',
        'FALSE', 'FINALLY', 'FIRST', 'FLOAT', 'FLOOR', 'FOR', 'FROM',
        'GENERIC',
        'IF', 'IMPORT', 'IN', 'INC', 'INTEGER', 'INTERFACE', 'ISTYPE',
        'LAST', 'LOCK', 'LONGREAL', 'LOOP', 'LOOPHOLE',
        'MAX', 'METHODS', 'MIN', 'MOD', 'MODULE', 'MUTEX',
        'NARROW', 'NEW', 'NIL', 'NOT', 'NULL', 'NUMBER',
        'OBJECT', 'OF', 'OR', 'ORD', 'OVERRIDES',
        'PROCEDURE',
        'RAISE', 'RAISES', 'READONLY', 'REAL', 'RECORD', 'REF', 'REFANY',
        'REPEAT', 'RETURN', 'REVEAL', 'ROOT', 'ROUND',
        'SET', 'SUBARRAY', 'TEXT', 'THEN', 'TO', 'TRUE', 'TRUNC', 'TRY',
        'TYPE', 'TYPECASE', 'TYPECODE', 'UNSAFE', 'UNTIL', 'UNTRACED',
        'VAL', 'VALUE', 'VAR',
        'WHILE', 'WITH',
    };
                        
    # The following h_states are lengthy, but work VERY well.  Unlike the
    # m_pascal.fte file (which m_modul3.fte is based on), punctuation
    # colours do not get 'stuck' on Normal text.

    # BUG: Keywords immediately following punctuation (ie: .IF) do not
    # highlight.  Please add a space between all punctuation and keywords,
    # for now.
    
    h_state 0 { 'Normal' }
    h_trans { 2, '<', '"', 'String' }
    h_trans { 3, '<', '\'', 'String' }
    h_trans { 4, '<', '(*', 'Comment' }
    h_trans { 8, '<', '<*', 'Command' }
    h_trans { 5, '<', '2_', 'HexNumber' }
    h_trans { 5, '<', '3_', 'HexNumber' }
    h_trans { 5, '<', '4_', 'HexNumber' }
    h_trans { 5, '<', '5_', 'HexNumber' }
    h_trans { 5, '<', '6_', 'HexNumber' }
    h_trans { 5, '<', '7_', 'HexNumber' }
    h_trans { 5, '<', '8_', 'HexNumber' }
    h_trans { 5, '<', '9_', 'HexNumber' }
    h_trans { 5, '<', '10_', 'HexNumber' }
    h_trans { 5, '<', '11_', 'HexNumber' }
    h_trans { 5, '<', '12_', 'HexNumber' }
    h_trans { 5, '<', '13_', 'HexNumber' }
    h_trans { 5, '<', '14_', 'HexNumber' }
    h_trans { 5, '<', '15_', 'HexNumber' }
    h_trans { 5, '<', '16_', 'HexNumber' }
    h_trans { 6, '<-s', '0-9', 'Number' }
    h_trans { 1, '-s', 'a-zA-Z_', 'Normal' }
    h_trans { 0, 's', ' ', 'Normal' }
    h_trans { 7, 'S', '_a-zA-Z0-9 ', 'Punctuation' }

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

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

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

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

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

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

    h_state 7 { 'Punctuation' }
    h_trans { 2, '<', '"', 'String' }
    h_trans { 3, '<', '\'', 'String' }
    h_trans { 4, '<', '(*', 'Comment' }
    h_trans { 8, '<', '<*', 'Command' }
    h_trans { 5, '<', '2_', 'HexNumber' }
    h_trans { 5, '<', '3_', 'HexNumber' }
    h_trans { 5, '<', '4_', 'HexNumber' }
    h_trans { 5, '<', '5_', 'HexNumber' }
    h_trans { 5, '<', '6_', 'HexNumber' }
    h_trans { 5, '<', '7_', 'HexNumber' }
    h_trans { 5, '<', '8_', 'HexNumber' }
    h_trans { 5, '<', '9_', 'HexNumber' }
    h_trans { 5, '<', '10_', 'HexNumber' }
    h_trans { 5, '<', '11_', 'HexNumber' }
    h_trans { 5, '<', '12_', 'HexNumber' }
    h_trans { 5, '<', '13_', 'HexNumber' }
    h_trans { 5, '<', '14_', 'HexNumber' }
    h_trans { 5, '<', '15_', 'HexNumber' }
    h_trans { 5, '<', '16_', 'HexNumber' }
    h_trans { 0, 's', '_a-zA-Z ', 'Normal' }
    h_trans { 0, '$', '', 'Normal' }    
    h_trans { 7, '<s', '0-9', 'Number' }
    
    h_state 8 { 'Command' }
    h_trans { 0, '>', '*>', 'Command' }
}
mode MODULA3: PLAIN {      # Modula-3 Mode
    FileNameRx          = /\.\c{m3}|{i3}$/;
    HilitOn             = 1;
    Colorizer           = 'MODULA3';
    AutoIndent          = 1;
    IndentMode          = 'PLAIN';
    MatchCase           = 1;
    Trim                = 1;
    MultiLineHilit      = 1;
    AutoHilitParen      = 1;

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

    # Needs to be modified to allow PROCEDURE to start anywhere on a line,
    # not just column 1.
    RoutineRegexp       = '^{PROCEDURE}'; 
}
