diff options
| author | orbitalquark <70453897+orbitalquark@users.noreply.github.com> | 2024-09-18 13:33:23 -0400 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2025-01-04 12:22:38 -0700 |
| commit | e3d6bdac6d0e7010143c048bf885fb72f47f2b73 (patch) | |
| tree | 7e95462f15e955f31559eef2bcdc5f9f0ea248bf | |
| parent | a916f1cf4291da3ba4ffc55df6427497b4006f93 (diff) | |
| download | vis-e3d6bdac6d0e7010143c048bf885fb72f47f2b73.tar.gz vis-e3d6bdac6d0e7010143c048bf885fb72f47f2b73.tar.xz | |
Migrate Literate Coffeescript lexer
| -rw-r--r-- | lua/lexers/litcoffee.lua | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/lua/lexers/litcoffee.lua b/lua/lexers/litcoffee.lua index 1b03501..e734c66 100644 --- a/lua/lexers/litcoffee.lua +++ b/lua/lexers/litcoffee.lua @@ -2,20 +2,18 @@ -- Literate CoffeeScript LPeg lexer. -- http://coffeescript.org/#literate -local lexer = require('lexer') -local token = lexer.token +local lexer = lexer local P, S = lpeg.P, lpeg.S -local lex = lexer.new('litcoffee', {inherit = lexer.load('markdown')}) +local lex = lexer.new(..., {inherit = lexer.load('markdown')}) + +-- Distinguish between horizontal and vertical space so coffee_start_rule has a chance to match. +lex:modify_rule('whitespace', lex:tag(lexer.WHITESPACE, S(' \t')^1 + S('\r\n')^1)) -- Embedded CoffeeScript. local coffeescript = lexer.load('coffeescript') -local coffee_start_rule = token(lexer.EMBEDDED, (P(' ')^4 + P('\t'))) -local coffee_end_rule = token(lexer.EMBEDDED, lexer.newline) +local coffee_start_rule = #(P(' ')^4 + P('\t')) * lex:get_rule('whitespace') +local coffee_end_rule = #lexer.newline * lex:get_rule('whitespace') 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 |
