mirror of
https://github.com/CCLeonOS/LeonOS.git
synced 2026-03-03 15:17:01 +00:00
feat(installer): 更新安装器版本号至1.0.1
feat(editor): 为高级编辑器添加Python语法高亮支持 - 新增python.lua语法定义文件 - 实现根据文件扩展名自动选择语法高亮 feat(pkg): 添加GitHub包安装支持 - 支持从GitHub仓库直接安装包 - 新增GitHub API基础URL配置 - 实现包元数据和文件下载功能 - 自动处理包版本和依赖关系 docs: 添加chest_sorter教程文档 - 新增chest_sorter_tutorial.md帮助文件 chore: 更新代码统计信息 - 添加VSCodeCounter生成的代码统计文件
This commit is contained in:
128
data/computercraft/lua/rom/modules/main/edit/syntax/python.lua
Normal file
128
data/computercraft/lua/rom/modules/main/edit/syntax/python.lua
Normal file
@@ -0,0 +1,128 @@
|
||||
local syn = {
|
||||
whitespace = {
|
||||
{
|
||||
function(c)
|
||||
return c:match("[ \n\r\t]")
|
||||
end,
|
||||
function()
|
||||
return false
|
||||
end,
|
||||
function(c)
|
||||
return c:match("^[ \n\r\t]+")
|
||||
end
|
||||
},
|
||||
},
|
||||
word = {
|
||||
{
|
||||
function(c)
|
||||
return not not c:match("[a-zA-Z_]")
|
||||
end,
|
||||
function(_, c)
|
||||
return not not c:match("[a-zA-Z_0-9]")
|
||||
end
|
||||
}
|
||||
},
|
||||
keyword = {
|
||||
"and", "as", "assert", "break", "class", "continue", "def",
|
||||
"del", "elif", "else", "except", "finally", "for", "from",
|
||||
"global", "if", "import", "in", "is", "lambda", "nonlocal",
|
||||
"not", "or", "pass", "raise", "return", "try", "while",
|
||||
"with", "yield"
|
||||
},
|
||||
builtin = {
|
||||
"abs", "all", "any", "ascii", "bin", "bool", "breakpoint", "bytearray",
|
||||
"bytes", "callable", "chr", "classmethod", "compile", "complex", "delattr",
|
||||
"dict", "dir", "divmod", "enumerate", "eval", "exec", "filter", "float",
|
||||
"format", "frozenset", "getattr", "globals", "hasattr", "hash", "help",
|
||||
"hex", "id", "input", "int", "isinstance", "issubclass", "iter", "len",
|
||||
"list", "locals", "map", "max", "memoryview", "min", "next", "object",
|
||||
"oct", "open", "ord", "pow", "print", "property", "range", "repr",
|
||||
"reversed", "round", "set", "setattr", "slice", "sorted", "staticmethod",
|
||||
"str", "sum", "super", "tuple", "type", "vars", "zip", "__import__"
|
||||
},
|
||||
separator = {
|
||||
",", "(", ")", "{", "}", "[", "]", ":", ";",
|
||||
},
|
||||
operator = {
|
||||
"+", "-", "/", "*", "**", "//", "==", "=", ">", "<", ">=", "<=",
|
||||
"!=", "&", "|", "^", "%", "~", ">>", "<<", "+=", "-=", "*=", "/=",
|
||||
"%=", "**=", "//=", "&=", "|=", "^=", ">>=", "<<="
|
||||
},
|
||||
boolean = {
|
||||
"True", "False", "None"
|
||||
},
|
||||
comment = {
|
||||
{
|
||||
function(c)
|
||||
return c == "#"
|
||||
end,
|
||||
function(t,c)
|
||||
return c ~= "\n"
|
||||
end,
|
||||
function(t)
|
||||
return #t > 0
|
||||
end
|
||||
}
|
||||
},
|
||||
string = {
|
||||
{
|
||||
function(c)
|
||||
return c == "'" or c == '"'
|
||||
end,
|
||||
function(t, c)
|
||||
local first = t:sub(1,1)
|
||||
local last = t:sub(#t)
|
||||
local penultimate = t:sub(-2, -2)
|
||||
if #t == 1 then return true end
|
||||
if first == last and penultimate ~= "\\" then return false end
|
||||
return true
|
||||
end
|
||||
},
|
||||
{
|
||||
function(c)
|
||||
return c == '"' and (t == '"' or t == '')
|
||||
end,
|
||||
function(t,c)
|
||||
if t:match("^"""$) and c == '"' then
|
||||
return false
|
||||
end
|
||||
if t:match("^"""[^"]*$) then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end,
|
||||
function(t)
|
||||
return t:match("^"""[^"]*"""$)
|
||||
end
|
||||
},
|
||||
{
|
||||
function(c)
|
||||
return c == "'" and (t == "'" or t == '')
|
||||
end,
|
||||
function(t,c)
|
||||
if t:match("^'''$") and c == "'" then
|
||||
return false
|
||||
end
|
||||
if t:match("^'''[^']*$") then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end,
|
||||
function(t)
|
||||
return t:match("^'''[^']*'''$)
|
||||
end
|
||||
}
|
||||
},
|
||||
number = {
|
||||
{
|
||||
function(c)
|
||||
return not not tonumber(c)
|
||||
end,
|
||||
function(t, c)
|
||||
return not not tonumber(t .. c .. "0") or (c == '.' and not t:find('\.'))
|
||||
end
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return syn
|
||||
Reference in New Issue
Block a user