From 8a420ecc4c1ed50111464ec66901bd983eaf2dbd Mon Sep 17 00:00:00 2001 From: qiu-x Date: Wed, 29 Jun 2022 07:56:51 +0200 Subject: Resync the lexers with Scintillua - Resync the lexers with Scintillua - Update the lexer readme - Update `zenburn` theme to fix some highlighting issues - lexers: redirect print function to vis:info() - Fix support for custom style names - As per error message "lexer.delimited_range() is deprecated, use lexer.range()". - Remove remaining `lexer.delimited_range()` call - Set syntax to `nil` if the file type has no matching lexer - Updated Go lexer for Go 1.18. - lexers/dsv: convert to new lexer format (cherry picked from commit 9edbc3cd9ea1d7142b1305840432a3d2739e755a) - lexers/gemini: disable legacy gemini lexer This reverts commit 468f9ee1b027a7ce98b1a249fa1af5888feeb989. It is in legacy format and of questionable quality. Ideally it should be contributed upstream from where it will eventually trickle down to us. - lexers/git-rebase: convert to new lexer format (cherry picked from commit 4000a4cc9ac4a4c2869dfae772b977a82aee8d8c) - lexers/strace: convert to new lexer format (cherry picked from commit e420451320d97eb164f5629c1bcfab0b595be29d) - lexers/typescript: add new upstream lexer revision 28e2b60 (cherry picked from commit 7326e6deecdaa75fa94ae9ebdb653f9f907b33f2) - use `package.searchpath` instead of a local `searchpath` function - Restore `filetype: support filetype detection via hashbang` - Remove redundant comment - Restore gemini lexer --- lua/lexers/pico8.lua | 60 +++++++++++++++++++--------------------------------- 1 file changed, 22 insertions(+), 38 deletions(-) (limited to 'lua/lexers/pico8.lua') diff --git a/lua/lexers/pico8.lua b/lua/lexers/pico8.lua index d6df3e2..03f260e 100644 --- a/lua/lexers/pico8.lua +++ b/lua/lexers/pico8.lua @@ -1,53 +1,37 @@ --- Copyright 2016-2017 Alejandro Baez (https://keybase.io/baez). See LICENSE. --- PICO-8 Lexer. +-- Copyright 2016-2022 Alejandro Baez (https://keybase.io/baez). See LICENSE. +-- PICO-8 lexer. -- http://www.lexaloffle.com/pico-8.php -local l = require('lexer') -local token, word_match = l.token, l.word_match -local P, R, S = lpeg.P, lpeg.R, lpeg.S +local lexer = require('lexer') +local token, word_match = lexer.token, lexer.word_match +local P, S = lpeg.P, lpeg.S -local M = {_NAME = 'pico8'} +local lex = lexer.new('pico8') -- Whitespace -local ws = token(l.WHITESPACE, l.space^1) - --- Comments -local comment = token(l.COMMENT, '//' * l.nonnewline_esc^0) - --- Numbers -local number = token(l.NUMBER, l.integer) +lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) -- Keywords -local keyword = token(l.KEYWORD, word_match{ - '__lua__', '__gfx__', '__gff__', '__map__', '__sfx__', '__music__' -}) +lex:add_rule('keyword', + token(lexer.KEYWORD, word_match('__lua__ __gfx__ __gff__ __map__ __sfx__ __music__'))) -- Identifiers -local identifier = token(l.IDENTIFIER, l.word) +lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) --- Operators -local operator = token(l.OPERATOR, S('_')) +-- Comments +lex:add_rule('comment', token(lexer.COMMENT, lexer.to_eol('//', true))) -M._rules = { - {'whitespace', ws}, - {'keyword', keyword}, - {'identifier', identifier}, - {'comment', comment}, - {'number', number}, - {'operator', operator}, -} +-- Numbers +lex:add_rule('number', token(lexer.NUMBER, lexer.integer)) --- Embed Lua into PICO-8. -local lua = l.load('lua') +-- Operators +lex:add_rule('operator', token(lexer.OPERATOR, '_')) +-- Embed Lua into PICO-8. +local lua = lexer.load('lua') local lua_start_rule = token('pico8_tag', '__lua__') -local lua_end_rule = token('pico8_tag', '__gfx__' ) -l.embed_lexer(M, lua, lua_start_rule, lua_end_rule) - -M._tokenstyles = { - pico8_tag = l.STYLE_EMBEDDED -} - -M._foldsymbols = lua._foldsymbols +local lua_end_rule = token('pico8_tag', '__gfx__') +lex:embed(lua, lua_start_rule, lua_end_rule) +lex:add_style('pico8_tag', lexer.styles.embedded) -return M +return lex -- cgit v1.2.3