<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
    <dict>
        <key>uuid</key>
        <string>6052353D-4EDA-4263-9535-4293100AA58A</string>
        <key>patterns</key>
        <array>
            <dict>
                <key>include</key>
                <string>#comments</string>
            </dict>
            <dict>
                <key>name</key>
                <string>support.constant.dbo.sql</string>
                <key>match</key>
                <string>(dbo|\[dbo\])</string>
            </dict>
            <dict>
                <key>name</key>
                <string>constant.other.symbol</string>
                <key>match</key>
                <string>\w+.(dbo|\[dbo\]).\w+</string>
            </dict>
            <dict>
                <key>include</key>
                <string>#variables</string>
            </dict>
            <dict>
                <key>include</key>
                <string>#quoted-identifier</string>
            </dict>
            <dict>
                <key>include</key>
                <string>#types</string>
            </dict>
            <dict>
                <key>include</key>
                <string>#single-quote-string</string>
            </dict>
            <dict>
                <key>begin</key>
                <string>(OBJECT_ID)(\()</string>
                <key>endCaptures</key>
                <dict>
                    <key>1</key>
                    <dict>
                        <key>name</key>
                        <string>punctuation.args.end.sql</string>
                    </dict>
                </dict>
                <key>beginCaptures</key>
                <dict>
                    <key>2</key>
                    <dict>
                        <key>name</key>
                        <string>punctuation.args.start.sql</string>
                    </dict>
                    <key>1</key>
                    <dict>
                        <key>name</key>
                        <string>support.function.sql</string>
                    </dict>
                </dict>
                <key>name</key>
                <string>meta.f.object-id.sql</string>
                <key>patterns</key>
                <array>
                    <dict>
                        <key>include</key>
                        <string>#single-quote-string</string>
                    </dict>
                </array>
                <key>end</key>
                <string>(\))</string>
            </dict>
            <dict>
                <key>name</key>
                <string>keyword.control.batch.sql</string>
                <key>match</key>
                <string>(?i)^\s*GO\b</string>
            </dict>
            <dict>
                <key>name</key>
                <string>keyword.control.sql</string>
                <key>match</key>
                <string>(?i)\b(EXEC)\b</string>
            </dict>
            <dict>
                <key>name</key>
                <string>keyword.control.logic.sql</string>
                <key>match</key>
                <string>(?i)\b(IF)\b</string>
            </dict>
            <dict>
                <key>name</key>
                <string>constant.language.sql</string>
                <key>match</key>
                <string>(?i)\b(NULL|NOT NULL|ASC|DESC)\b</string>
            </dict>
            <dict>
                <key>name</key>
                <string>keyword.control.operator.sql</string>
                <key>match</key>
                <string>(?i)\b(AND|OR|NOT|IS|IN|EXISTS|GOTO)\b</string>
            </dict>
            <dict>
                <key>name</key>
                <string>keyword.control.definitions.sql</string>
                <key>match</key>
                <string>(?i)\b(AS|BEGIN|END|BEGIN CATCH|END CATCH|CATCH|RAISERROR|RETURN)\b</string>
            </dict>
            <dict>
                <key>name</key>
                <string>keyword.data.sql</string>
                <key>match</key>
                <string>(?i)\b(INSERT|INTO|DELETE|SELECT|FROM|WHERE|ORDER BY|UNION|VALUES|REFERENCES|PRIMARY KEY|IDENTITY|DEFAULT|INNER|JOIN|DECLARE|SET|TABLE|OUTPUT|UPDATE|DISTINCT|ON|PRINT|CREATE VIEW|FOR XML PATH|FETCH|WHILE|NEXT|OPEN|FOR)\b</string>
            </dict>
            <dict>
                <key>name</key>
                <string>entity.name.function</string>
                <key>match</key>
                <string>(?i)\b(DATEDIFF|getdate)\b</string>
            </dict>

            <dict>
                <key>captures</key>
                <dict>
                    <key>2</key>
                    <dict>
                        <key>name</key>
                        <string>support.type.sql</string>
                    </dict>
                    <key>4</key>
                    <dict>
                        <key>name</key>
                        <string>support.constant.dbo.sql</string>
                    </dict>
                    <key>5</key>
                    <dict>
                        <key>name</key>
                        <string>punctuation.delimiter.sql</string>
                    </dict>
                    <key>1</key>
                    <dict>
                        <key>name</key>
                        <string>support.function.sql</string>
                    </dict>
                    <key>3</key>
                    <dict>
                        <key>name</key>
                        <string>entity.name.function.sql</string>
                    </dict>
                </dict>
                <key>name</key>
                <string>meta.create-procedure.sql</string>
                <key>match</key>
                <string>(?i)(CREATE)\s+(PROCEDURE)\s+((?:(dbo)(\.))?\S+)</string>
            </dict>
            <dict>
                <key>captures</key>
                <dict>
                    <key>2</key>
                    <dict>
                        <key>name</key>
                        <string>support.type.sql</string>
                    </dict>
                    <key>4</key>
                    <dict>
                        <key>name</key>
                        <string>support.constant.dbo.sql</string>
                    </dict>
                    <key>5</key>
                    <dict>
                        <key>name</key>
                        <string>punctuation.delimiter.sql</string>
                    </dict>
                    <key>1</key>
                    <dict>
                        <key>name</key>
                        <string>support.function.sql</string>
                    </dict>
                    <key>3</key>
                    <dict>
                        <key>name</key>
                        <string>entity.name.function.sql</string>
                    </dict>
                </dict>
                <key>name</key>
                <string>meta.create-table.sql</string>
                <key>match</key>
                <string>(?i)(CREATE)\s+(TABLE)\s+((?:(dbo)(\.))?\S+)</string>
            </dict>
            <dict>
                <key>name</key>
                <string>constant.numeric.sql</string>
                <key>match</key>
                <string>\d+</string>
            </dict>
        </array>
        <key>name</key>
        <string>T-SQL</string>
        <key>scopeName</key>
        <string>source.tsql</string>
        <key>fileTypes</key>
        <array>
            <string>sql</string>
        </array>
        <key>repository</key>
        <dict>
            <key>table-var</key>
            <dict>
                <key>name</key>
                <string>variable.table.sql</string>
                <key>match</key>
                <string>#([a-zA-Z])(\w)*</string>
            </dict>
            <key>types</key>
            <dict>
                <key>captures</key>
                <dict>
                    <key>2</key>
                    <dict>
                        <key>name</key>
                        <string>keyword.punctuation.size.start.sql</string>
                    </dict>
                    <key>4</key>
                    <dict>
                        <key>name</key>
                        <string>constant.language.sql</string>
                    </dict>
                    <key>5</key>
                    <dict>
                        <key>name</key>
                        <string>keyword.punctuation.size.end.sql</string>
                    </dict>
                    <key>1</key>
                    <dict>
                        <key>name</key>
                        <string>storage.type.sql</string>
                    </dict>
                    <key>3</key>
                    <dict>
                        <key>name</key>
                        <string>storage.modifier.sql</string>
                    </dict>
                </dict>
                <key>name</key>
                <string>meta.datatype.sql</string>
                <key>match</key>
                <string>(?xi)
\b(
    bigint|
    int|
    integer|
    smallint|
    tinyint|
    bit|
    (?:decimal(\()(\d+|\d+\s*,\s*\d+))|
    numeric|
    money|
    smallmoney|
    float|
    real|
    datetime|
    smalldatetime|
    char|
    varchar|
    text|
    nchar|
    (?:nvarchar(\()(\d+|(max)))|
    ntext|
    binary|
    varbinary|
    image|
    cursor|
    rowversion|
    sql_variant|
    timestamp|
    uniqueidentifier|
    xml    
)\b
</string>
            </dict>
            <key>local-var</key>
            <dict>
                <key>name</key>
                <string>variable.parameter.local.sql</string>
                <key>match</key>
                <string>@{1,2}([a-zA-Z])(\w)*</string>
            </dict>
            <key>variables</key>
            <dict>
                <key>patterns</key>
                <array>
                    <dict>
                        <key>include</key>
                        <string>#local-var</string>
                    </dict>
                    <dict>
                        <key>include</key>
                        <string>#table-var</string>
                    </dict>
                    <dict>
                        <key>include</key>
                        <string>#script-var</string>
                    </dict>
                </array>
            </dict>
            <key>comments</key>
            <dict>
                <key>patterns</key>
                <array>
                    <dict>
                        <key>captures</key>
                        <dict>
                            <key>1</key>
                            <dict>
                                <key>name</key>
                                <string>punctuation.definition.comment.sql</string>
                            </dict>
                        </dict>
                        <key>name</key>
                        <string>comment.line.double-dash.sql</string>
                        <key>match</key>
                        <string>(--).*$\n?</string>
                    </dict>
                    <dict>
                        <key>begin</key>
                        <string>/\*</string>
                        <key>name</key>
                        <string>comment.block.sql</string>
                        <key>end</key>
                        <string>\*/</string>
                    </dict>
                </array>
            </dict>
            <key>quoted-identifier</key>
            <dict>
                <key>begin</key>
                <string>\[</string>
                <key>name</key>
                <string>variable.other.quoted-identifier.sql</string>
                <key>patterns</key>
                <array>
                    <dict>
                        <key>include</key>
                        <string>#script-var</string>
                    </dict>
                </array>
                <key>end</key>
                <string>\]</string>
            </dict>
            <key>script-var</key>
            <dict>
                <key>name</key>
                <string>variable.scripting.sql</string>
                <key>match</key>
                <string>\$\(([a-zA-Z])(\w)*\)</string>
            </dict>
            <key>single-quote-string</key>
            <dict>
                <key>begin</key>
                <string>(N?)'</string>
                <key>name</key>
                <string>string.quoted.single.sql</string>
                <key>patterns</key>
                <array>
                    <dict>
                        <key>include</key>
                        <string>#script-var</string>
                    </dict>
                </array>
                <key>end</key>
                <string>'</string>
            </dict>
        </dict>
    </dict>
</plist>
