|
@@ -1,11 +1,6 @@
|
|
-(function (mod) {
|
|
|
|
- if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
|
|
- mod(require("codemirror/lib/codemirror"));
|
|
|
|
- else if (typeof define == "function" && define.amd) // AMD
|
|
|
|
- define(["codemirror/lib/codemirror"], mod);
|
|
|
|
- else // Plain browser env
|
|
|
|
- mod(CodeMirror);
|
|
|
|
-})(function (CodeMirror) {
|
|
|
|
|
|
+import { getCodeEditorModeConfig } from "./utils";
|
|
|
|
+
|
|
|
|
+export function CodeEditorMode (CodeMirror) {
|
|
"use strict";
|
|
"use strict";
|
|
|
|
|
|
function Context(indented, column, type, info, align, prev) {
|
|
function Context(indented, column, type, info, align, prev) {
|
|
@@ -266,13 +261,13 @@
|
|
return words.propertyIsEnumerable(word);
|
|
return words.propertyIsEnumerable(word);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- var ivprogKeywords = "programa E OU nao senao se " +
|
|
|
|
- "enquanto faca pare para retorne funcao const " +
|
|
|
|
- "contrario caso escolha";
|
|
|
|
|
|
+ const codeConfig = getCodeEditorModeConfig();
|
|
|
|
+
|
|
|
|
+ var ivprogKeywords = codeConfig.keywords.join(" ");
|
|
|
|
|
|
// Do not use this. Use the cTypes function below. This is global just to avoid
|
|
// Do not use this. Use the cTypes function below. This is global just to avoid
|
|
// excessive calls when cTypes is being called multiple times during a parse.
|
|
// excessive calls when cTypes is being called multiple times during a parse.
|
|
- var basicTypes = words("inteiro logico cadeia real vazio");
|
|
|
|
|
|
+ var basicTypes = words(codeConfig.types.join(" "));
|
|
|
|
|
|
// Returns true if identifier is a "C" type.
|
|
// Returns true if identifier is a "C" type.
|
|
// C type is defined as those that are reserved by the compiler (basicTypes),
|
|
// C type is defined as those that are reserved by the compiler (basicTypes),
|
|
@@ -282,7 +277,7 @@
|
|
return contains(basicTypes, identifier);
|
|
return contains(basicTypes, identifier);
|
|
}
|
|
}
|
|
|
|
|
|
- var ivprogBlockKeywords = "programa caso escolha contrario faca enquanto para se senao";
|
|
|
|
|
|
+ var ivprogBlockKeywords = codeConfig.blocks.join(" ");
|
|
var ivprogDefKeywords = "funcao const";
|
|
var ivprogDefKeywords = "funcao const";
|
|
|
|
|
|
function def(mimes, mode) {
|
|
function def(mimes, mode) {
|
|
@@ -304,7 +299,7 @@
|
|
for (var i = 0; i < mimes.length; ++i)
|
|
for (var i = 0; i < mimes.length; ++i)
|
|
CodeMirror.defineMIME(mimes[i], mode);
|
|
CodeMirror.defineMIME(mimes[i], mode);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
def(["text/x-ivprog"], {
|
|
def(["text/x-ivprog"], {
|
|
name: "ivprog",
|
|
name: "ivprog",
|
|
keywords: words(ivprogKeywords),
|
|
keywords: words(ivprogKeywords),
|
|
@@ -312,11 +307,11 @@
|
|
blockKeywords: words(ivprogBlockKeywords),
|
|
blockKeywords: words(ivprogBlockKeywords),
|
|
defKeywords: words(ivprogDefKeywords),
|
|
defKeywords: words(ivprogDefKeywords),
|
|
typeFirstDefinitions: true,
|
|
typeFirstDefinitions: true,
|
|
- atoms: words("verdadeiro falso"),
|
|
|
|
- switchKeyword: "escolha",
|
|
|
|
- caseKeyword: "caso",
|
|
|
|
- defaultKeyword: "contrario",
|
|
|
|
|
|
+ atoms: words(codeConfig.atoms.join(" ")),
|
|
|
|
+ switchKeyword: codeConfig.switchString,
|
|
|
|
+ caseKeyword: codeConfig.case_default[0],
|
|
|
|
+ defaultKeyword: codeConfig.case_default[1],
|
|
modeProps: { fold: ["brace"] }
|
|
modeProps: { fold: ["brace"] }
|
|
});
|
|
});
|
|
|
|
|
|
-});
|
|
|
|
|
|
+}
|