diff options
| author | Matěj Cepl <mcepl@cepl.eu> | 2023-08-11 01:27:32 +0200 |
|---|---|---|
| committer | Randy Palamar <randy@rnpnr.xyz> | 2024-03-27 06:04:21 -0600 |
| commit | 4c4392d29df777ff702dfe99b4f3c23142976e05 (patch) | |
| tree | 5355324abe18952f7d19d6cfc5dbeb5d6cb72b84 /lua/lexers/pico8.lua | |
| parent | 95bf9f59f8a9a37148bdc0787db378d62c7cd032 (diff) | |
| download | vis-4c4392d29df777ff702dfe99b4f3c23142976e05.tar.gz vis-4c4392d29df777ff702dfe99b4f3c23142976e05.tar.xz | |
update lexers to orbitalquark/scintillua@b789dde
Rather than cherry pick patches from after 6.2 we will just grab
everything as is.
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 |
