[TxMt] language grammars

sam aaron sam.maillists at googlemail.com
Mon Oct 9 17:07:37 UTC 2006


thanks for your clarifications Allan :-)

On 09/10/06, Allan Odgaard <throw-away-1 at macromates.com> wrote:
> On 9. Oct 2006, at 18:39, sam aaron wrote:
>
> >> This is not how the parser works. When one rule has matched a portion
> >> of the text, no other rules can match that text.
> > ok, so only one scope can be applied to each character of the
> > document?
>
> Only one rule can assign a scope to a particular character, yes. But
> scopes nest, so if you use a begin/end rule, everything matching
> inside this, will inherit the scope of the begin/end rule.
>
> >> but it appears to me that
> >> what you want is for the different rules to overlap, i.e. match the
> >> same characters in the document.
> >
> > yes, for some reason i thought that this was possible. For example,
> > consider the following line:
> >
> > * this is part of a list _here i want italics_
> >
> > I thought it was possible to have the characters between the
> > underscores to belong to an 'italic scope' and also a 'list item
> > scope'.  I guess you kind of achieve this by naming the italics scope
> > as an extention of the list scope: list.italics or is it recommended
> > to just use an italics scope, losing its relationship with the list?
>
> You nest the rules, e.g.:
>
>     { name = 'markup.list';
>       begin = '^ \* '; // simplified list item start
>       end = '$';       // end list item at end-of-line
>       patterns = (
>           { name = 'markup.italic';
>             begin = '_'; end = '_';
>           }
>       );
>     }
>
> > My next question (which I think I already know the answer to), so if I
> > want to have the equivalent of an underscore italics rule, i have to
> > declare it as an internal pattern to all the patterns I want itallic
> > behaviour inside? I guess this is where you'd use the grammar
> > repository?
>
> Yes.
>
>
>
>
> ______________________________________________________________________
> For new threads USE THIS: textmate at lists.macromates.com
> (threading gets destroyed and the universe will collapse if you don't)
> http://lists.macromates.com/mailman/listinfo/textmate
>



More information about the textmate mailing list