mirror of
https://github.com/janet-lang/janet
synced 2024-11-25 01:37:19 +00:00
Add textmate syntax highlighting file.
This commit is contained in:
parent
8333c22e8a
commit
696866ae51
330
grammar/janet.tmLanguage
Normal file
330
grammar/janet.tmLanguage
Normal file
@ -0,0 +1,330 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
<plist version="1.0">
|
||||||
|
<dict>
|
||||||
|
<key>fileTypes</key>
|
||||||
|
<array>
|
||||||
|
<string>janet</string>
|
||||||
|
</array>
|
||||||
|
<key>foldingStartMarker</key>
|
||||||
|
<string>\{</string>
|
||||||
|
<key>foldingStopMarker</key>
|
||||||
|
<string>\}</string>
|
||||||
|
<key>foldingStartMarker</key>
|
||||||
|
<string>\[</string>
|
||||||
|
<key>foldingStopMarker</key>
|
||||||
|
<string>\]</string>
|
||||||
|
<key>foldingStartMarker</key>
|
||||||
|
<string>\(</string>
|
||||||
|
<key>foldingStopMarker</key>
|
||||||
|
<string>\)</string>
|
||||||
|
<key>keyEquivalent</key>
|
||||||
|
<string>^~L</string>
|
||||||
|
<key>name</key>
|
||||||
|
<string>Janet</string>
|
||||||
|
<key>patterns</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#all</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
<key>repository</key>
|
||||||
|
<dict>
|
||||||
|
<key>all</key>
|
||||||
|
<dict>
|
||||||
|
<key>patterns</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#comment</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#parens</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#brackets</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#braces</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#readermac</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#literal</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#corelib</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#r-number</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#dec-number</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#hex-number</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#keysym</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#symbol</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#string</string>
|
||||||
|
</dict>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#longstring</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<key>comment</key>
|
||||||
|
<dict>
|
||||||
|
<key>captures</key>
|
||||||
|
<dict>
|
||||||
|
<key>1</key>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>punctuation.definition.comment.janet</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>match</key>
|
||||||
|
<string>(#).*$</string>
|
||||||
|
<key>name</key>
|
||||||
|
<string>comment.line.janet</string>
|
||||||
|
</dict>
|
||||||
|
<key>braces</key>
|
||||||
|
<dict>
|
||||||
|
<key>begin</key>
|
||||||
|
<string>(@?{)</string>
|
||||||
|
<key>captures</key>
|
||||||
|
<dict>
|
||||||
|
<key>1</key>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>punctuation.definition.braces.begin.janet</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>end</key>
|
||||||
|
<string>(})</string>
|
||||||
|
<key>captures</key>
|
||||||
|
<dict>
|
||||||
|
<key>1</key>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>punctuation.definition.braces.end.janet</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>patterns</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#all</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<key>brackets</key>
|
||||||
|
<dict>
|
||||||
|
<key>begin</key>
|
||||||
|
<string>(@?\[)</string>
|
||||||
|
<key>captures</key>
|
||||||
|
<dict>
|
||||||
|
<key>1</key>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>punctuation.definition.brackets.begin.janet</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>end</key>
|
||||||
|
<string>(\])</string>
|
||||||
|
<key>captures</key>
|
||||||
|
<dict>
|
||||||
|
<key>1</key>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>punctuation.definition.brackets.end.janet</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>patterns</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#all</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<key>parens</key>
|
||||||
|
<dict>
|
||||||
|
<key>begin</key>
|
||||||
|
<string>(@?\()</string>
|
||||||
|
<key>captures</key>
|
||||||
|
<dict>
|
||||||
|
<key>1</key>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>punctuation.definition.parens.begin.janet</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>end</key>
|
||||||
|
<string>(\))</string>
|
||||||
|
<key>captures</key>
|
||||||
|
<dict>
|
||||||
|
<key>1</key>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>punctuation.definition.parens.end.janet</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>patterns</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>include</key>
|
||||||
|
<string>#all</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<key>readermac</key>
|
||||||
|
<dict>
|
||||||
|
<key>match</key>
|
||||||
|
<string>[\'\~\;\,]</string>
|
||||||
|
<key>name</key>
|
||||||
|
<string>punctuation.other.janet</string>
|
||||||
|
</dict>
|
||||||
|
<!-- string>(?<![\.:\w_\-=!@\$%^&?|\\/<>]) token match here (?![\.:\w_\-=!@\$%^&?|\\/<>])</string -->
|
||||||
|
<key>literal</key>
|
||||||
|
<dict>
|
||||||
|
<key>match</key>
|
||||||
|
<string>(?<![\.:\w_\-=!@\$%^&?|\\/<>])(true|false|nil)(?![\.:\w_\-=!@\$%^&?|\\/<>])</string>
|
||||||
|
<key>name</key>
|
||||||
|
<string>constant.language.janet</string>
|
||||||
|
</dict>
|
||||||
|
<key>corelib</key>
|
||||||
|
<dict>
|
||||||
|
<key>match</key>
|
||||||
|
<string>(?<![\.:\w_\-=!@\$%^&?|\\/<>])(def|do|fn|if|quasiquote|quote|splice|unquote|while|%|%=|&|&=|\*|\*=|\*doc\-width\*|\*env\*|\+|\+\+|\+=|\-|\-\-|\-=|\->|\->>|/|/=|<|<<|<<=|<=|=|==|>|>=|>>|>>=|>>>|>>>=|\^|\^=|_env|abstract\?|all|all\-symbols|and|apply|array|array/concat|array/ensure|array/insert|array/new|array/peek|array/pop|array/push|array/slice|array\?|asm|bnot|boolean\?|buffer|buffer/clear|buffer/new|buffer/popn|buffer/push\-byte|buffer/push\-integer|buffer/push\-string|buffer/slice|buffer\?|bytes\?|callable\?|case|cfunction\?|comment|comp|compile|complement|cond|coro|count|debug|debug/arg\-stack|debug/break|debug/fbreak|debug/lineage|debug/stack|debug/unbreak|debug/unfbreak|dec|deep\-not=|deep=|def\-|default|defglobal|defmacro|defmacro\-|defn|defn\-|describe|dictionary\?|disasm|distinct|doc|doc\*|doc\-format|drop\-until|drop\-while|each|empty\?|env\-lookup|error|eval|eval\-string|even\?|every\?|extreme|false\?|fiber/current|fiber/maxstack|fiber/new|fiber/setmaxstack|fiber/status|fiber\?|file/close|file/flush|file/open|file/popen|file/read|file/seek|file/write|filter|find|find\-index|first|flatten|flatten\-into|for|frequencies|function\?|gccollect|gcinterval|gcsetinterval|generate|gensym|get|getline|hash|idempotent\?|identity|if\-let|if\-not|import|import\*|inc|indexed\?|int|integer\?|interleave|interpose|invert|janet/build|janet/version|juxt|juxt\*|keep|keys|keyword\?|kvs|last|length|let|loop|macex|macex1|make\-env|map|mapcat|marshal|match|match\-1|math/acos|math/asin|math/atan|math/ceil|math/cos|math/e|math/exp|math/floor|math/inf|math/log|math/log10|math/pi|math/pow|math/random|math/seedrandom|math/sin|math/sqrt|math/tan|max|max\-order|merge|merge\-into|min|min\-order|module/find|module/native\-paths|module/paths|native|neg\?|next|nil\?|not|not=|not==|number\?|odd\?|one\?|or|order<|order<=|order>|order>=|os/clock|os/cwd|os/execute|os/exit|os/getenv|os/setenv|os/shell|os/sleep|os/time|os/which|pairs|parser/byte|parser/consume|parser/error|parser/flush|parser/new|parser/produce|parser/state|parser/status|parser/where|partial|pos\?|print|process/args|product|put|range|real|real\?|reduce|repl|require|resume|reverse|run\-context|scan\-integer|scan\-number|scan\-real|sentinel|seq|some|sort|sorted|status\-pp|stderr|stdin|stdout|string|string/ascii\-lower|string/ascii\-upper|string/bytes|string/check\-set|string/find|string/find\-all|string/from\-bytes|string/join|string/number|string/pretty|string/repeat|string/replace|string/replace\-all|string/reverse|string/slice|string/split|string\?|struct|struct\?|sum|symbol|symbol\?|table|table/getproto|table/new|table/rawget|table/setproto|table/to\-struct|table\?|take\-until|take\-while|true\?|tuple|tuple/append|tuple/prepend|tuple/slice|tuple\?|type|unless|unmarshal|update|values|varglobal|when|when\-let|with\-idemp|yield|zero\?|zipcoll|\||\|=)(?![\.:\w_\-=!@\$%^&?|\\/<>])</string>
|
||||||
|
<key>name</key>
|
||||||
|
<string>keyword.control.janet</string>
|
||||||
|
</dict>
|
||||||
|
<key>keysym</key>
|
||||||
|
<dict>
|
||||||
|
<key>match</key>
|
||||||
|
<string>(?<![\.:\w_\-=!@\$%^&?|\\/<>]):[\.:\w_\-=!@\$%^&?|\\/<>]*</string>
|
||||||
|
<key>name</key>
|
||||||
|
<string>constant.keyword.janet</string>
|
||||||
|
</dict>
|
||||||
|
<key>symbol</key>
|
||||||
|
<dict>
|
||||||
|
<key>match</key>
|
||||||
|
<string>(?<![\.:\w_\-=!@\$%^&?|\\/<>])[\.a-zA-Z_\-=!@\$%^&?|\\/<>][\.:\w_\-=!@\$%^&?|\\/<>]*</string>
|
||||||
|
<key>name</key>
|
||||||
|
<string>variable.other.janet</string>
|
||||||
|
</dict>
|
||||||
|
<key>hex-number</key>
|
||||||
|
<dict>
|
||||||
|
<key>match</key>
|
||||||
|
<string>(?<![\.:\w_\-=!@\$%^&?|\\/<>])[-+]?0x([_\da-fA-F]+|[_\da-fA-F]+\.[_\da-fA-F]*|\.[_\da-fA-F]+)(&[+-]?[\da-fA-F]+)?(?![\.:\w_\-=!@\$%^&?|\\/<>])</string>
|
||||||
|
<key>name</key>
|
||||||
|
<string>constant.numeric.hex.janet</string>
|
||||||
|
</dict>
|
||||||
|
<key>dec-number</key>
|
||||||
|
<dict>
|
||||||
|
<key>match</key>
|
||||||
|
<string>(?<![\.:\w_\-=!@\$%^&?|\\/<>])[-+]?([_\d]+|[_\d]+\.[_\d]*|\.[_\d]+)([eE&][+-]?[\d]+)?(?![\.:\w_\-=!@\$%^&?|\\/<>])</string>
|
||||||
|
<key>name</key>
|
||||||
|
<string>constant.numeric.decimal.janet</string>
|
||||||
|
</dict>
|
||||||
|
<key>r-number</key>
|
||||||
|
<dict>
|
||||||
|
<key>match</key>
|
||||||
|
<string>(?<![\.:\w_\-=!@\$%^&?|\\/<>])[-+]?\d\d?r([_\w]+|[_\w]+\.[_\w]*|\.[_\w]+)(&[+-]?[\w]+)?(?![\.:\w_\-=!@\$%^&?|\\/<>])</string>
|
||||||
|
<key>name</key>
|
||||||
|
<string>constant.numeric.decimal.janet</string>
|
||||||
|
</dict>
|
||||||
|
<key>string</key>
|
||||||
|
<dict>
|
||||||
|
<key>begin</key>
|
||||||
|
<string>(@?")</string>
|
||||||
|
<key>beginCaptures</key>
|
||||||
|
<dict>
|
||||||
|
<key>0</key>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>punctuation.definition.string.begin.janet</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>end</key>
|
||||||
|
<string>(")</string>
|
||||||
|
<key>endCaptures</key>
|
||||||
|
<dict>
|
||||||
|
<key>0</key>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>punctuation.definition.string.end.janet</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>string.quoted.double.janet</string>
|
||||||
|
<key>patterns</key>
|
||||||
|
<array>
|
||||||
|
<dict>
|
||||||
|
<key>match</key>
|
||||||
|
<string>(\\[ne0zft"\\']|\\x[0-9a-fA-F][0-9a-fA-f])</string>
|
||||||
|
<key>name</key>
|
||||||
|
<string>constant.character.escape.janet</string>
|
||||||
|
</dict>
|
||||||
|
</array>
|
||||||
|
</dict>
|
||||||
|
<key>longstring</key>
|
||||||
|
<dict>
|
||||||
|
<key>begin</key>
|
||||||
|
<string>@?(`+)</string>
|
||||||
|
<key>beginCaptures</key>
|
||||||
|
<dict>
|
||||||
|
<key>0</key>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>punctuation.definition.string.begin.janet</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>end</key>
|
||||||
|
<string>\1</string>
|
||||||
|
<key>endCaptures</key>
|
||||||
|
<dict>
|
||||||
|
<key>0</key>
|
||||||
|
<dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>punctuation.definition.string.end.janet</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>name</key>
|
||||||
|
<string>string.quoted.triple.janet</string>
|
||||||
|
</dict>
|
||||||
|
<key>nomatch</key>
|
||||||
|
<dict>
|
||||||
|
<key>match</key>
|
||||||
|
<string>\S+</string>
|
||||||
|
<key>name</key>
|
||||||
|
<string>invalid.illegal.janet</string>
|
||||||
|
</dict>
|
||||||
|
</dict>
|
||||||
|
<key>scopeName</key>
|
||||||
|
<string>source.janet</string>
|
||||||
|
<key>uuid</key>
|
||||||
|
<string>3743190f-20c4-44d0-8640-6611a983296b</string>
|
||||||
|
</dict>
|
||||||
|
</plist>
|
30
grammar/tmcorelib.janet
Normal file
30
grammar/tmcorelib.janet
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
# Helper to generate core library mappings for janet
|
||||||
|
|
||||||
|
(def allsyms (all-symbols))
|
||||||
|
|
||||||
|
(def- escapes
|
||||||
|
{(get "|" 0) `\|`
|
||||||
|
(get "-" 0) `\-`
|
||||||
|
(get "+" 0) `\+`
|
||||||
|
(get "*" 0) `\*`
|
||||||
|
(get "^" 0) `\^`
|
||||||
|
(get "$" 0) `\$`
|
||||||
|
(get "?" 0) `\?`
|
||||||
|
38 "&"
|
||||||
|
60 "<"
|
||||||
|
62 ">"
|
||||||
|
34 """
|
||||||
|
39 "'"
|
||||||
|
47 "/"})
|
||||||
|
|
||||||
|
(defn- escape
|
||||||
|
"Escape special characters for HTML encoding."
|
||||||
|
[str]
|
||||||
|
(def buf @"")
|
||||||
|
(loop [byte :in str]
|
||||||
|
(if-let [rep escapes.byte]
|
||||||
|
(buffer/push-string buf rep)
|
||||||
|
(buffer/push-byte buf byte)))
|
||||||
|
buf)
|
||||||
|
|
||||||
|
(print (string/join (map escape allsyms)) "|"))
|
Loading…
Reference in New Issue
Block a user