logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

vbscript.lua (1736B)


  1. -- Copyright 2006-2017 Mitchell mitchell.att.foicica.com. See LICENSE.
  2. -- VisualBasic LPeg lexer.
  3. local l = require('lexer')
  4. local token, word_match = l.token, l.word_match
  5. local P, R, S = lpeg.P, lpeg.R, lpeg.S
  6. local M = {_NAME = 'vbscript'}
  7. -- Whitespace.
  8. local ws = token(l.WHITESPACE, l.space^1)
  9. -- Comments.
  10. local comment = token(l.COMMENT, (P("'") + word_match({'rem'}, nil, true)) * l.nonnewline^0)
  11. -- Strings.
  12. local string = token(l.STRING, l.range('"', true, true))
  13. -- Numbers.
  14. local number = token(l.NUMBER, (l.float + l.integer) * S('LlUuFf')^-2)
  15. -- Keywords.
  16. local keyword = token(l.KEYWORD, word_match({
  17. -- Control.
  18. 'If', 'Then', 'Else', 'ElseIf', 'While', 'Wend', 'For', 'To', 'Each',
  19. 'In', 'Step', 'Case', 'Select', 'Return', 'Continue', 'Do',
  20. 'Until', 'Loop', 'Next', 'With', 'Exit',
  21. -- Operators.
  22. 'Mod', 'And', 'Not', 'Or', 'Xor', 'Is',
  23. -- Storage types.
  24. 'Call', 'Class', 'Const', 'Dim', 'ReDim', 'Preserve', 'Function', 'Sub',
  25. 'Property', 'End', 'Set', 'Let', 'Get', 'New', 'Randomize', 'Option',
  26. 'Explicit', 'On', 'Error', 'Execute',
  27. -- Storage modifiers.
  28. 'Private', 'Public', 'Default',
  29. -- Constants.
  30. 'Empty', 'False', 'Nothing', 'Null', 'True'
  31. }, nil, true))
  32. -- Types.
  33. local type = token(l.TYPE, word_match({
  34. 'Boolean', 'Byte', 'Char', 'Date', 'Decimal', 'Double', 'Long', 'Object',
  35. 'Short', 'Single', 'String'
  36. }, nil, true))
  37. -- Identifiers.
  38. local identifier = token(l.IDENTIFIER, l.word)
  39. -- Operators.
  40. local operator = token(l.OPERATOR, S('=><+-*^&:.,_()'))
  41. M._rules = {
  42. {'whitespace', ws},
  43. {'keyword', keyword},
  44. {'type', type},
  45. {'comment', comment},
  46. {'identifier', identifier},
  47. {'string', string},
  48. {'number', number},
  49. {'operator', operator},
  50. }
  51. return M