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

ada.lua (1790B)


  1. -- Copyright 2006-2024 Mitchell. See LICENSE.
  2. -- Ada 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('ada')
  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. 'abort', 'abs', 'abstract', 'accept', 'access', 'aliased', 'all', 'and', 'array', 'at', 'begin',
  12. 'body', 'case', 'constant', 'declare', 'delay', 'delta', 'digits', 'do', 'else', 'elsif', 'end',
  13. 'entry', 'exception', 'exit', 'for', 'function', 'generic', 'goto', 'if', 'in', 'interface', 'is',
  14. 'limited', 'loop', 'mod', 'new', 'not', 'null', 'of', 'or', 'others', 'out', 'overriding',
  15. 'package', 'parallel', 'pragma', 'private', 'procedure', 'protected', 'raise', 'range', 'record',
  16. 'rem', 'renames', 'requeue', 'return', 'reverse', 'select', 'separate', 'some', 'subtype',
  17. 'synchronized', 'tagged', 'task', 'terminate', 'then', 'type', 'until', 'use', 'when', 'while',
  18. 'with', 'xor', --
  19. 'true', 'false'
  20. }, true)))
  21. -- Types.
  22. lex:add_rule('type', token(lexer.TYPE, word_match({
  23. 'boolean', 'character', 'count', 'duration', 'float', 'integer', 'long_float', 'long_integer',
  24. 'priority', 'short_float', 'short_integer', 'string'
  25. }, true)))
  26. -- Identifiers.
  27. lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word))
  28. -- Strings.
  29. lex:add_rule('string', token(lexer.STRING, lexer.range('"', true, false)))
  30. -- Comments.
  31. lex:add_rule('comment', token(lexer.COMMENT, lexer.to_eol('--')))
  32. -- Numbers.
  33. lex:add_rule('number', token(lexer.NUMBER, lexer.number_('_')))
  34. -- Operators.
  35. lex:add_rule('operator', token(lexer.OPERATOR, S(':;=<>&+-*/.()')))
  36. lexer.property['scintillua.comment'] = '--'
  37. return lex