honeylisp/vendor/lite/data/core/syntax.lua
Jeremy Penner 3d52b70bbc git subrepo clone https://github.com/jeremypenner/lite.git vendor/lite
subrepo:
  subdir:   "vendor/lite"
  merged:   "2783adc"
upstream:
  origin:   "https://github.com/jeremypenner/lite.git"
  branch:   "master"
  commit:   "2783adc"
git-subrepo:
  version:  "0.4.2"
  origin:   "https://github.com/ingydotnet/git-subrepo"
  commit:   "65fde50"
2020-11-19 15:40:36 -05:00

31 lines
537 B
Lua

local common = require "core.common"
local syntax = {}
syntax.items = {}
local plain_text_syntax = { patterns = {}, symbols = {} }
function syntax.add(t)
table.insert(syntax.items, t)
end
local function find(string, field)
for i = #syntax.items, 1, -1 do
local t = syntax.items[i]
if common.match_pattern(string, t[field] or {}) then
return t
end
end
end
function syntax.get(filename, header)
return find(filename, "files")
or find(header, "headers")
or plain_text_syntax
end
return syntax