2014-07-10 21:05:51 -07:00
|
|
|
" Vim syntax file
|
2021-05-02 09:20:57 -07:00
|
|
|
" Language: Modula-3
|
|
|
|
" Maintainer: Doug Kearns <dougkearns@gmail.com>
|
|
|
|
" Previous Maintainer: Timo Pedersen <dat97tpe@ludat.lth.se>
|
2022-11-10 02:05:25 -07:00
|
|
|
" Last Change: 2022 Oct 31
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2017-04-28 12:06:44 -07:00
|
|
|
if exists("b:current_syntax")
|
2014-07-10 21:05:51 -07:00
|
|
|
finish
|
|
|
|
endif
|
|
|
|
|
2022-11-10 02:05:25 -07:00
|
|
|
" Whitespace errors {{{1
|
|
|
|
if exists("modula3_space_errors")
|
|
|
|
if !exists("modula3_no_trail_space_error")
|
|
|
|
syn match modula3SpaceError display excludenl "\s\+$"
|
|
|
|
endif
|
|
|
|
if !exists("modula3_no_tab_space_error")
|
|
|
|
syn match modula3SpaceError display " \+\t"me=e-1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
" Keywords {{{1
|
|
|
|
syn keyword modula3Keyword ANY ARRAY AS BITS BRANDED BY CASE CONST
|
|
|
|
syn keyword modula3Keyword DEFINITION EVAL EXIT EXCEPT EXCEPTION EXIT
|
|
|
|
syn keyword modula3Keyword EXPORTS FINALLY FROM GENERIC IMPORT LOCK METHOD
|
|
|
|
syn keyword modula3Keyword OF RAISE RAISES READONLY RECORD REF
|
|
|
|
syn keyword modula3Keyword RETURN SET TRY TYPE TYPECASE UNSAFE
|
|
|
|
syn keyword modula3Keyword VALUE VAR WITH
|
2021-05-02 09:20:57 -07:00
|
|
|
|
|
|
|
syn match modula3keyword "\<UNTRACED\>"
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
" Special keywords, block delimiters etc
|
|
|
|
syn keyword modula3Block PROCEDURE FUNCTION MODULE INTERFACE REPEAT THEN
|
|
|
|
syn keyword modula3Block BEGIN END OBJECT METHODS OVERRIDES RECORD REVEAL
|
|
|
|
syn keyword modula3Block WHILE UNTIL DO TO IF FOR ELSIF ELSE LOOP
|
|
|
|
|
2022-11-10 02:05:25 -07:00
|
|
|
" Reserved identifiers {{{1
|
2021-05-02 09:20:57 -07:00
|
|
|
syn keyword modula3Identifier ABS ADR ADRSIZE BITSIZE BYTESIZE CEILING DEC
|
|
|
|
syn keyword modula3Identifier DISPOSE FIRST FLOAT FLOOR INC ISTYPE LAST
|
|
|
|
syn keyword modula3Identifier LOOPHOLE MAX MIN NARROW NEW NUMBER ORD ROUND
|
|
|
|
syn keyword modula3Identifier SUBARRAY TRUNC TYPECODE VAL
|
|
|
|
|
2022-11-10 02:05:25 -07:00
|
|
|
" Predefined types {{{1
|
2021-05-02 09:20:57 -07:00
|
|
|
syn keyword modula3Type ADDRESS BOOLEAN CARDINAL CHAR EXTENDED INTEGER
|
|
|
|
syn keyword modula3Type LONGCARD LONGINT LONGREAL MUTEX NULL REAL REFANY TEXT
|
|
|
|
syn keyword modula3Type WIDECHAR
|
|
|
|
|
|
|
|
syn match modula3Type "\<\%(UNTRACED\s\+\)\=ROOT\>"
|
|
|
|
|
2022-11-10 02:05:25 -07:00
|
|
|
" Operators {{{1
|
|
|
|
syn keyword modula3Operator DIV MOD
|
|
|
|
syn keyword modula3Operator IN
|
|
|
|
syn keyword modula3Operator NOT AND OR
|
2021-05-02 09:20:57 -07:00
|
|
|
|
2022-11-10 02:05:25 -07:00
|
|
|
" TODO: exclude = from declarations
|
2021-05-02 09:20:57 -07:00
|
|
|
if exists("modula3_operators")
|
|
|
|
syn match modula3Operator "\^"
|
2022-11-10 02:05:25 -07:00
|
|
|
syn match modula3Operator "[-+/*]"
|
|
|
|
syn match modula3Operator "&"
|
|
|
|
syn match modula3Operator "<=\|<:\@!\|>=\|>"
|
|
|
|
syn match modula3Operator ":\@<!=\|#"
|
2021-05-02 09:20:57 -07:00
|
|
|
endif
|
|
|
|
|
2022-11-10 02:05:25 -07:00
|
|
|
" Literals {{{1
|
|
|
|
|
2021-05-02 09:20:57 -07:00
|
|
|
" Booleans
|
|
|
|
syn keyword modula3Boolean TRUE FALSE
|
|
|
|
|
|
|
|
" Nil
|
|
|
|
syn keyword modula3Nil NIL
|
|
|
|
|
2022-11-10 02:05:25 -07:00
|
|
|
" Numbers {{{2
|
|
|
|
|
|
|
|
" NOTE: Negated numbers are constant expressions not literals
|
|
|
|
|
|
|
|
syn case ignore
|
|
|
|
|
|
|
|
" Integers
|
|
|
|
|
|
|
|
syn match modula3Integer "\<\d\+L\=\>"
|
2021-05-02 09:20:57 -07:00
|
|
|
|
2022-11-10 02:05:25 -07:00
|
|
|
if exists("modula3_number_errors")
|
|
|
|
syn match modula3IntegerError "\<\d\d\=_\x\+L\=\>"
|
|
|
|
endif
|
|
|
|
|
|
|
|
let s:digits = "0123456789ABCDEF"
|
|
|
|
for s:radix in range(2, 16)
|
|
|
|
" Nvim does not support interpolated strings yet.
|
|
|
|
" exe $'syn match modula3Integer "\<{s:radix}_[{s:digits[:s:radix - 1]}]\+L\=\>"'
|
|
|
|
exe 'syn match modula3Integer "\<' .. s:radix .. '_[' .. s:digits[:s:radix - 1] .. ']\+L\=\>"'
|
|
|
|
endfor
|
|
|
|
unlet s:digits s:radix
|
|
|
|
|
|
|
|
" Reals
|
|
|
|
syn match modula3Real "\<\d\+\.\d\+\%([EDX][+-]\=\d\+\)\=\>"
|
|
|
|
|
|
|
|
syn case match
|
|
|
|
|
|
|
|
" Strings and characters {{{2
|
2021-05-02 09:20:57 -07:00
|
|
|
|
|
|
|
" String escape sequences
|
|
|
|
syn match modula3Escape "\\['"ntrf]" contained display
|
2022-11-10 02:05:25 -07:00
|
|
|
" TODO: limit to <= 377 (255)
|
2021-05-02 09:20:57 -07:00
|
|
|
syn match modula3Escape "\\\o\{3}" contained display
|
|
|
|
syn match modula3Escape "\\\\" contained display
|
|
|
|
|
|
|
|
" Characters
|
|
|
|
syn match modula3Character "'\%([^']\|\\.\|\\\o\{3}\)'" contains=modula3Escape
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
" Strings
|
2021-05-02 09:20:57 -07:00
|
|
|
syn region modula3String start=+"+ end=+"+ contains=modula3Escape
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2022-11-10 02:05:25 -07:00
|
|
|
" Pragmas {{{1
|
|
|
|
" EXTERNAL INLINE ASSERT TRACE FATAL UNUSED OBSOLETE CALLBACK EXPORTED PRAGMA NOWARN LINE LL LL.sup SPEC
|
|
|
|
" Documented: INLINE ASSERT TRACE FATAL UNUSED OBSOLETE NOWARN
|
2021-05-02 09:20:57 -07:00
|
|
|
syn region modula3Pragma start="<\*" end="\*>"
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2022-11-10 02:05:25 -07:00
|
|
|
" Comments {{{1
|
|
|
|
if !exists("modula3_no_comment_fold")
|
|
|
|
syn region modula3Comment start="(\*" end="\*)" contains=modula3Comment,@Spell fold
|
|
|
|
syn region modula3LineCommentBlock start="^\s*(\*.*\*)\s*\n\%(^\s*(\*.*\*)\s*$\)\@=" end="^\s*(\*.*\*)\s*\n\%(^\s*(\*.*\*)\s*$\)\@!" contains=modula3Comment transparent fold keepend
|
|
|
|
else
|
|
|
|
syn region modula3Comment start="(\*" end="\*)" contains=modula3Comment,@Spell
|
|
|
|
endif
|
|
|
|
|
|
|
|
" Syncing "{{{1
|
|
|
|
syn sync minlines=100
|
2014-07-10 21:05:51 -07:00
|
|
|
|
2022-11-10 02:05:25 -07:00
|
|
|
" Default highlighting {{{1
|
2021-05-02 09:20:57 -07:00
|
|
|
hi def link modula3Block Statement
|
|
|
|
hi def link modula3Boolean Boolean
|
|
|
|
hi def link modula3Character Character
|
|
|
|
hi def link modula3Comment Comment
|
|
|
|
hi def link modula3Escape Special
|
|
|
|
hi def link modula3Identifier Keyword
|
|
|
|
hi def link modula3Integer Number
|
|
|
|
hi def link modula3Keyword Statement
|
|
|
|
hi def link modula3Nil Constant
|
2022-11-10 02:05:25 -07:00
|
|
|
hi def link modula3IntegerError Error
|
2021-05-02 09:20:57 -07:00
|
|
|
hi def link modula3Operator Operator
|
|
|
|
hi def link modula3Pragma PreProc
|
|
|
|
hi def link modula3Real Float
|
|
|
|
hi def link modula3String String
|
2022-11-10 02:05:25 -07:00
|
|
|
hi def link modula3Type Type "}}}
|
2014-07-10 21:05:51 -07:00
|
|
|
|
|
|
|
let b:current_syntax = "modula3"
|
|
|
|
|
2022-11-10 02:05:25 -07:00
|
|
|
" vim: nowrap sw=2 sts=2 ts=8 noet fdm=marker:
|