mirror of
https://github.com/zadam/trilium.git
synced 2025-11-02 11:26:15 +01:00
codemirror 5.65.9
This commit is contained in:
41
libraries/codemirror/mode/scheme/scheme.js
vendored
41
libraries/codemirror/mode/scheme/scheme.js
vendored
@@ -1,8 +1,9 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: https://codemirror.net/LICENSE
|
||||
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
||||
|
||||
/**
|
||||
* Author: Koh Zi Han, based on implementation by Koh Zi Chun
|
||||
* Improved by: Jakub T. Jankiewicz
|
||||
*/
|
||||
|
||||
(function(mod) {
|
||||
@@ -17,7 +18,7 @@
|
||||
|
||||
CodeMirror.defineMode("scheme", function () {
|
||||
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
|
||||
ATOM = "atom", NUMBER = "number", BRACKET = "bracket";
|
||||
SYMBOL = "symbol", ATOM = "atom", NUMBER = "number", BRACKET = "bracket";
|
||||
var INDENT_WORD_SKIP = 2;
|
||||
|
||||
function makeKeywords(str) {
|
||||
@@ -67,6 +68,18 @@ CodeMirror.defineMode("scheme", function () {
|
||||
return stream.match(hexMatcher);
|
||||
}
|
||||
|
||||
function processEscapedSequence(stream, options) {
|
||||
var next, escaped = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == options.token && !escaped) {
|
||||
|
||||
options.state.mode = false;
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function () {
|
||||
return {
|
||||
@@ -92,17 +105,19 @@ CodeMirror.defineMode("scheme", function () {
|
||||
|
||||
switch(state.mode){
|
||||
case "string": // multi-line string parsing mode
|
||||
var next, escaped = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == "\"" && !escaped) {
|
||||
|
||||
state.mode = false;
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
processEscapedSequence(stream, {
|
||||
token: "\"",
|
||||
state: state
|
||||
});
|
||||
returnType = STRING; // continue on in scheme-string mode
|
||||
break;
|
||||
case "symbol": // escape symbol
|
||||
processEscapedSequence(stream, {
|
||||
token: "|",
|
||||
state: state
|
||||
});
|
||||
returnType = SYMBOL; // continue on in scheme-symbol mode
|
||||
break;
|
||||
case "comment": // comment parsing mode
|
||||
var next, maybeEnd = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
@@ -143,6 +158,9 @@ CodeMirror.defineMode("scheme", function () {
|
||||
stream.eatWhile(/[\w_\-!$%&*+\.\/:<=>?@\^~]/);
|
||||
returnType = ATOM;
|
||||
}
|
||||
} else if (ch == '|') {
|
||||
state.mode = "symbol";
|
||||
returnType = SYMBOL;
|
||||
} else if (ch == '#') {
|
||||
if (stream.eat("|")) { // Multi-line comment
|
||||
state.mode = "comment"; // toggle to comment mode
|
||||
@@ -255,6 +273,7 @@ CodeMirror.defineMode("scheme", function () {
|
||||
return state.indentStack.indent;
|
||||
},
|
||||
|
||||
fold: "brace-paren",
|
||||
closeBrackets: {pairs: "()[]{}\"\""},
|
||||
lineComment: ";;"
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user