<?xml version="1.0" encoding="UTF-8"?>
<!--
  SQF grammar for Sublime Text, TextMate-compatible editors, and GitHub Linguist.

  This file is generated by tools/generate_sqf_template.py from:
    https://github.com/hemtt/wiki/tree/dist
  HEMTT wiki version: $$SOURCE_VERSION$$
  Commands: $$COMMAND_COUNT$$ (nular: $$NULAR_COUNT$$, unary: $$UNARY_COUNT$$, binary: $$BINARY_COUNT$$)

  Do not edit SQF.tmLanguage directly. Edit tools/template_file and regenerate.
-->
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>name</key>
    <string>SQF</string>
    <key>fileTypes</key>
    <array>
        <string>sqf</string>
        <string>sqs</string>
        <string>sqm</string>
        <string>ext</string>
    </array>
    <key>scopeName</key>
    <string>source.sqf</string>
    <key>uuid</key>
    <string>A36E13D0-57F2-3590-8ED7-F16B00AC67EC</string>
    <key>firstLineMatch</key>
    <string>//\s*(?i:SQF)</string>

    <key>foldingStartMarker</key>
    <string>(\{\s*(#.*)?$)</string>
    <key>foldingStopMarker</key>
    <string>^\s*(\})</string>

    <!-- The grammar lives in #main so arrays, blocks and parentheses can
         recursively re-enter it via include. -->
    <key>patterns</key>
    <array>
        <dict>
            <key>include</key>
            <string>#main</string>
        </dict>
    </array>

    <key>repository</key>
    <dict>
        <key>main</key>
        <dict>
            <key>patterns</key>
            <array>
                <!-- =========================================================
                     Preprocessor
                     ========================================================= -->
                <dict>
                    <key>match</key>
                    <string>^\s*(#)\s*(include)\s+("(?:[^"]|"")*")</string>
                    <key>captures</key>
                    <dict>
                        <key>1</key><dict><key>name</key><string>punctuation.definition.preprocessor.sqf</string></dict>
                        <key>2</key><dict><key>name</key><string>keyword.control.preprocessor.include.sqf</string></dict>
                        <key>3</key><dict><key>name</key><string>string.quoted.double.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>meta.preprocessor.include.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>^\s*(#)\s*(include)\s+('(?:[^']|'')*')</string>
                    <key>captures</key>
                    <dict>
                        <key>1</key><dict><key>name</key><string>punctuation.definition.preprocessor.sqf</string></dict>
                        <key>2</key><dict><key>name</key><string>keyword.control.preprocessor.include.sqf</string></dict>
                        <key>3</key><dict><key>name</key><string>string.quoted.single.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>meta.preprocessor.include.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>^\s*(#)\s*(include)\s+(&lt;[^&gt;]*&gt;)</string>
                    <key>captures</key>
                    <dict>
                        <key>1</key><dict><key>name</key><string>punctuation.definition.preprocessor.sqf</string></dict>
                        <key>2</key><dict><key>name</key><string>keyword.control.preprocessor.include.sqf</string></dict>
                        <key>3</key><dict><key>name</key><string>string.quoted.other.lt-gt.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>meta.preprocessor.include.sqf</string>
                </dict>
                <dict>
                    <key>begin</key>
                    <string>^\s*(#)\s*(define)\s+([A-Za-z_]\w*)(?:\(([^)]*)\))?</string>
                    <key>beginCaptures</key>
                    <dict>
                        <key>1</key><dict><key>name</key><string>punctuation.definition.preprocessor.sqf</string></dict>
                        <key>2</key><dict><key>name</key><string>keyword.control.preprocessor.define.sqf</string></dict>
                        <key>3</key><dict><key>name</key><string>entity.name.function.preprocessor.sqf</string></dict>
                        <key>4</key><dict><key>name</key><string>variable.parameter.preprocessor.sqf</string></dict>
                    </dict>
                    <key>end</key>
                    <string>(?&lt;!\\)$</string>
                    <key>name</key>
                    <string>meta.preprocessor.define.sqf</string>
                    <key>patterns</key>
                    <array>
                        <dict>
                            <key>match</key>
                            <string>\\$</string>
                            <key>name</key>
                            <string>constant.character.escape.line-continuation.sqf</string>
                        </dict>
                    </array>
                </dict>
                <dict>
                    <key>match</key>
                    <string>^\s*(#)\s*(undef)\s+([A-Za-z_]\w*)</string>
                    <key>captures</key>
                    <dict>
                        <key>1</key><dict><key>name</key><string>punctuation.definition.preprocessor.sqf</string></dict>
                        <key>2</key><dict><key>name</key><string>keyword.control.preprocessor.undef.sqf</string></dict>
                        <key>3</key><dict><key>name</key><string>entity.name.function.preprocessor.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>meta.preprocessor.undef.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>^\s*(#)\s*(if|ifdef|ifndef|else|elseif|endif)\b(.*)$</string>
                    <key>captures</key>
                    <dict>
                        <key>1</key><dict><key>name</key><string>punctuation.definition.preprocessor.sqf</string></dict>
                        <key>2</key><dict><key>name</key><string>keyword.control.preprocessor.conditional.sqf</string></dict>
                        <key>3</key><dict><key>name</key><string>meta.preprocessor.expression.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>meta.preprocessor.conditional.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>^\s*(#)\s*(pragma)\b(.*)$</string>
                    <key>captures</key>
                    <dict>
                        <key>1</key><dict><key>name</key><string>punctuation.definition.preprocessor.sqf</string></dict>
                        <key>2</key><dict><key>name</key><string>keyword.control.preprocessor.pragma.sqf</string></dict>
                        <key>3</key><dict><key>name</key><string>meta.preprocessor.expression.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>meta.preprocessor.pragma.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>^\s*(#)\s*([A-Za-z_]\w*)\b(.*)$</string>
                    <key>captures</key>
                    <dict>
                        <key>1</key><dict><key>name</key><string>punctuation.definition.preprocessor.sqf</string></dict>
                        <key>2</key><dict><key>name</key><string>keyword.control.preprocessor.sqf</string></dict>
                        <key>3</key><dict><key>name</key><string>meta.preprocessor.expression.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>meta.preprocessor.sqf</string>
                </dict>

                <!-- =========================================================
                     Comments
                     ========================================================= -->
                <dict>
                    <key>match</key>
                    <string>(//).*$</string>
                    <key>captures</key>
                    <dict>
                        <key>1</key><dict><key>name</key><string>punctuation.definition.comment.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>comment.line.double-slash.sqf</string>
                </dict>
                <dict>
                    <key>begin</key>
                    <string>/\*</string>
                    <key>beginCaptures</key>
                    <dict>
                        <key>0</key><dict><key>name</key><string>punctuation.definition.comment.begin.sqf</string></dict>
                    </dict>
                    <key>end</key>
                    <string>\*/</string>
                    <key>endCaptures</key>
                    <dict>
                        <key>0</key><dict><key>name</key><string>punctuation.definition.comment.end.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>comment.block.sqf</string>
                </dict>

                <!-- =========================================================
                     Strings
                     ========================================================= -->
                <dict>
                    <key>begin</key>
                    <string>"</string>
                    <key>beginCaptures</key>
                    <dict>
                        <key>0</key><dict><key>name</key><string>punctuation.definition.string.begin.sqf</string></dict>
                    </dict>
                    <key>end</key>
                    <string>"(?!")</string>
                    <key>endCaptures</key>
                    <dict>
                        <key>0</key><dict><key>name</key><string>punctuation.definition.string.end.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>string.quoted.double.sqf</string>
                    <key>patterns</key>
                    <array>
                        <dict>
                            <key>match</key>
                            <string>""</string>
                            <key>name</key>
                            <string>constant.character.escape.quote.double.sqf</string>
                        </dict>
                        <dict>
                            <key>match</key>
                            <string>\\(?:n|t|r|"|\\)</string>
                            <key>name</key>
                            <string>constant.character.escape.sqf</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.sqf</string></dict>
                    </dict>
                    <key>end</key>
                    <string>'(?!')</string>
                    <key>endCaptures</key>
                    <dict>
                        <key>0</key><dict><key>name</key><string>punctuation.definition.string.end.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>string.quoted.single.sqf</string>
                    <key>patterns</key>
                    <array>
                        <dict>
                            <key>match</key>
                            <string>''</string>
                            <key>name</key>
                            <string>constant.character.escape.quote.single.sqf</string>
                        </dict>
                    </array>
                </dict>

                <!-- =========================================================
                     Language variables and constants
                     ========================================================= -->
                <dict>
                    <key>match</key>
                    <string>\b(?i:$$MAGIC_VARIABLES$$)\b</string>
                    <key>name</key>
                    <string>variable.language.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>\b(?i:$$CONSTANT_KEYWORDS$$)\b</string>
                    <key>name</key>
                    <string>constant.language.sqf</string>
                </dict>

                <!-- =========================================================
                     Control flow and declarations
                     ========================================================= -->
                <dict>
                    <key>match</key>
                    <string>\b(?i:$$CONTROL_KEYWORDS$$)\b</string>
                    <key>name</key>
                    <string>keyword.control.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>\b(?i:private)\b</string>
                    <key>name</key>
                    <string>keyword.declaration.sqf</string>
                </dict>

                <!-- =========================================================
                     Operators (symbols before word operators is not required,
                     but keep the longest alternatives first inside each rule).
                     ========================================================= -->
                <dict>
                    <key>match</key>
                    <string>&gt;&gt;|:|#</string>
                    <key>name</key>
                    <string>keyword.operator.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>==|!=|&lt;=|&gt;=|&lt;|&gt;</string>
                    <key>name</key>
                    <string>keyword.operator.comparison.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>&amp;&amp;|\|\||!</string>
                    <key>name</key>
                    <string>keyword.operator.logical.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>\+|-|\*|/|%|\^</string>
                    <key>name</key>
                    <string>keyword.operator.arithmetic.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>=</string>
                    <key>name</key>
                    <string>keyword.operator.assignment.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>\b(?i:$$WORD_OPERATORS$$)\b</string>
                    <key>name</key>
                    <string>keyword.operator.word.sqf</string>
                </dict>

                <!-- =========================================================
                     Functions and engine commands
                     ========================================================= -->
                <dict>
                    <key>match</key>
                    <string>\b(?i:[A-Za-z][A-Za-z0-9_]*_fnc_[A-Za-z0-9_]+)\b</string>
                    <key>name</key>
                    <string>entity.name.function.sqf</string>
                </dict>
                <!-- Engine commands are split by documented arity. Existing
                     themes that match support.function still color all of these;
                     themes can opt into the finer sub-scopes for readability. -->
                <dict>
                    <key>match</key>
                    <string>\b(?i:$$NULAR_COMMANDS$$)\b</string>
                    <key>name</key>
                    <string>support.function.sqf.nular</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>\b(?i:$$UNARY_COMMANDS$$)\b</string>
                    <key>name</key>
                    <string>support.function.sqf.unary</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>\b(?i:$$BINARY_COMMANDS$$)\b</string>
                    <key>name</key>
                    <string>support.function.sqf.binary</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>\b(?i:$$OVERLOADED_COMMANDS$$)\b</string>
                    <key>name</key>
                    <string>support.function.sqf.overloaded</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>\b(?i:$$LEGACY_COMMANDS$$)\b</string>
                    <key>name</key>
                    <string>support.function.sqf</string>
                </dict>

                <!-- =========================================================
                     Numbers
                     ========================================================= -->
                <dict>
                    <key>match</key>
                    <string>\b0[xX][0-9A-Fa-f]+\b|(?:\b\d+\.\d*|\.\d+|\b\d+)(?:[eE][+-]?\d+)?(?!\w)</string>
                    <key>name</key>
                    <string>constant.numeric.sqf</string>
                </dict>

                <!-- =========================================================
                     Punctuation, arrays and code blocks
                     ========================================================= -->
                <dict>
                    <key>match</key>
                    <string>;</string>
                    <key>name</key>
                    <string>punctuation.terminator.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>,</string>
                    <key>name</key>
                    <string>punctuation.separator.sqf</string>
                </dict>
                <dict>
                    <key>begin</key>
                    <string>\(</string>
                    <key>beginCaptures</key>
                    <dict>
                        <key>0</key><dict><key>name</key><string>punctuation.section.group.begin.sqf</string></dict>
                    </dict>
                    <key>end</key>
                    <string>\)</string>
                    <key>endCaptures</key>
                    <dict>
                        <key>0</key><dict><key>name</key><string>punctuation.section.group.end.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>meta.expression.sqf</string>
                    <key>patterns</key>
                    <array>
                        <dict>
                            <key>include</key>
                            <string>#main</string>
                        </dict>
                    </array>
                </dict>
                <dict>
                    <key>begin</key>
                    <string>\[</string>
                    <key>beginCaptures</key>
                    <dict>
                        <key>0</key><dict><key>name</key><string>punctuation.section.array.begin.sqf</string></dict>
                    </dict>
                    <key>end</key>
                    <string>\]</string>
                    <key>endCaptures</key>
                    <dict>
                        <key>0</key><dict><key>name</key><string>punctuation.section.array.end.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>meta.array.sqf</string>
                    <key>patterns</key>
                    <array>
                        <dict>
                            <key>include</key>
                            <string>#main</string>
                        </dict>
                    </array>
                </dict>
                <dict>
                    <key>begin</key>
                    <string>\{</string>
                    <key>beginCaptures</key>
                    <dict>
                        <key>0</key><dict><key>name</key><string>punctuation.section.block.begin.sqf</string></dict>
                    </dict>
                    <key>end</key>
                    <string>\}</string>
                    <key>endCaptures</key>
                    <dict>
                        <key>0</key><dict><key>name</key><string>punctuation.section.block.end.sqf</string></dict>
                    </dict>
                    <key>name</key>
                    <string>meta.block.sqf</string>
                    <key>patterns</key>
                    <array>
                        <dict>
                            <key>include</key>
                            <string>#main</string>
                        </dict>
                    </array>
                </dict>

                <!-- =========================================================
                     Local variables and preprocessor macros
                     ========================================================= -->
                <dict>
                    <key>match</key>
                    <string>\b_[A-Za-z][A-Za-z0-9_]*\b</string>
                    <key>name</key>
                    <string>variable.other.sqf</string>
                </dict>
                <dict>
                    <key>match</key>
                    <string>\b__[A-Za-z0-9_]+__\b|\b__has_include\b</string>
                    <key>name</key>
                    <string>keyword.control.preprocessor.macro.sqf</string>
                </dict>

                <!-- =========================================================
                     Legacy SQS line controls (the grammar also covers .sqs)
                     ========================================================= -->
                <dict>
                    <key>match</key>
                    <string>^\s*(\?|~|@)</string>
                    <key>name</key>
                    <string>keyword.control.sqs.sqf</string>
                </dict>
            </array>
        </dict>
    </dict>
</dict>
</plist>
