neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

poke.vim (5189B)


      1 " Copyright (C) 2021 Matthew T. Ihlenfield.
      2 "
      3 " This program is free software: you can redistribute it and/or modify
      4 " it under the terms of the GNU General Public License as published by
      5 " the Free Software Foundation, either version 3 of the License, or
      6 " (at your option) any later version.
      7 "
      8 " This program is distributed in the hope that it will be useful,
      9 " but WITHOUT ANY WARRANTY; without even the implied warranty of
     10 " MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     11 " GNU General Public License for more details.
     12 "
     13 " You should have received a copy of the GNU General Public License
     14 " along with this program.  If not, see <http://www.gnu.org/licenses/>.
     15 "
     16 " Vim syntax file
     17 " Language: Poke
     18 " Maintainer: Matt Ihlenfield <mtihlenfield@protonmail.com>
     19 " Filenames: *.pk
     20 " Latest Revision: 10 March 2021
     21 
     22 if exists('b:current_syntax')
     23    finish
     24 endif
     25 
     26 " Poke statement
     27 syn keyword pokeStatement assert break continue return
     28 syn keyword pokeStatement type unit fun method nextgroup=pokeFunction skipwhite
     29 syn keyword pokeStatement var nextgroup=pokeVar skipWhite
     30 
     31 " Identifiers
     32 syn match pokeVar '\h\w*' display contained
     33 
     34 " User defined functions
     35 syn match pokeFunction '\h\w*' display contained
     36 
     37 " Poke operators
     38 syn keyword pokeOperator in sizeof as isa unmap
     39 
     40 " Conditionals
     41 syn keyword pokeConditional if else where
     42 
     43 " Structures, unions, etc...
     44 syn keyword pokeStructure struct union pinned
     45 
     46 " Loops
     47 syn keyword pokeRepeat while for
     48 
     49 " Imports
     50 syn keyword pokeLoad load
     51 
     52 " Exceptions
     53 syn keyword pokeException try catch until raise
     54 
     55 " Exception types
     56 syn keyword pokeExceptionType Exception E_generic E_out_of_bounds
     57 syn keyword pokeExceptionType E_eof E_elem E_constraint
     58 syn keyword pokeExceptionType E_conv E_map_bounds E_map
     59 syn keyword pokeExceptionType E_div_by_zero E_no_ios E_no_return
     60 syn keyword pokeExceptionType E_io E_io_flags E_assert E_overflow
     61 
     62 " Exception codes
     63 syn keyword pokeExceptionCode EC_generic EC_out_of_bounds
     64 syn keyword pokeExceptionCode EC_eof EC_elem EC_constraint
     65 syn keyword pokeExceptionCode EC_conv EC_map_bounds EC_map
     66 syn keyword pokeExceptionCode EC_div_by_zero EC_no_ios EC_no_return
     67 syn keyword pokeExceptionCode EC_io EC_io_flags EC_assert EC_overflow
     68 
     69 " Poke builtin types
     70 syn keyword pokeBuiltinType string void int uint bit nibble
     71 syn keyword pokeBuiltinType byte char ushort short ulong long
     72 syn keyword pokeBuiltinType uint8 uint16 uint32 uint64
     73 syn keyword pokeBuiltinType off64 uoff64 offset
     74 syn keyword pokeBuiltinType Comparator POSIX_Time32 POSIX_Time64
     75 syn keyword pokeBuiltinType big little any
     76 
     77 " Poke constants
     78 syn keyword pokeConstant ENDIAN_LITTLE ENDIAN_BIG
     79 syn keyword pokeConstant IOS_F_READ IOS_F_WRITE IOS_F_TRUNCATE IOS_F_CREATE
     80 syn keyword pokeConstant IOS_M_RDONLY IOS_M_WRONLY IOS_M_RDWR
     81 syn keyword pokeConstant load_path NULL OFFSET
     82 
     83 " Poke std lib
     84 syn keyword pokeBuiltinFunction print printf catos stoca atoi ltos reverse
     85 syn keyword pokeBuiltinFunction ltrim rtrim strchr qsort crc32 alignto
     86 syn keyword pokeBuiltinFunction open close flush get_ios set_ios iosize
     87 syn keyword pokeBuiltinFunction rand get_endian set_endian strace exit
     88 syn keyword pokeBuiltinFunction getenv
     89 
     90 " Formats
     91 
     92 " Special chars
     93 syn match pokeSpecial "\\\([nt\\]\|\o\{1,3}\)" display contained
     94 
     95 " Chars
     96 syn match pokeChar "'[^']*'" contains=pokeSpecial
     97 
     98 " Attributes
     99 syn match pokeAttribute "\h\w*'\h\w"
    100 
    101 " Strings
    102 syn region pokeString skip=+\\\\\|\\"+ start=+"+ end=+"+ contains=pokeSpecial
    103 
    104 " Integer literals
    105 syn match pokeInteger "\<\d\+_*\d*\([LlHhBbNn]\=[Uu]\=\|[Uu]\=[LlHhBbNn]\=\)\>"
    106 syn match pokeInteger "\<0[Xx]\x\+_*\x*\([LlHhBbNn]\=[Uu]\=\|[Uu]\=[LlHhBbNn]\=\)\>"
    107 syn match pokeInteger "\<0[Oo]\o\+_*\o*\([LlHhBbNn]\=[Uu]\=\|[Uu]\=[LlHhBbNn]\=\)\>"
    108 syn match pokeInteger "\<0[Bb][01]\+_*[01]*\([LlHhBbNn]\=[Uu]\=\|[Uu]\=[LlHhBbNn]\=\)\>"
    109 
    110 " Units
    111 syn keyword pokeBuiltinUnit b M B
    112 syn keyword pokeBuiltinUnit Kb KB Mb MB Gb GB
    113 syn keyword pokeBuiltinUnit Kib KiB Mib MiB Gib GiB
    114 
    115 " Offsets
    116 syn match pokeOffset "#\h\w*" contains=pokeBuiltinUnit
    117 
    118 " Comments
    119 syn keyword pokeCommentTodo TODO FIXME XXX TBD contained
    120 syn match pokeLineComment "\/\/.*" contains=pokeCommentTodo,@Spell extend
    121 syn region pokeComment start="/\*"  end="\*/" contains=pokeCommentTodo,@Spell fold extend
    122 
    123 " Allow folding of blocks
    124 syn region pokeBlock start="{" end="}" transparent fold
    125 
    126 " Highlight groups
    127 hi def link pokeBuiltinFunction Function
    128 hi def link pokeBuiltinType Type
    129 hi def link pokeBuiltinUnit Keyword
    130 hi def link pokeChar Character
    131 hi def link pokeComment Comment
    132 hi def link pokeCommentTodo Todo
    133 hi def link pokeConditional Conditional
    134 hi def link pokeConstant Constant
    135 hi def link pokeException Exception
    136 hi def link pokeExceptionCode Constant
    137 hi def link pokeExceptionType Type
    138 hi def link pokeFunction Function
    139 hi def link pokeInteger Number
    140 hi def link pokeLineComment Comment
    141 hi def link pokeLoad Include
    142 hi def link pokeOffset StorageClass
    143 hi def link pokeOperator Operator
    144 hi def link pokeSpecial SpecialChar
    145 hi def link pokeStatement Statement
    146 hi def link pokeString String
    147 hi def link pokeStructure Structure
    148 hi def link pokeRepeat Repeat
    149 hi def link pokeVar Identifier
    150 
    151 let b:current_syntax = 'poke'