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

rexx.lua (3841B)


  1. -- Copyright 2006-2024 Mitchell. See LICENSE.
  2. -- Rexx LPeg lexer.
  3. local lexer = require('lexer')
  4. local token, word_match = lexer.token, lexer.word_match
  5. local P, S = lpeg.P, lpeg.S
  6. local lex = lexer.new('rexx')
  7. -- Whitespace.
  8. lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1))
  9. -- Keywords.
  10. lex:add_rule('keyword', token(lexer.KEYWORD, word_match({
  11. 'address', 'arg', 'by', 'call', 'class', 'do', 'drop', 'else', 'end', 'exit', 'expose', 'forever',
  12. 'forward', 'guard', 'if', 'interpret', 'iterate', 'leave', 'method', 'nop', 'numeric',
  13. 'otherwise', 'parse', 'procedure', 'pull', 'push', 'queue', 'raise', 'reply', 'requires',
  14. 'return', 'routine', 'result', 'rc', 'say', 'select', 'self', 'sigl', 'signal', 'super', 'then',
  15. 'to', 'trace', 'use', 'when', 'while', 'until'
  16. }, true)))
  17. -- Functions.
  18. lex:add_rule('function', token(lexer.FUNCTION, word_match({
  19. 'abbrev', 'abs', 'address', 'arg', 'beep', 'bitand', 'bitor', 'bitxor', 'b2x', 'center',
  20. 'changestr', 'charin', 'charout', 'chars', 'compare', 'consition', 'copies', 'countstr', 'c2d',
  21. 'c2x', 'datatype', 'date', 'delstr', 'delword', 'digits', 'directory', 'd2c', 'd2x', 'errortext',
  22. 'filespec', 'form', 'format', 'fuzz', 'insert', 'lastpos', 'left', 'length', 'linein', 'lineout',
  23. 'lines', 'max', 'min', 'overlay', 'pos', 'queued', 'random', 'reverse', 'right', 'sign',
  24. 'sourceline', 'space', 'stream', 'strip', 'substr', 'subword', 'symbol', 'time', 'trace',
  25. 'translate', 'trunc', 'value', 'var', 'verify', 'word', 'wordindex', 'wordlength', 'wordpos',
  26. 'words', 'xrange', 'x2b', 'x2c', 'x2d', --
  27. 'rxfuncadd', 'rxfuncdrop', 'rxfuncquery', 'rxmessagebox', 'rxwinexec', 'sysaddrexxmacro',
  28. 'sysbootdrive', 'sysclearrexxmacrospace', 'syscloseeventsem', 'sysclosemutexsem', 'syscls',
  29. 'syscreateeventsem', 'syscreatemutexsem', 'syscurpos', 'syscurstate', 'sysdriveinfo',
  30. 'sysdrivemap', 'sysdropfuncs', 'sysdroprexxmacro', 'sysdumpvariables', 'sysfiledelete',
  31. 'sysfilesearch', 'sysfilesystemtype', 'sysfiletree', 'sysfromunicode', 'systounicode',
  32. 'sysgeterrortext', 'sysgetfiledatetime', 'sysgetkey', 'sysini', 'sysloadfuncs',
  33. 'sysloadrexxmacrospace', 'sysmkdir', 'sysopeneventsem', 'sysopenmutexsem', 'sysposteventsem',
  34. 'syspulseeventsem', 'sysqueryprocess', 'sysqueryrexxmacro', 'sysreleasemutexsem',
  35. 'sysreorderrexxmacro', 'sysrequestmutexsem', 'sysreseteventsem', 'sysrmdir',
  36. 'syssaverexxmacrospace', 'syssearchpath', 'syssetfiledatetime', 'syssetpriority', 'syssleep',
  37. 'sysstemcopy', 'sysstemdelete', 'syssteminsert', 'sysstemsort', 'sysswitchsession',
  38. 'syssystemdirectory', 'systempfilename', 'systextscreenread', 'systextscreensize',
  39. 'sysutilversion', 'sysversion', 'sysvolumelabel', 'syswaiteventsem', 'syswaitnamedpipe',
  40. 'syswindecryptfile', 'syswinencryptfile', 'syswinver'
  41. }, true)))
  42. -- Identifiers.
  43. lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.alpha * (lexer.alnum + S('@#$\\.!?_'))^0))
  44. -- Strings.
  45. local sq_str = lexer.range("'", true, false)
  46. local dq_str = lexer.range('"', true, false)
  47. lex:add_rule('string', token(lexer.STRING, sq_str + dq_str))
  48. -- Comments.
  49. local line_comment = lexer.to_eol('--', true)
  50. local block_comment = lexer.range('/*', '*/', false, false, true)
  51. lex:add_rule('comment', token(lexer.COMMENT, line_comment + block_comment))
  52. -- Numbers.
  53. lex:add_rule('number', token(lexer.NUMBER, lexer.number))
  54. -- Preprocessor.
  55. lex:add_rule('preprocessor', token(lexer.PREPROCESSOR, lexer.to_eol(lexer.starts_line('#'))))
  56. -- Operators.
  57. lex:add_rule('operator', token(lexer.OPERATOR, S('=!<>+-/\\*%&|^~.,:;(){}')))
  58. -- Fold points
  59. lex:add_fold_point(lexer.KEYWORD, 'do', 'end')
  60. lex:add_fold_point(lexer.KEYWORD, 'select', 'return')
  61. lex:add_fold_point(lexer.COMMENT, '/*', '*/')
  62. -- lex:add_fold_point(lexer.OPERATOR, ':', ?)
  63. lexer.property['scintillua.comment'] = '--'
  64. return lex