vis: implement :set cursorline
[vis.git] / lexers / apdl.lua
blob97d8d2cd603c522c56145f306fada7c28440cd95
1 -- Copyright 2006-2015 Mitchell mitchell.att.foicica.com. See LICENSE.
2 -- APDL LPeg lexer.
4 local l = require('lexer')
5 local token, word_match = l.token, l.word_match
6 local P, R, S = lpeg.P, lpeg.R, lpeg.S
8 local M = {_NAME = 'apdl'}
10 -- Whitespace.
11 local ws = token(l.WHITESPACE, l.space^1)
13 -- Comments.
14 local comment = token(l.COMMENT, '!' * l.nonnewline^0)
16 -- Strings.
17 local string = token(l.STRING, l.delimited_range("'", true, true))
19 -- Numbers.
20 local number = token(l.NUMBER, l.float + l.integer)
22 -- Keywords.
23 local keyword = token(l.KEYWORD, word_match({
24 '*abbr', '*abb', '*afun', '*afu', '*ask', '*cfclos', '*cfc', '*cfopen',
25 '*cfo', '*cfwrite', '*cfw', '*create', '*cre', '*cycle', '*cyc', '*del',
26 '*dim', '*do', '*elseif', '*else', '*enddo', '*endif', '*end', '*eval',
27 '*eva', '*exit', '*exi', '*get', '*go', '*if', '*list', '*lis', '*mfouri',
28 '*mfo', '*mfun', '*mfu', '*mooney', '*moo', '*moper', '*mop', '*msg',
29 '*repeat', '*rep', '*set', '*status', '*sta', '*tread', '*tre', '*ulib',
30 '*uli', '*use', '*vabs', '*vab', '*vcol', '*vco', '*vcum', '*vcu', '*vedit',
31 '*ved', '*vfact', '*vfa', '*vfill', '*vfi', '*vfun', '*vfu', '*vget', '*vge',
32 '*vitrp', '*vit', '*vlen', '*vle', '*vmask', '*vma', '*voper', '*vop',
33 '*vplot', '*vpl', '*vput', '*vpu', '*vread', '*vre', '*vscfun', '*vsc',
34 '*vstat', '*vst', '*vwrite', '*vwr', '/anfile', '/anf', '/angle', '/ang',
35 '/annot', '/ann', '/anum', '/anu', '/assign', '/ass', '/auto', '/aut',
36 '/aux15', '/aux2', '/aux', '/axlab', '/axl', '/batch', '/bat', '/clabel',
37 '/cla', '/clear', '/cle', '/clog', '/clo', '/cmap', '/cma', '/color', '/col',
38 '/com', '/config', '/contour', '/con', '/copy', '/cop', '/cplane', '/cpl',
39 '/ctype', '/cty', '/cval', '/cva', '/delete', '/del', '/devdisp', '/device',
40 '/dev', '/dist', '/dis', '/dscale', '/dsc', '/dv3d', '/dv3', '/edge', '/edg',
41 '/efacet', '/efa', '/eof', '/erase', '/era', '/eshape', '/esh', '/exit',
42 '/exi', '/expand', '/exp', '/facet', '/fac', '/fdele', '/fde', '/filname',
43 '/fil', '/focus', '/foc', '/format', '/for', '/ftype', '/fty', '/gcmd',
44 '/gcm', '/gcolumn', '/gco', '/gfile', '/gfi', '/gformat', '/gfo', '/gline',
45 '/gli', '/gmarker', '/gma', '/golist', '/gol', '/gopr', '/gop', '/go',
46 '/graphics', '/gra', '/gresume', '/gre', '/grid', '/gri', '/gropt', '/gro',
47 '/grtyp', '/grt', '/gsave', '/gsa', '/gst', '/gthk', '/gth', '/gtype', '/gty',
48 '/header', '/hea', '/input', '/inp', '/larc', '/lar', '/light', '/lig',
49 '/line', '/lin', '/lspec', '/lsp', '/lsymbol', '/lsy', '/menu', '/men',
50 '/mplib', '/mpl', '/mrep', '/mre', '/mstart', '/mst', '/nerr', '/ner',
51 '/noerase', '/noe', '/nolist', '/nol', '/nopr', '/nop', '/normal', '/nor',
52 '/number', '/num', '/opt', '/output', '/out', '/page', '/pag', '/pbc', '/pbf',
53 '/pcircle', '/pci', '/pcopy', '/pco', '/plopts', '/plo', '/pmacro', '/pma',
54 '/pmeth', '/pme', '/pmore', '/pmo', '/pnum', '/pnu', '/polygon', '/pol',
55 '/post26', '/post1', '/pos', '/prep7', '/pre', '/psearch', '/pse', '/psf',
56 '/pspec', '/psp', '/pstatus', '/pst', '/psymb', '/psy', '/pwedge', '/pwe',
57 '/quit', '/qui', '/ratio', '/rat', '/rename', '/ren', '/replot', '/rep',
58 '/reset', '/res', '/rgb', '/runst', '/run', '/seclib', '/sec', '/seg',
59 '/shade', '/sha', '/showdisp', '/show', '/sho', '/shrink', '/shr', '/solu',
60 '/sol', '/sscale', '/ssc', '/status', '/sta', '/stitle', '/sti', '/syp',
61 '/sys', '/title', '/tit', '/tlabel', '/tla', '/triad', '/tri', '/trlcy',
62 '/trl', '/tspec', '/tsp', '/type', '/typ', '/ucmd', '/ucm', '/uis', '/ui',
63 '/units', '/uni', '/user', '/use', '/vcone', '/vco', '/view', '/vie',
64 '/vscale', '/vsc', '/vup', '/wait', '/wai', '/window', '/win', '/xrange',
65 '/xra', '/yrange', '/yra', '/zoom', '/zoo'
66 }, '*/', true))
68 -- Identifiers.
69 local identifier = token(l.IDENTIFIER, l.word)
71 -- Functions.
72 local func = token(l.FUNCTION, l.delimited_range('%', true, true))
74 -- Operators.
75 local operator = token(l.OPERATOR, S('+-*/$=,;()'))
77 -- Labels.
78 local label = token(l.LABEL, l.starts_line(':') * l.word)
80 M._rules = {
81 {'whitespace', ws},
82 {'keyword', keyword},
83 {'identifier', identifier},
84 {'string', string},
85 {'number', number},
86 {'function', func},
87 {'label', label},
88 {'comment', comment},
89 {'operator', operator},
92 M._foldsymbols = {
93 _patterns = {'%*[A-Za-z]+', '!'},
94 [l.KEYWORD] = {
95 ['*if'] = 1, ['*IF'] = 1, ['*do'] = 1, ['*DO'] = 1, ['*dowhile'] = 1,
96 ['*DOWHILE'] = 1,
97 ['*endif'] = -1, ['*ENDIF'] = -1, ['*enddo'] = -1, ['*ENDDO'] = -1
99 [l.COMMENT] = {['!'] = l.fold_line_comments('!')}
102 return M