ox

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

ox.yaml (2931B)



filetype: ox

detect:
    filename: "(\\.(ox|OX)$)"

rules:
    - identifier: "\\b[A-Z_][0-9A-Z_]+\\b"
    - type: "\\b(float|bool|char|int|uint|short|str|err|bool|string|long|enum|void|union|voidptr|typeof|typeof_unqual|(un)?signed|_Noreturn)\\b"
    - type: "\\b((s?size)|ptr|cstr|ccstr|(i|u|f)(8|16|32)|chr)_?t?\\b"
    - type: "\\b(_Float16|__fp16|_Float32|_Float32x|_Float64|_Float64x|__float80|_Float128|_Float128x|__float128|__ibm128|__int128|_Fract|_Sat|_Accum)\\b"
    - type: "\\b[a-z_][0-9a-z_]+(_t|_T)\\b"
    - type: "\\b[A-Z]I?[0-9a-zA-Z_]+\\b"
    - statement: "\\b(auto|volatile|register|typedef|new|extend|restrict|_Alignas|alignas|_Alignof|alignof|static|async|await|inline|const|var|constexpr|extern c|_Thread_local|thread_local)\\b"
    - statement: "\\b(fx|fn|use ?c?|as|try|or|export|c_str|c_const_str|unsafe|struct|set|vec|arr|free|heap|print_?|warn_?|fatal|cast|in|ns|for|each|if|while|loop|match|else|case|default|switch|_Generic|_Static_assert|static_assert)\\b"
    - statement: "\\b(goto|continue|break|return)\\b"
    - statement: "\\b(asm|fortran)\\b"
    - preproc: "^[[:space:]]*#[[:space:]]*(define|embed|pragma|include|(un|ifn?)def|endif|el(if|ifdef|ifndef|se)|if|line|warning|error|__has_include|__has_embed|__has_c_attribute)"
    - preproc: "^[[:space:]]*_Pragma\\b"
      # GCC builtins
    - statement: "__attribute__[[:space:]]*\\(\\([^)]*\\)\\)"
    - statement: "__(aligned|asm|builtin|extension|hidden|inline|packed|restrict|section|typeof|weak)__"
      # Operator Color
    - symbol.operator: "[-+*/%=<>.:;,~&|^!?]|\\b(offsetof|sizeof)\\b"
    - symbol.brackets: "[(){}]|\\[|\\]"
      # Integer Constants
    - constant.number: "(\\b([1-9][0-9]*|0[0-7]*|0[Xx][0-9A-Fa-f]+|0[Bb][01]+)([Uu][Ll]?[Ll]?|[Ll][Ll]?[Uu]?)?\\b)"
      # Decimal Floating Constants
    - constant.number: "(\\b(([0-9]*[.][0-9]+|[0-9]+[.][0-9]*)([Ee][+-]?[0-9]+)?|[0-9]+[Ee][+-]?[0-9]+)[FfLl]?\\b)"
      # Hexadecimal Floating Constants
    - constant.number: "(\\b0[Xx]([0-9A-Za-z]*[.][0-9A-Za-z]+|[0-9A-Za-z]+[.][0-9A-Za-z]*)[Pp][+-]?[0-9]+[FfLl]?\\b)"
    - constant.bool: "(\\b(true|false|NULL|nullptr|TRUE|FALSE)\\b)"

    - constant.string:
        start: "\""
        end: "\""
        skip: "\\\\."
        rules:
            - constant.specialChar: "\\\\([\"'abfnrtv\\\\]|[0-3]?[0-7]{1,2}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})"

    - constant.string:
        start: "'"
        end: "'"
        skip: "\\\\."
        rules:
              # TODO: Revert back to - error: "..+" once #3127 is merged
            - error: "[[:graph:]]{2,}'"
            - constant.specialChar: "\\\\([\"'abfnrtv\\\\]|[0-3]?[0-7]{1,2}|x[0-9A-Fa-f]{1,2}|u[0-9A-Fa-f]{4}|U[0-9A-Fa-f]{8})"

    - comment:
        start: "//"
        end: "$"
        rules:
            - todo: "(TODO|XXX|FIXME):?"

    - comment:
        start: "/\\*"
        end: "\\*/"
        rules:
            - todo: "(TODO|XXX|FIXME):?"