Hello,
I am working on a language grammar for HCS12 assembly language. I have read the portion of the manual on language grammars (chapter 12) and unfortunately for me it has led to more questions than answers. I have read the re.txt file and have tried many things with no apparent effect, certainly not the one I am looking for.
I have the following code that matches a label definition perfectly:
{ name = 'string.label.def'; comment = 'case insensitive - label definition'; match = '^(\S)+:'; captures = { 1 = { name = 'string.label'; }; }; },
Now what I want to do is use the capture in another match statement to find all references to the same labels when they are being called. They will no longer be the first word of line and they will no longer have a ":" suffix. It seems to me that capture group above should have just the labels. If I could use that capture group to then find all matches of the label then my problem to match unknown labels and not get false matches to other strings that are not being matched.
An example code snippet my language grammar is intended for is:
staa PORTB ; light the segments ldaa PTP ; only alter port p bits we are using anda #$f0 oraa dspmap,x ; light up correct char staa PTP bra TA3 TA2: bset PTP #$0f ; turn off seven segment LEDs movb displ PORTB ; set value of LED row bclr PTJ #2 ; turn on LED row TA3:
In the above snippet TA2: and TA3: are matched by my regex. I want to use capture group if possible to match the labels when in the third column, in the above snippet only TA3 is shown. I don't want to match anything in the third column that is not a label. A label will never appear in the first column which is already matched by other regex. The forth column are obviously comments and they are matched by other regex.
So, how do I do what I want to do?
Thank you kindly in advance, ~Chris
-- View this message in context: http://textmate.1073791.n5.nabble.com/is-it-possible-to-use-a-capture-in-ano... Sent from the textmate users mailing list archive at Nabble.com.
On Oct 18, 2012, at 11:14 AM, Chris Knight cpk.stealth@gmail.com wrote:
[…] I want to do is use the capture in another match statement to find all references to the same labels when they are being called.
Sorry, this is not possible.
In your example you branch forward to the label (before it’s declared), so there would be no way to achieve your desired goal (of highlighting known labels) without a multi-pass parser (which the TextMate syntax highlighter is certainly not).