Hello,
I am writing a bundle for Spice-like circuit simulator input files. For these text files, one of the rules is to have the first line as a comment, no matter what is on the line. I was wondering how this could be incorporated into the language grammar to set the appropriate scope for the first line.
Pavan
On Jun 3, 2007, at 4:11 PM, Pavan Gunupudi wrote:
I am writing a bundle for Spice-like circuit simulator input files. For these text files, one of the rules is to have the first line as a comment, no matter what is on the line. I was wondering how this could be incorporated into the language grammar to set the appropriate scope for the first line.
This would almost be impossible because there is no way for a match or begin to see any surrounding line, hence it is impossible to know if your on the first line or not.
However we know there is a first line, so we can create a begin/end match that never ends to match the first line:
http://pastie.textmate.org/67495
Then put the remaining patterns inside it, case solved. (Note the use of capture 0 here, which matches the entire begin line.)
Neat hack. Works like a charm. Thanks.
Pavan
On 3-Jun-07, at 7:46 PM, Michael Sheets wrote:
On Jun 3, 2007, at 4:11 PM, Pavan Gunupudi wrote:
I am writing a bundle for Spice-like circuit simulator input files. For these text files, one of the rules is to have the first line as a comment, no matter what is on the line. I was wondering how this could be incorporated into the language grammar to set the appropriate scope for the first line.
This would almost be impossible because there is no way for a match or begin to see any surrounding line, hence it is impossible to know if your on the first line or not.
However we know there is a first line, so we can create a begin/end match that never ends to match the first line:
http://pastie.textmate.org/67495
Then put the remaining patterns inside it, case solved. (Note the use of capture 0 here, which matches the entire begin line.)
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate