summaryrefslogtreecommitdiff
path: root/syntax/pvx.vim
blob: d7210a454f9eb6de7fbc386f077710daa247c33e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
" Vim syntax file
" Language:    ProvideX / PVX (Sage 100 business object source, *.pvxsrc)
" Maintainer:  native-sage-connector

if exists("b:current_syntax")
  finish
endif

" PVX keywords are case-insensitive in practice (mixed-case is common).
syntax case ignore

" --- Comments -------------------------------------------------------
syn keyword pvxTodo TODO FIXME XXX NOTE contained
syn match   pvxComment "!.*$" contains=pvxTodo,@Spell

" --- Strings & literals ---------------------------------------------
" Doubled quotes ("") inside a string are a literal embedded quote.
syn region  pvxString start=/"/ skip=/""/ end=/"/

" $$ is the "any/blank key" marker used in select/begin ranges.
syn match   pvxByteLiteral "\$\$"
" $XX$ is a two-digit hex byte literal, e.g. $8A$ (field separator).
syn match   pvxByteLiteral "\$[0-9A-Fa-f][0-9A-Fa-f]\$"

syn match   pvxNumber "\<\d\+\(\.\d\+\)\?\>"

" Pseudo-labels used as err=/dom= targets (*next, *break, *resume, ...)
syn match   pvxPseudoLabel "\*\h\w*"

" Labels: BARE_WORD: alone on a line (optionally trailing a comment)
syn match   pvxLabel "^\s*[A-Za-z_][A-Za-z0-9_.]*:\s*\(!.*\)\=$"

" Object method-call operator: obj'MethodName(
syn match   pvxMethodCall "'\h\w*"

" --- Statements / control flow --------------------------------------
syn keyword pvxConditional if then else switch case default
syn keyword pvxRepeat      for to step next while wend repeat until
syn keyword pvxLabelKw     break continue exit goto gosub return stop

syn keyword pvxStatement
      \ open close read write dim remove call select from begin where
      \ sep iol rec key err dom execute drop object on error try catch
      \ finally let print input rem

syn keyword pvxStructure
      \ def class like function perform local public global common
      \ create delete required end

syn keyword pvxOperator and or not

" --- Built-in functions ----------------------------------------------
syn keyword pvxFunction
      \ nul pos tbl ucs lcs mid str stp pad varchar sub new find len
      \ num evn clear msg dte lst vis dll max min val kec tim mod fib
      \ lof eof dir exists chr asc int sqr rnd cvs cvt day abs kgen
      \ ioc iol ios opt lpt ptr env exp log pi sgn dle fin fid dlm dod

" --- Highlight links --------------------------------------------------
hi def link pvxComment      Comment
hi def link pvxTodo         Todo
hi def link pvxString       String
hi def link pvxByteLiteral  SpecialChar
hi def link pvxNumber       Number
hi def link pvxPseudoLabel  Special
hi def link pvxLabel        Label
hi def link pvxMethodCall   Function
hi def link pvxConditional  Conditional
hi def link pvxRepeat       Repeat
hi def link pvxLabelKw      Keyword
hi def link pvxStatement    Statement
hi def link pvxStructure    Structure
hi def link pvxOperator     Operator
hi def link pvxFunction     Function

let b:current_syntax = "pvx"