diff options
author | mitchell <unknown> | 2018-03-11 23:04:41 -0400 |
---|---|---|
committer | mitchell <unknown> | 2018-03-11 23:04:41 -0400 |
commit | 519b7328b66c4c84f03893a31e4be5ba6b1395f2 (patch) | |
tree | 2055cd79006357e94c185f341d0df17b9a8769eb /lexlua/litcoffee.lua | |
parent | c0373e036e965a70045971e2abc582cb4bf12a4e (diff) | |
download | scintilla-mirror-519b7328b66c4c84f03893a31e4be5ba6b1395f2.tar.gz |
Added optional Lua lexer support.
This support is disabled by default and must be enabled via compile-time option.
Diffstat (limited to 'lexlua/litcoffee.lua')
-rw-r--r-- | lexlua/litcoffee.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lexlua/litcoffee.lua b/lexlua/litcoffee.lua new file mode 100644 index 000000000..d122ae2db --- /dev/null +++ b/lexlua/litcoffee.lua @@ -0,0 +1,22 @@ +-- Copyright 2006-2018 Robert Gieseke. See License.txt. +-- Literate CoffeeScript LPeg lexer. +-- http://coffeescript.org/#literate + +local lexer = require('lexer') +local token = lexer.token +local P, S = lpeg.P, lpeg.S + +local lex = lexer.new('litcoffee', {inherit = lexer.load('markdown')}) + +-- Embedded CoffeeScript. +local coffeescript = lexer.load('coffeescript') +local coffee_start_rule = token(lexer.STYLE_EMBEDDED, (P(' ')^4 + P('\t'))) +local coffee_end_rule = token(lexer.STYLE_EMBEDDED, lexer.newline) +lex:embed(coffeescript, coffee_start_rule, coffee_end_rule) + +-- Use 'markdown_whitespace' instead of lexer.WHITESPACE since the latter would +-- expand to 'litcoffee_whitespace'. +lex:modify_rule('whitespace', token('markdown_whitespace', S(' \t')^1 + + S('\r\n')^1)) + +return lex |