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

gettext.lua (834B)


  1. -- Copyright 2006-2024 Mitchell. See LICENSE.
  2. -- Gettext 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('gettext')
  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. 'msgid msgid_plural msgstr fuzzy c-format no-c-format', true)))
  12. -- Identifiers.
  13. lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word))
  14. -- Variables.
  15. lex:add_rule('variable', token(lexer.VARIABLE, S('%$@') * lexer.word))
  16. -- Strings.
  17. lex:add_rule('string', token(lexer.STRING, lexer.range('"', true)))
  18. -- Comments.
  19. lex:add_rule('comment', token(lexer.COMMENT, lexer.to_eol('#' * S(': .~'))))
  20. lexer.property['scintillua.comment'] = '#'
  21. return lex