newdatasystems / vscode-foxpro

VSCode Extension for the Microsoft Visual Foxpro programming language
MIT License
20 stars 5 forks source link

strings #9

Open tpeixinho opened 3 months ago

tpeixinho commented 3 months ago

Hi,

with this code: && xxx ** ccccc wait window "str('', '"')" wait window 'str("", "'")' for i=1 to 10 msg("ola") next

you can see that it breaks coloring because of ' inside "

you can fix this with these changes in FoxPro.plist:

<dict>
        <key>match</key>
        <string>(")(.*)(")</string>
        <key>name</key>
        <string>string.foxpro</string>
    </dict>
<dict>
        <key>match</key>
        <string>(')(.*)(')</string>
        <key>name</key>
        <string>string.foxpro</string>
    </dict>
<dict>
        <key>match</key>
        <string>(\[)(.*)(\])</string>
        <key>name</key>
        <string>string.foxpro</string>
    </dict>

    <!-- <dict>
        <key>begin</key>
        <string>(")</string>
        <key>beginCaptures</key>
        <dict>
            <key>0</key>
            <dict>
                <key>name</key>
                <string>punctuation.definition.string.begin.foxpro</string>
            </dict>
        </dict>
        <key>end</key>
        <string>(")</string>
        <key>endCaptures</key>
        <dict>
            <key>0</key>
            <dict>
                <key>name</key>
                <string>punctuation.definition.string.end.foxpro</string>
            </dict>
        </dict>
        <key>name</key>
        <string>string.quoted.double.foxpro</string>
        <key>patterns</key>
        <array>
            <dict>
                <key>match</key>
                <string>("")</string>
                <key>name</key>
                <string>constant.character.escape.apostrophe.foxpro</string>
            </dict>
        </array>
    </dict>
<dict>
        <key>begin</key>
        <string>(')</string>
        <key>beginCaptures</key>
        <dict>
            <key>0</key>
            <dict>
                <key>name</key>
                <string>punctuation.definition.string.begin.foxpro</string>
            </dict>
        </dict>
        <key>end</key>
        <string>(')</string>
        <key>endCaptures</key>
        <dict>
            <key>0</key>
            <dict>
                <key>name</key>
                <string>punctuation.definition.string.end.foxpro</string>
            </dict>
        </dict>
        <key>name</key>
        <string>string.quoted.double.foxpro</string>
    </dict> -->
tpeixinho commented 3 months ago

I got the solution from: https://github.com/mattslay/Sublime-Text-2-Syntax-Coloring-for-Visual-FoxPro/blob/master/Visual%20Foxpro.tmLanguage

maybe you can incorporate other things too.

tpeixinho commented 3 months ago

even better solution for both double and single quotes:

<dict>
  <key>match</key>
  <string>(["'])(?:(?=(\\?))\2.)*?\1</string>
  <key>name</key>
  <string>string.foxpro</string>
</dict>
<dict>
  <key>match</key>
  <string>(\[)(.*)(\])</string>
  <key>name</key>
  <string>string.foxpro</string>
</dict>