diff options
Diffstat (limited to 'lua/lexers/pico8.lua')
| -rw-r--r-- | lua/lexers/pico8.lua | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/lua/lexers/pico8.lua b/lua/lexers/pico8.lua index 03f260e..760dc4f 100644 --- a/lua/lexers/pico8.lua +++ b/lua/lexers/pico8.lua @@ -1,37 +1,35 @@ --- Copyright 2016-2022 Alejandro Baez (https://keybase.io/baez). See LICENSE. +-- Copyright 2016-2024 Alejandro Baez (https://keybase.io/baez). See LICENSE. -- PICO-8 lexer. -- http://www.lexaloffle.com/pico-8.php -local lexer = require('lexer') -local token, word_match = lexer.token, lexer.word_match +local lexer = lexer +local word_match = lexer.word_match local P, S = lpeg.P, lpeg.S -local lex = lexer.new('pico8') - --- Whitespace -lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1)) +local lex = lexer.new(...) -- Keywords lex:add_rule('keyword', - token(lexer.KEYWORD, word_match('__lua__ __gfx__ __gff__ __map__ __sfx__ __music__'))) + lex:tag(lexer.KEYWORD, lexer.word_match('__gff__ __map__ __sfx__ __music__'))) -- Identifiers -lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word)) +lex:add_rule('identifier', lex:tag(lexer.IDENTIFIER, lexer.word)) -- Comments -lex:add_rule('comment', token(lexer.COMMENT, lexer.to_eol('//', true))) +lex:add_rule('comment', lex:tag(lexer.COMMENT, lexer.to_eol('//', true))) -- Numbers -lex:add_rule('number', token(lexer.NUMBER, lexer.integer)) +lex:add_rule('number', lex:tag(lexer.NUMBER, lexer.integer)) -- Operators -lex:add_rule('operator', token(lexer.OPERATOR, '_')) +lex:add_rule('operator', lex:tag(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__') +local lua_start_rule = lex:tag(lexer.KEYWORD, word_match('__lua__')) +local lua_end_rule = lex:tag(lexer.KEYWORD, word_match('__gfx__')) lex:embed(lua, lua_start_rule, lua_end_rule) -lex:add_style('pico8_tag', lexer.styles.embedded) + +lexer.property['scintillua.comment'] = '//' return lex |
