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

props.lua (958B)


  1. -- Copyright 2006-2024 Mitchell. See LICENSE.
  2. -- Props LPeg lexer.
  3. local lexer = lexer
  4. local P, S = lpeg.P, lpeg.S
  5. local lex = lexer.new(..., {lex_by_line = true})
  6. -- Identifiers.
  7. lex:add_rule('identifier',
  8. lex:tag(lexer.IDENTIFIER, (lexer.alpha + S('.-_')) * (lexer.alnum + S('.-_')^0)))
  9. -- Colors.
  10. local xdigit = lexer.xdigit
  11. lex:add_rule('color',
  12. lex:tag(lexer.NUMBER, '#' * xdigit * xdigit * xdigit * xdigit * xdigit * xdigit))
  13. -- Comments.
  14. lex:add_rule('comment', lex:tag(lexer.COMMENT, lexer.to_eol('#')))
  15. -- Equals.
  16. lex:add_rule('equals', lex:tag(lexer.OPERATOR, '='))
  17. -- Strings.
  18. local sq_str = lexer.range("'")
  19. local dq_str = lexer.range('"')
  20. lex:add_rule('string', lex:tag(lexer.STRING, sq_str + dq_str))
  21. -- Variables.
  22. lex:add_rule('variable',
  23. lex:tag(lexer.OPERATOR, '$(') * lex:tag(lexer.VARIABLE, (lexer.nonnewline - lexer.space - ')')^0) *
  24. lex:tag(lexer.OPERATOR, ')'))
  25. lexer.property['scintillua.comment'] = '#'
  26. return lex