aboutsummaryrefslogtreecommitdiff
path: root/plugins/language_haxe.lua
blob: 0289d8daa97b8fb50ed0f16f3b3743802dc8b72e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
-- mod-version:3
local syntax = require "core.syntax"

syntax.add {
  name = "Haxe Compiler Arguments",
  files = "%.hxml$",
  comment = "#",
  patterns = {
    { pattern = "#.*",             type = "comment"},
    { pattern = "%-[%-%w_]*",      type="keyword"},
    { pattern = "%.()%u[%w_]*",    type = {"normal", "keyword2"}},
  },
  symbols = {}
}

syntax.add {
  name = "Haxe String Interpolation",
  files = "%.hx__string_interp$",
  patterns = {
    { pattern = {"%${", "}", "\\"},     type="keyword", syntax = ".hx" },
    { pattern = {"%$", "%s", "\\"},     type="keyword", syntax = ".hx" },
    { pattern = "[^ ]",                 type = "string"}
  },
  symbols = {}
}

syntax.add {
  name = "Haxe Regular Expressions",
  files = "%.hx__regex$",
  patterns = {
    { pattern = "[%[%]%(%)]",           type = "string" },
    { pattern = "[%.%*%+%?%^%$%|%-]",   type = "operator" },
  },
  symbols = {}
}

syntax.add {
  name = "Haxe",
  files = "%.hx$",
  comment = "//",
  patterns = {
    { pattern = {"%~%/", "%/[igmsu]*"},                     type = "keyword2", syntax = ".hx__regex" },
    { pattern = "%.%.%.",                                   type = "operator" },
    { pattern = "%<()%u[%w_]*()%>*",                        type = {"operator", "keyword2", "operator"}},
    { pattern = "%#%s*[%a_]*().*\n",                        type = {"keyword", "normal"}   },
    { pattern = "import%s+()%u[%w]*",                       type = {"keyword", "keyword2"}},
    { pattern = "import%s+()[%w%.]*%.()%u[%w]*",            type = {"keyword", "normal", "keyword2"}},
    { pattern = "abstract%s+()%u[%w_]*%s*%(()%s*%u[%w_]*",  type = {"keyword2", "normal", "keyword2"} },
    { pattern = "from%s+()%u[%w_]*%s+()to%s+()%u[%w_]*",    type = {"keyword", "keyword2", "keyword", "keyword2"}},
    { pattern = "//.*\n",                                   type = "comment"  },
    { pattern = { "/%*", "%*/" },                           type = "comment"  },
    { pattern = { '"', '"', '\\' },                         type = "string"   },
    { pattern = { "'", "'", "\\" },                         type = "string", syntax = ".hx__string_interp"},  
    { pattern = "-?%.?%d+",                                 type = "number"   },
    { pattern = "-?0x%x+",                                  type = "number"   },
    { pattern = "-?%d+%.[%deE]+",                           type = "number"   },
    { pattern = "-?%d+[%deE]+",                             type = "number"   },
    { pattern = "[%+%-%.=/%*%^%%<>!~|&]",                   type = "operator" },
    { pattern = "[%a_][%w_]*()%s*%f[(]",                    type = {"function", "normal"} },
    { pattern = "[%a_][%w_]*",                              type = "symbol"   },
    { pattern = ":()%u[%a_][%w_]*",                         type = {"normal", "keyword2"}},
    { pattern = "@:[%a_][%w_]*%f[(]",                       type = "keyword"   },
    { pattern = "%$type",                                   type = "keyword"   },
  },
  symbols = {
    ["abstract"]   = "keyword2",
    ["extends"]    = "keyword2",
    ["typedef"]    = "keyword2",
    ["implements"] = "keyword2",
    ["import"]     = "keyword",
    ["package"]    = "keyword",
    ["using"]      = "keyword2",
    ["macro"]      = "keyword2",
    ["class"]      = "keyword",
    ["function"]   = "keyword2",
    ["var"]        = "keyword2",
    ["extern"]     = "keyword2",
    ["in"]         = "keyword",
    ["cast"]       = "keyword",
    ["get"]        = "keyword",
    ["set"]        = "keyword",
    ["never"]      = "keyword",
    ["inline"]     = "keyword",
    ["trace"]      = "keyword",
    ["final"]      = "keyword",
    ["break"]      = "keyword",
    ["case"]       = "keyword",
    ["catch"]      = "keyword",
    ["continue"]   = "keyword",
    ["default"]    = "keyword",
    ["do"]         = "keyword",
    ["else"]       = "keyword",
    ["enum"]       = "keyword",
    ["for"]        = "keyword",
    ["if"]         = "keyword",
    ["interface"]  = "keyword",
    ["new"]        = "keyword",
    ["override"]   = "keyword",
    ["private"]    = "keyword",
    ["public"]     = "keyword",
    ["return"]     = "keyword",
    ["static"]     = "keyword",
    ["switch"]     = "keyword",
    ["this"]       = "keyword",
    ["throw"]      = "keyword",
    ["try"]        = "keyword",
    ["while"]      = "keyword",
    ["true"]       = "literal",
    ["false"]      = "literal",
    ["null"]       = "literal",
  },
}