Using the capture from begin in the text between in tmLanguage

165 Views Asked by At

enter image description here

I am trying to color my language like this, where the loop variable in detected from the variable name in the ?myFor and subsequently colored in the body of the for loop.

My grammar looks like this for now where I am able to detect begin and end using ?myFor and ?endMyFor. But I can't seem to understand how I can use the capture group from the begin's capture for the rest of the body.

<key>begin</key>
            <string>\s*\\?myFor\s?\((.*)\s*=.?,\s*(.*)(<=|<|>|>=|=|==|!=).*,\s*(.*)(\+=|=|-|-=|\*)</string>
            <key>beginCaptures</key>
            <dict>
                <key>1</key>
                <dict>
                    <key>name</key>
                    <string>support.variable.generic.a</string>
                </dict>
                <key>2</key>
                <dict>
                    <key>name</key>
                    <string>support.variable.generic.a</string>
                </dict>
                <key>4</key>
                <dict>
                    <key>name</key>
                    <string>support.variable.generic.a</string>
                </dict>
            </dict>
            <key>end</key>
            <string>\?endMyFor</string>
0

There are 0 best solutions below