aboutsummaryrefslogtreecommitdiff
path: root/lua/lexers/nim.lua
diff options
context:
space:
mode:
authorMatěj Cepl <mcepl@cepl.eu>2023-08-11 01:27:32 +0200
committerRandy Palamar <randy@rnpnr.xyz>2024-03-27 06:04:21 -0600
commit4c4392d29df777ff702dfe99b4f3c23142976e05 (patch)
tree5355324abe18952f7d19d6cfc5dbeb5d6cb72b84 /lua/lexers/nim.lua
parent95bf9f59f8a9a37148bdc0787db378d62c7cd032 (diff)
downloadvis-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/nim.lua')
-rw-r--r--lua/lexers/nim.lua15
1 files changed, 5 insertions, 10 deletions
diff --git a/lua/lexers/nim.lua b/lua/lexers/nim.lua
index af333bb..a6f0335 100644
--- a/lua/lexers/nim.lua
+++ b/lua/lexers/nim.lua
@@ -1,4 +1,4 @@
--- Copyright 2006-2022 Mitchell. See LICENSE.
+-- Copyright 2006-2024 Mitchell. See LICENSE.
-- Nim LPeg lexer.
local lexer = require('lexer')
@@ -86,17 +86,12 @@ local block_comment = lexer.range('#[', ']#')
lex:add_rule('comment', token(lexer.COMMENT, block_comment + line_comment))
-- Numbers.
-local dec = lexer.digit^1 * ('_' * lexer.digit^1)^0
-local hex = '0' * S('xX') * lexer.xdigit^1 * ('_' * lexer.xdigit^1)^0
-local bin = '0' * S('bB') * S('01')^1 * ('_' * S('01')^1)^0 * -lexer.xdigit
-local oct = '0o' * lpeg.R('07')^1
-local integer = S('+-')^-1 * (bin + hex + oct + dec) *
- ("'" * S('iIuUfF') * (P('8') + '16' + '32' + '64'))^-1
-local float = lexer.digit^1 * ('_' * lexer.digit^1)^0 * ('.' * ('_' * lexer.digit)^0)^-1 * S('eE') *
- S('+-')^-1 * lexer.digit^1 * ('_' * lexer.digit^1)^0
-lex:add_rule('number', token(lexer.NUMBER, float + integer))
+lex:add_rule('number', token(lexer.NUMBER, lexer.float_('_') + lexer.integer_('_') *
+ ("'" * S('iIuUfF') * (P('8') + '16' + '32' + '64'))^-1))
-- Operators.
lex:add_rule('operator', token(lexer.OPERATOR, S('=+-*/<>@$~&%|!?^.:\\`()[]{},;')))
+lexer.property['scintillua.comment'] = '#'
+
return lex