[TxMt] Re: language grammars

sam aaron sam.maillists at googlemail.com
Sun Oct 8 19:52:16 UTC 2006


After a bit more work I've come up with the following:

{	scopeName = 'source.feedback';
	fileTypes = ( 'feedback' );
	patterns = (
		{	name = 'meta.comment.suggestion.feedback';
			match = '\s-  suggestion:\s".*"\s?\n';
		},
		{	name = 'keyword.other.feedback';
			match = '\b(suggestion|query|typo)\b';
		},
		{	name = 'markup.italic.feedback';
			match = '\b_.*?_\b';
		},
	);
}

This is a list of rules I'd like to get working, but they don't seem
to play nicely together. For example, if the meta pattern matches a
line, then the keyword and markup patterns fail to match anything
inside the meta pattern.

If I add a final pattern at the end of the patterns list:

{       include = 'source.yaml'; },

Then this seems to override the keyword and markup patterns, but not
the meta pattern. I really don't understand this behaviour.

Hopefully this makes my query a little easier to understand.

Thanks again,
Sam Aaron



On 08/10/06, sam aaron <sam.maillists at googlemail.com> wrote:
> Hi there,
>
> I'm working on a particular form of yaml (called Feedback) which I'm
> using as a way of marking up suggestions for documentation. It's still
> in very early days (say, about 3 hours), but I'm having trouble
> writing my own language grammar for it.
>
> An example Feedback file currently looks like this:
>
>
> thesis_author: chris
> version: 1
> commenter: sam
>
> errata:
>   6:
>     para: 1
>     comments:
>
>       -  suggestion: "_in which there are no jobs_, what are jobs?
> Wouldn't it be simpler to just say that DynaSOAr (oh the pain of mixed
> case acronyms!) only consists of services?"
>
>     para: 2
>     comments:
>
>       -  query: "If you're capitalising Web service with capital W,
> lower case s, why is 'Web Service Provider' all uppercase?"
>
>       -  typo: "_who's responsibility is to recieve..._ should be
> whose, and receive. Does LyX still not have a spell-checker? :-("
>
>       -  typo: "_dynmaically_ should be dynamically"
>
>       -  suggestion: "_The ability to dynmaically deploy services in
> response to consumer requests without interruption to the invocation
> gives considerable scope for different deployment patterns._ This
> sentence needs breaking down."
>
>
> This document describes some comments on paragraphs 1 and 2 of page 6
> of chris's thesis. As you can see, there are currently three types of
> comment, a query, suggestion and typo.
>
> I would like the file to have all the features of yaml (inheriting
> from the lovely yaml bundle), yet override certain things. I want
> everything between underscores to be italicised (although this will
> probably change due to code_variables), and I want the different types
> of comment to be understood by the language grammar separately. I also
> want certain keywords to be understood.
>
> Attempting to implement these, I came up with the following:
>
> {       scopeName = 'source.yaml.feedback';
>         fileTypes = ( 'feedback' );
>         patterns = (
>                 {       name = 'markup.italic.feedback';
>                         begin = '_';
>                         end = '_';
>                 },
>                 {       name = 'keyword.control.feedback.suggestion';
>                         begin = '-  suggestion: "';
>                         end = '"';
>                         patterns = (
>                                 {       name = 'keyword.operator.feedback';
>                                         match = 'suggestion';
>                                 }
>                         );
>                 },
>                 {       include = 'source.yaml'; },
>         );
> }
>
>
> However, I didn't get the behaviour I wanted. Nothing seems to be in
> italics, the suggestion keyword is scoped as
> 'keyword.control.feedback.suggestion', and 'source.yaml.feedback'
> only. There's no mention of 'keyword.operator.feedback'.
>
> Is there anything obvious that I seem to be doing incorrectly? How is
> it possible to get a bunch of characters to be scoped with different
> names. I want to be able to write something like:
>
> {       name = 'keyword.control.feedback';
>                         match = '\b(suggestion|query|typo|technical)\b';
> },
>
> I'm sorry if I'm being a numpty with this!
>
> Thanks in advance of any help,
> Sam Aaron
>



More information about the textmate mailing list