ui: make primary cursor blink even if no lua theme has been loaded
[vis.git] / lexers / vb.lua
blob453a74c3d59ff2459211e3ab5b860391af025f40
1 -- Copyright 2006-2016 Mitchell mitchell.att.foicica.com. See LICENSE.
2 -- VisualBasic 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 = 'vb'}
10 -- Whitespace.
11 local ws = token(l.WHITESPACE, l.space^1)
13 -- Comments.
14 local comment = token(l.COMMENT, (P("'") + word_match({'rem'}, nil, true)) *
15 l.nonnewline^0)
17 -- Strings.
18 local string = token(l.STRING, l.delimited_range('"', true, true))
20 -- Numbers.
21 local number = token(l.NUMBER, (l.float + l.integer) * S('LlUuFf')^-2)
23 -- Keywords.
24 local keyword = token(l.KEYWORD, word_match({
25 -- Control.
26 'If', 'Then', 'Else', 'ElseIf', 'While', 'Wend', 'For', 'To', 'Each',
27 'In', 'Step', 'Case', 'Select', 'Return', 'Continue', 'Do',
28 'Until', 'Loop', 'Next', 'With', 'Exit',
29 -- Operators.
30 'Mod', 'And', 'Not', 'Or', 'Xor', 'Is',
31 -- Storage types.
32 'Call', 'Class', 'Const', 'Dim', 'ReDim', 'Preserve', 'Function', 'Sub',
33 'Property', 'End', 'Set', 'Let', 'Get', 'New', 'Randomize', 'Option',
34 'Explicit', 'On', 'Error', 'Execute',
35 -- Storage modifiers.
36 'Private', 'Public', 'Default',
37 -- Constants.
38 'Empty', 'False', 'Nothing', 'Null', 'True'
39 }, nil, true))
41 -- Types.
42 local type = token(l.TYPE, word_match({
43 'Boolean', 'Byte', 'Char', 'Date', 'Decimal', 'Double', 'Long', 'Object',
44 'Short', 'Single', 'String'
45 }, nil, true))
47 -- Identifiers.
48 local identifier = token(l.IDENTIFIER, l.word)
50 -- Operators.
51 local operator = token(l.OPERATOR, S('=><+-*^&:.,_()'))
53 M._rules = {
54 {'whitespace', ws},
55 {'keyword', keyword},
56 {'type', type},
57 {'comment', comment},
58 {'identifier', identifier},
59 {'string', string},
60 {'number', number},
61 {'operator', operator},
64 return M