[TxMt] punctuation.whitespace.function-call.leading.c

Gerd Knops gerti-textmate at bitart.com
Fri Feb 8 19:35:02 UTC 2008


I get that. However could the same not be achieved without actually  
consuming the whitespace, eg with lookahead/lookbehind?

Gerd

On Feb 8, 2008, at 12:23 PM, Joachim Mårtensson wrote:

> So I guess I should explain why I added the leading spaces scope to  
> the
> grammar.
>
> TextMate syntax parser works as follows,
>
> for each line there will be a bunch of rules (the regexes in the  
> language
> files), that needs to be tested, these rules vary depending on scope  
> and
> other stuff.
>
> the way that textmate knows which rule "wins" depends on the  
> following,
>
> first the start position if there is a tie the order in which the  
> rules
> are defined, determines the winner.
>
> So how does this affect the C grammar?
> the way that I differentiate between function definitions and function
> calls in the C grammar, is that I start a new Scope when I encounter
> {...}, inside the braces rule I place an identical rule to the  
> function
> definition matcher. Since these rules are identical there will be a  
> tie
> when looking at just the start postion of the match, so order will
> determine. Outside of {...} the function-call rule will not win  
> since it
> isn't even defined there.
>
> So what is the problem?
> In short C++, there are a few constructs in C++ that looks like this
>
> void foo(){
> 	std::string myString("hello world");
> }
>
> Since we want to differentiate between function-calls and variable
> initialization such as the one above, we need a rule that matches  
> those,
> for technical reasons that rule needs to match the leading spaces.  
> Trouble
> is, this will make the rule win over the function-call rule, as the
> leading spaces will ensure a "headstart". It does not matter that it  
> has
> lower precedence than the function-call rule.
>
> Hopefully this explains things, If anyone can think of a better  
> solution
> please mail ideas.
>
> To Hans and everyone interested:
> Hans, I assume that you have defined a "super" grammar that includes  
> the C
> and Objective-C ones, in that case the problem is that your additional
> rules gets included at the root level, and that is included after the
> function-call matching inside {...}, this will probably be solvable  
> once
> Allan adds injections. Anyway perhaps you could send your grammar  
> file and
> we can decide on a format so that leading spaces will get scoped
> uniformly.
>
> Joachim Mårtensson
>
>
> ______________________________________________________________________
> 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