|
From: | Lorenzo Bettini |
Subject: | Re: [Help-source-highlight] regexp for scheme blocks in lilypond language |
Date: | Sat, 21 Jan 2012 15:24:40 +0100 |
User-agent: | Mozilla/5.0 (X11; Linux i686; rv:8.0) Gecko/20111124 Thunderbird/8.0 |
On 01/18/2012 11:55 PM, Federico Bruni wrote:
Il 18/01/2012 10:01, Lorenzo Bettini ha scritto:On 18/01/2012 09:54, Federico Bruni wrote:Hi, lilypond files can contain blocks of scheme code in several ways. The main challenge is handling conflicts between single and multiline and especially blocks where the number of parentheses cannot be known in advance (there's a way to match balanced parentheses?).Hi very quick answer: you can match balanced parenthesis using 'nested' (see the documentation);Thanks, this should be the direction, but it's not so easy. First, the doc says: "Note that, in order for a delimited language element to be nested, its starting and ending elements must be different" I may be wrong, but I would add: they also have to be specular. In my case delimiters are not specular.
no, that's not requested :)note that end delimiter may refer to start delimiter (using the regex syntax for referring the matched part of another expression); this is the case for lua.lang where nested comments can have different syntax and the delimiter has to match the starting delimiter and refers to it (with this respect, source-highlight is pretty powerful, but I may be biased ;)
Start delimiter: #( End delimiter: ) I can't consider just parenthesis for two reasons: - I want to highlight # as well - ( and ) have also a different meaning (slurs) in lilypond synthax and must be highlighted differently So this doesn't work: scheme_block delim "(" ")" multiline nested I wrote this but it doesn't work correctly: scheme_block delim '(?<!#)\(' '\)' multiline nested The most external () block is omitted and slurs higlighting is broken (see file attached). What do you recommend to do?
you can (but I haven't tested it) have an 'environment/state' which uses 'start' that matches '#' followed by '(' (but '(' is not consumed, using lookahead) and inside this environment have the 'delim' environment... this will let you highlight # differently...
hope to hear from you soon cheers Lorenzo -- Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino ICQ# lbetto, 16080134 (GNU/Linux User # 158233) HOME: http://www.lorenzobettini.it MUSIC: http://www.purplesucker.com http://www.myspace.com/supertrouperabba BLOGS: http://tronprog.blogspot.com http://longlivemusic.blogspot.com http://www.gnu.org/software/src-highlite http://www.gnu.org/software/gengetopt http://www.gnu.org/software/gengen http://doublecpp.sourceforge.net
[Prev in Thread] | Current Thread | [Next in Thread] |