On 3/8/2006, at 11:05, cormullion@mac.com wrote:
I've got the idea of matching the names, but now I'm trying to work out how to match the shape of possible function definitions. Assuming temporarily that names are just [a-z]*, I'm trying to match:
(define (func) (define (fun arg1) (define (func arg1 arg2) (define (func arg1 arg2 arg3)
I can find these patterns with:
((define)(\s+)((\w+\s*)+())
but I can't successfully capture a variable number of arguments for use with 'capture'?
No, that is not possible, as regexp captures will only capture the last repeat.
In this case you would change the rule to using begin/end, like:
{ name = 'meta.function.newlisp'; begin = '((define)\s+('; beginCaptures = { 1 = { name = 'keyword.control.define.newlisp'; }; }; end = ')'; patterns = ( { name = 'variable.parameter.newlisp'; match = '[a-z]+'; } ); }