ox

The Ox programming language, compiler and tools (WIP)
Log | Files | Refs | README | LICENSE

ox.tmLanguage.json (4661B)



{
    "name": "Ox",
    "scopeName": "source.ox",
    "fileTypes": [
        "ox"
    ],
    "patterns": [
        {
            "include": "#comments"
        },
        {
            "include": "#keywords"
        },
        {
            "include": "#numbers"
        },
        {
            "include": "#strings"
        },
        {
            "include": "#basic-types"
        },
        {
            "include": "#functions"
        },
        {
            "include": "#typedefs"
        },
        {
            "include": "#builtins"
        }
    ],
    "repository": {
        "keywords": {
            "patterns": [
                {
                    "match": "\\b(const|else|for|if|pkg|record|return|typedef|match|case|while)\\b",
                    "name": "keyword.control"
                },
                {
                    "match": "\\b(and|by|in|not|or)\\b",
                    "name": "keyword.operator"
                },
                {
                    "match": "\\b(false|nil|true)\\b",
                    "name": "constant.language"
                }
            ]
        },
        "builtins": {
            "patterns": [
                {
                    "match": "\\b(abs|len|assert|print|exit|panic)\\b",
                    "name": "variable.function support.function.builtin"
                }
            ]
        },
        "numbers": {
            "patterns": [
                {
                    "match": "\\b([+-])?[0-9]+(.[0-9]*(e[0-9]+))?\\b",
                    "name": "constant.numeric"
                },
                {
                    "match": "\\b([+-])?0x[0-9A-Fa-f]+\\b",
                    "name": "constant.numeric"
                }
            ]
        },
        "basic-types": {
            "patterns": [
                {
                    "match": "\\b(int|void|float|char|string|bool)\\b",
                    "name": "storage.type"
                }
            ]
        },
        "functions": {
            "patterns": [
                {
                    "match": "\\b([A-Za-z_][A-Za-z0-9_]*)\\s*(?=\\()",
                    "name": "entity.name.function"
                }
            ]
        },
        "typedefs": {
            "patterns": [
                {
                    "match": "\\b[A-Z][A-Za-z0-9_]*\\b",
                    "name": "entity.name.type"
                }
            ]
        },
        "strings": {
            "patterns": [
                {
                    "begin": "\\\"",
                    "beginCaptures": {
                        "0": {
                            "name": "punctuation.definition.string.begin"
                        }
                    },
                    "end": "\\\"",
                    "endCaptures": {
                        "0": {
                            "name": "punctuation.definition.string.end"
                        }
                    },
                    "name": "string.quoted.double",
                    "patterns": [
                        {
                            "match": "\\\\.",
                            "name": "constant.character.escape"
                        }
                    ]
                }
            ]
        },
        "block-comment": {
            "begin": "/\\*",
            "beginCaptures": {
                "0": {
                    "name": "punctuation.definition.comment"
                }
            },
            "end": "\\*/",
            "endCaptures": {
                "0": {
                    "name": "punctuation.definition.comment"
                }
            },
            "name": "comment.block",
            "patterns": [
                {
                    "include": "#block-comment"
                }
            ]
        },
        "comments": {
            "patterns": [
                {
                    "include": "#block-comment"
                },
                {
                    "begin": "//",
                    "beginCaptures": {
                        "0": {
                            "name": "punctuation.definition.comment"
                        }
                    },
                    "end": "\\n",
                    "name": "comment.line.double-slash"
                },
                {
                    "begin": "#!",
                    "beginCaptures": {
                        "0": {
                            "name": "punctuation.definition.comment"
                        }
                    },
                    "end": "\\n",
                    "name": "comment.line.double-slash"
                }
            ]
        }
    }
}