2022-05-31 22:34:14 +02:00
|
|
|
-- mod-version:3
|
2019-12-28 12:16:32 +01:00
|
|
|
local syntax = require "core.syntax"
|
|
|
|
|
|
|
|
syntax.add {
|
2021-11-21 03:46:43 +01:00
|
|
|
name = "Python",
|
2021-11-01 16:30:15 +01:00
|
|
|
files = { "%.py$", "%.pyw$", "%.rpy$" },
|
2020-06-08 10:44:51 +02:00
|
|
|
headers = "^#!.*[ /]python",
|
2019-12-28 12:16:32 +01:00
|
|
|
comment = "#",
|
2022-07-13 17:06:42 +02:00
|
|
|
block_comment = { '"""', '"""' },
|
2019-12-28 12:16:32 +01:00
|
|
|
patterns = {
|
2022-07-13 09:16:32 +02:00
|
|
|
{ pattern = "#.*", type = "comment" },
|
2022-07-13 17:06:42 +02:00
|
|
|
{ pattern = { '^%s*"""', '"""' }, type = "comment" },
|
|
|
|
{ pattern = '[uUrR]%f["]', type = "keyword" },
|
|
|
|
{ pattern = "class%s+()[%a_][%w_]*", type = {"keyword", "keyword2"} },
|
2021-10-23 15:01:16 +02:00
|
|
|
{ pattern = { '[ruU]?"""', '"""'; '\\' }, type = "string" },
|
2022-04-18 20:22:25 +02:00
|
|
|
{ pattern = { "[ruU]?'''", "'''", '\\' }, type = "string" },
|
2021-10-23 15:01:16 +02:00
|
|
|
{ pattern = { '[ruU]?"', '"', '\\' }, type = "string" },
|
|
|
|
{ pattern = { "[ruU]?'", "'", '\\' }, type = "string" },
|
2024-01-20 01:04:49 +01:00
|
|
|
{ pattern = "-?0[xboXBO][%da-fA-F_]+",type = "number" },
|
|
|
|
{ pattern = "-?%d+[%d%.eE_]*", type = "number" },
|
2021-10-23 15:01:16 +02:00
|
|
|
{ pattern = "-?%.?%d+", type = "number" },
|
|
|
|
{ pattern = "[%+%-=/%*%^%%<>!~|&]", type = "operator" },
|
|
|
|
{ pattern = "[%a_][%w_]*%f[(]", type = "function" },
|
|
|
|
{ pattern = "[%a_][%w_]*", type = "symbol" },
|
2019-12-28 12:16:32 +01:00
|
|
|
},
|
|
|
|
symbols = {
|
|
|
|
["class"] = "keyword",
|
|
|
|
["finally"] = "keyword",
|
|
|
|
["is"] = "keyword",
|
|
|
|
["return"] = "keyword",
|
|
|
|
["continue"] = "keyword",
|
|
|
|
["for"] = "keyword",
|
|
|
|
["lambda"] = "keyword",
|
|
|
|
["try"] = "keyword",
|
|
|
|
["def"] = "keyword",
|
2022-08-16 09:52:46 +02:00
|
|
|
["async"] = "keyword",
|
|
|
|
["await"] = "keyword",
|
2019-12-28 12:16:32 +01:00
|
|
|
["from"] = "keyword",
|
|
|
|
["nonlocal"] = "keyword",
|
|
|
|
["while"] = "keyword",
|
|
|
|
["and"] = "keyword",
|
|
|
|
["global"] = "keyword",
|
|
|
|
["not"] = "keyword",
|
|
|
|
["with"] = "keyword",
|
|
|
|
["as"] = "keyword",
|
|
|
|
["elif"] = "keyword",
|
|
|
|
["if"] = "keyword",
|
|
|
|
["or"] = "keyword",
|
|
|
|
["else"] = "keyword",
|
2022-07-03 15:15:51 +02:00
|
|
|
["match"] = "keyword",
|
|
|
|
["case"] = "keyword",
|
2019-12-28 12:16:32 +01:00
|
|
|
["import"] = "keyword",
|
|
|
|
["pass"] = "keyword",
|
|
|
|
["break"] = "keyword",
|
|
|
|
["except"] = "keyword",
|
|
|
|
["in"] = "keyword",
|
|
|
|
["del"] = "keyword",
|
|
|
|
["raise"] = "keyword",
|
|
|
|
["yield"] = "keyword",
|
|
|
|
["assert"] = "keyword",
|
|
|
|
["self"] = "keyword2",
|
|
|
|
["None"] = "literal",
|
|
|
|
["True"] = "literal",
|
|
|
|
["False"] = "literal",
|
|
|
|
}
|
|
|
|
}
|