vis

a vi-like editor based on Plan 9's structural regular expressions

git clone https://9o.is/git/vis.git

lilypond.lua

(844B)


      1 -- Copyright 2006-2025 Robert Gieseke. See LICENSE.
      2 -- Lilypond LPeg lexer.
      3 -- TODO Embed Scheme; Notes?, Numbers?
      4 
      5 local lexer = require('lexer')
      6 local token, word_match = lexer.token, lexer.word_match
      7 local P, S = lpeg.P, lpeg.S
      8 
      9 local lex = lexer.new('lilypond')
     10 
     11 -- Whitespace.
     12 lex:add_rule('whitespace', token(lexer.WHITESPACE, lexer.space^1))
     13 
     14 -- Keywords, commands.
     15 lex:add_rule('keyword', token(lexer.KEYWORD, '\\' * lexer.word))
     16 
     17 -- Identifiers.
     18 lex:add_rule('identifier', token(lexer.IDENTIFIER, lexer.word))
     19 
     20 -- Strings.
     21 lex:add_rule('string', token(lexer.STRING, lexer.range('"', false, false)))
     22 
     23 -- Comments.
     24 -- TODO: block comment.
     25 lex:add_rule('comment', token(lexer.COMMENT, lexer.to_eol('%')))
     26 
     27 -- Operators.
     28 lex:add_rule('operator', token(lexer.OPERATOR, S("{}'~<>|")))
     29 
     30 lexer.property['scintillua.comment'] = '%'
     31 
     32 return lex