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

litcoffee.lua (766B)


  1. -- Copyright 2006-2024 Robert Gieseke. See LICENSE.
  2. -- Literate CoffeeScript LPeg lexer.
  3. -- http://coffeescript.org/#literate
  4. local lexer = require('lexer')
  5. local token = lexer.token
  6. local P, S = lpeg.P, lpeg.S
  7. local lex = lexer.new('litcoffee', {inherit = lexer.load('markdown')})
  8. -- Embedded CoffeeScript.
  9. local coffeescript = lexer.load('coffeescript')
  10. local coffee_start_rule = token(lexer.EMBEDDED, (P(' ')^4 + P('\t')))
  11. local coffee_end_rule = token(lexer.EMBEDDED, lexer.newline)
  12. lex:embed(coffeescript, coffee_start_rule, coffee_end_rule)
  13. -- Use 'markdown_whitespace' instead of lexer.WHITESPACE since the latter would expand to
  14. -- 'litcoffee_whitespace'.
  15. lex:modify_rule('whitespace', token('markdown_whitespace', S(' \t')^1 + S('\r\n')^1))
  16. return lex