1 -- Copyright 2006-2013 Robert Gieseke. See LICENSE.
2 -- Lilypond LPeg lexer.
3 -- TODO Embed Scheme; Notes?, Numbers?
5 local l
= require('lexer')
6 local token
, word_match
= l
.token
, l
.word_match
7 local P
, R
, S
= lpeg
.P
, lpeg
.R
, lpeg
.S
9 local M
= {_NAME
= 'lilypond'}
12 local ws
= token(l
.WHITESPACE
, l
.space^
1)
15 local line_comment
= '%' * l
.nonnewline^
0
16 -- TODO: block comment.
17 local comment
= token(l
.COMMENT
, line_comment
)
20 local string = token(l
.STRING
, l
.delimited_range('"', false, true))
22 -- Keywords, commands.
23 local keyword
= token(l
.KEYWORD
, '\\' * l
.word
)
26 local identifier
= token(l
.IDENTIFIER
, l
.word
)
29 local operator
= token(l
.OPERATOR
, S("{}'~<>|"))
36 {'operator', operator
},
37 {'identifier', identifier
},