[TxMt] (Another) Language grammar question

Édouard Gilbert edouard.gilbert at eleves.bretagne.ens-cachan.fr
Sun Jun 3 22:57:14 UTC 2007


Hi everyone,

<not very interesting context>
I'm currently working with a software called OpenMusic. It's based on  
an extension of Lisp and make massive use of CLOS.

I thus often have to define new classes. I don't know if it's CLOS or  
OpenMusic related, but class slots definition are quite ineffective.  
Typically, defining a class in OM would look like

(defclass* name (superclasses)
	((<slot name> :accessor <slot name> :initarg :<slot name> :initform  
<default value> :type <type of the slot>
	  :documentation "<obscure string>"))
)

The boring part, that is slot definition, could of course benefit a  
lot of snippets. Typically, a <enter> short cut (or is it <return> ?  
Well, the keypad one.), as in LaTeX itemize environment, would be  
perfect.

So I'd like to define and extension of the Lisp language to match my  
need. I already had a slight problem and expect more to come (like  
when I started to write one for the GP language).

So here is the first one that I met. As you can see above, class are  
usually defined by defclass* instead of defclass.
I didn't find in the documentation how to match the * character.  
Escaping the * with \, as in

		{	name = 'meta.class.lisp.openmusic';
			match = '(\b(defclass|defclass\*)\b)(\s+)((\w|\-|\!|\?)*)';
			captures = {
				2 = { name = 'storage.type.class.lisp.openmusic'; };
				4 = { name = 'entity.name.class.lisp.openmusic'; };
			# Of course, there are still plenty of things missing.
		};

apparently won't work. What did I wrote wrong in that part ? It's  
just the meta.function.lisp rewritten and it does what expected when  
used with "defclass".

Thanks for your help,
Édouard

PS : I know I could perfectly avoid such troubles by creating a tab  
triggered snippet, but that's just a nice occasion to get in TM  
languages definition a bit further.


More information about the textmate mailing list