ats-vim/syntax/ats.vim

164 lines
6.0 KiB
VimL
Raw Normal View History

2017-11-05 11:41:12 -05:00
if !exists('main_syntax')
if exists('b:current_syntax')
2009-06-26 20:00:00 -04:00
finish
endif
let main_syntax = 'ats'
endif
2017-11-05 11:38:18 -05:00
" comment highlighting
syn keyword atsTodo TODO FIXME NOTE contained
2009-06-26 20:00:00 -04:00
syn match atscCommentError display "\*/"
syn match atscCommentStartError display "/\*"me=e-1 contained
syn region atscComment matchgroup=atscCommentStart start="/\*" end="\*/" contains=atsTodo,@Spell,atscCommentStartError
syn match atsNestedCommentError display "\*)"
" mercilessly ripped from d.vim
syn region atsNestedComment start="(\*" end="\*)" contains=atsNestedComment,atsTodo,@Spell
syn match atsComment "//.*" contains=atsTodo
"
" denotation highlighting
"
2017-11-05 11:36:44 -05:00
" special characters
2009-06-26 20:00:00 -04:00
syn match atsSpecial display contained "\\\(x\x\+\|\o\{1,3}\|.\|$\)"
syn match atsSpecial display contained "\\\(u\x\{4}\|U\x\{8}\)"
2017-11-05 11:36:44 -05:00
syn match atsSpecial '\\n'
2017-12-04 01:01:53 -05:00
syn match atsSpecial '@'
2017-12-07 00:11:03 -05:00
" syn match atsSpecial '#'
2009-06-26 20:00:00 -04:00
syn match atsFormat display "%\(\d\+\$\)\=[-+' #0*]*\(\d*\|\*\|\*\d\+\$\)\(\.\(\d*\|\*\|\*\d\+\$\)\)\=\([hlL]\|ll\)\=\([bdiuoxXDOUfeEgGcCsSpn]\|\[\^\=.[^]]*\]\)" contained
2017-11-05 11:36:44 -05:00
syn region atsStringDenot start=+"+ skip=+\\\\\|\\"+ end=+"+ contains=atsSpecial,atsFormat,atsSpecial,@Spell
2009-06-26 20:00:00 -04:00
syn match atsCharDenot "'[^\\]'"
syn match atsCharDenot "'[^']*'" contains=atsSpecial
syn keyword atsBoolDenot true false
syn case ignore
syn match atsNumbers display transparent "\<\d\|\.\d" contains=atsNumber,atsFloat,atsOctalError,atsOctal
syn match atsNumber display contained "\d\+\(u\=l\{0,2}\|ll\=u\)\>"
syn match atsNumber display contained "0x\x\+\(u\=l\{0,2}\ll\=\u\)\>"
" flag the first zero of an octal number as something special
syn match atsOctal display contained "0\o\+\(u\=l\{0,2}\|ll\=u\)\>" contains=atsOctalZero
syn match atsFloat display contained "\d\+\.\d*\(e[-+]\=\d\+\)\="
syn match atsFloat display contained "\.\d\+\(e[-+]\=\d\+\)\>"
syn match atsFloat display contained "\d\+e[-+]\=\d\+\>"
" flag an octal number with wrong digits
syn match atsOctalError display contained "0\o*[89]\d*"
syn case match
2017-11-30 19:02:38 -05:00
syn region atsIncludes oneline start='#include' end='"' contains=atsStringDenot
2009-06-26 20:00:00 -04:00
syn match atsIdent "[A-Za-z_][0-9A-Za-z_\']*"
" embedded C
" %{^ %} %{ %} %{$ %} %{# %}
2017-11-05 11:41:12 -05:00
if main_syntax !=# 'c' || exists('c')
2009-06-26 20:00:00 -04:00
syn include @atsC syntax/c.vim
unlet b:current_syntax
syn region embC start=+%{[^#$]\=+ keepend end=+%}+ contains=@atsC
endif
"
" keyword highlighting
"
" keyword highlighting
2017-12-29 11:29:02 -05:00
syn keyword atsKeyword prefix postfix infix infixl infixr op nonfix addr
syn keyword atsKeyword staload stadef sta dynload stacst assertloc
2017-12-21 19:45:31 -05:00
syn keyword atsCond if then else case sif
2009-06-26 20:00:00 -04:00
syn keyword atsRepeat while
syn keyword atsException exception raise try
syn keyword atsStatement let in where local
2017-12-07 00:11:03 -05:00
syn keyword atsStatement val and fnx fun fn llam lam fix rec var of assume castfn prfun
2009-06-26 20:00:00 -04:00
syn keyword atsStatement begin end
2017-12-07 00:23:29 -05:00
syn keyword atsTypedef typedef sortdef viewtypedef vtypedef viewdef
2017-12-02 21:39:48 -05:00
syn keyword atsStructure datatype datavtype abstype dataviewtype dataprop dataview
2017-12-07 20:39:19 -05:00
syn keyword atsExternal extern implement primplmnt
2009-06-26 20:00:00 -04:00
syn keyword atsKeyword symintr overload with
syn keyword atsKeyword prval praxi datasort
2017-12-21 22:42:37 -05:00
syn keyword atsSorts bool char int absprop prop type view viewtype nat absvtype absviewtype vtype
2009-06-26 20:00:00 -04:00
syn keyword atsTypes string float double void
syn match atsSym "[%&+-\./:=@~`^|*!$#?]+\|[%&+-\./:=@~`^|*<>]+"
" C preprocessor directives
syn match atsError display "^\s*\(%:\|#\).*$"
syn region atsPreCondit start="^\s*\(%:\|#\)\s*\(if\|ifdef\|ifndef\|elif\)\>" skip="\\$" end="$" end="//"me=s-1 contains=atsComment,atsCommentError
syn match atsPreCondit display "^\s*\(%:\|#\)\s*\(else\|endif\)\>"
syn region atsCppOut start="^\s*\(%\|#\)\s*if\s\+0\+\>" end=".\@=\|$" contains=atsCppOut2
syn region atsCppOut2 contained start="0" end="^\s*\(%:\|#\)\s*\(endif\>\|else\>\|elif\>\)" contains=atsCppSkip
2017-12-21 19:45:31 -05:00
syn region atsCppSkip contained start="^\s*\(%:\|#\)\s*\(if\>\|ifdef\>\|print\>\|ifndef\>\)" skip="\\$" end="^\s*\(%:\|#\)\s*endif\>" contains=atsCppSkip
2017-11-05 11:33:07 -05:00
syn region atsIncluded display contained start=+"+ skip=+\\\\\|\\"+ end=+"+
syn match atsIncluded display contained "<[^>]*>"
2017-11-05 11:30:52 -05:00
syn match atsInclude "^\s*\(%:\|#\)\s*include\>\s*["<]" contains=atsIncluded
2009-06-26 20:00:00 -04:00
syn cluster atsPreProcGroup contains=atsPreCondit,atsIncluded,atsInclude,atsDefine,atsCppOut,atsCppOut2,atsCppSkip
syn region atsDefine matchgroup=atsPreCondit start="\s*\(%:\|#\)\s*\(define\|undef\)\>" skip="\\$" end="$"
syn region atsPreProc matchgroup=atsPreCondit start="^\s*\(%:\|#\)\s*\(pragma\>\|line\>warning\>\|warn\>\|error\>\)" skip="\\$" end="$" keepend
"
" linking
"
" don't use standard HiLink, it won't work with included syntax files
command! -nargs=+ AtsHiLink hi def link <args>
2017-10-02 23:05:17 -04:00
" includes
2017-11-05 11:29:49 -05:00
AtsHiLink atsIncludes Special
AtsHiLink atsSpecial Special
2017-10-02 23:05:17 -04:00
2009-06-26 20:00:00 -04:00
" comments
AtsHiLink atsCommentStart atsComment
AtsHiLink atsNestedComment Comment
AtsHiLink atscCommentStart Comment
AtsHiLink atscComment Comment
AtsHiLink atsComment Comment
" delimiters
AtsHiLink atsEncl Keyword
" constants and denotations
AtsHiLink atsBoolDenot Boolean
AtsHiLink atsCharsDenot String
AtsHiLink atsCharDenot Character
AtsHiLink atsStringDenot String
AtsHiLink atsNumber Number
AtsHiLink atsOctal Number
AtsHiLink atsOctalZero PreProc " link this to Error if you want
AtsHiLink atsFloat Float
AtsHiLink atsOctalError atsError
" identifiers
AtsHiLink atsIdent Identifier
" various keywords
AtsHiLink atsKey Keyword
AtsHiLink atsCond Conditional
AtsHiLink atsRepeat Repeat
AtsHiLink atsException Exception
AtsHiLink atsStatement Statement
2017-11-16 22:01:37 -05:00
AtsHiLink atsKeyword Statement
2009-06-26 20:00:00 -04:00
AtsHiLink atsTypedef Typedef
AtsHiLink atsStructure Structure
AtsHiLink atsExternal StorageClass
AtsHiLink atsTypes Type
2017-11-16 20:56:10 -05:00
AtsHiLink atsSorts Type
2009-06-26 20:00:00 -04:00
AtsHiLink atsSym Operator
AtsHiLink atsEncl Keyword
" embedded C
AtsHiLink embC Special
AtsHiLink atsPreProc PreProc
AtsHiLink atsCommentError atsError
AtsHiLink atscCommentStartError atsError
AtsHiLink atscCommentError atsError
AtsHiLink atsNestedCommentError atsError
AtsHiLink atsError Error
AtsHiLink atsAllErrs Error
delcommand AtsHiLink
2017-11-05 11:41:12 -05:00
let b:current_syntax = 'ats'
2009-06-26 20:00:00 -04:00
2017-11-05 11:41:12 -05:00
if main_syntax ==# 'ats'
2009-06-26 20:00:00 -04:00
unlet main_syntax
endif