blob: 4a07a77d6cdd7e8b3eaa75aa9838aded4059bb51 [file] [log] [blame]
Bram Moolenaarc8cdf0f2021-03-13 13:28:13 +01001" 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
22if exists('b:current_syntax')
23 finish
24endif
25
26" Poke statement
27syn keyword pokeStatement assert break continue return
28syn keyword pokeStatement type unit fun method nextgroup=pokeFunction skipwhite
29syn keyword pokeStatement var nextgroup=pokeVar skipWhite
30
31" Identifiers
32syn match pokeVar '\h\w*' display contained
33
34" User defined functions
35syn match pokeFunction '\h\w*' display contained
36
37" Poke operators
38syn keyword pokeOperator in sizeof as isa unmap
39
40" Conditionals
41syn keyword pokeConditional if else where
42
43" Structures, unions, etc...
44syn keyword pokeStructure struct union pinned
45
46" Loops
47syn keyword pokeRepeat while for
48
49" Imports
50syn keyword pokeLoad load
51
52" Exceptions
53syn keyword pokeException try catch until raise
54
55" Exception types
56syn keyword pokeExceptionType Exception E_generic E_out_of_bounds
57syn keyword pokeExceptionType E_eof E_elem E_constraint
58syn keyword pokeExceptionType E_conv E_map_bounds E_map
59syn keyword pokeExceptionType E_div_by_zero E_no_ios E_no_return
60syn keyword pokeExceptionType E_io E_io_flags E_assert E_overflow
61
62" Exception codes
63syn keyword pokeExceptionCode EC_generic EC_out_of_bounds
64syn keyword pokeExceptionCode EC_eof EC_elem EC_constraint
65syn keyword pokeExceptionCode EC_conv EC_map_bounds EC_map
66syn keyword pokeExceptionCode EC_div_by_zero EC_no_ios EC_no_return
67syn keyword pokeExceptionCode EC_io EC_io_flags EC_assert EC_overflow
68
69" Poke builtin types
70syn keyword pokeBuiltinType string void int uint bit nibble
71syn keyword pokeBuiltinType byte char ushort short ulong long
72syn keyword pokeBuiltinType uint8 uint16 uint32 uint64
73syn keyword pokeBuiltinType off64 uoff64 offset
74syn keyword pokeBuiltinType Comparator POSIX_Time32 POSIX_Time64
75syn keyword pokeBuiltinType big little any
76
77" Poke constants
78syn keyword pokeConstant ENDIAN_LITTLE ENDIAN_BIG
79syn keyword pokeConstant IOS_F_READ IOS_F_WRITE IOS_F_TRUNCATE IOS_F_CREATE
80syn keyword pokeConstant IOS_M_RDONLY IOS_M_WRONLY IOS_M_RDWR
81syn keyword pokeConstant load_path NULL OFFSET
82
83" Poke std lib
84syn keyword pokeBuiltinFunction print printf catos stoca atoi ltos reverse
85syn keyword pokeBuiltinFunction ltrim rtrim strchr qsort crc32 alignto
86syn keyword pokeBuiltinFunction open close flush get_ios set_ios iosize
87syn keyword pokeBuiltinFunction rand get_endian set_endian strace exit
88syn keyword pokeBuiltinFunction getenv
89
90" Formats
91
92" Special chars
93syn match pokeSpecial "\\\([nt\\]\|\o\{1,3}\)" display contained
94
95" Chars
96syn match pokeChar "'[^']*'" contains=pokeSpecial
97
98" Attributes
99syn match pokeAttribute "\h\w*'\h\w"
100
101" Strings
102syn region pokeString skip=+\\\\\|\\"+ start=+"+ end=+"+ contains=pokeSpecial
103
104" Integer literals
105syn match pokeInteger "\<\d\+_*\d*\([LlHhBbNn]\=[Uu]\=\|[Uu]\=[LlHhBbNn]\=\)\>"
106syn match pokeInteger "\<0[Xx]\x\+_*\x*\([LlHhBbNn]\=[Uu]\=\|[Uu]\=[LlHhBbNn]\=\)\>"
107syn match pokeInteger "\<0[Oo]\o\+_*\o*\([LlHhBbNn]\=[Uu]\=\|[Uu]\=[LlHhBbNn]\=\)\>"
108syn match pokeInteger "\<0[Bb][01]\+_*[01]*\([LlHhBbNn]\=[Uu]\=\|[Uu]\=[LlHhBbNn]\=\)\>"
109
110" Units
111syn keyword pokeBuiltinUnit b M B
112syn keyword pokeBuiltinUnit Kb KB Mb MB Gb GB
113syn keyword pokeBuiltinUnit Kib KiB Mib MiB Gib GiB
114
115" Offsets
116syn match pokeOffset "#\h\w*" contains=pokeBuiltinUnit
117
118" Comments
119syn keyword pokeCommentTodo TODO FIXME XXX TBD contained
120syn match pokeLineComment "\/\/.*" contains=pokeCommentTodo,@Spell extend
121syn region pokeComment start="/\*" end="\*/" contains=pokeCommentTodo,@Spell fold extend
122
123" Allow folding of blocks
124syn region pokeBlock start="{" end="}" transparent fold
125
126" Highlight groups
127hi def link pokeBuiltinFunction Function
128hi def link pokeBuiltinType Type
129hi def link pokeBuiltinUnit Keyword
130hi def link pokeChar Character
131hi def link pokeComment Comment
132hi def link pokeCommentTodo Todo
133hi def link pokeConditional Conditional
134hi def link pokeConstant Constant
135hi def link pokeException Exception
136hi def link pokeExceptionCode Constant
137hi def link pokeExceptionType Type
138hi def link pokeFunction Function
139hi def link pokeInteger Number
140hi def link pokeLineComment Comment
141hi def link pokeLoad Include
142hi def link pokeOffset StorageClass
143hi def link pokeOperator Operator
144hi def link pokeSpecial SpecialChar
145hi def link pokeStatement Statement
146hi def link pokeString String
147hi def link pokeStructure Structure
148hi def link pokeRepeat Repeat
149hi def link pokeVar Identifier
150
151let b:current_syntax = 'poke'