removed some files but not all (for now)
This commit is contained in:
2
VERSION
2
VERSION
@@ -1 +1 @@
|
||||
Version 2.9.5-trunk+timestamp.2014.05.07.17.03.15
|
||||
Version 2.9.5-trunk+timestamp.2014.05.09.15.22.59
|
||||
|
||||
160
applications/admin/static/codemirror/mode/apl/apl.js
vendored
160
applications/admin/static/codemirror/mode/apl/apl.js
vendored
@@ -1,160 +0,0 @@
|
||||
CodeMirror.defineMode("apl", function() {
|
||||
var builtInOps = {
|
||||
".": "innerProduct",
|
||||
"\\": "scan",
|
||||
"/": "reduce",
|
||||
"⌿": "reduce1Axis",
|
||||
"⍀": "scan1Axis",
|
||||
"¨": "each",
|
||||
"⍣": "power"
|
||||
};
|
||||
var builtInFuncs = {
|
||||
"+": ["conjugate", "add"],
|
||||
"−": ["negate", "subtract"],
|
||||
"×": ["signOf", "multiply"],
|
||||
"÷": ["reciprocal", "divide"],
|
||||
"⌈": ["ceiling", "greaterOf"],
|
||||
"⌊": ["floor", "lesserOf"],
|
||||
"∣": ["absolute", "residue"],
|
||||
"⍳": ["indexGenerate", "indexOf"],
|
||||
"?": ["roll", "deal"],
|
||||
"⋆": ["exponentiate", "toThePowerOf"],
|
||||
"⍟": ["naturalLog", "logToTheBase"],
|
||||
"○": ["piTimes", "circularFuncs"],
|
||||
"!": ["factorial", "binomial"],
|
||||
"⌹": ["matrixInverse", "matrixDivide"],
|
||||
"<": [null, "lessThan"],
|
||||
"≤": [null, "lessThanOrEqual"],
|
||||
"=": [null, "equals"],
|
||||
">": [null, "greaterThan"],
|
||||
"≥": [null, "greaterThanOrEqual"],
|
||||
"≠": [null, "notEqual"],
|
||||
"≡": ["depth", "match"],
|
||||
"≢": [null, "notMatch"],
|
||||
"∈": ["enlist", "membership"],
|
||||
"⍷": [null, "find"],
|
||||
"∪": ["unique", "union"],
|
||||
"∩": [null, "intersection"],
|
||||
"∼": ["not", "without"],
|
||||
"∨": [null, "or"],
|
||||
"∧": [null, "and"],
|
||||
"⍱": [null, "nor"],
|
||||
"⍲": [null, "nand"],
|
||||
"⍴": ["shapeOf", "reshape"],
|
||||
",": ["ravel", "catenate"],
|
||||
"⍪": [null, "firstAxisCatenate"],
|
||||
"⌽": ["reverse", "rotate"],
|
||||
"⊖": ["axis1Reverse", "axis1Rotate"],
|
||||
"⍉": ["transpose", null],
|
||||
"↑": ["first", "take"],
|
||||
"↓": [null, "drop"],
|
||||
"⊂": ["enclose", "partitionWithAxis"],
|
||||
"⊃": ["diclose", "pick"],
|
||||
"⌷": [null, "index"],
|
||||
"⍋": ["gradeUp", null],
|
||||
"⍒": ["gradeDown", null],
|
||||
"⊤": ["encode", null],
|
||||
"⊥": ["decode", null],
|
||||
"⍕": ["format", "formatByExample"],
|
||||
"⍎": ["execute", null],
|
||||
"⊣": ["stop", "left"],
|
||||
"⊢": ["pass", "right"]
|
||||
};
|
||||
|
||||
var isOperator = /[\.\/⌿⍀¨⍣]/;
|
||||
var isNiladic = /⍬/;
|
||||
var isFunction = /[\+−×÷⌈⌊∣⍳\?⋆⍟○!⌹<≤=>≥≠≡≢∈⍷∪∩∼∨∧⍱⍲⍴,⍪⌽⊖⍉↑↓⊂⊃⌷⍋⍒⊤⊥⍕⍎⊣⊢]/;
|
||||
var isArrow = /←/;
|
||||
var isComment = /[⍝#].*$/;
|
||||
|
||||
var stringEater = function(type) {
|
||||
var prev;
|
||||
prev = false;
|
||||
return function(c) {
|
||||
prev = c;
|
||||
if (c === type) {
|
||||
return prev === "\\";
|
||||
}
|
||||
return true;
|
||||
};
|
||||
};
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
prev: false,
|
||||
func: false,
|
||||
op: false,
|
||||
string: false,
|
||||
escape: false
|
||||
};
|
||||
},
|
||||
token: function(stream, state) {
|
||||
var ch, funcName, word;
|
||||
if (stream.eatSpace()) {
|
||||
return null;
|
||||
}
|
||||
ch = stream.next();
|
||||
if (ch === '"' || ch === "'") {
|
||||
stream.eatWhile(stringEater(ch));
|
||||
stream.next();
|
||||
state.prev = true;
|
||||
return "string";
|
||||
}
|
||||
if (/[\[{\(]/.test(ch)) {
|
||||
state.prev = false;
|
||||
return null;
|
||||
}
|
||||
if (/[\]}\)]/.test(ch)) {
|
||||
state.prev = true;
|
||||
return null;
|
||||
}
|
||||
if (isNiladic.test(ch)) {
|
||||
state.prev = false;
|
||||
return "niladic";
|
||||
}
|
||||
if (/[¯\d]/.test(ch)) {
|
||||
if (state.func) {
|
||||
state.func = false;
|
||||
state.prev = false;
|
||||
} else {
|
||||
state.prev = true;
|
||||
}
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
return "number";
|
||||
}
|
||||
if (isOperator.test(ch)) {
|
||||
return "operator apl-" + builtInOps[ch];
|
||||
}
|
||||
if (isArrow.test(ch)) {
|
||||
return "apl-arrow";
|
||||
}
|
||||
if (isFunction.test(ch)) {
|
||||
funcName = "apl-";
|
||||
if (builtInFuncs[ch] != null) {
|
||||
if (state.prev) {
|
||||
funcName += builtInFuncs[ch][1];
|
||||
} else {
|
||||
funcName += builtInFuncs[ch][0];
|
||||
}
|
||||
}
|
||||
state.func = true;
|
||||
state.prev = false;
|
||||
return "function " + funcName;
|
||||
}
|
||||
if (isComment.test(ch)) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
if (ch === "∘" && stream.peek() === ".") {
|
||||
stream.next();
|
||||
return "function jot-dot";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
word = stream.current();
|
||||
state.prev = true;
|
||||
return "keyword";
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/apl", "apl");
|
||||
@@ -1,72 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: APL mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="./apl.js"></script>
|
||||
<style>
|
||||
.CodeMirror { border: 2px inset #dee; }
|
||||
</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">APL</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>APL mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
⍝ Conway's game of life
|
||||
|
||||
⍝ This example was inspired by the impressive demo at
|
||||
⍝ http://www.youtube.com/watch?v=a9xAKttWgP4
|
||||
|
||||
⍝ Create a matrix:
|
||||
⍝ 0 1 1
|
||||
⍝ 1 1 0
|
||||
⍝ 0 1 0
|
||||
creature ← (3 3 ⍴ ⍳ 9) ∈ 1 2 3 4 7 ⍝ Original creature from demo
|
||||
creature ← (3 3 ⍴ ⍳ 9) ∈ 1 3 6 7 8 ⍝ Glider
|
||||
|
||||
⍝ Place the creature on a larger board, near the centre
|
||||
board ← ¯1 ⊖ ¯2 ⌽ 5 7 ↑ creature
|
||||
|
||||
⍝ A function to move from one generation to the next
|
||||
life ← {∨/ 1 ⍵ ∧ 3 4 = ⊂+/ +⌿ 1 0 ¯1 ∘.⊖ 1 0 ¯1 ⌽¨ ⊂⍵}
|
||||
|
||||
⍝ Compute n-th generation and format it as a
|
||||
⍝ character matrix
|
||||
gen ← {' #'[(life ⍣ ⍵) board]}
|
||||
|
||||
⍝ Show first three generations
|
||||
(gen 1) (gen 2) (gen 3)
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/apl"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Simple mode that tries to handle APL as well as it can.</p>
|
||||
<p>It attempts to label functions/operators based upon
|
||||
monadic/dyadic usage (but this is far from fully fleshed out).
|
||||
This means there are meaningful classnames so hover states can
|
||||
have popups etc.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/apl</code> (APL code)</p>
|
||||
</article>
|
||||
@@ -1,183 +0,0 @@
|
||||
/*
|
||||
* =====================================================================================
|
||||
*
|
||||
* Filename: mode/asterisk/asterisk.js
|
||||
*
|
||||
* Description: CodeMirror mode for Asterisk dialplan
|
||||
*
|
||||
* Created: 05/17/2012 09:20:25 PM
|
||||
* Revision: none
|
||||
*
|
||||
* Author: Stas Kobzar (stas@modulis.ca),
|
||||
* Company: Modulis.ca Inc.
|
||||
*
|
||||
* =====================================================================================
|
||||
*/
|
||||
|
||||
CodeMirror.defineMode("asterisk", function() {
|
||||
var atoms = ["exten", "same", "include","ignorepat","switch"],
|
||||
dpcmd = ["#include","#exec"],
|
||||
apps = [
|
||||
"addqueuemember","adsiprog","aelsub","agentlogin","agentmonitoroutgoing","agi",
|
||||
"alarmreceiver","amd","answer","authenticate","background","backgrounddetect",
|
||||
"bridge","busy","callcompletioncancel","callcompletionrequest","celgenuserevent",
|
||||
"changemonitor","chanisavail","channelredirect","chanspy","clearhash","confbridge",
|
||||
"congestion","continuewhile","controlplayback","dahdiacceptr2call","dahdibarge",
|
||||
"dahdiras","dahdiscan","dahdisendcallreroutingfacility","dahdisendkeypadfacility",
|
||||
"datetime","dbdel","dbdeltree","deadagi","dial","dictate","directory","disa",
|
||||
"dumpchan","eagi","echo","endwhile","exec","execif","execiftime","exitwhile","extenspy",
|
||||
"externalivr","festival","flash","followme","forkcdr","getcpeid","gosub","gosubif",
|
||||
"goto","gotoif","gotoiftime","hangup","iax2provision","ices","importvar","incomplete",
|
||||
"ivrdemo","jabberjoin","jabberleave","jabbersend","jabbersendgroup","jabberstatus",
|
||||
"jack","log","macro","macroexclusive","macroexit","macroif","mailboxexists","meetme",
|
||||
"meetmeadmin","meetmechanneladmin","meetmecount","milliwatt","minivmaccmess","minivmdelete",
|
||||
"minivmgreet","minivmmwi","minivmnotify","minivmrecord","mixmonitor","monitor","morsecode",
|
||||
"mp3player","mset","musiconhold","nbscat","nocdr","noop","odbc","odbc","odbcfinish",
|
||||
"originate","ospauth","ospfinish","osplookup","ospnext","page","park","parkandannounce",
|
||||
"parkedcall","pausemonitor","pausequeuemember","pickup","pickupchan","playback","playtones",
|
||||
"privacymanager","proceeding","progress","queue","queuelog","raiseexception","read","readexten",
|
||||
"readfile","receivefax","receivefax","receivefax","record","removequeuemember",
|
||||
"resetcdr","retrydial","return","ringing","sayalpha","saycountedadj","saycountednoun",
|
||||
"saycountpl","saydigits","saynumber","sayphonetic","sayunixtime","senddtmf","sendfax",
|
||||
"sendfax","sendfax","sendimage","sendtext","sendurl","set","setamaflags",
|
||||
"setcallerpres","setmusiconhold","sipaddheader","sipdtmfmode","sipremoveheader","skel",
|
||||
"slastation","slatrunk","sms","softhangup","speechactivategrammar","speechbackground",
|
||||
"speechcreate","speechdeactivategrammar","speechdestroy","speechloadgrammar","speechprocessingsound",
|
||||
"speechstart","speechunloadgrammar","stackpop","startmusiconhold","stopmixmonitor","stopmonitor",
|
||||
"stopmusiconhold","stopplaytones","system","testclient","testserver","transfer","tryexec",
|
||||
"trysystem","unpausemonitor","unpausequeuemember","userevent","verbose","vmauthenticate",
|
||||
"vmsayname","voicemail","voicemailmain","wait","waitexten","waitfornoise","waitforring",
|
||||
"waitforsilence","waitmusiconhold","waituntil","while","zapateller"
|
||||
];
|
||||
|
||||
function basicToken(stream,state){
|
||||
var cur = '';
|
||||
var ch = '';
|
||||
ch = stream.next();
|
||||
// comment
|
||||
if(ch == ";") {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
// context
|
||||
if(ch == '[') {
|
||||
stream.skipTo(']');
|
||||
stream.eat(']');
|
||||
return "header";
|
||||
}
|
||||
// string
|
||||
if(ch == '"') {
|
||||
stream.skipTo('"');
|
||||
return "string";
|
||||
}
|
||||
if(ch == "'") {
|
||||
stream.skipTo("'");
|
||||
return "string-2";
|
||||
}
|
||||
// dialplan commands
|
||||
if(ch == '#') {
|
||||
stream.eatWhile(/\w/);
|
||||
cur = stream.current();
|
||||
if(dpcmd.indexOf(cur) !== -1) {
|
||||
stream.skipToEnd();
|
||||
return "strong";
|
||||
}
|
||||
}
|
||||
// application args
|
||||
if(ch == '$'){
|
||||
var ch1 = stream.peek();
|
||||
if(ch1 == '{'){
|
||||
stream.skipTo('}');
|
||||
stream.eat('}');
|
||||
return "variable-3";
|
||||
}
|
||||
}
|
||||
// extension
|
||||
stream.eatWhile(/\w/);
|
||||
cur = stream.current();
|
||||
if(atoms.indexOf(cur) !== -1) {
|
||||
state.extenStart = true;
|
||||
switch(cur) {
|
||||
case 'same': state.extenSame = true; break;
|
||||
case 'include':
|
||||
case 'switch':
|
||||
case 'ignorepat':
|
||||
state.extenInclude = true;break;
|
||||
default:break;
|
||||
}
|
||||
return "atom";
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
extenStart: false,
|
||||
extenSame: false,
|
||||
extenInclude: false,
|
||||
extenExten: false,
|
||||
extenPriority: false,
|
||||
extenApplication: false
|
||||
};
|
||||
},
|
||||
token: function(stream, state) {
|
||||
|
||||
var cur = '';
|
||||
var ch = '';
|
||||
if(stream.eatSpace()) return null;
|
||||
// extension started
|
||||
if(state.extenStart){
|
||||
stream.eatWhile(/[^\s]/);
|
||||
cur = stream.current();
|
||||
if(/^=>?$/.test(cur)){
|
||||
state.extenExten = true;
|
||||
state.extenStart = false;
|
||||
return "strong";
|
||||
} else {
|
||||
state.extenStart = false;
|
||||
stream.skipToEnd();
|
||||
return "error";
|
||||
}
|
||||
} else if(state.extenExten) {
|
||||
// set exten and priority
|
||||
state.extenExten = false;
|
||||
state.extenPriority = true;
|
||||
stream.eatWhile(/[^,]/);
|
||||
if(state.extenInclude) {
|
||||
stream.skipToEnd();
|
||||
state.extenPriority = false;
|
||||
state.extenInclude = false;
|
||||
}
|
||||
if(state.extenSame) {
|
||||
state.extenPriority = false;
|
||||
state.extenSame = false;
|
||||
state.extenApplication = true;
|
||||
}
|
||||
return "tag";
|
||||
} else if(state.extenPriority) {
|
||||
state.extenPriority = false;
|
||||
state.extenApplication = true;
|
||||
ch = stream.next(); // get comma
|
||||
if(state.extenSame) return null;
|
||||
stream.eatWhile(/[^,]/);
|
||||
return "number";
|
||||
} else if(state.extenApplication) {
|
||||
stream.eatWhile(/,/);
|
||||
cur = stream.current();
|
||||
if(cur === ',') return null;
|
||||
stream.eatWhile(/\w/);
|
||||
cur = stream.current().toLowerCase();
|
||||
state.extenApplication = false;
|
||||
if(apps.indexOf(cur) !== -1){
|
||||
return "def strong";
|
||||
}
|
||||
} else{
|
||||
return basicToken(stream,state);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-asterisk", "asterisk");
|
||||
@@ -1,154 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Asterisk dialplan mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="asterisk.js"></script>
|
||||
<style>
|
||||
.CodeMirror {border: 1px solid #999;}
|
||||
.cm-s-default span.cm-arrow { color: red; }
|
||||
</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Asterisk dialplan</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Asterisk dialplan mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
; extensions.conf - the Asterisk dial plan
|
||||
;
|
||||
|
||||
[general]
|
||||
;
|
||||
; If static is set to no, or omitted, then the pbx_config will rewrite
|
||||
; this file when extensions are modified. Remember that all comments
|
||||
; made in the file will be lost when that happens.
|
||||
static=yes
|
||||
|
||||
#include "/etc/asterisk/additional_general.conf
|
||||
|
||||
[iaxprovider]
|
||||
switch => IAX2/user:[key]@myserver/mycontext
|
||||
|
||||
[dynamic]
|
||||
#exec /usr/bin/dynamic-peers.pl
|
||||
|
||||
[trunkint]
|
||||
;
|
||||
; International long distance through trunk
|
||||
;
|
||||
exten => _9011.,1,Macro(dundi-e164,${EXTEN:4})
|
||||
exten => _9011.,n,Dial(${GLOBAL(TRUNK)}/${FILTER(0-9,${EXTEN:${GLOBAL(TRUNKMSD)}})})
|
||||
|
||||
[local]
|
||||
;
|
||||
; Master context for local, toll-free, and iaxtel calls only
|
||||
;
|
||||
ignorepat => 9
|
||||
include => default
|
||||
|
||||
[demo]
|
||||
include => stdexten
|
||||
;
|
||||
; We start with what to do when a call first comes in.
|
||||
;
|
||||
exten => s,1,Wait(1) ; Wait a second, just for fun
|
||||
same => n,Answer ; Answer the line
|
||||
same => n,Set(TIMEOUT(digit)=5) ; Set Digit Timeout to 5 seconds
|
||||
same => n,Set(TIMEOUT(response)=10) ; Set Response Timeout to 10 seconds
|
||||
same => n(restart),BackGround(demo-congrats) ; Play a congratulatory message
|
||||
same => n(instruct),BackGround(demo-instruct) ; Play some instructions
|
||||
same => n,WaitExten ; Wait for an extension to be dialed.
|
||||
|
||||
exten => 2,1,BackGround(demo-moreinfo) ; Give some more information.
|
||||
exten => 2,n,Goto(s,instruct)
|
||||
|
||||
exten => 3,1,Set(LANGUAGE()=fr) ; Set language to french
|
||||
exten => 3,n,Goto(s,restart) ; Start with the congratulations
|
||||
|
||||
exten => 1000,1,Goto(default,s,1)
|
||||
;
|
||||
; We also create an example user, 1234, who is on the console and has
|
||||
; voicemail, etc.
|
||||
;
|
||||
exten => 1234,1,Playback(transfer,skip) ; "Please hold while..."
|
||||
; (but skip if channel is not up)
|
||||
exten => 1234,n,Gosub(${EXTEN},stdexten(${GLOBAL(CONSOLE)}))
|
||||
exten => 1234,n,Goto(default,s,1) ; exited Voicemail
|
||||
|
||||
exten => 1235,1,Voicemail(1234,u) ; Right to voicemail
|
||||
|
||||
exten => 1236,1,Dial(Console/dsp) ; Ring forever
|
||||
exten => 1236,n,Voicemail(1234,b) ; Unless busy
|
||||
|
||||
;
|
||||
; # for when they're done with the demo
|
||||
;
|
||||
exten => #,1,Playback(demo-thanks) ; "Thanks for trying the demo"
|
||||
exten => #,n,Hangup ; Hang them up.
|
||||
|
||||
;
|
||||
; A timeout and "invalid extension rule"
|
||||
;
|
||||
exten => t,1,Goto(#,1) ; If they take too long, give up
|
||||
exten => i,1,Playback(invalid) ; "That's not valid, try again"
|
||||
|
||||
;
|
||||
; Create an extension, 500, for dialing the
|
||||
; Asterisk demo.
|
||||
;
|
||||
exten => 500,1,Playback(demo-abouttotry); Let them know what's going on
|
||||
exten => 500,n,Dial(IAX2/guest@pbx.digium.com/s@default) ; Call the Asterisk demo
|
||||
exten => 500,n,Playback(demo-nogo) ; Couldn't connect to the demo site
|
||||
exten => 500,n,Goto(s,6) ; Return to the start over message.
|
||||
|
||||
;
|
||||
; Create an extension, 600, for evaluating echo latency.
|
||||
;
|
||||
exten => 600,1,Playback(demo-echotest) ; Let them know what's going on
|
||||
exten => 600,n,Echo ; Do the echo test
|
||||
exten => 600,n,Playback(demo-echodone) ; Let them know it's over
|
||||
exten => 600,n,Goto(s,6) ; Start over
|
||||
|
||||
;
|
||||
; You can use the Macro Page to intercom a individual user
|
||||
exten => 76245,1,Macro(page,SIP/Grandstream1)
|
||||
; or if your peernames are the same as extensions
|
||||
exten => _7XXX,1,Macro(page,SIP/${EXTEN})
|
||||
;
|
||||
;
|
||||
; System Wide Page at extension 7999
|
||||
;
|
||||
exten => 7999,1,Set(TIMEOUT(absolute)=60)
|
||||
exten => 7999,2,Page(Local/Grandstream1@page&Local/Xlite1@page&Local/1234@page/n,d)
|
||||
|
||||
; Give voicemail at extension 8500
|
||||
;
|
||||
exten => 8500,1,VoicemailMain
|
||||
exten => 8500,n,Goto(s,6)
|
||||
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: "text/x-asterisk",
|
||||
matchBrackets: true,
|
||||
lineNumber: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-asterisk</code>.</p>
|
||||
|
||||
</article>
|
||||
@@ -1,240 +0,0 @@
|
||||
/**
|
||||
* Author: Gautam Mehta
|
||||
* Branched from CodeMirror's Scheme mode
|
||||
*/
|
||||
CodeMirror.defineMode("cobol", function () {
|
||||
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
|
||||
ATOM = "atom", NUMBER = "number", KEYWORD = "keyword", MODTAG = "header",
|
||||
COBOLLINENUM = "def", PERIOD = "link";
|
||||
function makeKeywords(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
var atoms = makeKeywords("TRUE FALSE ZEROES ZEROS ZERO SPACES SPACE LOW-VALUE LOW-VALUES ");
|
||||
var keywords = makeKeywords(
|
||||
"ACCEPT ACCESS ACQUIRE ADD ADDRESS " +
|
||||
"ADVANCING AFTER ALIAS ALL ALPHABET " +
|
||||
"ALPHABETIC ALPHABETIC-LOWER ALPHABETIC-UPPER ALPHANUMERIC ALPHANUMERIC-EDITED " +
|
||||
"ALSO ALTER ALTERNATE AND ANY " +
|
||||
"ARE AREA AREAS ARITHMETIC ASCENDING " +
|
||||
"ASSIGN AT ATTRIBUTE AUTHOR AUTO " +
|
||||
"AUTO-SKIP AUTOMATIC B-AND B-EXOR B-LESS " +
|
||||
"B-NOT B-OR BACKGROUND-COLOR BACKGROUND-COLOUR BEEP " +
|
||||
"BEFORE BELL BINARY BIT BITS " +
|
||||
"BLANK BLINK BLOCK BOOLEAN BOTTOM " +
|
||||
"BY CALL CANCEL CD CF " +
|
||||
"CH CHARACTER CHARACTERS CLASS CLOCK-UNITS " +
|
||||
"CLOSE COBOL CODE CODE-SET COL " +
|
||||
"COLLATING COLUMN COMMA COMMIT COMMITMENT " +
|
||||
"COMMON COMMUNICATION COMP COMP-0 COMP-1 " +
|
||||
"COMP-2 COMP-3 COMP-4 COMP-5 COMP-6 " +
|
||||
"COMP-7 COMP-8 COMP-9 COMPUTATIONAL COMPUTATIONAL-0 " +
|
||||
"COMPUTATIONAL-1 COMPUTATIONAL-2 COMPUTATIONAL-3 COMPUTATIONAL-4 COMPUTATIONAL-5 " +
|
||||
"COMPUTATIONAL-6 COMPUTATIONAL-7 COMPUTATIONAL-8 COMPUTATIONAL-9 COMPUTE " +
|
||||
"CONFIGURATION CONNECT CONSOLE CONTAINED CONTAINS " +
|
||||
"CONTENT CONTINUE CONTROL CONTROL-AREA CONTROLS " +
|
||||
"CONVERTING COPY CORR CORRESPONDING COUNT " +
|
||||
"CRT CRT-UNDER CURRENCY CURRENT CURSOR " +
|
||||
"DATA DATE DATE-COMPILED DATE-WRITTEN DAY " +
|
||||
"DAY-OF-WEEK DB DB-ACCESS-CONTROL-KEY DB-DATA-NAME DB-EXCEPTION " +
|
||||
"DB-FORMAT-NAME DB-RECORD-NAME DB-SET-NAME DB-STATUS DBCS " +
|
||||
"DBCS-EDITED DE DEBUG-CONTENTS DEBUG-ITEM DEBUG-LINE " +
|
||||
"DEBUG-NAME DEBUG-SUB-1 DEBUG-SUB-2 DEBUG-SUB-3 DEBUGGING " +
|
||||
"DECIMAL-POINT DECLARATIVES DEFAULT DELETE DELIMITED " +
|
||||
"DELIMITER DEPENDING DESCENDING DESCRIBED DESTINATION " +
|
||||
"DETAIL DISABLE DISCONNECT DISPLAY DISPLAY-1 " +
|
||||
"DISPLAY-2 DISPLAY-3 DISPLAY-4 DISPLAY-5 DISPLAY-6 " +
|
||||
"DISPLAY-7 DISPLAY-8 DISPLAY-9 DIVIDE DIVISION " +
|
||||
"DOWN DROP DUPLICATE DUPLICATES DYNAMIC " +
|
||||
"EBCDIC EGI EJECT ELSE EMI " +
|
||||
"EMPTY EMPTY-CHECK ENABLE END END. END-ACCEPT END-ACCEPT. " +
|
||||
"END-ADD END-CALL END-COMPUTE END-DELETE END-DISPLAY " +
|
||||
"END-DIVIDE END-EVALUATE END-IF END-INVOKE END-MULTIPLY " +
|
||||
"END-OF-PAGE END-PERFORM END-READ END-RECEIVE END-RETURN " +
|
||||
"END-REWRITE END-SEARCH END-START END-STRING END-SUBTRACT " +
|
||||
"END-UNSTRING END-WRITE END-XML ENTER ENTRY " +
|
||||
"ENVIRONMENT EOP EQUAL EQUALS ERASE " +
|
||||
"ERROR ESI EVALUATE EVERY EXCEEDS " +
|
||||
"EXCEPTION EXCLUSIVE EXIT EXTEND EXTERNAL " +
|
||||
"EXTERNALLY-DESCRIBED-KEY FD FETCH FILE FILE-CONTROL " +
|
||||
"FILE-STREAM FILES FILLER FINAL FIND " +
|
||||
"FINISH FIRST FOOTING FOR FOREGROUND-COLOR " +
|
||||
"FOREGROUND-COLOUR FORMAT FREE FROM FULL " +
|
||||
"FUNCTION GENERATE GET GIVING GLOBAL " +
|
||||
"GO GOBACK GREATER GROUP HEADING " +
|
||||
"HIGH-VALUE HIGH-VALUES HIGHLIGHT I-O I-O-CONTROL " +
|
||||
"ID IDENTIFICATION IF IN INDEX " +
|
||||
"INDEX-1 INDEX-2 INDEX-3 INDEX-4 INDEX-5 " +
|
||||
"INDEX-6 INDEX-7 INDEX-8 INDEX-9 INDEXED " +
|
||||
"INDIC INDICATE INDICATOR INDICATORS INITIAL " +
|
||||
"INITIALIZE INITIATE INPUT INPUT-OUTPUT INSPECT " +
|
||||
"INSTALLATION INTO INVALID INVOKE IS " +
|
||||
"JUST JUSTIFIED KANJI KEEP KEY " +
|
||||
"LABEL LAST LD LEADING LEFT " +
|
||||
"LEFT-JUSTIFY LENGTH LENGTH-CHECK LESS LIBRARY " +
|
||||
"LIKE LIMIT LIMITS LINAGE LINAGE-COUNTER " +
|
||||
"LINE LINE-COUNTER LINES LINKAGE LOCAL-STORAGE " +
|
||||
"LOCALE LOCALLY LOCK " +
|
||||
"MEMBER MEMORY MERGE MESSAGE METACLASS " +
|
||||
"MODE MODIFIED MODIFY MODULES MOVE " +
|
||||
"MULTIPLE MULTIPLY NATIONAL NATIVE NEGATIVE " +
|
||||
"NEXT NO NO-ECHO NONE NOT " +
|
||||
"NULL NULL-KEY-MAP NULL-MAP NULLS NUMBER " +
|
||||
"NUMERIC NUMERIC-EDITED OBJECT OBJECT-COMPUTER OCCURS " +
|
||||
"OF OFF OMITTED ON ONLY " +
|
||||
"OPEN OPTIONAL OR ORDER ORGANIZATION " +
|
||||
"OTHER OUTPUT OVERFLOW OWNER PACKED-DECIMAL " +
|
||||
"PADDING PAGE PAGE-COUNTER PARSE PERFORM " +
|
||||
"PF PH PIC PICTURE PLUS " +
|
||||
"POINTER POSITION POSITIVE PREFIX PRESENT " +
|
||||
"PRINTING PRIOR PROCEDURE PROCEDURE-POINTER PROCEDURES " +
|
||||
"PROCEED PROCESS PROCESSING PROGRAM PROGRAM-ID " +
|
||||
"PROMPT PROTECTED PURGE QUEUE QUOTE " +
|
||||
"QUOTES RANDOM RD READ READY " +
|
||||
"REALM RECEIVE RECONNECT RECORD RECORD-NAME " +
|
||||
"RECORDS RECURSIVE REDEFINES REEL REFERENCE " +
|
||||
"REFERENCE-MONITOR REFERENCES RELATION RELATIVE RELEASE " +
|
||||
"REMAINDER REMOVAL RENAMES REPEATED REPLACE " +
|
||||
"REPLACING REPORT REPORTING REPORTS REPOSITORY " +
|
||||
"REQUIRED RERUN RESERVE RESET RETAINING " +
|
||||
"RETRIEVAL RETURN RETURN-CODE RETURNING REVERSE-VIDEO " +
|
||||
"REVERSED REWIND REWRITE RF RH " +
|
||||
"RIGHT RIGHT-JUSTIFY ROLLBACK ROLLING ROUNDED " +
|
||||
"RUN SAME SCREEN SD SEARCH " +
|
||||
"SECTION SECURE SECURITY SEGMENT SEGMENT-LIMIT " +
|
||||
"SELECT SEND SENTENCE SEPARATE SEQUENCE " +
|
||||
"SEQUENTIAL SET SHARED SIGN SIZE " +
|
||||
"SKIP1 SKIP2 SKIP3 SORT SORT-MERGE " +
|
||||
"SORT-RETURN SOURCE SOURCE-COMPUTER SPACE-FILL " +
|
||||
"SPECIAL-NAMES STANDARD STANDARD-1 STANDARD-2 " +
|
||||
"START STARTING STATUS STOP STORE " +
|
||||
"STRING SUB-QUEUE-1 SUB-QUEUE-2 SUB-QUEUE-3 SUB-SCHEMA " +
|
||||
"SUBFILE SUBSTITUTE SUBTRACT SUM SUPPRESS " +
|
||||
"SYMBOLIC SYNC SYNCHRONIZED SYSIN SYSOUT " +
|
||||
"TABLE TALLYING TAPE TENANT TERMINAL " +
|
||||
"TERMINATE TEST TEXT THAN THEN " +
|
||||
"THROUGH THRU TIME TIMES TITLE " +
|
||||
"TO TOP TRAILING TRAILING-SIGN TRANSACTION " +
|
||||
"TYPE TYPEDEF UNDERLINE UNEQUAL UNIT " +
|
||||
"UNSTRING UNTIL UP UPDATE UPON " +
|
||||
"USAGE USAGE-MODE USE USING VALID " +
|
||||
"VALIDATE VALUE VALUES VARYING VLR " +
|
||||
"WAIT WHEN WHEN-COMPILED WITH WITHIN " +
|
||||
"WORDS WORKING-STORAGE WRITE XML XML-CODE " +
|
||||
"XML-EVENT XML-NTEXT XML-TEXT ZERO ZERO-FILL " );
|
||||
|
||||
var builtins = makeKeywords("- * ** / + < <= = > >= ");
|
||||
var tests = {
|
||||
digit: /\d/,
|
||||
digit_or_colon: /[\d:]/,
|
||||
hex: /[0-9a-f]/i,
|
||||
sign: /[+-]/,
|
||||
exponent: /e/i,
|
||||
keyword_char: /[^\s\(\[\;\)\]]/,
|
||||
symbol: /[\w*+\-]/
|
||||
};
|
||||
function isNumber(ch, stream){
|
||||
// hex
|
||||
if ( ch === '0' && stream.eat(/x/i) ) {
|
||||
stream.eatWhile(tests.hex);
|
||||
return true;
|
||||
}
|
||||
// leading sign
|
||||
if ( ( ch == '+' || ch == '-' ) && ( tests.digit.test(stream.peek()) ) ) {
|
||||
stream.eat(tests.sign);
|
||||
ch = stream.next();
|
||||
}
|
||||
if ( tests.digit.test(ch) ) {
|
||||
stream.eat(ch);
|
||||
stream.eatWhile(tests.digit);
|
||||
if ( '.' == stream.peek()) {
|
||||
stream.eat('.');
|
||||
stream.eatWhile(tests.digit);
|
||||
}
|
||||
if ( stream.eat(tests.exponent) ) {
|
||||
stream.eat(tests.sign);
|
||||
stream.eatWhile(tests.digit);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return {
|
||||
startState: function () {
|
||||
return {
|
||||
indentStack: null,
|
||||
indentation: 0,
|
||||
mode: false
|
||||
};
|
||||
},
|
||||
token: function (stream, state) {
|
||||
if (state.indentStack == null && stream.sol()) {
|
||||
// update indentation, but only if indentStack is empty
|
||||
state.indentation = 6 ; //stream.indentation();
|
||||
}
|
||||
// skip spaces
|
||||
if (stream.eatSpace()) {
|
||||
return null;
|
||||
}
|
||||
var returnType = null;
|
||||
switch(state.mode){
|
||||
case "string": // multi-line string parsing mode
|
||||
var next = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == "\"" || next == "\'") {
|
||||
state.mode = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
returnType = STRING; // continue on in string mode
|
||||
break;
|
||||
default: // default parsing mode
|
||||
var ch = stream.next();
|
||||
var col = stream.column();
|
||||
if (col >= 0 && col <= 5) {
|
||||
returnType = COBOLLINENUM;
|
||||
} else if (col >= 72 && col <= 79) {
|
||||
stream.skipToEnd();
|
||||
returnType = MODTAG;
|
||||
} else if (ch == "*" && col == 6) { // comment
|
||||
stream.skipToEnd(); // rest of the line is a comment
|
||||
returnType = COMMENT;
|
||||
} else if (ch == "\"" || ch == "\'") {
|
||||
state.mode = "string";
|
||||
returnType = STRING;
|
||||
} else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) {
|
||||
returnType = ATOM;
|
||||
} else if (ch == ".") {
|
||||
returnType = PERIOD;
|
||||
} else if (isNumber(ch,stream)){
|
||||
returnType = NUMBER;
|
||||
} else {
|
||||
if (stream.current().match(tests.symbol)) {
|
||||
while (col < 71) {
|
||||
if (stream.eat(tests.symbol) === undefined) {
|
||||
break;
|
||||
} else {
|
||||
col++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (keywords && keywords.propertyIsEnumerable(stream.current().toUpperCase())) {
|
||||
returnType = KEYWORD;
|
||||
} else if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase())) {
|
||||
returnType = BUILTIN;
|
||||
} else if (atoms && atoms.propertyIsEnumerable(stream.current().toUpperCase())) {
|
||||
returnType = ATOM;
|
||||
} else returnType = null;
|
||||
}
|
||||
}
|
||||
return returnType;
|
||||
},
|
||||
indent: function (state) {
|
||||
if (state.indentStack == null) return state.indentation;
|
||||
return state.indentStack.indent;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-cobol", "cobol");
|
||||
@@ -1,210 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: COBOL mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../theme/neat.css">
|
||||
<link rel="stylesheet" href="../../theme/elegant.css">
|
||||
<link rel="stylesheet" href="../../theme/erlang-dark.css">
|
||||
<link rel="stylesheet" href="../../theme/night.css">
|
||||
<link rel="stylesheet" href="../../theme/monokai.css">
|
||||
<link rel="stylesheet" href="../../theme/cobalt.css">
|
||||
<link rel="stylesheet" href="../../theme/eclipse.css">
|
||||
<link rel="stylesheet" href="../../theme/rubyblue.css">
|
||||
<link rel="stylesheet" href="../../theme/lesser-dark.css">
|
||||
<link rel="stylesheet" href="../../theme/xq-dark.css">
|
||||
<link rel="stylesheet" href="../../theme/xq-light.css">
|
||||
<link rel="stylesheet" href="../../theme/ambiance.css">
|
||||
<link rel="stylesheet" href="../../theme/blackboard.css">
|
||||
<link rel="stylesheet" href="../../theme/vibrant-ink.css">
|
||||
<link rel="stylesheet" href="../../theme/solarized.css">
|
||||
<link rel="stylesheet" href="../../theme/twilight.css">
|
||||
<link rel="stylesheet" href="../../theme/midnight.css">
|
||||
<link rel="stylesheet" href="../../addon/dialog/dialog.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="cobol.js"></script>
|
||||
<script src="../../addon/selection/active-line.js"></script>
|
||||
<script src="../../addon/search/search.js"></script>
|
||||
<script src="../../addon/dialog/dialog.js"></script>
|
||||
<script src="../../addon/search/searchcursor.js"></script>
|
||||
<style>
|
||||
.CodeMirror {
|
||||
border: 1px solid #eee;
|
||||
font-size : 20px;
|
||||
height : auto !important;
|
||||
}
|
||||
.CodeMirror-activeline-background {background: #555555 !important;}
|
||||
</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">COBOL</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>COBOL mode</h2>
|
||||
|
||||
<p> Select Theme <select onchange="selectTheme()" id="selectTheme">
|
||||
<option>default</option>
|
||||
<option>ambiance</option>
|
||||
<option>blackboard</option>
|
||||
<option>cobalt</option>
|
||||
<option>eclipse</option>
|
||||
<option>elegant</option>
|
||||
<option>erlang-dark</option>
|
||||
<option>lesser-dark</option>
|
||||
<option>midnight</option>
|
||||
<option>monokai</option>
|
||||
<option>neat</option>
|
||||
<option>night</option>
|
||||
<option>rubyblue</option>
|
||||
<option>solarized dark</option>
|
||||
<option>solarized light</option>
|
||||
<option selected>twilight</option>
|
||||
<option>vibrant-ink</option>
|
||||
<option>xq-dark</option>
|
||||
<option>xq-light</option>
|
||||
</select> Select Font Size <select onchange="selectFontsize()" id="selectFontSize">
|
||||
<option value="13px">13px</option>
|
||||
<option value="14px">14px</option>
|
||||
<option value="16px">16px</option>
|
||||
<option value="18px">18px</option>
|
||||
<option value="20px" selected="selected">20px</option>
|
||||
<option value="24px">24px</option>
|
||||
<option value="26px">26px</option>
|
||||
<option value="28px">28px</option>
|
||||
<option value="30px">30px</option>
|
||||
<option value="32px">32px</option>
|
||||
<option value="34px">34px</option>
|
||||
<option value="36px">36px</option>
|
||||
</select>
|
||||
<label for="checkBoxReadOnly">Read-only</label>
|
||||
<input type="checkbox" id="checkBoxReadOnly" onchange="selectReadOnly()">
|
||||
<label for="id_tabToIndentSpace">Insert Spaces on Tab</label>
|
||||
<input type="checkbox" id="id_tabToIndentSpace" onchange="tabToIndentSpace()">
|
||||
</p>
|
||||
<textarea id="code" name="code">
|
||||
---------1---------2---------3---------4---------5---------6---------7---------8
|
||||
12345678911234567892123456789312345678941234567895123456789612345678971234567898
|
||||
000010 IDENTIFICATION DIVISION. MODTGHERE
|
||||
000020 PROGRAM-ID. SAMPLE.
|
||||
000030 AUTHOR. TEST SAM.
|
||||
000040 DATE-WRITTEN. 5 February 2013
|
||||
000041
|
||||
000042* A sample program just to show the form.
|
||||
000043* The program copies its input to the output,
|
||||
000044* and counts the number of records.
|
||||
000045* At the end this number is printed.
|
||||
000046
|
||||
000050 ENVIRONMENT DIVISION.
|
||||
000060 INPUT-OUTPUT SECTION.
|
||||
000070 FILE-CONTROL.
|
||||
000080 SELECT STUDENT-FILE ASSIGN TO SYSIN
|
||||
000090 ORGANIZATION IS LINE SEQUENTIAL.
|
||||
000100 SELECT PRINT-FILE ASSIGN TO SYSOUT
|
||||
000110 ORGANIZATION IS LINE SEQUENTIAL.
|
||||
000120
|
||||
000130 DATA DIVISION.
|
||||
000140 FILE SECTION.
|
||||
000150 FD STUDENT-FILE
|
||||
000160 RECORD CONTAINS 43 CHARACTERS
|
||||
000170 DATA RECORD IS STUDENT-IN.
|
||||
000180 01 STUDENT-IN PIC X(43).
|
||||
000190
|
||||
000200 FD PRINT-FILE
|
||||
000210 RECORD CONTAINS 80 CHARACTERS
|
||||
000220 DATA RECORD IS PRINT-LINE.
|
||||
000230 01 PRINT-LINE PIC X(80).
|
||||
000240
|
||||
000250 WORKING-STORAGE SECTION.
|
||||
000260 01 DATA-REMAINS-SWITCH PIC X(2) VALUE SPACES.
|
||||
000261 01 RECORDS-WRITTEN PIC 99.
|
||||
000270
|
||||
000280 01 DETAIL-LINE.
|
||||
000290 05 FILLER PIC X(7) VALUE SPACES.
|
||||
000300 05 RECORD-IMAGE PIC X(43).
|
||||
000310 05 FILLER PIC X(30) VALUE SPACES.
|
||||
000311
|
||||
000312 01 SUMMARY-LINE.
|
||||
000313 05 FILLER PIC X(7) VALUE SPACES.
|
||||
000314 05 TOTAL-READ PIC 99.
|
||||
000315 05 FILLER PIC X VALUE SPACE.
|
||||
000316 05 FILLER PIC X(17)
|
||||
000317 VALUE 'Records were read'.
|
||||
000318 05 FILLER PIC X(53) VALUE SPACES.
|
||||
000319
|
||||
000320 PROCEDURE DIVISION.
|
||||
000321
|
||||
000330 PREPARE-SENIOR-REPORT.
|
||||
000340 OPEN INPUT STUDENT-FILE
|
||||
000350 OUTPUT PRINT-FILE.
|
||||
000351 MOVE ZERO TO RECORDS-WRITTEN.
|
||||
000360 READ STUDENT-FILE
|
||||
000370 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH
|
||||
000380 END-READ.
|
||||
000390 PERFORM PROCESS-RECORDS
|
||||
000410 UNTIL DATA-REMAINS-SWITCH = 'NO'.
|
||||
000411 PERFORM PRINT-SUMMARY.
|
||||
000420 CLOSE STUDENT-FILE
|
||||
000430 PRINT-FILE.
|
||||
000440 STOP RUN.
|
||||
000450
|
||||
000460 PROCESS-RECORDS.
|
||||
000470 MOVE STUDENT-IN TO RECORD-IMAGE.
|
||||
000480 MOVE DETAIL-LINE TO PRINT-LINE.
|
||||
000490 WRITE PRINT-LINE.
|
||||
000500 ADD 1 TO RECORDS-WRITTEN.
|
||||
000510 READ STUDENT-FILE
|
||||
000520 AT END MOVE 'NO' TO DATA-REMAINS-SWITCH
|
||||
000530 END-READ.
|
||||
000540
|
||||
000550 PRINT-SUMMARY.
|
||||
000560 MOVE RECORDS-WRITTEN TO TOTAL-READ.
|
||||
000570 MOVE SUMMARY-LINE TO PRINT-LINE.
|
||||
000571 WRITE PRINT-LINE.
|
||||
000572
|
||||
000580
|
||||
</textarea>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-cobol",
|
||||
theme : "twilight",
|
||||
styleActiveLine: true,
|
||||
showCursorWhenSelecting : true,
|
||||
});
|
||||
function selectTheme() {
|
||||
var themeInput = document.getElementById("selectTheme");
|
||||
var theme = themeInput.options[themeInput.selectedIndex].innerHTML;
|
||||
editor.setOption("theme", theme);
|
||||
}
|
||||
function selectFontsize() {
|
||||
var fontSizeInput = document.getElementById("selectFontSize");
|
||||
var fontSize = fontSizeInput.options[fontSizeInput.selectedIndex].innerHTML;
|
||||
editor.getWrapperElement().style["font-size"] = fontSize;
|
||||
editor.refresh();
|
||||
}
|
||||
function selectReadOnly() {
|
||||
editor.setOption("readOnly", document.getElementById("checkBoxReadOnly").checked);
|
||||
}
|
||||
function tabToIndentSpace() {
|
||||
if (document.getElementById("id_tabToIndentSpace").checked) {
|
||||
editor.setOption("extraKeys", {Tab: function(cm) { cm.replaceSelection(" ", "end"); }});
|
||||
} else {
|
||||
editor.setOption("extraKeys", {Tab: function(cm) { cm.replaceSelection(" ", "end"); }});
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</article>
|
||||
192
applications/admin/static/codemirror/mode/ecl/ecl.js
vendored
192
applications/admin/static/codemirror/mode/ecl/ecl.js
vendored
@@ -1,192 +0,0 @@
|
||||
CodeMirror.defineMode("ecl", function(config) {
|
||||
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
function metaHook(stream, state) {
|
||||
if (!state.startOfLine) return false;
|
||||
stream.skipToEnd();
|
||||
return "meta";
|
||||
}
|
||||
|
||||
var indentUnit = config.indentUnit;
|
||||
var keyword = words("abs acos allnodes ascii asin asstring atan atan2 ave case choose choosen choosesets clustersize combine correlation cos cosh count covariance cron dataset dedup define denormalize distribute distributed distribution ebcdic enth error evaluate event eventextra eventname exists exp failcode failmessage fetch fromunicode getisvalid global graph group hash hash32 hash64 hashcrc hashmd5 having if index intformat isvalid iterate join keyunicode length library limit ln local log loop map matched matchlength matchposition matchtext matchunicode max merge mergejoin min nolocal nonempty normalize parse pipe power preload process project pull random range rank ranked realformat recordof regexfind regexreplace regroup rejected rollup round roundup row rowdiff sample set sin sinh sizeof soapcall sort sorted sqrt stepped stored sum table tan tanh thisnode topn tounicode transfer trim truncate typeof ungroup unicodeorder variance which workunit xmldecode xmlencode xmltext xmlunicode");
|
||||
var variable = words("apply assert build buildindex evaluate fail keydiff keypatch loadxml nothor notify output parallel sequential soapcall wait");
|
||||
var variable_2 = words("__compressed__ all and any as atmost before beginc++ best between case const counter csv descend encrypt end endc++ endmacro except exclusive expire export extend false few first flat from full function group header heading hole ifblock import in interface joined keep keyed last left limit load local locale lookup macro many maxcount maxlength min skew module named nocase noroot noscan nosort not of only opt or outer overwrite packed partition penalty physicallength pipe quote record relationship repeat return right scan self separator service shared skew skip sql store terminator thor threshold token transform trim true type unicodeorder unsorted validate virtual whole wild within xml xpath");
|
||||
var variable_3 = words("ascii big_endian boolean data decimal ebcdic integer pattern qstring real record rule set of string token udecimal unicode unsigned varstring varunicode");
|
||||
var builtin = words("checkpoint deprecated failcode failmessage failure global independent onwarning persist priority recovery stored success wait when");
|
||||
var blockKeywords = words("catch class do else finally for if switch try while");
|
||||
var atoms = words("true false null");
|
||||
var hooks = {"#": metaHook};
|
||||
var multiLineStrings;
|
||||
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
||||
|
||||
var curPunc;
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (hooks[ch]) {
|
||||
var result = hooks[ch](stream, state);
|
||||
if (result !== false) return result;
|
||||
}
|
||||
if (ch == '"' || ch == "'") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
}
|
||||
if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
return "number";
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment;
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var cur = stream.current().toLowerCase();
|
||||
if (keyword.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "keyword";
|
||||
} else if (variable.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "variable";
|
||||
} else if (variable_2.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "variable-2";
|
||||
} else if (variable_3.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "variable-3";
|
||||
} else if (builtin.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "builtin";
|
||||
} else { //Data types are of from KEYWORD##
|
||||
var i = cur.length - 1;
|
||||
while(i >= 0 && (!isNaN(cur[i]) || cur[i] == '_'))
|
||||
--i;
|
||||
|
||||
if (i > 0) {
|
||||
var cur2 = cur.substr(0, i + 1);
|
||||
if (variable_3.propertyIsEnumerable(cur2)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur2)) curPunc = "newstatement";
|
||||
return "variable-3";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
||||
return null;
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next, end = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {end = true; break;}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end || !(escaped || multiLineStrings))
|
||||
state.tokenize = tokenBase;
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
return state.context = new Context(state.indented, col, type, null, state.context);
|
||||
}
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}")
|
||||
state.indented = state.context.indented;
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: null,
|
||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
var style = (state.tokenize || tokenBase)(stream, state);
|
||||
if (style == "comment" || style == "meta") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
||||
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "}") {
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
if (ctx.type == "}") ctx = popContext(state);
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
}
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
||||
pushContext(state, stream.column(), "statement");
|
||||
state.startOfLine = false;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
||||
var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
|
||||
if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
|
||||
var closing = firstChar == ctx.type;
|
||||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
|
||||
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
||||
else return ctx.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
electricChars: "{}"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-ecl", "ecl");
|
||||
@@ -1,52 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: ECL mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="ecl.js"></script>
|
||||
<style>.CodeMirror {border: 1px solid black;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">ECL</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>ECL mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
/*
|
||||
sample useless code to demonstrate ecl syntax highlighting
|
||||
this is a multiline comment!
|
||||
*/
|
||||
|
||||
// this is a singleline comment!
|
||||
|
||||
import ut;
|
||||
r :=
|
||||
record
|
||||
string22 s1 := '123';
|
||||
integer4 i1 := 123;
|
||||
end;
|
||||
#option('tmp', true);
|
||||
d := dataset('tmp::qb', r, thor);
|
||||
output(d);
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p>Based on CodeMirror's clike mode. For more information see <a href="http://hpccsystems.com">HPCC Systems</a> web site.</p>
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-ecl</code>.</p>
|
||||
|
||||
</article>
|
||||
330
applications/admin/static/codemirror/mode/gas/gas.js
vendored
330
applications/admin/static/codemirror/mode/gas/gas.js
vendored
@@ -1,330 +0,0 @@
|
||||
CodeMirror.defineMode("gas", function(_config, parserConfig) {
|
||||
'use strict';
|
||||
|
||||
// If an architecture is specified, its initialization function may
|
||||
// populate this array with custom parsing functions which will be
|
||||
// tried in the event that the standard functions do not find a match.
|
||||
var custom = [];
|
||||
|
||||
// The symbol used to start a line comment changes based on the target
|
||||
// architecture.
|
||||
// If no architecture is pased in "parserConfig" then only multiline
|
||||
// comments will have syntax support.
|
||||
var lineCommentStartSymbol = "";
|
||||
|
||||
// These directives are architecture independent.
|
||||
// Machine specific directives should go in their respective
|
||||
// architecture initialization function.
|
||||
// Reference:
|
||||
// http://sourceware.org/binutils/docs/as/Pseudo-Ops.html#Pseudo-Ops
|
||||
var directives = {
|
||||
".abort" : "builtin",
|
||||
".align" : "builtin",
|
||||
".altmacro" : "builtin",
|
||||
".ascii" : "builtin",
|
||||
".asciz" : "builtin",
|
||||
".balign" : "builtin",
|
||||
".balignw" : "builtin",
|
||||
".balignl" : "builtin",
|
||||
".bundle_align_mode" : "builtin",
|
||||
".bundle_lock" : "builtin",
|
||||
".bundle_unlock" : "builtin",
|
||||
".byte" : "builtin",
|
||||
".cfi_startproc" : "builtin",
|
||||
".comm" : "builtin",
|
||||
".data" : "builtin",
|
||||
".def" : "builtin",
|
||||
".desc" : "builtin",
|
||||
".dim" : "builtin",
|
||||
".double" : "builtin",
|
||||
".eject" : "builtin",
|
||||
".else" : "builtin",
|
||||
".elseif" : "builtin",
|
||||
".end" : "builtin",
|
||||
".endef" : "builtin",
|
||||
".endfunc" : "builtin",
|
||||
".endif" : "builtin",
|
||||
".equ" : "builtin",
|
||||
".equiv" : "builtin",
|
||||
".eqv" : "builtin",
|
||||
".err" : "builtin",
|
||||
".error" : "builtin",
|
||||
".exitm" : "builtin",
|
||||
".extern" : "builtin",
|
||||
".fail" : "builtin",
|
||||
".file" : "builtin",
|
||||
".fill" : "builtin",
|
||||
".float" : "builtin",
|
||||
".func" : "builtin",
|
||||
".global" : "builtin",
|
||||
".gnu_attribute" : "builtin",
|
||||
".hidden" : "builtin",
|
||||
".hword" : "builtin",
|
||||
".ident" : "builtin",
|
||||
".if" : "builtin",
|
||||
".incbin" : "builtin",
|
||||
".include" : "builtin",
|
||||
".int" : "builtin",
|
||||
".internal" : "builtin",
|
||||
".irp" : "builtin",
|
||||
".irpc" : "builtin",
|
||||
".lcomm" : "builtin",
|
||||
".lflags" : "builtin",
|
||||
".line" : "builtin",
|
||||
".linkonce" : "builtin",
|
||||
".list" : "builtin",
|
||||
".ln" : "builtin",
|
||||
".loc" : "builtin",
|
||||
".loc_mark_labels" : "builtin",
|
||||
".local" : "builtin",
|
||||
".long" : "builtin",
|
||||
".macro" : "builtin",
|
||||
".mri" : "builtin",
|
||||
".noaltmacro" : "builtin",
|
||||
".nolist" : "builtin",
|
||||
".octa" : "builtin",
|
||||
".offset" : "builtin",
|
||||
".org" : "builtin",
|
||||
".p2align" : "builtin",
|
||||
".popsection" : "builtin",
|
||||
".previous" : "builtin",
|
||||
".print" : "builtin",
|
||||
".protected" : "builtin",
|
||||
".psize" : "builtin",
|
||||
".purgem" : "builtin",
|
||||
".pushsection" : "builtin",
|
||||
".quad" : "builtin",
|
||||
".reloc" : "builtin",
|
||||
".rept" : "builtin",
|
||||
".sbttl" : "builtin",
|
||||
".scl" : "builtin",
|
||||
".section" : "builtin",
|
||||
".set" : "builtin",
|
||||
".short" : "builtin",
|
||||
".single" : "builtin",
|
||||
".size" : "builtin",
|
||||
".skip" : "builtin",
|
||||
".sleb128" : "builtin",
|
||||
".space" : "builtin",
|
||||
".stab" : "builtin",
|
||||
".string" : "builtin",
|
||||
".struct" : "builtin",
|
||||
".subsection" : "builtin",
|
||||
".symver" : "builtin",
|
||||
".tag" : "builtin",
|
||||
".text" : "builtin",
|
||||
".title" : "builtin",
|
||||
".type" : "builtin",
|
||||
".uleb128" : "builtin",
|
||||
".val" : "builtin",
|
||||
".version" : "builtin",
|
||||
".vtable_entry" : "builtin",
|
||||
".vtable_inherit" : "builtin",
|
||||
".warning" : "builtin",
|
||||
".weak" : "builtin",
|
||||
".weakref" : "builtin",
|
||||
".word" : "builtin"
|
||||
};
|
||||
|
||||
var registers = {};
|
||||
|
||||
function x86(_parserConfig) {
|
||||
lineCommentStartSymbol = "#";
|
||||
|
||||
registers.ax = "variable";
|
||||
registers.eax = "variable-2";
|
||||
registers.rax = "variable-3";
|
||||
|
||||
registers.bx = "variable";
|
||||
registers.ebx = "variable-2";
|
||||
registers.rbx = "variable-3";
|
||||
|
||||
registers.cx = "variable";
|
||||
registers.ecx = "variable-2";
|
||||
registers.rcx = "variable-3";
|
||||
|
||||
registers.dx = "variable";
|
||||
registers.edx = "variable-2";
|
||||
registers.rdx = "variable-3";
|
||||
|
||||
registers.si = "variable";
|
||||
registers.esi = "variable-2";
|
||||
registers.rsi = "variable-3";
|
||||
|
||||
registers.di = "variable";
|
||||
registers.edi = "variable-2";
|
||||
registers.rdi = "variable-3";
|
||||
|
||||
registers.sp = "variable";
|
||||
registers.esp = "variable-2";
|
||||
registers.rsp = "variable-3";
|
||||
|
||||
registers.bp = "variable";
|
||||
registers.ebp = "variable-2";
|
||||
registers.rbp = "variable-3";
|
||||
|
||||
registers.ip = "variable";
|
||||
registers.eip = "variable-2";
|
||||
registers.rip = "variable-3";
|
||||
|
||||
registers.cs = "keyword";
|
||||
registers.ds = "keyword";
|
||||
registers.ss = "keyword";
|
||||
registers.es = "keyword";
|
||||
registers.fs = "keyword";
|
||||
registers.gs = "keyword";
|
||||
}
|
||||
|
||||
function armv6(_parserConfig) {
|
||||
// Reference:
|
||||
// http://infocenter.arm.com/help/topic/com.arm.doc.qrc0001l/QRC0001_UAL.pdf
|
||||
// http://infocenter.arm.com/help/topic/com.arm.doc.ddi0301h/DDI0301H_arm1176jzfs_r0p7_trm.pdf
|
||||
lineCommentStartSymbol = "@";
|
||||
directives.syntax = "builtin";
|
||||
|
||||
registers.r0 = "variable";
|
||||
registers.r1 = "variable";
|
||||
registers.r2 = "variable";
|
||||
registers.r3 = "variable";
|
||||
registers.r4 = "variable";
|
||||
registers.r5 = "variable";
|
||||
registers.r6 = "variable";
|
||||
registers.r7 = "variable";
|
||||
registers.r8 = "variable";
|
||||
registers.r9 = "variable";
|
||||
registers.r10 = "variable";
|
||||
registers.r11 = "variable";
|
||||
registers.r12 = "variable";
|
||||
|
||||
registers.sp = "variable-2";
|
||||
registers.lr = "variable-2";
|
||||
registers.pc = "variable-2";
|
||||
registers.r13 = registers.sp;
|
||||
registers.r14 = registers.lr;
|
||||
registers.r15 = registers.pc;
|
||||
|
||||
custom.push(function(ch, stream) {
|
||||
if (ch === '#') {
|
||||
stream.eatWhile(/\w/);
|
||||
return "number";
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
var arch = parserConfig.architecture.toLowerCase();
|
||||
if (arch === "x86") {
|
||||
x86(parserConfig);
|
||||
} else if (arch === "arm" || arch === "armv6") {
|
||||
armv6(parserConfig);
|
||||
}
|
||||
|
||||
function nextUntilUnescaped(stream, end) {
|
||||
var escaped = false, next;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next === end && !escaped) {
|
||||
return false;
|
||||
}
|
||||
escaped = !escaped && next === "\\";
|
||||
}
|
||||
return escaped;
|
||||
}
|
||||
|
||||
function clikeComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch === "/" && maybeEnd) {
|
||||
state.tokenize = null;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch === "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
tokenize: null
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (state.tokenize) {
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
|
||||
if (stream.eatSpace()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var style, cur, ch = stream.next();
|
||||
|
||||
if (ch === "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = clikeComment;
|
||||
return clikeComment(stream, state);
|
||||
}
|
||||
}
|
||||
|
||||
if (ch === lineCommentStartSymbol) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
|
||||
if (ch === '"') {
|
||||
nextUntilUnescaped(stream, '"');
|
||||
return "string";
|
||||
}
|
||||
|
||||
if (ch === '.') {
|
||||
stream.eatWhile(/\w/);
|
||||
cur = stream.current().toLowerCase();
|
||||
style = directives[cur];
|
||||
return style || null;
|
||||
}
|
||||
|
||||
if (ch === '=') {
|
||||
stream.eatWhile(/\w/);
|
||||
return "tag";
|
||||
}
|
||||
|
||||
if (ch === '{') {
|
||||
return "braket";
|
||||
}
|
||||
|
||||
if (ch === '}') {
|
||||
return "braket";
|
||||
}
|
||||
|
||||
if (/\d/.test(ch)) {
|
||||
if (ch === "0" && stream.eat("x")) {
|
||||
stream.eatWhile(/[0-9a-fA-F]/);
|
||||
return "number";
|
||||
}
|
||||
stream.eatWhile(/\d/);
|
||||
return "number";
|
||||
}
|
||||
|
||||
if (/\w/.test(ch)) {
|
||||
stream.eatWhile(/\w/);
|
||||
if (stream.eat(":")) {
|
||||
return 'tag';
|
||||
}
|
||||
cur = stream.current().toLowerCase();
|
||||
style = registers[cur];
|
||||
return style || null;
|
||||
}
|
||||
|
||||
for (var i = 0; i < custom.length; i++) {
|
||||
style = custom[i](ch, stream, state);
|
||||
if (style) {
|
||||
return style;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
lineComment: lineCommentStartSymbol,
|
||||
blockCommentStart: "/*",
|
||||
blockCommentEnd: "*/"
|
||||
};
|
||||
});
|
||||
@@ -1,68 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Gas mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="gas.js"></script>
|
||||
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Gas</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Gas mode</h2>
|
||||
<form>
|
||||
<textarea id="code" name="code">
|
||||
.syntax unified
|
||||
.global main
|
||||
|
||||
/*
|
||||
* A
|
||||
* multi-line
|
||||
* comment.
|
||||
*/
|
||||
|
||||
@ A single line comment.
|
||||
|
||||
main:
|
||||
push {sp, lr}
|
||||
ldr r0, =message
|
||||
bl puts
|
||||
mov r0, #0
|
||||
pop {sp, pc}
|
||||
|
||||
message:
|
||||
.asciz "Hello world!<br />"
|
||||
</textarea>
|
||||
</form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
mode: {name: "gas", architecture: "ARMv6"},
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Handles AT&T assembler syntax (more specifically this handles
|
||||
the GNU Assembler (gas) syntax.)
|
||||
It takes a single optional configuration parameter:
|
||||
<code>architecture</code>, which can be one of <code>"ARM"</code>,
|
||||
<code>"ARMv6"</code> or <code>"x86"</code>.
|
||||
Including the parameter adds syntax for the registers and special
|
||||
directives for the supplied architecture.
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-gas</code></p>
|
||||
</article>
|
||||
@@ -1,96 +0,0 @@
|
||||
CodeMirror.defineMode("gfm", function(config) {
|
||||
var codeDepth = 0;
|
||||
function blankLine(state) {
|
||||
state.code = false;
|
||||
return null;
|
||||
}
|
||||
var gfmOverlay = {
|
||||
startState: function() {
|
||||
return {
|
||||
code: false,
|
||||
codeBlock: false,
|
||||
ateSpace: false
|
||||
};
|
||||
},
|
||||
copyState: function(s) {
|
||||
return {
|
||||
code: s.code,
|
||||
codeBlock: s.codeBlock,
|
||||
ateSpace: s.ateSpace
|
||||
};
|
||||
},
|
||||
token: function(stream, state) {
|
||||
// Hack to prevent formatting override inside code blocks (block and inline)
|
||||
if (state.codeBlock) {
|
||||
if (stream.match(/^```/)) {
|
||||
state.codeBlock = false;
|
||||
return null;
|
||||
}
|
||||
stream.skipToEnd();
|
||||
return null;
|
||||
}
|
||||
if (stream.sol()) {
|
||||
state.code = false;
|
||||
}
|
||||
if (stream.sol() && stream.match(/^```/)) {
|
||||
stream.skipToEnd();
|
||||
state.codeBlock = true;
|
||||
return null;
|
||||
}
|
||||
// If this block is changed, it may need to be updated in Markdown mode
|
||||
if (stream.peek() === '`') {
|
||||
stream.next();
|
||||
var before = stream.pos;
|
||||
stream.eatWhile('`');
|
||||
var difference = 1 + stream.pos - before;
|
||||
if (!state.code) {
|
||||
codeDepth = difference;
|
||||
state.code = true;
|
||||
} else {
|
||||
if (difference === codeDepth) { // Must be exact
|
||||
state.code = false;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
} else if (state.code) {
|
||||
stream.next();
|
||||
return null;
|
||||
}
|
||||
// Check if space. If so, links can be formatted later on
|
||||
if (stream.eatSpace()) {
|
||||
state.ateSpace = true;
|
||||
return null;
|
||||
}
|
||||
if (stream.sol() || state.ateSpace) {
|
||||
state.ateSpace = false;
|
||||
if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
|
||||
// User/Project@SHA
|
||||
// User@SHA
|
||||
// SHA
|
||||
return "link";
|
||||
} else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
|
||||
// User/Project#Num
|
||||
// User#Num
|
||||
// #Num
|
||||
return "link";
|
||||
}
|
||||
}
|
||||
if (stream.match(/^((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\([^\s()<>]*\))+(?:\([^\s()<>]*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i)) {
|
||||
// URLs
|
||||
// Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
|
||||
// And then (issue #1160) simplified to make it not crash the Chrome Regexp engine
|
||||
return "link";
|
||||
}
|
||||
stream.next();
|
||||
return null;
|
||||
},
|
||||
blankLine: blankLine
|
||||
};
|
||||
CodeMirror.defineMIME("gfmBase", {
|
||||
name: "markdown",
|
||||
underscoresBreakWords: false,
|
||||
taskLists: true,
|
||||
fencedCodeBlocks: true
|
||||
});
|
||||
return CodeMirror.overlayMode(CodeMirror.getMode(config, "gfmBase"), gfmOverlay);
|
||||
}, "markdown");
|
||||
@@ -1,82 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: GFM mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/mode/overlay.js"></script>
|
||||
<script src="../xml/xml.js"></script>
|
||||
<script src="../markdown/markdown.js"></script>
|
||||
<script src="gfm.js"></script>
|
||||
<script src="../javascript/javascript.js"></script>
|
||||
<script src="../css/css.js"></script>
|
||||
<script src="../htmlmixed/htmlmixed.js"></script>
|
||||
<script src="../clike/clike.js"></script>
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">GFM</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>GFM mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
GitHub Flavored Markdown
|
||||
========================
|
||||
|
||||
Everything from markdown plus GFM features:
|
||||
|
||||
## URL autolinking
|
||||
|
||||
Underscores_are_allowed_between_words.
|
||||
|
||||
## Fenced code blocks (and syntax highlighting)
|
||||
|
||||
```javascript
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
console.log(items[i], i); // log them
|
||||
}
|
||||
```
|
||||
|
||||
## Task Lists
|
||||
|
||||
- [ ] Incomplete task list item
|
||||
- [x] **Completed** task list item
|
||||
|
||||
## A bit of GitHub spice
|
||||
|
||||
* SHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
|
||||
* User@SHA ref: mojombo@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
|
||||
* User/Project@SHA: mojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
|
||||
* \#Num: #1
|
||||
* User/#Num: mojombo#1
|
||||
* User/Project#Num: mojombo/god#1
|
||||
|
||||
See http://github.github.com/github-flavored-markdown/.
|
||||
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
mode: 'gfm',
|
||||
lineNumbers: true,
|
||||
theme: "default"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Optionally depends on other modes for properly highlighted code blocks.</p>
|
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gfm_*">normal</a>, <a href="../../test/index.html#verbose,gfm_*">verbose</a>.</p>
|
||||
|
||||
</article>
|
||||
@@ -1,112 +0,0 @@
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({tabSize: 4}, "gfm");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT("emInWordAsterisk",
|
||||
"foo[em *bar*]hello");
|
||||
|
||||
MT("emInWordUnderscore",
|
||||
"foo_bar_hello");
|
||||
|
||||
MT("emStrongUnderscore",
|
||||
"[strong __][em&strong _foo__][em _] bar");
|
||||
|
||||
MT("fencedCodeBlocks",
|
||||
"[comment ```]",
|
||||
"[comment foo]",
|
||||
"",
|
||||
"[comment ```]",
|
||||
"bar");
|
||||
|
||||
MT("fencedCodeBlockModeSwitching",
|
||||
"[comment ```javascript]",
|
||||
"[variable foo]",
|
||||
"",
|
||||
"[comment ```]",
|
||||
"bar");
|
||||
|
||||
MT("taskListAsterisk",
|
||||
"[variable-2 * []] foo]", // Invalid; must have space or x between []
|
||||
"[variable-2 * [ ]]bar]", // Invalid; must have space after ]
|
||||
"[variable-2 * [x]]hello]", // Invalid; must have space after ]
|
||||
"[variable-2 * ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
|
||||
" [variable-3 * ][property [x]]][variable-3 foo]"); // Valid; can be nested
|
||||
|
||||
MT("taskListPlus",
|
||||
"[variable-2 + []] foo]", // Invalid; must have space or x between []
|
||||
"[variable-2 + [ ]]bar]", // Invalid; must have space after ]
|
||||
"[variable-2 + [x]]hello]", // Invalid; must have space after ]
|
||||
"[variable-2 + ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
|
||||
" [variable-3 + ][property [x]]][variable-3 foo]"); // Valid; can be nested
|
||||
|
||||
MT("taskListDash",
|
||||
"[variable-2 - []] foo]", // Invalid; must have space or x between []
|
||||
"[variable-2 - [ ]]bar]", // Invalid; must have space after ]
|
||||
"[variable-2 - [x]]hello]", // Invalid; must have space after ]
|
||||
"[variable-2 - ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
|
||||
" [variable-3 - ][property [x]]][variable-3 foo]"); // Valid; can be nested
|
||||
|
||||
MT("taskListNumber",
|
||||
"[variable-2 1. []] foo]", // Invalid; must have space or x between []
|
||||
"[variable-2 2. [ ]]bar]", // Invalid; must have space after ]
|
||||
"[variable-2 3. [x]]hello]", // Invalid; must have space after ]
|
||||
"[variable-2 4. ][meta [ ]]][variable-2 [world]]]", // Valid; tests reference style links
|
||||
" [variable-3 1. ][property [x]]][variable-3 foo]"); // Valid; can be nested
|
||||
|
||||
MT("SHA",
|
||||
"foo [link be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] bar");
|
||||
|
||||
MT("shortSHA",
|
||||
"foo [link be6a8cc] bar");
|
||||
|
||||
MT("tooShortSHA",
|
||||
"foo be6a8c bar");
|
||||
|
||||
MT("longSHA",
|
||||
"foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar");
|
||||
|
||||
MT("badSHA",
|
||||
"foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar");
|
||||
|
||||
MT("userSHA",
|
||||
"foo [link bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] hello");
|
||||
|
||||
MT("userProjectSHA",
|
||||
"foo [link bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2] world");
|
||||
|
||||
MT("num",
|
||||
"foo [link #1] bar");
|
||||
|
||||
MT("badNum",
|
||||
"foo #1bar hello");
|
||||
|
||||
MT("userNum",
|
||||
"foo [link bar#1] hello");
|
||||
|
||||
MT("userProjectNum",
|
||||
"foo [link bar/hello#1] world");
|
||||
|
||||
MT("vanillaLink",
|
||||
"foo [link http://www.example.com/] bar");
|
||||
|
||||
MT("vanillaLinkPunctuation",
|
||||
"foo [link http://www.example.com/]. bar");
|
||||
|
||||
MT("vanillaLinkExtension",
|
||||
"foo [link http://www.example.com/index.html] bar");
|
||||
|
||||
MT("notALink",
|
||||
"[comment ```css]",
|
||||
"[tag foo] {[property color][operator :][keyword black];}",
|
||||
"[comment ```][link http://www.example.com/]");
|
||||
|
||||
MT("notALink",
|
||||
"[comment ``foo `bar` http://www.example.com/``] hello");
|
||||
|
||||
MT("notALink",
|
||||
"[comment `foo]",
|
||||
"[link http://www.example.com/]",
|
||||
"[comment `foo]",
|
||||
"",
|
||||
"[link http://www.example.com/]");
|
||||
})();
|
||||
@@ -1,211 +0,0 @@
|
||||
CodeMirror.defineMode("groovy", function(config) {
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
var keywords = words(
|
||||
"abstract as assert boolean break byte case catch char class const continue def default " +
|
||||
"do double else enum extends final finally float for goto if implements import in " +
|
||||
"instanceof int interface long native new package private protected public return " +
|
||||
"short static strictfp super switch synchronized threadsafe throw throws transient " +
|
||||
"try void volatile while");
|
||||
var blockKeywords = words("catch class do else finally for if switch try while enum interface def");
|
||||
var atoms = words("null true false this");
|
||||
|
||||
var curPunc;
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == '"' || ch == "'") {
|
||||
return startString(ch, stream, state);
|
||||
}
|
||||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
}
|
||||
if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
if (stream.eat(/eE/)) { stream.eat(/\+\-/); stream.eatWhile(/\d/); }
|
||||
return "number";
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize.push(tokenComment);
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
if (expectExpression(state.lastToken)) {
|
||||
return startString(ch, stream, state);
|
||||
}
|
||||
}
|
||||
if (ch == "-" && stream.eat(">")) {
|
||||
curPunc = "->";
|
||||
return null;
|
||||
}
|
||||
if (/[+\-*&%=<>!?|\/~]/.test(ch)) {
|
||||
stream.eatWhile(/[+\-*&%=<>|~]/);
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
if (ch == "@") { stream.eatWhile(/[\w\$_\.]/); return "meta"; }
|
||||
if (state.lastToken == ".") return "property";
|
||||
if (stream.eat(":")) { curPunc = "proplabel"; return "property"; }
|
||||
var cur = stream.current();
|
||||
if (atoms.propertyIsEnumerable(cur)) { return "atom"; }
|
||||
if (keywords.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "keyword";
|
||||
}
|
||||
return "variable";
|
||||
}
|
||||
tokenBase.isBase = true;
|
||||
|
||||
function startString(quote, stream, state) {
|
||||
var tripleQuoted = false;
|
||||
if (quote != "/" && stream.eat(quote)) {
|
||||
if (stream.eat(quote)) tripleQuoted = true;
|
||||
else return "string";
|
||||
}
|
||||
function t(stream, state) {
|
||||
var escaped = false, next, end = !tripleQuoted;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {
|
||||
if (!tripleQuoted) { break; }
|
||||
if (stream.match(quote + quote)) { end = true; break; }
|
||||
}
|
||||
if (quote == '"' && next == "$" && !escaped && stream.eat("{")) {
|
||||
state.tokenize.push(tokenBaseUntilBrace());
|
||||
return "string";
|
||||
}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end) state.tokenize.pop();
|
||||
return "string";
|
||||
}
|
||||
state.tokenize.push(t);
|
||||
return t(stream, state);
|
||||
}
|
||||
|
||||
function tokenBaseUntilBrace() {
|
||||
var depth = 1;
|
||||
function t(stream, state) {
|
||||
if (stream.peek() == "}") {
|
||||
depth--;
|
||||
if (depth == 0) {
|
||||
state.tokenize.pop();
|
||||
return state.tokenize[state.tokenize.length-1](stream, state);
|
||||
}
|
||||
} else if (stream.peek() == "{") {
|
||||
depth++;
|
||||
}
|
||||
return tokenBase(stream, state);
|
||||
}
|
||||
t.isBase = true;
|
||||
return t;
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize.pop();
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function expectExpression(last) {
|
||||
return !last || last == "operator" || last == "->" || /[\.\[\{\(,;:]/.test(last) ||
|
||||
last == "newstatement" || last == "keyword" || last == "proplabel";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
return state.context = new Context(state.indented, col, type, null, state.context);
|
||||
}
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}")
|
||||
state.indented = state.context.indented;
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: [tokenBase],
|
||||
context: new Context((basecolumn || 0) - config.indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true,
|
||||
lastToken: null
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
// Automatic semicolon insertion
|
||||
if (ctx.type == "statement" && !expectExpression(state.lastToken)) {
|
||||
popContext(state); ctx = state.context;
|
||||
}
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
var style = state.tokenize[state.tokenize.length-1](stream, state);
|
||||
if (style == "comment") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
||||
// Handle indentation for {x -> \n ... }
|
||||
else if (curPunc == "->" && ctx.type == "statement" && ctx.prev.type == "}") {
|
||||
popContext(state);
|
||||
state.context.align = false;
|
||||
}
|
||||
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "}") {
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
if (ctx.type == "}") ctx = popContext(state);
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
}
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
||||
pushContext(state, stream.column(), "statement");
|
||||
state.startOfLine = false;
|
||||
state.lastToken = curPunc || style;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (!state.tokenize[state.tokenize.length-1].isBase) return 0;
|
||||
var firstChar = textAfter && textAfter.charAt(0), ctx = state.context;
|
||||
if (ctx.type == "statement" && !expectExpression(state.lastToken)) ctx = ctx.prev;
|
||||
var closing = firstChar == ctx.type;
|
||||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : config.indentUnit);
|
||||
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
||||
else return ctx.indented + (closing ? 0 : config.indentUnit);
|
||||
},
|
||||
|
||||
electricChars: "{}",
|
||||
fold: "brace"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-groovy", "groovy");
|
||||
@@ -1,84 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Groovy mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="../../addon/edit/matchbrackets.js"></script>
|
||||
<script src="groovy.js"></script>
|
||||
<style>.CodeMirror {border-top: 1px solid #500; border-bottom: 1px solid #500;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Groovy</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Groovy mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
//Pattern for groovy script
|
||||
def p = ~/.*\.groovy/
|
||||
new File( 'd:\\scripts' ).eachFileMatch(p) {f ->
|
||||
// imports list
|
||||
def imports = []
|
||||
f.eachLine {
|
||||
// condition to detect an import instruction
|
||||
ln -> if ( ln =~ '^import .*' ) {
|
||||
imports << "${ln - 'import '}"
|
||||
}
|
||||
}
|
||||
// print thmen
|
||||
if ( ! imports.empty ) {
|
||||
println f
|
||||
imports.each{ println " $it" }
|
||||
}
|
||||
}
|
||||
|
||||
/* Coin changer demo code from http://groovy.codehaus.org */
|
||||
|
||||
enum UsCoin {
|
||||
quarter(25), dime(10), nickel(5), penny(1)
|
||||
UsCoin(v) { value = v }
|
||||
final value
|
||||
}
|
||||
|
||||
enum OzzieCoin {
|
||||
fifty(50), twenty(20), ten(10), five(5)
|
||||
OzzieCoin(v) { value = v }
|
||||
final value
|
||||
}
|
||||
|
||||
def plural(word, count) {
|
||||
if (count == 1) return word
|
||||
word[-1] == 'y' ? word[0..-2] + "ies" : word + "s"
|
||||
}
|
||||
|
||||
def change(currency, amount) {
|
||||
currency.values().inject([]){ list, coin ->
|
||||
int count = amount / coin.value
|
||||
amount = amount % coin.value
|
||||
list += "$count ${plural(coin.toString(), count)}"
|
||||
}
|
||||
}
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
mode: "text/x-groovy"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-groovy</code></p>
|
||||
</article>
|
||||
@@ -1,161 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: mIRC mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link rel="stylesheet" href="../../theme/twilight.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="mirc.js"></script>
|
||||
<style>.CodeMirror {border: 1px solid black;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">mIRC</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>mIRC mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
;AKA Nick Tracker by Ford_Lawnmower irc.GeekShed.net #Script-Help
|
||||
;*****************************************************************************;
|
||||
;**Start Setup
|
||||
;Change JoinDisplay, below, for On Join AKA Display. On = 1 - Off = 0
|
||||
alias -l JoinDisplay { return 1 }
|
||||
;Change MaxNicks, below, to the number of nicknames you want to store for each hostmask. I wouldn't go over 400 with this ;/
|
||||
alias -l MaxNicks { return 20 }
|
||||
;Change AKALogo, below, To the text you want displayed before each AKA result.
|
||||
alias -l AKALogo { return 06 05A06K07A 06 }
|
||||
;**End Setup
|
||||
;*****************************************************************************;
|
||||
On *:Join:#: {
|
||||
if ($nick == $me) { .timer 1 1 ialupdateCheck $chan }
|
||||
NickNamesAdd $nick $+($network,$wildsite)
|
||||
if ($JoinDisplay) { .timerNickNames $+ $nick 1 2 NickNames.display $nick $chan $network $wildsite }
|
||||
}
|
||||
on *:Nick: { NickNamesAdd $newnick $+($network,$wildsite) $nick }
|
||||
alias -l NickNames.display {
|
||||
if ($gettok($hget(NickNames,$+($3,$4)),0,126) > 1) {
|
||||
echo -g $2 $AKALogo $+(09,$1) $AKALogo 07 $mid($replace($hget(NickNames,$+($3,$4)),$chr(126),$chr(44)),2,-1)
|
||||
}
|
||||
}
|
||||
alias -l NickNamesAdd {
|
||||
if ($hget(NickNames,$2)) {
|
||||
if (!$regex($hget(NickNames,$2),/~\Q $+ $replacecs($1,\E,\E\\E\Q) $+ \E~/i)) {
|
||||
if ($gettok($hget(NickNames,$2),0,126) <= $MaxNicks) {
|
||||
hadd NickNames $2 $+($hget(NickNames,$2),$1,~)
|
||||
}
|
||||
else {
|
||||
hadd NickNames $2 $+($mid($hget(NickNames,$2),$pos($hget(NickNames,$2),~,2)),$1,~)
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
hadd -m NickNames $2 $+(~,$1,~,$iif($3,$+($3,~)))
|
||||
}
|
||||
}
|
||||
alias -l Fix.All.MindUser {
|
||||
var %Fix.Count = $hfind(NickNames,/[^~]+[0-9]{4}~/,0,r).data
|
||||
while (%Fix.Count) {
|
||||
if ($Fix.MindUser($hget(NickNames,$hfind(NickNames,/[^~]+[0-9]{4}~/,%Fix.Count,r).data))) {
|
||||
echo -ag Record %Fix.Count - $v1 - Was Cleaned
|
||||
hadd NickNames $hfind(NickNames,/[^~]+[0-9]{4}~/,%Fix.Count,r).data $v1
|
||||
}
|
||||
dec %Fix.Count
|
||||
}
|
||||
}
|
||||
alias -l Fix.MindUser { return $regsubex($1,/[^~]+[0-9]{4}~/g,$null) }
|
||||
menu nicklist,query {
|
||||
-
|
||||
.AKA
|
||||
..Check $$1: {
|
||||
if ($gettok($hget(NickNames,$+($network,$address($1,2))),0,126) > 1) {
|
||||
NickNames.display $1 $active $network $address($1,2)
|
||||
}
|
||||
else { echo -ag $AKALogo $+(09,$1) 07has not been known by any other nicknames while I have been watching. }
|
||||
}
|
||||
..Cleanup $$1:hadd NickNames $+($network,$address($1,2)) $fix.minduser($hget(NickNames,$+($network,$address($1,2))))
|
||||
..Clear $$1:hadd NickNames $+($network,$address($1,2)) $+(~,$1,~)
|
||||
..AKA Search Dialog:dialog $iif($dialog(AKA_Search),-v,-m) AKA_Search AKA_Search
|
||||
-
|
||||
}
|
||||
menu status,channel {
|
||||
-
|
||||
.AKA
|
||||
..AKA Search Dialog:dialog $iif($dialog(AKA_Search),-v,-m) AKA_Search AKA_Search
|
||||
..Clean All Records:Fix.All.Minduser
|
||||
-
|
||||
}
|
||||
dialog AKA_Search {
|
||||
title "AKA Search Engine"
|
||||
size -1 -1 206 221
|
||||
option dbu
|
||||
edit "", 1, 8 5 149 10, autohs
|
||||
button "Search", 2, 163 4 32 12
|
||||
radio "Search HostMask", 4, 61 22 55 10
|
||||
radio "Search Nicknames", 5, 123 22 56 10
|
||||
list 6, 8 38 190 169, sort extsel vsbar
|
||||
button "Check Selected", 7, 67 206 40 12
|
||||
button "Close", 8, 160 206 38 12, cancel
|
||||
box "Search Type", 3, 11 17 183 18
|
||||
button "Copy to Clipboard", 9, 111 206 46 12
|
||||
}
|
||||
On *:Dialog:Aka_Search:init:*: { did -c $dname 5 }
|
||||
On *:Dialog:Aka_Search:Sclick:2,7,9: {
|
||||
if ($did == 2) && ($did($dname,1)) {
|
||||
did -r $dname 6
|
||||
var %search $+(*,$v1,*), %type $iif($did($dname,5).state,data,item), %matches = $hfind(NickNames,%search,0,w). [ $+ [ %type ] ]
|
||||
while (%matches) {
|
||||
did -a $dname 6 $hfind(NickNames,%search,%matches,w). [ $+ [ %type ] ]
|
||||
dec %matches
|
||||
}
|
||||
did -c $dname 6 1
|
||||
}
|
||||
elseif ($did == 7) && ($did($dname,6).seltext) { echo -ga $AKALogo 07 $mid($replace($hget(NickNames,$v1),$chr(126),$chr(44)),2,-1) }
|
||||
elseif ($did == 9) && ($did($dname,6).seltext) { clipboard $mid($v1,$pos($v1,*,1)) }
|
||||
}
|
||||
On *:Start:{
|
||||
if (!$hget(NickNames)) { hmake NickNames 10 }
|
||||
if ($isfile(NickNames.hsh)) { hload NickNames NickNames.hsh }
|
||||
}
|
||||
On *:Exit: { if ($hget(NickNames)) { hsave NickNames NickNames.hsh } }
|
||||
On *:Disconnect: { if ($hget(NickNames)) { hsave NickNames NickNames.hsh } }
|
||||
On *:Unload: { hfree NickNames }
|
||||
alias -l ialupdateCheck {
|
||||
inc -z $+(%,ialupdateCheck,$network) $calc($nick($1,0) / 4)
|
||||
;If your ial is already being updated on join .who $1 out.
|
||||
;If you are using /names to update ial you will still need this line.
|
||||
.who $1
|
||||
}
|
||||
Raw 352:*: {
|
||||
if ($($+(%,ialupdateCheck,$network),2)) haltdef
|
||||
NickNamesAdd $6 $+($network,$address($6,2))
|
||||
}
|
||||
Raw 315:*: {
|
||||
if ($($+(%,ialupdateCheck,$network),2)) haltdef
|
||||
}
|
||||
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
tabMode: "indent",
|
||||
theme: "twilight",
|
||||
lineNumbers: true,
|
||||
matchBrackets: true,
|
||||
indentUnit: 4,
|
||||
mode: "text/mirc"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/mirc</code>.</p>
|
||||
|
||||
</article>
|
||||
@@ -1,177 +0,0 @@
|
||||
//mIRC mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara
|
||||
CodeMirror.defineMIME("text/mirc", "mirc");
|
||||
CodeMirror.defineMode("mirc", function() {
|
||||
function parseWords(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
var specials = parseWords("$! $$ $& $? $+ $abook $abs $active $activecid " +
|
||||
"$activewid $address $addtok $agent $agentname $agentstat $agentver " +
|
||||
"$alias $and $anick $ansi2mirc $aop $appactive $appstate $asc $asctime " +
|
||||
"$asin $atan $avoice $away $awaymsg $awaytime $banmask $base $bfind " +
|
||||
"$binoff $biton $bnick $bvar $bytes $calc $cb $cd $ceil $chan $chanmodes " +
|
||||
"$chantypes $chat $chr $cid $clevel $click $cmdbox $cmdline $cnick $color " +
|
||||
"$com $comcall $comchan $comerr $compact $compress $comval $cos $count " +
|
||||
"$cr $crc $creq $crlf $ctime $ctimer $ctrlenter $date $day $daylight " +
|
||||
"$dbuh $dbuw $dccignore $dccport $dde $ddename $debug $decode $decompress " +
|
||||
"$deltok $devent $dialog $did $didreg $didtok $didwm $disk $dlevel $dll " +
|
||||
"$dllcall $dname $dns $duration $ebeeps $editbox $emailaddr $encode $error " +
|
||||
"$eval $event $exist $feof $ferr $fgetc $file $filename $filtered $finddir " +
|
||||
"$finddirn $findfile $findfilen $findtok $fline $floor $fopen $fread $fserve " +
|
||||
"$fulladdress $fulldate $fullname $fullscreen $get $getdir $getdot $gettok $gmt " +
|
||||
"$group $halted $hash $height $hfind $hget $highlight $hnick $hotline " +
|
||||
"$hotlinepos $ial $ialchan $ibl $idle $iel $ifmatch $ignore $iif $iil " +
|
||||
"$inelipse $ini $inmidi $inpaste $inpoly $input $inrect $inroundrect " +
|
||||
"$insong $instok $int $inwave $ip $isalias $isbit $isdde $isdir $isfile " +
|
||||
"$isid $islower $istok $isupper $keychar $keyrpt $keyval $knick $lactive " +
|
||||
"$lactivecid $lactivewid $left $len $level $lf $line $lines $link $lock " +
|
||||
"$lock $locked $log $logstamp $logstampfmt $longfn $longip $lower $ltimer " +
|
||||
"$maddress $mask $matchkey $matchtok $md5 $me $menu $menubar $menucontext " +
|
||||
"$menutype $mid $middir $mircdir $mircexe $mircini $mklogfn $mnick $mode " +
|
||||
"$modefirst $modelast $modespl $mouse $msfile $network $newnick $nick $nofile " +
|
||||
"$nopath $noqt $not $notags $notify $null $numeric $numok $oline $onpoly " +
|
||||
"$opnick $or $ord $os $passivedcc $pic $play $pnick $port $portable $portfree " +
|
||||
"$pos $prefix $prop $protect $puttok $qt $query $rand $r $rawmsg $read $readomo " +
|
||||
"$readn $regex $regml $regsub $regsubex $remove $remtok $replace $replacex " +
|
||||
"$reptok $result $rgb $right $round $scid $scon $script $scriptdir $scriptline " +
|
||||
"$sdir $send $server $serverip $sfile $sha1 $shortfn $show $signal $sin " +
|
||||
"$site $sline $snick $snicks $snotify $sock $sockbr $sockerr $sockname " +
|
||||
"$sorttok $sound $sqrt $ssl $sreq $sslready $status $strip $str $stripped " +
|
||||
"$syle $submenu $switchbar $tan $target $ticks $time $timer $timestamp " +
|
||||
"$timestampfmt $timezone $tip $titlebar $toolbar $treebar $trust $ulevel " +
|
||||
"$ulist $upper $uptime $url $usermode $v1 $v2 $var $vcmd $vcmdstat $vcmdver " +
|
||||
"$version $vnick $vol $wid $width $wildsite $wildtok $window $wrap $xor");
|
||||
var keywords = parseWords("abook ajinvite alias aline ame amsg anick aop auser autojoin avoice " +
|
||||
"away background ban bcopy beep bread break breplace bset btrunc bunset bwrite " +
|
||||
"channel clear clearall cline clipboard close cnick color comclose comopen " +
|
||||
"comreg continue copy creq ctcpreply ctcps dcc dccserver dde ddeserver " +
|
||||
"debug dec describe dialog did didtok disable disconnect dlevel dline dll " +
|
||||
"dns dqwindow drawcopy drawdot drawfill drawline drawpic drawrect drawreplace " +
|
||||
"drawrot drawsave drawscroll drawtext ebeeps echo editbox emailaddr enable " +
|
||||
"events exit fclose filter findtext finger firewall flash flist flood flush " +
|
||||
"flushini font fopen fseek fsend fserve fullname fwrite ghide gload gmove " +
|
||||
"gopts goto gplay gpoint gqreq groups gshow gsize gstop gtalk gunload hadd " +
|
||||
"halt haltdef hdec hdel help hfree hinc hload hmake hop hsave ial ialclear " +
|
||||
"ialmark identd if ignore iline inc invite iuser join kick linesep links list " +
|
||||
"load loadbuf localinfo log mdi me menubar mkdir mnick mode msg nick noop notice " +
|
||||
"notify omsg onotice part partall pdcc perform play playctrl pop protect pvoice " +
|
||||
"qme qmsg query queryn quit raw reload remini remote remove rename renwin " +
|
||||
"reseterror resetidle return rlevel rline rmdir run ruser save savebuf saveini " +
|
||||
"say scid scon server set showmirc signam sline sockaccept sockclose socklist " +
|
||||
"socklisten sockmark sockopen sockpause sockread sockrename sockudp sockwrite " +
|
||||
"sound speak splay sreq strip switchbar timer timestamp titlebar tnick tokenize " +
|
||||
"toolbar topic tray treebar ulist unload unset unsetall updatenl url uwho " +
|
||||
"var vcadd vcmd vcrem vol while whois window winhelp write writeint if isalnum " +
|
||||
"isalpha isaop isavoice isban ischan ishop isignore isin isincs isletter islower " +
|
||||
"isnotify isnum ison isop isprotect isreg isupper isvoice iswm iswmcs " +
|
||||
"elseif else goto menu nicklist status title icon size option text edit " +
|
||||
"button check radio box scroll list combo link tab item");
|
||||
var functions = parseWords("if elseif else and not or eq ne in ni for foreach while switch");
|
||||
var isOperatorChar = /[+\-*&%=<>!?^\/\|]/;
|
||||
function chain(stream, state, f) {
|
||||
state.tokenize = f;
|
||||
return f(stream, state);
|
||||
}
|
||||
function tokenBase(stream, state) {
|
||||
var beforeParams = state.beforeParams;
|
||||
state.beforeParams = false;
|
||||
var ch = stream.next();
|
||||
if (/[\[\]{}\(\),\.]/.test(ch)) {
|
||||
if (ch == "(" && beforeParams) state.inParams = true;
|
||||
else if (ch == ")") state.inParams = false;
|
||||
return null;
|
||||
}
|
||||
else if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
return "number";
|
||||
}
|
||||
else if (ch == "\\") {
|
||||
stream.eat("\\");
|
||||
stream.eat(/./);
|
||||
return "number";
|
||||
}
|
||||
else if (ch == "/" && stream.eat("*")) {
|
||||
return chain(stream, state, tokenComment);
|
||||
}
|
||||
else if (ch == ";" && stream.match(/ *\( *\(/)) {
|
||||
return chain(stream, state, tokenUnparsed);
|
||||
}
|
||||
else if (ch == ";" && !state.inParams) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
else if (ch == '"') {
|
||||
stream.eat(/"/);
|
||||
return "keyword";
|
||||
}
|
||||
else if (ch == "$") {
|
||||
stream.eatWhile(/[$_a-z0-9A-Z\.:]/);
|
||||
if (specials && specials.propertyIsEnumerable(stream.current().toLowerCase())) {
|
||||
return "keyword";
|
||||
}
|
||||
else {
|
||||
state.beforeParams = true;
|
||||
return "builtin";
|
||||
}
|
||||
}
|
||||
else if (ch == "%") {
|
||||
stream.eatWhile(/[^,^\s^\(^\)]/);
|
||||
state.beforeParams = true;
|
||||
return "string";
|
||||
}
|
||||
else if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return "operator";
|
||||
}
|
||||
else {
|
||||
stream.eatWhile(/[\w\$_{}]/);
|
||||
var word = stream.current().toLowerCase();
|
||||
if (keywords && keywords.propertyIsEnumerable(word))
|
||||
return "keyword";
|
||||
if (functions && functions.propertyIsEnumerable(word)) {
|
||||
state.beforeParams = true;
|
||||
return "keyword";
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
function tokenUnparsed(stream, state) {
|
||||
var maybeEnd = 0, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == ";" && maybeEnd == 2) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
if (ch == ")")
|
||||
maybeEnd++;
|
||||
else if (ch != " ")
|
||||
maybeEnd = 0;
|
||||
}
|
||||
return "meta";
|
||||
}
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
tokenize: tokenBase,
|
||||
beforeParams: false,
|
||||
inParams: false
|
||||
};
|
||||
},
|
||||
token: function(stream, state) {
|
||||
if (stream.eatSpace()) return null;
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
};
|
||||
});
|
||||
@@ -1,146 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: OCaml mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel=stylesheet href=../../lib/codemirror.css>
|
||||
<script src=../../lib/codemirror.js></script>
|
||||
<script src=../../addon/edit/matchbrackets.js></script>
|
||||
<script src=ocaml.js></script>
|
||||
<style type=text/css>
|
||||
.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}
|
||||
</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">OCaml</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>OCaml mode</h2>
|
||||
|
||||
|
||||
<textarea id=code>
|
||||
(* Summing a list of integers *)
|
||||
let rec sum xs =
|
||||
match xs with
|
||||
| [] -> 0
|
||||
| x :: xs' -> x + sum xs'
|
||||
|
||||
(* Quicksort *)
|
||||
let rec qsort = function
|
||||
| [] -> []
|
||||
| pivot :: rest ->
|
||||
let is_less x = x < pivot in
|
||||
let left, right = List.partition is_less rest in
|
||||
qsort left @ [pivot] @ qsort right
|
||||
|
||||
(* Fibonacci Sequence *)
|
||||
let rec fib_aux n a b =
|
||||
match n with
|
||||
| 0 -> a
|
||||
| _ -> fib_aux (n - 1) (a + b) a
|
||||
let fib n = fib_aux n 0 1
|
||||
|
||||
(* Birthday paradox *)
|
||||
let year_size = 365.
|
||||
|
||||
let rec birthday_paradox prob people =
|
||||
let prob' = (year_size -. float people) /. year_size *. prob in
|
||||
if prob' < 0.5 then
|
||||
Printf.printf "answer = %d\n" (people+1)
|
||||
else
|
||||
birthday_paradox prob' (people+1) ;;
|
||||
|
||||
birthday_paradox 1.0 1
|
||||
|
||||
(* Church numerals *)
|
||||
let zero f x = x
|
||||
let succ n f x = f (n f x)
|
||||
let one = succ zero
|
||||
let two = succ (succ zero)
|
||||
let add n1 n2 f x = n1 f (n2 f x)
|
||||
let to_string n = n (fun k -> "S" ^ k) "0"
|
||||
let _ = to_string (add (succ two) two)
|
||||
|
||||
(* Elementary functions *)
|
||||
let square x = x * x;;
|
||||
let rec fact x =
|
||||
if x <= 1 then 1 else x * fact (x - 1);;
|
||||
|
||||
(* Automatic memory management *)
|
||||
let l = 1 :: 2 :: 3 :: [];;
|
||||
[1; 2; 3];;
|
||||
5 :: l;;
|
||||
|
||||
(* Polymorphism: sorting lists *)
|
||||
let rec sort = function
|
||||
| [] -> []
|
||||
| x :: l -> insert x (sort l)
|
||||
|
||||
and insert elem = function
|
||||
| [] -> [elem]
|
||||
| x :: l ->
|
||||
if elem < x then elem :: x :: l else x :: insert elem l;;
|
||||
|
||||
(* Imperative features *)
|
||||
let add_polynom p1 p2 =
|
||||
let n1 = Array.length p1
|
||||
and n2 = Array.length p2 in
|
||||
let result = Array.create (max n1 n2) 0 in
|
||||
for i = 0 to n1 - 1 do result.(i) <- p1.(i) done;
|
||||
for i = 0 to n2 - 1 do result.(i) <- result.(i) + p2.(i) done;
|
||||
result;;
|
||||
add_polynom [| 1; 2 |] [| 1; 2; 3 |];;
|
||||
|
||||
(* We may redefine fact using a reference cell and a for loop *)
|
||||
let fact n =
|
||||
let result = ref 1 in
|
||||
for i = 2 to n do
|
||||
result := i * !result
|
||||
done;
|
||||
!result;;
|
||||
fact 5;;
|
||||
|
||||
(* Triangle (graphics) *)
|
||||
let () =
|
||||
ignore( Glut.init Sys.argv );
|
||||
Glut.initDisplayMode ~double_buffer:true ();
|
||||
ignore (Glut.createWindow ~title:"OpenGL Demo");
|
||||
let angle t = 10. *. t *. t in
|
||||
let render () =
|
||||
GlClear.clear [ `color ];
|
||||
GlMat.load_identity ();
|
||||
GlMat.rotate ~angle: (angle (Sys.time ())) ~z:1. ();
|
||||
GlDraw.begins `triangles;
|
||||
List.iter GlDraw.vertex2 [-1., -1.; 0., 1.; 1., -1.];
|
||||
GlDraw.ends ();
|
||||
Glut.swapBuffers () in
|
||||
GlMat.mode `modelview;
|
||||
Glut.displayFunc ~cb:render;
|
||||
Glut.idleFunc ~cb:(Some Glut.postRedisplay);
|
||||
Glut.mainLoop ()
|
||||
|
||||
(* A Hundred Lines of Caml - http://caml.inria.fr/about/taste.en.html *)
|
||||
(* OCaml page on Wikipedia - http://en.wikipedia.org/wiki/OCaml *)
|
||||
</textarea>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById('code'), {
|
||||
mode: 'ocaml',
|
||||
lineNumbers: true,
|
||||
matchBrackets: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-ocaml</code>.</p>
|
||||
</article>
|
||||
@@ -1,116 +0,0 @@
|
||||
CodeMirror.defineMode('ocaml', function() {
|
||||
|
||||
var words = {
|
||||
'true': 'atom',
|
||||
'false': 'atom',
|
||||
'let': 'keyword',
|
||||
'rec': 'keyword',
|
||||
'in': 'keyword',
|
||||
'of': 'keyword',
|
||||
'and': 'keyword',
|
||||
'succ': 'keyword',
|
||||
'if': 'keyword',
|
||||
'then': 'keyword',
|
||||
'else': 'keyword',
|
||||
'for': 'keyword',
|
||||
'to': 'keyword',
|
||||
'while': 'keyword',
|
||||
'do': 'keyword',
|
||||
'done': 'keyword',
|
||||
'fun': 'keyword',
|
||||
'function': 'keyword',
|
||||
'val': 'keyword',
|
||||
'type': 'keyword',
|
||||
'mutable': 'keyword',
|
||||
'match': 'keyword',
|
||||
'with': 'keyword',
|
||||
'try': 'keyword',
|
||||
'raise': 'keyword',
|
||||
'begin': 'keyword',
|
||||
'end': 'keyword',
|
||||
'open': 'builtin',
|
||||
'trace': 'builtin',
|
||||
'ignore': 'builtin',
|
||||
'exit': 'builtin',
|
||||
'print_string': 'builtin',
|
||||
'print_endline': 'builtin'
|
||||
};
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch === '"') {
|
||||
state.tokenize = tokenString;
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
if (ch === '(') {
|
||||
if (stream.eat('*')) {
|
||||
state.commentLevel++;
|
||||
state.tokenize = tokenComment;
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
}
|
||||
if (ch === '~') {
|
||||
stream.eatWhile(/\w/);
|
||||
return 'variable-2';
|
||||
}
|
||||
if (ch === '`') {
|
||||
stream.eatWhile(/\w/);
|
||||
return 'quote';
|
||||
}
|
||||
if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\d]/);
|
||||
if (stream.eat('.')) {
|
||||
stream.eatWhile(/[\d]/);
|
||||
}
|
||||
return 'number';
|
||||
}
|
||||
if ( /[+\-*&%=<>!?|]/.test(ch)) {
|
||||
return 'operator';
|
||||
}
|
||||
stream.eatWhile(/\w/);
|
||||
var cur = stream.current();
|
||||
return words[cur] || 'variable';
|
||||
}
|
||||
|
||||
function tokenString(stream, state) {
|
||||
var next, end = false, escaped = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next === '"' && !escaped) {
|
||||
end = true;
|
||||
break;
|
||||
}
|
||||
escaped = !escaped && next === '\\';
|
||||
}
|
||||
if (end && !escaped) {
|
||||
state.tokenize = tokenBase;
|
||||
}
|
||||
return 'string';
|
||||
};
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var prev, next;
|
||||
while(state.commentLevel > 0 && (next = stream.next()) != null) {
|
||||
if (prev === '(' && next === '*') state.commentLevel++;
|
||||
if (prev === '*' && next === ')') state.commentLevel--;
|
||||
prev = next;
|
||||
}
|
||||
if (state.commentLevel <= 0) {
|
||||
state.tokenize = tokenBase;
|
||||
}
|
||||
return 'comment';
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {return {tokenize: tokenBase, commentLevel: 0};},
|
||||
token: function(stream, state) {
|
||||
if (stream.eatSpace()) return null;
|
||||
return state.tokenize(stream, state);
|
||||
},
|
||||
|
||||
blockCommentStart: "(*",
|
||||
blockCommentEnd: "*)"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME('text/x-ocaml', 'ocaml');
|
||||
@@ -1,55 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Pig Latin mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="pig.js"></script>
|
||||
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Pig Latin</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Pig Latin mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
-- Apache Pig (Pig Latin Language) Demo
|
||||
/*
|
||||
This is a multiline comment.
|
||||
*/
|
||||
a = LOAD "\path\to\input" USING PigStorage('\t') AS (x:long, y:chararray, z:bytearray);
|
||||
b = GROUP a BY (x,y,3+4);
|
||||
c = FOREACH b GENERATE flatten(group) as (x,y), SUM(group.$2) as z;
|
||||
STORE c INTO "\path\to\output";
|
||||
|
||||
--
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
indentUnit: 4,
|
||||
mode: "text/x-pig"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>
|
||||
Simple mode that handles Pig Latin language.
|
||||
</p>
|
||||
|
||||
<p><strong>MIME type defined:</strong> <code>text/x-pig</code>
|
||||
(PIG code)
|
||||
</html>
|
||||
</article>
|
||||
171
applications/admin/static/codemirror/mode/pig/pig.js
vendored
171
applications/admin/static/codemirror/mode/pig/pig.js
vendored
@@ -1,171 +0,0 @@
|
||||
/*
|
||||
* Pig Latin Mode for CodeMirror 2
|
||||
* @author Prasanth Jayachandran
|
||||
* @link https://github.com/prasanthj/pig-codemirror-2
|
||||
* This implementation is adapted from PL/SQL mode in CodeMirror 2.
|
||||
*/
|
||||
CodeMirror.defineMode("pig", function(_config, parserConfig) {
|
||||
var keywords = parserConfig.keywords,
|
||||
builtins = parserConfig.builtins,
|
||||
types = parserConfig.types,
|
||||
multiLineStrings = parserConfig.multiLineStrings;
|
||||
|
||||
var isOperatorChar = /[*+\-%<>=&?:\/!|]/;
|
||||
|
||||
function chain(stream, state, f) {
|
||||
state.tokenize = f;
|
||||
return f(stream, state);
|
||||
}
|
||||
|
||||
var type;
|
||||
function ret(tp, style) {
|
||||
type = tp;
|
||||
return style;
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var isEnd = false;
|
||||
var ch;
|
||||
while(ch = stream.next()) {
|
||||
if(ch == "/" && isEnd) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
isEnd = (ch == "*");
|
||||
}
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next, end = false;
|
||||
while((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {
|
||||
end = true; break;
|
||||
}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end || !(escaped || multiLineStrings))
|
||||
state.tokenize = tokenBase;
|
||||
return ret("string", "error");
|
||||
};
|
||||
}
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
|
||||
// is a start of string?
|
||||
if (ch == '"' || ch == "'")
|
||||
return chain(stream, state, tokenString(ch));
|
||||
// is it one of the special chars
|
||||
else if(/[\[\]{}\(\),;\.]/.test(ch))
|
||||
return ret(ch);
|
||||
// is it a number?
|
||||
else if(/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\w\.]/);
|
||||
return ret("number", "number");
|
||||
}
|
||||
// multi line comment or operator
|
||||
else if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
return chain(stream, state, tokenComment);
|
||||
}
|
||||
else {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return ret("operator", "operator");
|
||||
}
|
||||
}
|
||||
// single line comment or operator
|
||||
else if (ch=="-") {
|
||||
if(stream.eat("-")){
|
||||
stream.skipToEnd();
|
||||
return ret("comment", "comment");
|
||||
}
|
||||
else {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return ret("operator", "operator");
|
||||
}
|
||||
}
|
||||
// is it an operator
|
||||
else if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return ret("operator", "operator");
|
||||
}
|
||||
else {
|
||||
// get the while word
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
// is it one of the listed keywords?
|
||||
if (keywords && keywords.propertyIsEnumerable(stream.current().toUpperCase())) {
|
||||
if (stream.eat(")") || stream.eat(".")) {
|
||||
//keywords can be used as variables like flatten(group), group.$0 etc..
|
||||
}
|
||||
else {
|
||||
return ("keyword", "keyword");
|
||||
}
|
||||
}
|
||||
// is it one of the builtin functions?
|
||||
if (builtins && builtins.propertyIsEnumerable(stream.current().toUpperCase()))
|
||||
{
|
||||
return ("keyword", "variable-2");
|
||||
}
|
||||
// is it one of the listed types?
|
||||
if (types && types.propertyIsEnumerable(stream.current().toUpperCase()))
|
||||
return ("keyword", "variable-3");
|
||||
// default is a 'variable'
|
||||
return ret("variable", "pig-word");
|
||||
}
|
||||
}
|
||||
|
||||
// Interface
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
tokenize: tokenBase,
|
||||
startOfLine: true
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if(stream.eatSpace()) return null;
|
||||
var style = state.tokenize(stream, state);
|
||||
return style;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
(function() {
|
||||
function keywords(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
// builtin funcs taken from trunk revision 1303237
|
||||
var pBuiltins = "ABS ACOS ARITY ASIN ATAN AVG BAGSIZE BINSTORAGE BLOOM BUILDBLOOM CBRT CEIL "
|
||||
+ "CONCAT COR COS COSH COUNT COUNT_STAR COV CONSTANTSIZE CUBEDIMENSIONS DIFF DISTINCT DOUBLEABS "
|
||||
+ "DOUBLEAVG DOUBLEBASE DOUBLEMAX DOUBLEMIN DOUBLEROUND DOUBLESUM EXP FLOOR FLOATABS FLOATAVG "
|
||||
+ "FLOATMAX FLOATMIN FLOATROUND FLOATSUM GENERICINVOKER INDEXOF INTABS INTAVG INTMAX INTMIN "
|
||||
+ "INTSUM INVOKEFORDOUBLE INVOKEFORFLOAT INVOKEFORINT INVOKEFORLONG INVOKEFORSTRING INVOKER "
|
||||
+ "ISEMPTY JSONLOADER JSONMETADATA JSONSTORAGE LAST_INDEX_OF LCFIRST LOG LOG10 LOWER LONGABS "
|
||||
+ "LONGAVG LONGMAX LONGMIN LONGSUM MAX MIN MAPSIZE MONITOREDUDF NONDETERMINISTIC OUTPUTSCHEMA "
|
||||
+ "PIGSTORAGE PIGSTREAMING RANDOM REGEX_EXTRACT REGEX_EXTRACT_ALL REPLACE ROUND SIN SINH SIZE "
|
||||
+ "SQRT STRSPLIT SUBSTRING SUM STRINGCONCAT STRINGMAX STRINGMIN STRINGSIZE TAN TANH TOBAG "
|
||||
+ "TOKENIZE TOMAP TOP TOTUPLE TRIM TEXTLOADER TUPLESIZE UCFIRST UPPER UTF8STORAGECONVERTER ";
|
||||
|
||||
// taken from QueryLexer.g
|
||||
var pKeywords = "VOID IMPORT RETURNS DEFINE LOAD FILTER FOREACH ORDER CUBE DISTINCT COGROUP "
|
||||
+ "JOIN CROSS UNION SPLIT INTO IF OTHERWISE ALL AS BY USING INNER OUTER ONSCHEMA PARALLEL "
|
||||
+ "PARTITION GROUP AND OR NOT GENERATE FLATTEN ASC DESC IS STREAM THROUGH STORE MAPREDUCE "
|
||||
+ "SHIP CACHE INPUT OUTPUT STDERROR STDIN STDOUT LIMIT SAMPLE LEFT RIGHT FULL EQ GT LT GTE LTE "
|
||||
+ "NEQ MATCHES TRUE FALSE ";
|
||||
|
||||
// data types
|
||||
var pTypes = "BOOLEAN INT LONG FLOAT DOUBLE CHARARRAY BYTEARRAY BAG TUPLE MAP ";
|
||||
|
||||
CodeMirror.defineMIME("text/x-pig", {
|
||||
name: "pig",
|
||||
builtins: keywords(pBuiltins),
|
||||
keywords: keywords(pKeywords),
|
||||
types: keywords(pTypes)
|
||||
});
|
||||
}());
|
||||
@@ -1,19 +0,0 @@
|
||||
Copyright (C) 2012 Thomas Schmid <schmid-thomas@gmx.net>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -1,93 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Sieve (RFC5228) mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="sieve.js"></script>
|
||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Sieve (RFC5228)</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Sieve (RFC5228) mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
#
|
||||
# Example Sieve Filter
|
||||
# Declare any optional features or extension used by the script
|
||||
#
|
||||
|
||||
require ["fileinto", "reject"];
|
||||
|
||||
#
|
||||
# Reject any large messages (note that the four leading dots get
|
||||
# "stuffed" to three)
|
||||
#
|
||||
if size :over 1M
|
||||
{
|
||||
reject text:
|
||||
Please do not send me large attachments.
|
||||
Put your file on a server and send me the URL.
|
||||
Thank you.
|
||||
.... Fred
|
||||
.
|
||||
;
|
||||
stop;
|
||||
}
|
||||
|
||||
#
|
||||
# Handle messages from known mailing lists
|
||||
# Move messages from IETF filter discussion list to filter folder
|
||||
#
|
||||
if header :is "Sender" "owner-ietf-mta-filters@imc.org"
|
||||
{
|
||||
fileinto "filter"; # move to "filter" folder
|
||||
}
|
||||
#
|
||||
# Keep all messages to or from people in my company
|
||||
#
|
||||
elsif address :domain :is ["From", "To"] "example.com"
|
||||
{
|
||||
keep; # keep in "In" folder
|
||||
}
|
||||
|
||||
#
|
||||
# Try and catch unsolicited email. If a message is not to me,
|
||||
# or it contains a subject known to be spam, file it away.
|
||||
#
|
||||
elsif anyof (not address :all :contains
|
||||
["To", "Cc", "Bcc"] "me@example.com",
|
||||
header :matches "subject"
|
||||
["*make*money*fast*", "*university*dipl*mas*"])
|
||||
{
|
||||
# If message header does not contain my address,
|
||||
# it's from a list.
|
||||
fileinto "spam"; # move to "spam" folder
|
||||
}
|
||||
else
|
||||
{
|
||||
# Move all other (non-company) mail to "personal"
|
||||
# folder.
|
||||
fileinto "personal";
|
||||
}
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>application/sieve</code>.</p>
|
||||
|
||||
</article>
|
||||
@@ -1,183 +0,0 @@
|
||||
/*
|
||||
* See LICENSE in this directory for the license under which this code
|
||||
* is released.
|
||||
*/
|
||||
|
||||
CodeMirror.defineMode("sieve", function(config) {
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
var keywords = words("if elsif else stop require");
|
||||
var atoms = words("true false not");
|
||||
var indentUnit = config.indentUnit;
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
|
||||
var ch = stream.next();
|
||||
if (ch == "/" && stream.eat("*")) {
|
||||
state.tokenize = tokenCComment;
|
||||
return tokenCComment(stream, state);
|
||||
}
|
||||
|
||||
if (ch === '#') {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
|
||||
if (ch == "\"") {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
|
||||
if (ch == "(") {
|
||||
state._indent.push("(");
|
||||
// add virtual angel wings so that editor behaves...
|
||||
// ...more sane incase of broken brackets
|
||||
state._indent.push("{");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (ch === "{") {
|
||||
state._indent.push("{");
|
||||
return null;
|
||||
}
|
||||
|
||||
if (ch == ")") {
|
||||
state._indent.pop();
|
||||
state._indent.pop();
|
||||
}
|
||||
|
||||
if (ch === "}") {
|
||||
state._indent.pop();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (ch == ",")
|
||||
return null;
|
||||
|
||||
if (ch == ";")
|
||||
return null;
|
||||
|
||||
|
||||
if (/[{}\(\),;]/.test(ch))
|
||||
return null;
|
||||
|
||||
// 1*DIGIT "K" / "M" / "G"
|
||||
if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/[\d]/);
|
||||
stream.eat(/[KkMmGg]/);
|
||||
return "number";
|
||||
}
|
||||
|
||||
// ":" (ALPHA / "_") *(ALPHA / DIGIT / "_")
|
||||
if (ch == ":") {
|
||||
stream.eatWhile(/[a-zA-Z_]/);
|
||||
stream.eatWhile(/[a-zA-Z0-9_]/);
|
||||
|
||||
return "operator";
|
||||
}
|
||||
|
||||
stream.eatWhile(/\w/);
|
||||
var cur = stream.current();
|
||||
|
||||
// "text:" *(SP / HTAB) (hash-comment / CRLF)
|
||||
// *(multiline-literal / multiline-dotstart)
|
||||
// "." CRLF
|
||||
if ((cur == "text") && stream.eat(":"))
|
||||
{
|
||||
state.tokenize = tokenMultiLineString;
|
||||
return "string";
|
||||
}
|
||||
|
||||
if (keywords.propertyIsEnumerable(cur))
|
||||
return "keyword";
|
||||
|
||||
if (atoms.propertyIsEnumerable(cur))
|
||||
return "atom";
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function tokenMultiLineString(stream, state)
|
||||
{
|
||||
state._multiLineString = true;
|
||||
// the first line is special it may contain a comment
|
||||
if (!stream.sol()) {
|
||||
stream.eatSpace();
|
||||
|
||||
if (stream.peek() == "#") {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
|
||||
stream.skipToEnd();
|
||||
return "string";
|
||||
}
|
||||
|
||||
if ((stream.next() == ".") && (stream.eol()))
|
||||
{
|
||||
state._multiLineString = false;
|
||||
state.tokenize = tokenBase;
|
||||
}
|
||||
|
||||
return "string";
|
||||
}
|
||||
|
||||
function tokenCComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (maybeEnd && ch == "/") {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == quote && !escaped)
|
||||
break;
|
||||
escaped = !escaped && ch == "\\";
|
||||
}
|
||||
if (!escaped) state.tokenize = tokenBase;
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function(base) {
|
||||
return {tokenize: tokenBase,
|
||||
baseIndent: base || 0,
|
||||
_indent: []};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.eatSpace())
|
||||
return null;
|
||||
|
||||
return (state.tokenize || tokenBase)(stream, state);;
|
||||
},
|
||||
|
||||
indent: function(state, _textAfter) {
|
||||
var length = state._indent.length;
|
||||
if (_textAfter && (_textAfter[0] == "}"))
|
||||
length--;
|
||||
|
||||
if (length <0)
|
||||
length = 0;
|
||||
|
||||
return length * indentUnit;
|
||||
},
|
||||
|
||||
electricChars: "}"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("application/sieve", "sieve");
|
||||
@@ -1,136 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Smarty mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="smarty.js"></script>
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Smarty</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Smarty mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
{extends file="parent.tpl"}
|
||||
{include file="template.tpl"}
|
||||
|
||||
{* some example Smarty content *}
|
||||
{if isset($name) && $name == 'Blog'}
|
||||
This is a {$var}.
|
||||
{$integer = 451}, {$array[] = "a"}, {$stringvar = "string"}
|
||||
{assign var='bob' value=$var.prop}
|
||||
{elseif $name == $foo}
|
||||
{function name=menu level=0}
|
||||
{foreach $data as $entry}
|
||||
{if is_array($entry)}
|
||||
- {$entry@key}
|
||||
{menu data=$entry level=$level+1}
|
||||
{else}
|
||||
{$entry}
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/function}
|
||||
{/if}</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
mode: "smarty"
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
|
||||
<h3>Smarty 2, custom delimiters</h3>
|
||||
<form><textarea id="code2" name="code2">
|
||||
{--extends file="parent.tpl"--}
|
||||
{--include file="template.tpl"--}
|
||||
|
||||
{--* some example Smarty content *--}
|
||||
{--if isset($name) && $name == 'Blog'--}
|
||||
This is a {--$var--}.
|
||||
{--$integer = 451--}, {--$array[] = "a"--}, {--$stringvar = "string"--}
|
||||
{--assign var='bob' value=$var.prop--}
|
||||
{--elseif $name == $foo--}
|
||||
{--function name=menu level=0--}
|
||||
{--foreach $data as $entry--}
|
||||
{--if is_array($entry)--}
|
||||
- {--$entry@key--}
|
||||
{--menu data=$entry level=$level+1--}
|
||||
{--else--}
|
||||
{--$entry--}
|
||||
{--/if--}
|
||||
{--/foreach--}
|
||||
{--/function--}
|
||||
{--/if--}</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code2"), {
|
||||
lineNumbers: true,
|
||||
mode: {
|
||||
name: "smarty",
|
||||
leftDelimiter: "{--",
|
||||
rightDelimiter: "--}"
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<br />
|
||||
|
||||
<h3>Smarty 3</h3>
|
||||
|
||||
<textarea id="code3" name="code3">
|
||||
Nested tags {$foo={counter one=1 two={inception}}+3} are now valid in Smarty 3.
|
||||
|
||||
<script>
|
||||
function test() {
|
||||
console.log("Smarty 3 permits single curly braces followed by whitespace to NOT slip into Smarty mode.");
|
||||
}
|
||||
</script>
|
||||
|
||||
{assign var=foo value=[1,2,3]}
|
||||
{assign var=foo value=['y'=>'yellow','b'=>'blue']}
|
||||
{assign var=foo value=[1,[9,8],3]}
|
||||
|
||||
{$foo=$bar+2} {* a comment *}
|
||||
{$foo.bar=1} {* another comment *}
|
||||
{$foo = myfunct(($x+$y)*3)}
|
||||
{$foo = strlen($bar)}
|
||||
{$foo.bar.baz=1}, {$foo[]=1}
|
||||
|
||||
Smarty "dot" syntax (note: embedded {} are used to address ambiguities):
|
||||
|
||||
{$foo.a.b.c} => $foo['a']['b']['c']
|
||||
{$foo.a.$b.c} => $foo['a'][$b]['c']
|
||||
{$foo.a.{$b+4}.c} => $foo['a'][$b+4]['c']
|
||||
{$foo.a.{$b.c}} => $foo['a'][$b['c']]
|
||||
|
||||
{$object->method1($x)->method2($y)}</textarea>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code3"), {
|
||||
lineNumbers: true,
|
||||
mode: "smarty",
|
||||
smartyVersion: 3
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
<p>A plain text/Smarty version 2 or 3 mode, which allows for custom delimiter tags.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-smarty</code></p>
|
||||
</article>
|
||||
@@ -1,205 +0,0 @@
|
||||
/**
|
||||
* Smarty 2 and 3 mode.
|
||||
*/
|
||||
CodeMirror.defineMode("smarty", function(config) {
|
||||
"use strict";
|
||||
|
||||
// our default settings; check to see if they're overridden
|
||||
var settings = {
|
||||
rightDelimiter: '}',
|
||||
leftDelimiter: '{',
|
||||
smartyVersion: 2 // for backward compatibility
|
||||
};
|
||||
if (config.hasOwnProperty("leftDelimiter")) {
|
||||
settings.leftDelimiter = config.leftDelimiter;
|
||||
}
|
||||
if (config.hasOwnProperty("rightDelimiter")) {
|
||||
settings.rightDelimiter = config.rightDelimiter;
|
||||
}
|
||||
if (config.hasOwnProperty("smartyVersion") && config.smartyVersion === 3) {
|
||||
settings.smartyVersion = 3;
|
||||
}
|
||||
|
||||
var keyFunctions = ["debug", "extends", "function", "include", "literal"];
|
||||
var last;
|
||||
var regs = {
|
||||
operatorChars: /[+\-*&%=<>!?]/,
|
||||
validIdentifier: /[a-zA-Z0-9_]/,
|
||||
stringChar: /['"]/
|
||||
};
|
||||
|
||||
var helpers = {
|
||||
cont: function(style, lastType) {
|
||||
last = lastType;
|
||||
return style;
|
||||
},
|
||||
chain: function(stream, state, parser) {
|
||||
state.tokenize = parser;
|
||||
return parser(stream, state);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// our various parsers
|
||||
var parsers = {
|
||||
|
||||
// the main tokenizer
|
||||
tokenizer: function(stream, state) {
|
||||
if (stream.match(settings.leftDelimiter, true)) {
|
||||
if (stream.eat("*")) {
|
||||
return helpers.chain(stream, state, parsers.inBlock("comment", "*" + settings.rightDelimiter));
|
||||
} else {
|
||||
// Smarty 3 allows { and } surrounded by whitespace to NOT slip into Smarty mode
|
||||
state.depth++;
|
||||
var isEol = stream.eol();
|
||||
var isFollowedByWhitespace = /\s/.test(stream.peek());
|
||||
if (settings.smartyVersion === 3 && settings.leftDelimiter === "{" && (isEol || isFollowedByWhitespace)) {
|
||||
state.depth--;
|
||||
return null;
|
||||
} else {
|
||||
state.tokenize = parsers.smarty;
|
||||
last = "startTag";
|
||||
return "tag";
|
||||
}
|
||||
}
|
||||
} else {
|
||||
stream.next();
|
||||
return null;
|
||||
}
|
||||
},
|
||||
|
||||
// parsing Smarty content
|
||||
smarty: function(stream, state) {
|
||||
if (stream.match(settings.rightDelimiter, true)) {
|
||||
if (settings.smartyVersion === 3) {
|
||||
state.depth--;
|
||||
if (state.depth <= 0) {
|
||||
state.tokenize = parsers.tokenizer;
|
||||
}
|
||||
} else {
|
||||
state.tokenize = parsers.tokenizer;
|
||||
}
|
||||
return helpers.cont("tag", null);
|
||||
}
|
||||
|
||||
if (stream.match(settings.leftDelimiter, true)) {
|
||||
state.depth++;
|
||||
return helpers.cont("tag", "startTag");
|
||||
}
|
||||
|
||||
var ch = stream.next();
|
||||
if (ch == "$") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("variable-2", "variable");
|
||||
} else if (ch == "|") {
|
||||
return helpers.cont("operator", "pipe");
|
||||
} else if (ch == ".") {
|
||||
return helpers.cont("operator", "property");
|
||||
} else if (regs.stringChar.test(ch)) {
|
||||
state.tokenize = parsers.inAttribute(ch);
|
||||
return helpers.cont("string", "string");
|
||||
} else if (regs.operatorChars.test(ch)) {
|
||||
stream.eatWhile(regs.operatorChars);
|
||||
return helpers.cont("operator", "operator");
|
||||
} else if (ch == "[" || ch == "]") {
|
||||
return helpers.cont("bracket", "bracket");
|
||||
} else if (ch == "(" || ch == ")") {
|
||||
return helpers.cont("bracket", "operator");
|
||||
} else if (/\d/.test(ch)) {
|
||||
stream.eatWhile(/\d/);
|
||||
return helpers.cont("number", "number");
|
||||
} else {
|
||||
|
||||
if (state.last == "variable") {
|
||||
if (ch == "@") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("property", "property");
|
||||
} else if (ch == "|") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("qualifier", "modifier");
|
||||
}
|
||||
} else if (state.last == "pipe") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("qualifier", "modifier");
|
||||
} else if (state.last == "whitespace") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("attribute", "modifier");
|
||||
} if (state.last == "property") {
|
||||
stream.eatWhile(regs.validIdentifier);
|
||||
return helpers.cont("property", null);
|
||||
} else if (/\s/.test(ch)) {
|
||||
last = "whitespace";
|
||||
return null;
|
||||
}
|
||||
|
||||
var str = "";
|
||||
if (ch != "/") {
|
||||
str += ch;
|
||||
}
|
||||
var c = null;
|
||||
while (c = stream.eat(regs.validIdentifier)) {
|
||||
str += c;
|
||||
}
|
||||
for (var i=0, j=keyFunctions.length; i<j; i++) {
|
||||
if (keyFunctions[i] == str) {
|
||||
return helpers.cont("keyword", "keyword");
|
||||
}
|
||||
}
|
||||
if (/\s/.test(ch)) {
|
||||
return null;
|
||||
}
|
||||
return helpers.cont("tag", "tag");
|
||||
}
|
||||
},
|
||||
|
||||
inAttribute: function(quote) {
|
||||
return function(stream, state) {
|
||||
var prevChar = null;
|
||||
var currChar = null;
|
||||
while (!stream.eol()) {
|
||||
currChar = stream.peek();
|
||||
if (stream.next() == quote && prevChar !== '\\') {
|
||||
state.tokenize = parsers.smarty;
|
||||
break;
|
||||
}
|
||||
prevChar = currChar;
|
||||
}
|
||||
return "string";
|
||||
};
|
||||
},
|
||||
|
||||
inBlock: function(style, terminator) {
|
||||
return function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.match(terminator)) {
|
||||
state.tokenize = parsers.tokenizer;
|
||||
break;
|
||||
}
|
||||
stream.next();
|
||||
}
|
||||
return style;
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// the public API for CodeMirror
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
tokenize: parsers.tokenizer,
|
||||
mode: "smarty",
|
||||
last: null,
|
||||
depth: 0
|
||||
};
|
||||
},
|
||||
token: function(stream, state) {
|
||||
var style = state.tokenize(stream, state);
|
||||
state.last = last;
|
||||
return style;
|
||||
},
|
||||
electricChars: ""
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-smarty", "smarty");
|
||||
@@ -1,110 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: sTeX mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="stex.js"></script>
|
||||
<style>.CodeMirror {background: #f8f8f8;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">sTeX</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>sTeX mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
\begin{module}[id=bbt-size]
|
||||
\importmodule[balanced-binary-trees]{balanced-binary-trees}
|
||||
\importmodule[\KWARCslides{dmath/en/cardinality}]{cardinality}
|
||||
|
||||
\begin{frame}
|
||||
\frametitle{Size Lemma for Balanced Trees}
|
||||
\begin{itemize}
|
||||
\item
|
||||
\begin{assertion}[id=size-lemma,type=lemma]
|
||||
Let $G=\tup{V,E}$ be a \termref[cd=binary-trees]{balanced binary tree}
|
||||
of \termref[cd=graph-depth,name=vertex-depth]{depth}$n>i$, then the set
|
||||
$\defeq{\livar{V}i}{\setst{\inset{v}{V}}{\gdepth{v} = i}}$ of
|
||||
\termref[cd=graphs-intro,name=node]{nodes} at
|
||||
\termref[cd=graph-depth,name=vertex-depth]{depth} $i$ has
|
||||
\termref[cd=cardinality,name=cardinality]{cardinality} $\power2i$.
|
||||
\end{assertion}
|
||||
\item
|
||||
\begin{sproof}[id=size-lemma-pf,proofend=,for=size-lemma]{via induction over the depth $i$.}
|
||||
\begin{spfcases}{We have to consider two cases}
|
||||
\begin{spfcase}{$i=0$}
|
||||
\begin{spfstep}[display=flow]
|
||||
then $\livar{V}i=\set{\livar{v}r}$, where $\livar{v}r$ is the root, so
|
||||
$\eq{\card{\livar{V}0},\card{\set{\livar{v}r}},1,\power20}$.
|
||||
\end{spfstep}
|
||||
\end{spfcase}
|
||||
\begin{spfcase}{$i>0$}
|
||||
\begin{spfstep}[display=flow]
|
||||
then $\livar{V}{i-1}$ contains $\power2{i-1}$ vertexes
|
||||
\begin{justification}[method=byIH](IH)\end{justification}
|
||||
\end{spfstep}
|
||||
\begin{spfstep}
|
||||
By the \begin{justification}[method=byDef]definition of a binary
|
||||
tree\end{justification}, each $\inset{v}{\livar{V}{i-1}}$ is a leaf or has
|
||||
two children that are at depth $i$.
|
||||
\end{spfstep}
|
||||
\begin{spfstep}
|
||||
As $G$ is \termref[cd=balanced-binary-trees,name=balanced-binary-tree]{balanced} and $\gdepth{G}=n>i$, $\livar{V}{i-1}$ cannot contain
|
||||
leaves.
|
||||
\end{spfstep}
|
||||
\begin{spfstep}[type=conclusion]
|
||||
Thus $\eq{\card{\livar{V}i},{\atimes[cdot]{2,\card{\livar{V}{i-1}}}},{\atimes[cdot]{2,\power2{i-1}}},\power2i}$.
|
||||
\end{spfstep}
|
||||
\end{spfcase}
|
||||
\end{spfcases}
|
||||
\end{sproof}
|
||||
\item
|
||||
\begin{assertion}[id=fbbt,type=corollary]
|
||||
A fully balanced tree of depth $d$ has $\power2{d+1}-1$ nodes.
|
||||
\end{assertion}
|
||||
\item
|
||||
\begin{sproof}[for=fbbt,id=fbbt-pf]{}
|
||||
\begin{spfstep}
|
||||
Let $\defeq{G}{\tup{V,E}}$ be a fully balanced tree
|
||||
\end{spfstep}
|
||||
\begin{spfstep}
|
||||
Then $\card{V}=\Sumfromto{i}1d{\power2i}= \power2{d+1}-1$.
|
||||
\end{spfstep}
|
||||
\end{sproof}
|
||||
\end{itemize}
|
||||
\end{frame}
|
||||
\begin{note}
|
||||
\begin{omtext}[type=conclusion,for=binary-tree]
|
||||
This shows that balanced binary trees grow in breadth very quickly, a consequence of
|
||||
this is that they are very shallow (and this compute very fast), which is the essence of
|
||||
the next result.
|
||||
\end{omtext}
|
||||
\end{note}
|
||||
\end{module}
|
||||
|
||||
%%% Local Variables:
|
||||
%%% mode: LaTeX
|
||||
%%% TeX-master: "all"
|
||||
%%% End: \end{document}
|
||||
</textarea></form>
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-stex</code>.</p>
|
||||
|
||||
<p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#stex_*">normal</a>, <a href="../../test/index.html#verbose,stex_*">verbose</a>.</p>
|
||||
|
||||
</article>
|
||||
@@ -1,246 +0,0 @@
|
||||
/*
|
||||
* Author: Constantin Jucovschi (c.jucovschi@jacobs-university.de)
|
||||
* Licence: MIT
|
||||
*/
|
||||
|
||||
CodeMirror.defineMode("stex", function() {
|
||||
"use strict";
|
||||
|
||||
function pushCommand(state, command) {
|
||||
state.cmdState.push(command);
|
||||
}
|
||||
|
||||
function peekCommand(state) {
|
||||
if (state.cmdState.length > 0) {
|
||||
return state.cmdState[state.cmdState.length - 1];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function popCommand(state) {
|
||||
var plug = state.cmdState.pop();
|
||||
if (plug) {
|
||||
plug.closeBracket();
|
||||
}
|
||||
}
|
||||
|
||||
// returns the non-default plugin closest to the end of the list
|
||||
function getMostPowerful(state) {
|
||||
var context = state.cmdState;
|
||||
for (var i = context.length - 1; i >= 0; i--) {
|
||||
var plug = context[i];
|
||||
if (plug.name == "DEFAULT") {
|
||||
continue;
|
||||
}
|
||||
return plug;
|
||||
}
|
||||
return { styleIdentifier: function() { return null; } };
|
||||
}
|
||||
|
||||
function addPluginPattern(pluginName, cmdStyle, styles) {
|
||||
return function () {
|
||||
this.name = pluginName;
|
||||
this.bracketNo = 0;
|
||||
this.style = cmdStyle;
|
||||
this.styles = styles;
|
||||
this.argument = null; // \begin and \end have arguments that follow. These are stored in the plugin
|
||||
|
||||
this.styleIdentifier = function() {
|
||||
return this.styles[this.bracketNo - 1] || null;
|
||||
};
|
||||
this.openBracket = function() {
|
||||
this.bracketNo++;
|
||||
return "bracket";
|
||||
};
|
||||
this.closeBracket = function() {};
|
||||
};
|
||||
}
|
||||
|
||||
var plugins = {};
|
||||
|
||||
plugins["importmodule"] = addPluginPattern("importmodule", "tag", ["string", "builtin"]);
|
||||
plugins["documentclass"] = addPluginPattern("documentclass", "tag", ["", "atom"]);
|
||||
plugins["usepackage"] = addPluginPattern("usepackage", "tag", ["atom"]);
|
||||
plugins["begin"] = addPluginPattern("begin", "tag", ["atom"]);
|
||||
plugins["end"] = addPluginPattern("end", "tag", ["atom"]);
|
||||
|
||||
plugins["DEFAULT"] = function () {
|
||||
this.name = "DEFAULT";
|
||||
this.style = "tag";
|
||||
|
||||
this.styleIdentifier = this.openBracket = this.closeBracket = function() {};
|
||||
};
|
||||
|
||||
function setState(state, f) {
|
||||
state.f = f;
|
||||
}
|
||||
|
||||
// called when in a normal (no environment) context
|
||||
function normal(source, state) {
|
||||
var plug;
|
||||
// Do we look like '\command' ? If so, attempt to apply the plugin 'command'
|
||||
if (source.match(/^\\[a-zA-Z@]+/)) {
|
||||
var cmdName = source.current().slice(1);
|
||||
plug = plugins[cmdName] || plugins["DEFAULT"];
|
||||
plug = new plug();
|
||||
pushCommand(state, plug);
|
||||
setState(state, beginParams);
|
||||
return plug.style;
|
||||
}
|
||||
|
||||
// escape characters
|
||||
if (source.match(/^\\[$&%#{}_]/)) {
|
||||
return "tag";
|
||||
}
|
||||
|
||||
// white space control characters
|
||||
if (source.match(/^\\[,;!\/\\]/)) {
|
||||
return "tag";
|
||||
}
|
||||
|
||||
// find if we're starting various math modes
|
||||
if (source.match("\\[")) {
|
||||
setState(state, function(source, state){ return inMathMode(source, state, "\\]"); });
|
||||
return "keyword";
|
||||
}
|
||||
if (source.match("$$")) {
|
||||
setState(state, function(source, state){ return inMathMode(source, state, "$$"); });
|
||||
return "keyword";
|
||||
}
|
||||
if (source.match("$")) {
|
||||
setState(state, function(source, state){ return inMathMode(source, state, "$"); });
|
||||
return "keyword";
|
||||
}
|
||||
|
||||
var ch = source.next();
|
||||
if (ch == "%") {
|
||||
// special case: % at end of its own line; stay in same state
|
||||
if (!source.eol()) {
|
||||
setState(state, inCComment);
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
else if (ch == '}' || ch == ']') {
|
||||
plug = peekCommand(state);
|
||||
if (plug) {
|
||||
plug.closeBracket(ch);
|
||||
setState(state, beginParams);
|
||||
} else {
|
||||
return "error";
|
||||
}
|
||||
return "bracket";
|
||||
} else if (ch == '{' || ch == '[') {
|
||||
plug = plugins["DEFAULT"];
|
||||
plug = new plug();
|
||||
pushCommand(state, plug);
|
||||
return "bracket";
|
||||
}
|
||||
else if (/\d/.test(ch)) {
|
||||
source.eatWhile(/[\w.%]/);
|
||||
return "atom";
|
||||
}
|
||||
else {
|
||||
source.eatWhile(/[\w\-_]/);
|
||||
plug = getMostPowerful(state);
|
||||
if (plug.name == 'begin') {
|
||||
plug.argument = source.current();
|
||||
}
|
||||
return plug.styleIdentifier();
|
||||
}
|
||||
}
|
||||
|
||||
function inCComment(source, state) {
|
||||
source.skipToEnd();
|
||||
setState(state, normal);
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function inMathMode(source, state, endModeSeq) {
|
||||
if (source.eatSpace()) {
|
||||
return null;
|
||||
}
|
||||
if (source.match(endModeSeq)) {
|
||||
setState(state, normal);
|
||||
return "keyword";
|
||||
}
|
||||
if (source.match(/^\\[a-zA-Z@]+/)) {
|
||||
return "tag";
|
||||
}
|
||||
if (source.match(/^[a-zA-Z]+/)) {
|
||||
return "variable-2";
|
||||
}
|
||||
// escape characters
|
||||
if (source.match(/^\\[$&%#{}_]/)) {
|
||||
return "tag";
|
||||
}
|
||||
// white space control characters
|
||||
if (source.match(/^\\[,;!\/]/)) {
|
||||
return "tag";
|
||||
}
|
||||
// special math-mode characters
|
||||
if (source.match(/^[\^_&]/)) {
|
||||
return "tag";
|
||||
}
|
||||
// non-special characters
|
||||
if (source.match(/^[+\-<>|=,\/@!*:;'"`~#?]/)) {
|
||||
return null;
|
||||
}
|
||||
if (source.match(/^(\d+\.\d*|\d*\.\d+|\d+)/)) {
|
||||
return "number";
|
||||
}
|
||||
var ch = source.next();
|
||||
if (ch == "{" || ch == "}" || ch == "[" || ch == "]" || ch == "(" || ch == ")") {
|
||||
return "bracket";
|
||||
}
|
||||
|
||||
// eat comments here, because inCComment returns us to normal state!
|
||||
if (ch == "%") {
|
||||
if (!source.eol()) {
|
||||
source.skipToEnd();
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
return "error";
|
||||
}
|
||||
|
||||
function beginParams(source, state) {
|
||||
var ch = source.peek(), lastPlug;
|
||||
if (ch == '{' || ch == '[') {
|
||||
lastPlug = peekCommand(state);
|
||||
lastPlug.openBracket(ch);
|
||||
source.eat(ch);
|
||||
setState(state, normal);
|
||||
return "bracket";
|
||||
}
|
||||
if (/[ \t\r]/.test(ch)) {
|
||||
source.eat(ch);
|
||||
return null;
|
||||
}
|
||||
setState(state, normal);
|
||||
popCommand(state);
|
||||
|
||||
return normal(source, state);
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {
|
||||
cmdState: [],
|
||||
f: normal
|
||||
};
|
||||
},
|
||||
copyState: function(s) {
|
||||
return {
|
||||
cmdState: s.cmdState.slice(),
|
||||
f: s.f
|
||||
};
|
||||
},
|
||||
token: function(stream, state) {
|
||||
return state.f(stream, state);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-stex", "stex");
|
||||
CodeMirror.defineMIME("text/x-latex", "stex");
|
||||
@@ -1,120 +0,0 @@
|
||||
(function() {
|
||||
var mode = CodeMirror.getMode({tabSize: 4}, "stex");
|
||||
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
|
||||
|
||||
MT("word",
|
||||
"foo");
|
||||
|
||||
MT("twoWords",
|
||||
"foo bar");
|
||||
|
||||
MT("beginEndDocument",
|
||||
"[tag \\begin][bracket {][atom document][bracket }]",
|
||||
"[tag \\end][bracket {][atom document][bracket }]");
|
||||
|
||||
MT("beginEndEquation",
|
||||
"[tag \\begin][bracket {][atom equation][bracket }]",
|
||||
" E=mc^2",
|
||||
"[tag \\end][bracket {][atom equation][bracket }]");
|
||||
|
||||
MT("beginModule",
|
||||
"[tag \\begin][bracket {][atom module][bracket }[[]]]");
|
||||
|
||||
MT("beginModuleId",
|
||||
"[tag \\begin][bracket {][atom module][bracket }[[]id=bbt-size[bracket ]]]");
|
||||
|
||||
MT("importModule",
|
||||
"[tag \\importmodule][bracket [[][string b-b-t][bracket ]]{][builtin b-b-t][bracket }]");
|
||||
|
||||
MT("importModulePath",
|
||||
"[tag \\importmodule][bracket [[][tag \\KWARCslides][bracket {][string dmath/en/cardinality][bracket }]]{][builtin card][bracket }]");
|
||||
|
||||
MT("psForPDF",
|
||||
"[tag \\PSforPDF][bracket [[][atom 1][bracket ]]{]#1[bracket }]");
|
||||
|
||||
MT("comment",
|
||||
"[comment % foo]");
|
||||
|
||||
MT("tagComment",
|
||||
"[tag \\item][comment % bar]");
|
||||
|
||||
MT("commentTag",
|
||||
" [comment % \\item]");
|
||||
|
||||
MT("commentLineBreak",
|
||||
"[comment %]",
|
||||
"foo");
|
||||
|
||||
MT("tagErrorCurly",
|
||||
"[tag \\begin][error }][bracket {]");
|
||||
|
||||
MT("tagErrorSquare",
|
||||
"[tag \\item][error ]]][bracket {]");
|
||||
|
||||
MT("commentCurly",
|
||||
"[comment % }]");
|
||||
|
||||
MT("tagHash",
|
||||
"the [tag \\#] key");
|
||||
|
||||
MT("tagNumber",
|
||||
"a [tag \\$][atom 5] stetson");
|
||||
|
||||
MT("tagPercent",
|
||||
"[atom 100][tag \\%] beef");
|
||||
|
||||
MT("tagAmpersand",
|
||||
"L [tag \\&] N");
|
||||
|
||||
MT("tagUnderscore",
|
||||
"foo[tag \\_]bar");
|
||||
|
||||
MT("tagBracketOpen",
|
||||
"[tag \\emph][bracket {][tag \\{][bracket }]");
|
||||
|
||||
MT("tagBracketClose",
|
||||
"[tag \\emph][bracket {][tag \\}][bracket }]");
|
||||
|
||||
MT("tagLetterNumber",
|
||||
"section [tag \\S][atom 1]");
|
||||
|
||||
MT("textTagNumber",
|
||||
"para [tag \\P][atom 2]");
|
||||
|
||||
MT("thinspace",
|
||||
"x[tag \\,]y");
|
||||
|
||||
MT("thickspace",
|
||||
"x[tag \\;]y");
|
||||
|
||||
MT("negativeThinspace",
|
||||
"x[tag \\!]y");
|
||||
|
||||
MT("periodNotSentence",
|
||||
"J.\\ L.\\ is");
|
||||
|
||||
MT("periodSentence",
|
||||
"X[tag \\@]. The");
|
||||
|
||||
MT("italicCorrection",
|
||||
"[bracket {][tag \\em] If[tag \\/][bracket }] I");
|
||||
|
||||
MT("tagBracket",
|
||||
"[tag \\newcommand][bracket {][tag \\pop][bracket }]");
|
||||
|
||||
MT("inlineMathTagFollowedByNumber",
|
||||
"[keyword $][tag \\pi][number 2][keyword $]");
|
||||
|
||||
MT("inlineMath",
|
||||
"[keyword $][number 3][variable-2 x][tag ^][number 2.45]-[tag \\sqrt][bracket {][tag \\$\\alpha][bracket }] = [number 2][keyword $] other text");
|
||||
|
||||
MT("displayMath",
|
||||
"More [keyword $$]\t[variable-2 S][tag ^][variable-2 n][tag \\sum] [variable-2 i][keyword $$] other text");
|
||||
|
||||
MT("mathWithComment",
|
||||
"[keyword $][variable-2 x] [comment % $]",
|
||||
"[variable-2 y][keyword $] other text");
|
||||
|
||||
MT("lineBreakArgument",
|
||||
"[tag \\\\][bracket [[][atom 1cm][bracket ]]]");
|
||||
})();
|
||||
@@ -1,21 +0,0 @@
|
||||
The MIT License
|
||||
|
||||
Copyright (c) 2012 Codility Limited, 107 Cheapside, London EC2V 6DN, UK
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
@@ -1,103 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: VB.NET mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<link href="http://fonts.googleapis.com/css?family=Inconsolata" rel="stylesheet" type="text/css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="vb.js"></script>
|
||||
<script type="text/javascript" src="../../addon/runmode/runmode.js"></script>
|
||||
<style>
|
||||
.CodeMirror {border: 1px solid #aaa; height:210px; height: auto;}
|
||||
.CodeMirror-scroll { overflow-x: auto; overflow-y: hidden;}
|
||||
.CodeMirror pre { font-family: Inconsolata; font-size: 14px}
|
||||
</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">VB.NET</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>VB.NET mode</h2>
|
||||
|
||||
<script type="text/javascript">
|
||||
function test(golden, text) {
|
||||
var ok = true;
|
||||
var i = 0;
|
||||
function callback(token, style, lineNo, pos){
|
||||
//console.log(String(token) + " " + String(style) + " " + String(lineNo) + " " + String(pos));
|
||||
var result = [String(token), String(style)];
|
||||
if (golden[i][0] != result[0] || golden[i][1] != result[1]){
|
||||
return "Error, expected: " + String(golden[i]) + ", got: " + String(result);
|
||||
ok = false;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
CodeMirror.runMode(text, "text/x-vb",callback);
|
||||
|
||||
if (ok) return "Tests OK";
|
||||
}
|
||||
function testTypes() {
|
||||
var golden = [['Integer','keyword'],[' ','null'],['Float','keyword']]
|
||||
var text = "Integer Float";
|
||||
return test(golden,text);
|
||||
}
|
||||
function testIf(){
|
||||
var golden = [['If','keyword'],[' ','null'],['True','keyword'],[' ','null'],['End','keyword'],[' ','null'],['If','keyword']];
|
||||
var text = 'If True End If';
|
||||
return test(golden, text);
|
||||
}
|
||||
function testDecl(){
|
||||
var golden = [['Dim','keyword'],[' ','null'],['x','variable'],[' ','null'],['as','keyword'],[' ','null'],['Integer','keyword']];
|
||||
var text = 'Dim x as Integer';
|
||||
return test(golden, text);
|
||||
}
|
||||
function testAll(){
|
||||
var result = "";
|
||||
|
||||
result += testTypes() + "\n";
|
||||
result += testIf() + "\n";
|
||||
result += testDecl() + "\n";
|
||||
return result;
|
||||
|
||||
}
|
||||
function initText(editor) {
|
||||
var content = 'Class rocket\nPrivate quality as Double\nPublic Sub launch() as String\nif quality > 0.8\nlaunch = "Successful"\nElse\nlaunch = "Failed"\nEnd If\nEnd sub\nEnd class\n';
|
||||
editor.setValue(content);
|
||||
for (var i =0; i< editor.lineCount(); i++) editor.indentLine(i);
|
||||
}
|
||||
function init() {
|
||||
editor = CodeMirror.fromTextArea(document.getElementById("solution"), {
|
||||
lineNumbers: true,
|
||||
mode: "text/x-vb",
|
||||
readOnly: false,
|
||||
tabMode: "shift"
|
||||
});
|
||||
runTest();
|
||||
}
|
||||
function runTest() {
|
||||
document.getElementById('testresult').innerHTML = testAll();
|
||||
initText(editor);
|
||||
|
||||
}
|
||||
document.body.onload = init;
|
||||
</script>
|
||||
|
||||
<div id="edit">
|
||||
<textarea style="width:95%;height:200px;padding:5px;" name="solution" id="solution" ></textarea>
|
||||
</div>
|
||||
<pre id="testresult"></pre>
|
||||
<p>MIME type defined: <code>text/x-vb</code>.</p>
|
||||
|
||||
</article>
|
||||
259
applications/admin/static/codemirror/mode/vb/vb.js
vendored
259
applications/admin/static/codemirror/mode/vb/vb.js
vendored
@@ -1,259 +0,0 @@
|
||||
CodeMirror.defineMode("vb", function(conf, parserConf) {
|
||||
var ERRORCLASS = 'error';
|
||||
|
||||
function wordRegexp(words) {
|
||||
return new RegExp("^((" + words.join(")|(") + "))\\b", "i");
|
||||
}
|
||||
|
||||
var singleOperators = new RegExp("^[\\+\\-\\*/%&\\\\|\\^~<>!]");
|
||||
var singleDelimiters = new RegExp('^[\\(\\)\\[\\]\\{\\}@,:`=;\\.]');
|
||||
var doubleOperators = new RegExp("^((==)|(<>)|(<=)|(>=)|(<>)|(<<)|(>>)|(//)|(\\*\\*))");
|
||||
var doubleDelimiters = new RegExp("^((\\+=)|(\\-=)|(\\*=)|(%=)|(/=)|(&=)|(\\|=)|(\\^=))");
|
||||
var tripleDelimiters = new RegExp("^((//=)|(>>=)|(<<=)|(\\*\\*=))");
|
||||
var identifiers = new RegExp("^[_A-Za-z][_A-Za-z0-9]*");
|
||||
|
||||
var openingKeywords = ['class','module', 'sub','enum','select','while','if','function', 'get','set','property', 'try'];
|
||||
var middleKeywords = ['else','elseif','case', 'catch'];
|
||||
var endKeywords = ['next','loop'];
|
||||
|
||||
var wordOperators = wordRegexp(['and', 'or', 'not', 'xor', 'in']);
|
||||
var commonkeywords = ['as', 'dim', 'break', 'continue','optional', 'then', 'until',
|
||||
'goto', 'byval','byref','new','handles','property', 'return',
|
||||
'const','private', 'protected', 'friend', 'public', 'shared', 'static', 'true','false'];
|
||||
var commontypes = ['integer','string','double','decimal','boolean','short','char', 'float','single'];
|
||||
|
||||
var keywords = wordRegexp(commonkeywords);
|
||||
var types = wordRegexp(commontypes);
|
||||
var stringPrefixes = '"';
|
||||
|
||||
var opening = wordRegexp(openingKeywords);
|
||||
var middle = wordRegexp(middleKeywords);
|
||||
var closing = wordRegexp(endKeywords);
|
||||
var doubleClosing = wordRegexp(['end']);
|
||||
var doOpening = wordRegexp(['do']);
|
||||
|
||||
var indentInfo = null;
|
||||
|
||||
|
||||
|
||||
|
||||
function indent(_stream, state) {
|
||||
state.currentIndent++;
|
||||
}
|
||||
|
||||
function dedent(_stream, state) {
|
||||
state.currentIndent--;
|
||||
}
|
||||
// tokenizers
|
||||
function tokenBase(stream, state) {
|
||||
if (stream.eatSpace()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
var ch = stream.peek();
|
||||
|
||||
// Handle Comments
|
||||
if (ch === "'") {
|
||||
stream.skipToEnd();
|
||||
return 'comment';
|
||||
}
|
||||
|
||||
|
||||
// Handle Number Literals
|
||||
if (stream.match(/^((&H)|(&O))?[0-9\.a-f]/i, false)) {
|
||||
var floatLiteral = false;
|
||||
// Floats
|
||||
if (stream.match(/^\d*\.\d+F?/i)) { floatLiteral = true; }
|
||||
else if (stream.match(/^\d+\.\d*F?/)) { floatLiteral = true; }
|
||||
else if (stream.match(/^\.\d+F?/)) { floatLiteral = true; }
|
||||
|
||||
if (floatLiteral) {
|
||||
// Float literals may be "imaginary"
|
||||
stream.eat(/J/i);
|
||||
return 'number';
|
||||
}
|
||||
// Integers
|
||||
var intLiteral = false;
|
||||
// Hex
|
||||
if (stream.match(/^&H[0-9a-f]+/i)) { intLiteral = true; }
|
||||
// Octal
|
||||
else if (stream.match(/^&O[0-7]+/i)) { intLiteral = true; }
|
||||
// Decimal
|
||||
else if (stream.match(/^[1-9]\d*F?/)) {
|
||||
// Decimal literals may be "imaginary"
|
||||
stream.eat(/J/i);
|
||||
// TODO - Can you have imaginary longs?
|
||||
intLiteral = true;
|
||||
}
|
||||
// Zero by itself with no other piece of number.
|
||||
else if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; }
|
||||
if (intLiteral) {
|
||||
// Integer literals may be "long"
|
||||
stream.eat(/L/i);
|
||||
return 'number';
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Strings
|
||||
if (stream.match(stringPrefixes)) {
|
||||
state.tokenize = tokenStringFactory(stream.current());
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
|
||||
// Handle operators and Delimiters
|
||||
if (stream.match(tripleDelimiters) || stream.match(doubleDelimiters)) {
|
||||
return null;
|
||||
}
|
||||
if (stream.match(doubleOperators)
|
||||
|| stream.match(singleOperators)
|
||||
|| stream.match(wordOperators)) {
|
||||
return 'operator';
|
||||
}
|
||||
if (stream.match(singleDelimiters)) {
|
||||
return null;
|
||||
}
|
||||
if (stream.match(doOpening)) {
|
||||
indent(stream,state);
|
||||
state.doInCurrentLine = true;
|
||||
return 'keyword';
|
||||
}
|
||||
if (stream.match(opening)) {
|
||||
if (! state.doInCurrentLine)
|
||||
indent(stream,state);
|
||||
else
|
||||
state.doInCurrentLine = false;
|
||||
return 'keyword';
|
||||
}
|
||||
if (stream.match(middle)) {
|
||||
return 'keyword';
|
||||
}
|
||||
|
||||
if (stream.match(doubleClosing)) {
|
||||
dedent(stream,state);
|
||||
dedent(stream,state);
|
||||
return 'keyword';
|
||||
}
|
||||
if (stream.match(closing)) {
|
||||
dedent(stream,state);
|
||||
return 'keyword';
|
||||
}
|
||||
|
||||
if (stream.match(types)) {
|
||||
return 'keyword';
|
||||
}
|
||||
|
||||
if (stream.match(keywords)) {
|
||||
return 'keyword';
|
||||
}
|
||||
|
||||
if (stream.match(identifiers)) {
|
||||
return 'variable';
|
||||
}
|
||||
|
||||
// Handle non-detected items
|
||||
stream.next();
|
||||
return ERRORCLASS;
|
||||
}
|
||||
|
||||
function tokenStringFactory(delimiter) {
|
||||
var singleline = delimiter.length == 1;
|
||||
var OUTCLASS = 'string';
|
||||
|
||||
return function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
stream.eatWhile(/[^'"]/);
|
||||
if (stream.match(delimiter)) {
|
||||
state.tokenize = tokenBase;
|
||||
return OUTCLASS;
|
||||
} else {
|
||||
stream.eat(/['"]/);
|
||||
}
|
||||
}
|
||||
if (singleline) {
|
||||
if (parserConf.singleLineStringErrors) {
|
||||
return ERRORCLASS;
|
||||
} else {
|
||||
state.tokenize = tokenBase;
|
||||
}
|
||||
}
|
||||
return OUTCLASS;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function tokenLexer(stream, state) {
|
||||
var style = state.tokenize(stream, state);
|
||||
var current = stream.current();
|
||||
|
||||
// Handle '.' connected identifiers
|
||||
if (current === '.') {
|
||||
style = state.tokenize(stream, state);
|
||||
current = stream.current();
|
||||
if (style === 'variable') {
|
||||
return 'variable';
|
||||
} else {
|
||||
return ERRORCLASS;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
var delimiter_index = '[({'.indexOf(current);
|
||||
if (delimiter_index !== -1) {
|
||||
indent(stream, state );
|
||||
}
|
||||
if (indentInfo === 'dedent') {
|
||||
if (dedent(stream, state)) {
|
||||
return ERRORCLASS;
|
||||
}
|
||||
}
|
||||
delimiter_index = '])}'.indexOf(current);
|
||||
if (delimiter_index !== -1) {
|
||||
if (dedent(stream, state)) {
|
||||
return ERRORCLASS;
|
||||
}
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
var external = {
|
||||
electricChars:"dDpPtTfFeE ",
|
||||
startState: function() {
|
||||
return {
|
||||
tokenize: tokenBase,
|
||||
lastToken: null,
|
||||
currentIndent: 0,
|
||||
nextLineIndent: 0,
|
||||
doInCurrentLine: false
|
||||
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.sol()) {
|
||||
state.currentIndent += state.nextLineIndent;
|
||||
state.nextLineIndent = 0;
|
||||
state.doInCurrentLine = 0;
|
||||
}
|
||||
var style = tokenLexer(stream, state);
|
||||
|
||||
state.lastToken = {style:style, content: stream.current()};
|
||||
|
||||
|
||||
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
var trueText = textAfter.replace(/^\s+|\s+$/g, '') ;
|
||||
if (trueText.match(closing) || trueText.match(doubleClosing) || trueText.match(middle)) return conf.indentUnit*(state.currentIndent-1);
|
||||
if(state.currentIndent < 0) return 0;
|
||||
return state.currentIndent * conf.indentUnit;
|
||||
}
|
||||
|
||||
};
|
||||
return external;
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-vb", "vb");
|
||||
@@ -1,55 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: VBScript mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="vbscript.js"></script>
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">VBScript</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>VBScript mode</h2>
|
||||
|
||||
|
||||
<div><textarea id="code" name="code">
|
||||
' Pete Guhl
|
||||
' 03-04-2012
|
||||
'
|
||||
' Basic VBScript support for codemirror2
|
||||
|
||||
Const ForReading = 1, ForWriting = 2, ForAppending = 8
|
||||
|
||||
Call Sub020_PostBroadcastToUrbanAirship(strUserName, strPassword, intTransmitID, strResponse)
|
||||
|
||||
If Not IsNull(strResponse) AND Len(strResponse) = 0 Then
|
||||
boolTransmitOkYN = False
|
||||
Else
|
||||
' WScript.Echo "Oh Happy Day! Oh Happy DAY!"
|
||||
boolTransmitOkYN = True
|
||||
End If
|
||||
</textarea></div>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
indentUnit: 4
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/vbscript</code>.</p>
|
||||
</article>
|
||||
@@ -1,334 +0,0 @@
|
||||
/*
|
||||
For extra ASP classic objects, initialize CodeMirror instance with this option:
|
||||
isASP: true
|
||||
|
||||
E.G.:
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
isASP: true
|
||||
});
|
||||
*/
|
||||
CodeMirror.defineMode("vbscript", function(conf, parserConf) {
|
||||
var ERRORCLASS = 'error';
|
||||
|
||||
function wordRegexp(words) {
|
||||
return new RegExp("^((" + words.join(")|(") + "))\\b", "i");
|
||||
}
|
||||
|
||||
var singleOperators = new RegExp("^[\\+\\-\\*/&\\\\\\^<>=]");
|
||||
var doubleOperators = new RegExp("^((<>)|(<=)|(>=))");
|
||||
var singleDelimiters = new RegExp('^[\\.,]');
|
||||
var brakets = new RegExp('^[\\(\\)]');
|
||||
var identifiers = new RegExp("^[A-Za-z][_A-Za-z0-9]*");
|
||||
|
||||
var openingKeywords = ['class','sub','select','while','if','function', 'property', 'with', 'for'];
|
||||
var middleKeywords = ['else','elseif','case'];
|
||||
var endKeywords = ['next','loop','wend'];
|
||||
|
||||
var wordOperators = wordRegexp(['and', 'or', 'not', 'xor', 'is', 'mod', 'eqv', 'imp']);
|
||||
var commonkeywords = ['dim', 'redim', 'then', 'until', 'randomize',
|
||||
'byval','byref','new','property', 'exit', 'in',
|
||||
'const','private', 'public',
|
||||
'get','set','let', 'stop', 'on error resume next', 'on error goto 0', 'option explicit', 'call', 'me'];
|
||||
|
||||
//This list was from: http://msdn.microsoft.com/en-us/library/f8tbc79x(v=vs.84).aspx
|
||||
var atomWords = ['true', 'false', 'nothing', 'empty', 'null'];
|
||||
//This list was from: http://msdn.microsoft.com/en-us/library/3ca8tfek(v=vs.84).aspx
|
||||
var builtinFuncsWords = ['abs', 'array', 'asc', 'atn', 'cbool', 'cbyte', 'ccur', 'cdate', 'cdbl', 'chr', 'cint', 'clng', 'cos', 'csng', 'cstr', 'date', 'dateadd', 'datediff', 'datepart',
|
||||
'dateserial', 'datevalue', 'day', 'escape', 'eval', 'execute', 'exp', 'filter', 'formatcurrency', 'formatdatetime', 'formatnumber', 'formatpercent', 'getlocale', 'getobject',
|
||||
'getref', 'hex', 'hour', 'inputbox', 'instr', 'instrrev', 'int', 'fix', 'isarray', 'isdate', 'isempty', 'isnull', 'isnumeric', 'isobject', 'join', 'lbound', 'lcase', 'left',
|
||||
'len', 'loadpicture', 'log', 'ltrim', 'rtrim', 'trim', 'maths', 'mid', 'minute', 'month', 'monthname', 'msgbox', 'now', 'oct', 'replace', 'rgb', 'right', 'rnd', 'round',
|
||||
'scriptengine', 'scriptenginebuildversion', 'scriptenginemajorversion', 'scriptengineminorversion', 'second', 'setlocale', 'sgn', 'sin', 'space', 'split', 'sqr', 'strcomp',
|
||||
'string', 'strreverse', 'tan', 'time', 'timer', 'timeserial', 'timevalue', 'typename', 'ubound', 'ucase', 'unescape', 'vartype', 'weekday', 'weekdayname', 'year'];
|
||||
|
||||
//This list was from: http://msdn.microsoft.com/en-us/library/ydz4cfk3(v=vs.84).aspx
|
||||
var builtinConsts = ['vbBlack', 'vbRed', 'vbGreen', 'vbYellow', 'vbBlue', 'vbMagenta', 'vbCyan', 'vbWhite', 'vbBinaryCompare', 'vbTextCompare',
|
||||
'vbSunday', 'vbMonday', 'vbTuesday', 'vbWednesday', 'vbThursday', 'vbFriday', 'vbSaturday', 'vbUseSystemDayOfWeek', 'vbFirstJan1', 'vbFirstFourDays', 'vbFirstFullWeek',
|
||||
'vbGeneralDate', 'vbLongDate', 'vbShortDate', 'vbLongTime', 'vbShortTime', 'vbObjectError',
|
||||
'vbOKOnly', 'vbOKCancel', 'vbAbortRetryIgnore', 'vbYesNoCancel', 'vbYesNo', 'vbRetryCancel', 'vbCritical', 'vbQuestion', 'vbExclamation', 'vbInformation', 'vbDefaultButton1', 'vbDefaultButton2',
|
||||
'vbDefaultButton3', 'vbDefaultButton4', 'vbApplicationModal', 'vbSystemModal', 'vbOK', 'vbCancel', 'vbAbort', 'vbRetry', 'vbIgnore', 'vbYes', 'vbNo',
|
||||
'vbCr', 'VbCrLf', 'vbFormFeed', 'vbLf', 'vbNewLine', 'vbNullChar', 'vbNullString', 'vbTab', 'vbVerticalTab', 'vbUseDefault', 'vbTrue', 'vbFalse',
|
||||
'vbEmpty', 'vbNull', 'vbInteger', 'vbLong', 'vbSingle', 'vbDouble', 'vbCurrency', 'vbDate', 'vbString', 'vbObject', 'vbError', 'vbBoolean', 'vbVariant', 'vbDataObject', 'vbDecimal', 'vbByte', 'vbArray'];
|
||||
//This list was from: http://msdn.microsoft.com/en-us/library/hkc375ea(v=vs.84).aspx
|
||||
var builtinObjsWords = ['WScript', 'err', 'debug', 'RegExp'];
|
||||
var knownProperties = ['description', 'firstindex', 'global', 'helpcontext', 'helpfile', 'ignorecase', 'length', 'number', 'pattern', 'source', 'value', 'count'];
|
||||
var knownMethods = ['clear', 'execute', 'raise', 'replace', 'test', 'write', 'writeline', 'close', 'open', 'state', 'eof', 'update', 'addnew', 'end', 'createobject', 'quit'];
|
||||
|
||||
var aspBuiltinObjsWords = ['server', 'response', 'request', 'session', 'application'];
|
||||
var aspKnownProperties = ['buffer', 'cachecontrol', 'charset', 'contenttype', 'expires', 'expiresabsolute', 'isclientconnected', 'pics', 'status', //response
|
||||
'clientcertificate', 'cookies', 'form', 'querystring', 'servervariables', 'totalbytes', //request
|
||||
'contents', 'staticobjects', //application
|
||||
'codepage', 'lcid', 'sessionid', 'timeout', //session
|
||||
'scripttimeout']; //server
|
||||
var aspKnownMethods = ['addheader', 'appendtolog', 'binarywrite', 'end', 'flush', 'redirect', //response
|
||||
'binaryread', //request
|
||||
'remove', 'removeall', 'lock', 'unlock', //application
|
||||
'abandon', //session
|
||||
'getlasterror', 'htmlencode', 'mappath', 'transfer', 'urlencode']; //server
|
||||
|
||||
var knownWords = knownMethods.concat(knownProperties);
|
||||
|
||||
builtinObjsWords = builtinObjsWords.concat(builtinConsts);
|
||||
|
||||
if (conf.isASP){
|
||||
builtinObjsWords = builtinObjsWords.concat(aspBuiltinObjsWords);
|
||||
knownWords = knownWords.concat(aspKnownMethods, aspKnownProperties);
|
||||
};
|
||||
|
||||
var keywords = wordRegexp(commonkeywords);
|
||||
var atoms = wordRegexp(atomWords);
|
||||
var builtinFuncs = wordRegexp(builtinFuncsWords);
|
||||
var builtinObjs = wordRegexp(builtinObjsWords);
|
||||
var known = wordRegexp(knownWords);
|
||||
var stringPrefixes = '"';
|
||||
|
||||
var opening = wordRegexp(openingKeywords);
|
||||
var middle = wordRegexp(middleKeywords);
|
||||
var closing = wordRegexp(endKeywords);
|
||||
var doubleClosing = wordRegexp(['end']);
|
||||
var doOpening = wordRegexp(['do']);
|
||||
var noIndentWords = wordRegexp(['on error resume next', 'exit']);
|
||||
var comment = wordRegexp(['rem']);
|
||||
|
||||
|
||||
function indent(_stream, state) {
|
||||
state.currentIndent++;
|
||||
}
|
||||
|
||||
function dedent(_stream, state) {
|
||||
state.currentIndent--;
|
||||
}
|
||||
// tokenizers
|
||||
function tokenBase(stream, state) {
|
||||
if (stream.eatSpace()) {
|
||||
return 'space';
|
||||
//return null;
|
||||
}
|
||||
|
||||
var ch = stream.peek();
|
||||
|
||||
// Handle Comments
|
||||
if (ch === "'") {
|
||||
stream.skipToEnd();
|
||||
return 'comment';
|
||||
}
|
||||
if (stream.match(comment)){
|
||||
stream.skipToEnd();
|
||||
return 'comment';
|
||||
}
|
||||
|
||||
|
||||
// Handle Number Literals
|
||||
if (stream.match(/^((&H)|(&O))?[0-9\.]/i, false) && !stream.match(/^((&H)|(&O))?[0-9\.]+[a-z_]/i, false)) {
|
||||
var floatLiteral = false;
|
||||
// Floats
|
||||
if (stream.match(/^\d*\.\d+/i)) { floatLiteral = true; }
|
||||
else if (stream.match(/^\d+\.\d*/)) { floatLiteral = true; }
|
||||
else if (stream.match(/^\.\d+/)) { floatLiteral = true; }
|
||||
|
||||
if (floatLiteral) {
|
||||
// Float literals may be "imaginary"
|
||||
stream.eat(/J/i);
|
||||
return 'number';
|
||||
}
|
||||
// Integers
|
||||
var intLiteral = false;
|
||||
// Hex
|
||||
if (stream.match(/^&H[0-9a-f]+/i)) { intLiteral = true; }
|
||||
// Octal
|
||||
else if (stream.match(/^&O[0-7]+/i)) { intLiteral = true; }
|
||||
// Decimal
|
||||
else if (stream.match(/^[1-9]\d*F?/)) {
|
||||
// Decimal literals may be "imaginary"
|
||||
stream.eat(/J/i);
|
||||
// TODO - Can you have imaginary longs?
|
||||
intLiteral = true;
|
||||
}
|
||||
// Zero by itself with no other piece of number.
|
||||
else if (stream.match(/^0(?![\dx])/i)) { intLiteral = true; }
|
||||
if (intLiteral) {
|
||||
// Integer literals may be "long"
|
||||
stream.eat(/L/i);
|
||||
return 'number';
|
||||
}
|
||||
}
|
||||
|
||||
// Handle Strings
|
||||
if (stream.match(stringPrefixes)) {
|
||||
state.tokenize = tokenStringFactory(stream.current());
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
|
||||
// Handle operators and Delimiters
|
||||
if (stream.match(doubleOperators)
|
||||
|| stream.match(singleOperators)
|
||||
|| stream.match(wordOperators)) {
|
||||
return 'operator';
|
||||
}
|
||||
if (stream.match(singleDelimiters)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (stream.match(brakets)) {
|
||||
return "bracket";
|
||||
}
|
||||
|
||||
if (stream.match(noIndentWords)) {
|
||||
state.doInCurrentLine = true;
|
||||
|
||||
return 'keyword';
|
||||
}
|
||||
|
||||
if (stream.match(doOpening)) {
|
||||
indent(stream,state);
|
||||
state.doInCurrentLine = true;
|
||||
|
||||
return 'keyword';
|
||||
}
|
||||
if (stream.match(opening)) {
|
||||
if (! state.doInCurrentLine)
|
||||
indent(stream,state);
|
||||
else
|
||||
state.doInCurrentLine = false;
|
||||
|
||||
return 'keyword';
|
||||
}
|
||||
if (stream.match(middle)) {
|
||||
return 'keyword';
|
||||
}
|
||||
|
||||
|
||||
if (stream.match(doubleClosing)) {
|
||||
dedent(stream,state);
|
||||
dedent(stream,state);
|
||||
|
||||
return 'keyword';
|
||||
}
|
||||
if (stream.match(closing)) {
|
||||
if (! state.doInCurrentLine)
|
||||
dedent(stream,state);
|
||||
else
|
||||
state.doInCurrentLine = false;
|
||||
|
||||
return 'keyword';
|
||||
}
|
||||
|
||||
if (stream.match(keywords)) {
|
||||
return 'keyword';
|
||||
}
|
||||
|
||||
if (stream.match(atoms)) {
|
||||
return 'atom';
|
||||
}
|
||||
|
||||
if (stream.match(known)) {
|
||||
return 'variable-2';
|
||||
}
|
||||
|
||||
if (stream.match(builtinFuncs)) {
|
||||
return 'builtin';
|
||||
}
|
||||
|
||||
if (stream.match(builtinObjs)){
|
||||
return 'variable-2';
|
||||
}
|
||||
|
||||
if (stream.match(identifiers)) {
|
||||
return 'variable';
|
||||
}
|
||||
|
||||
// Handle non-detected items
|
||||
stream.next();
|
||||
return ERRORCLASS;
|
||||
}
|
||||
|
||||
function tokenStringFactory(delimiter) {
|
||||
var singleline = delimiter.length == 1;
|
||||
var OUTCLASS = 'string';
|
||||
|
||||
return function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
stream.eatWhile(/[^'"]/);
|
||||
if (stream.match(delimiter)) {
|
||||
state.tokenize = tokenBase;
|
||||
return OUTCLASS;
|
||||
} else {
|
||||
stream.eat(/['"]/);
|
||||
}
|
||||
}
|
||||
if (singleline) {
|
||||
if (parserConf.singleLineStringErrors) {
|
||||
return ERRORCLASS;
|
||||
} else {
|
||||
state.tokenize = tokenBase;
|
||||
}
|
||||
}
|
||||
return OUTCLASS;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
function tokenLexer(stream, state) {
|
||||
var style = state.tokenize(stream, state);
|
||||
var current = stream.current();
|
||||
|
||||
// Handle '.' connected identifiers
|
||||
if (current === '.') {
|
||||
style = state.tokenize(stream, state);
|
||||
|
||||
current = stream.current();
|
||||
if (style.substr(0, 8) === 'variable' || style==='builtin' || style==='keyword'){//|| knownWords.indexOf(current.substring(1)) > -1) {
|
||||
if (style === 'builtin' || style === 'keyword') style='variable';
|
||||
if (knownWords.indexOf(current.substr(1)) > -1) style='variable-2';
|
||||
|
||||
return style;
|
||||
} else {
|
||||
return ERRORCLASS;
|
||||
}
|
||||
}
|
||||
|
||||
return style;
|
||||
}
|
||||
|
||||
var external = {
|
||||
electricChars:"dDpPtTfFeE ",
|
||||
startState: function() {
|
||||
return {
|
||||
tokenize: tokenBase,
|
||||
lastToken: null,
|
||||
currentIndent: 0,
|
||||
nextLineIndent: 0,
|
||||
doInCurrentLine: false,
|
||||
ignoreKeyword: false
|
||||
|
||||
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (stream.sol()) {
|
||||
state.currentIndent += state.nextLineIndent;
|
||||
state.nextLineIndent = 0;
|
||||
state.doInCurrentLine = 0;
|
||||
}
|
||||
var style = tokenLexer(stream, state);
|
||||
|
||||
state.lastToken = {style:style, content: stream.current()};
|
||||
|
||||
if (style==='space') style=null;
|
||||
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
var trueText = textAfter.replace(/^\s+|\s+$/g, '') ;
|
||||
if (trueText.match(closing) || trueText.match(doubleClosing) || trueText.match(middle)) return conf.indentUnit*(state.currentIndent-1);
|
||||
if(state.currentIndent < 0) return 0;
|
||||
return state.currentIndent * conf.indentUnit;
|
||||
}
|
||||
|
||||
};
|
||||
return external;
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/vbscript", "vbscript");
|
||||
@@ -1,132 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Verilog mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="verilog.js"></script>
|
||||
<style>.CodeMirror {border: 2px inset #dee;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Verilog</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Verilog mode</h2>
|
||||
<form><textarea id="code" name="code">
|
||||
/* Verilog demo code */
|
||||
|
||||
module butterfly
|
||||
#(
|
||||
parameter WIDTH = 32,
|
||||
parameter MWIDTH = 1
|
||||
)
|
||||
(
|
||||
input wire clk,
|
||||
input wire rst_n,
|
||||
// m_in contains data that passes through this block with no change.
|
||||
input wire [MWIDTH-1:0] m_in,
|
||||
// The twiddle factor.
|
||||
input wire signed [WIDTH-1:0] w,
|
||||
// XA
|
||||
input wire signed [WIDTH-1:0] xa,
|
||||
// XB
|
||||
input wire signed [WIDTH-1:0] xb,
|
||||
// Set to 1 when new data is present on inputs.
|
||||
input wire x_nd,
|
||||
// delayed version of m_in.
|
||||
output reg [MWIDTH-1:0] m_out,
|
||||
// YA = XA + W*XB
|
||||
// YB = XA - W*XB
|
||||
output wire signed [WIDTH-1:0] ya,
|
||||
output wire signed [WIDTH-1:0] yb,
|
||||
output reg y_nd,
|
||||
output reg error
|
||||
);
|
||||
|
||||
// Set wire to the real and imag parts for convenience.
|
||||
wire signed [WIDTH/2-1:0] xa_re;
|
||||
wire signed [WIDTH/2-1:0] xa_im;
|
||||
assign xa_re = xa[WIDTH-1:WIDTH/2];
|
||||
assign xa_im = xa[WIDTH/2-1:0];
|
||||
wire signed [WIDTH/2-1: 0] ya_re;
|
||||
wire signed [WIDTH/2-1: 0] ya_im;
|
||||
assign ya = {ya_re, ya_im};
|
||||
wire signed [WIDTH/2-1: 0] yb_re;
|
||||
wire signed [WIDTH/2-1: 0] yb_im;
|
||||
assign yb = {yb_re, yb_im};
|
||||
|
||||
// Delayed stuff.
|
||||
reg signed [WIDTH/2-1:0] xa_re_z;
|
||||
reg signed [WIDTH/2-1:0] xa_im_z;
|
||||
// Output of multiplier
|
||||
wire signed [WIDTH-1:0] xbw;
|
||||
wire signed [WIDTH/2-1:0] xbw_re;
|
||||
wire signed [WIDTH/2-1:0] xbw_im;
|
||||
assign xbw_re = xbw[WIDTH-1:WIDTH/2];
|
||||
assign xbw_im = xbw[WIDTH/2-1:0];
|
||||
// Do summing
|
||||
// I don't think we should get overflow here because of the
|
||||
// size of the twiddle factors.
|
||||
// If we do testing should catch it.
|
||||
assign ya_re = xa_re_z + xbw_re;
|
||||
assign ya_im = xa_im_z + xbw_im;
|
||||
assign yb_re = xa_re_z - xbw_re;
|
||||
assign yb_im = xa_im_z - xbw_im;
|
||||
|
||||
// Create the multiply module.
|
||||
multiply_complex #(WIDTH) multiply_complex_0
|
||||
(.clk(clk),
|
||||
.rst_n(rst_n),
|
||||
.x(xb),
|
||||
.y(w),
|
||||
.z(xbw)
|
||||
);
|
||||
|
||||
always @ (posedge clk)
|
||||
begin
|
||||
if (!rst_n)
|
||||
begin
|
||||
y_nd <= 1'b0;
|
||||
error <= 1'b0;
|
||||
end
|
||||
else
|
||||
begin
|
||||
// Set delay for x_nd_old and m.
|
||||
y_nd <= x_nd;
|
||||
m_out <= m_in;
|
||||
if (x_nd)
|
||||
begin
|
||||
xa_re_z <= xa_re/2;
|
||||
xa_im_z <= xa_im/2;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
endmodule
|
||||
</textarea></form>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true,
|
||||
mode: "text/x-verilog"
|
||||
});
|
||||
</script>
|
||||
|
||||
<p>Simple mode that tries to handle Verilog-like languages as well as it
|
||||
can. Takes one configuration parameters: <code>keywords</code>, an
|
||||
object whose property names are the keywords in the language.</p>
|
||||
|
||||
<p><strong>MIME types defined:</strong> <code>text/x-verilog</code> (Verilog code).</p>
|
||||
</article>
|
||||
@@ -1,182 +0,0 @@
|
||||
CodeMirror.defineMode("verilog", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit,
|
||||
keywords = parserConfig.keywords || {},
|
||||
blockKeywords = parserConfig.blockKeywords || {},
|
||||
atoms = parserConfig.atoms || {},
|
||||
hooks = parserConfig.hooks || {},
|
||||
multiLineStrings = parserConfig.multiLineStrings;
|
||||
var isOperatorChar = /[&|~><!\)\(*#%@+\/=?\:;}{,\.\^\-\[\]]/;
|
||||
|
||||
var curPunc;
|
||||
|
||||
function tokenBase(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (hooks[ch]) {
|
||||
var result = hooks[ch](stream, state);
|
||||
if (result !== false) return result;
|
||||
}
|
||||
if (ch == '"') {
|
||||
state.tokenize = tokenString(ch);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
||||
curPunc = ch;
|
||||
return null;
|
||||
}
|
||||
if (/[\d']/.test(ch)) {
|
||||
stream.eatWhile(/[\w\.']/);
|
||||
return "number";
|
||||
}
|
||||
if (ch == "/") {
|
||||
if (stream.eat("*")) {
|
||||
state.tokenize = tokenComment;
|
||||
return tokenComment(stream, state);
|
||||
}
|
||||
if (stream.eat("/")) {
|
||||
stream.skipToEnd();
|
||||
return "comment";
|
||||
}
|
||||
}
|
||||
if (isOperatorChar.test(ch)) {
|
||||
stream.eatWhile(isOperatorChar);
|
||||
return "operator";
|
||||
}
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
var cur = stream.current();
|
||||
if (keywords.propertyIsEnumerable(cur)) {
|
||||
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
||||
return "keyword";
|
||||
}
|
||||
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
||||
return "variable";
|
||||
}
|
||||
|
||||
function tokenString(quote) {
|
||||
return function(stream, state) {
|
||||
var escaped = false, next, end = false;
|
||||
while ((next = stream.next()) != null) {
|
||||
if (next == quote && !escaped) {end = true; break;}
|
||||
escaped = !escaped && next == "\\";
|
||||
}
|
||||
if (end || !(escaped || multiLineStrings))
|
||||
state.tokenize = tokenBase;
|
||||
return "string";
|
||||
};
|
||||
}
|
||||
|
||||
function tokenComment(stream, state) {
|
||||
var maybeEnd = false, ch;
|
||||
while (ch = stream.next()) {
|
||||
if (ch == "/" && maybeEnd) {
|
||||
state.tokenize = tokenBase;
|
||||
break;
|
||||
}
|
||||
maybeEnd = (ch == "*");
|
||||
}
|
||||
return "comment";
|
||||
}
|
||||
|
||||
function Context(indented, column, type, align, prev) {
|
||||
this.indented = indented;
|
||||
this.column = column;
|
||||
this.type = type;
|
||||
this.align = align;
|
||||
this.prev = prev;
|
||||
}
|
||||
function pushContext(state, col, type) {
|
||||
return state.context = new Context(state.indented, col, type, null, state.context);
|
||||
}
|
||||
function popContext(state) {
|
||||
var t = state.context.type;
|
||||
if (t == ")" || t == "]" || t == "}")
|
||||
state.indented = state.context.indented;
|
||||
return state.context = state.context.prev;
|
||||
}
|
||||
|
||||
// Interface
|
||||
|
||||
return {
|
||||
startState: function(basecolumn) {
|
||||
return {
|
||||
tokenize: null,
|
||||
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
||||
indented: 0,
|
||||
startOfLine: true
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
var ctx = state.context;
|
||||
if (stream.sol()) {
|
||||
if (ctx.align == null) ctx.align = false;
|
||||
state.indented = stream.indentation();
|
||||
state.startOfLine = true;
|
||||
}
|
||||
if (stream.eatSpace()) return null;
|
||||
curPunc = null;
|
||||
var style = (state.tokenize || tokenBase)(stream, state);
|
||||
if (style == "comment" || style == "meta") return style;
|
||||
if (ctx.align == null) ctx.align = true;
|
||||
|
||||
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
||||
else if (curPunc == "{") pushContext(state, stream.column(), "}");
|
||||
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
||||
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
||||
else if (curPunc == "}") {
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
if (ctx.type == "}") ctx = popContext(state);
|
||||
while (ctx.type == "statement") ctx = popContext(state);
|
||||
}
|
||||
else if (curPunc == ctx.type) popContext(state);
|
||||
else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
||||
pushContext(state, stream.column(), "statement");
|
||||
state.startOfLine = false;
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter) {
|
||||
if (state.tokenize != tokenBase && state.tokenize != null) return 0;
|
||||
var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
|
||||
if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
|
||||
else if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
||||
else return ctx.indented + (closing ? 0 : indentUnit);
|
||||
},
|
||||
|
||||
electricChars: "{}"
|
||||
};
|
||||
});
|
||||
|
||||
(function() {
|
||||
function words(str) {
|
||||
var obj = {}, words = str.split(" ");
|
||||
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
||||
return obj;
|
||||
}
|
||||
|
||||
var verilogKeywords = "always and assign automatic begin buf bufif0 bufif1 case casex casez cell cmos config " +
|
||||
"deassign default defparam design disable edge else end endcase endconfig endfunction endgenerate endmodule " +
|
||||
"endprimitive endspecify endtable endtask event for force forever fork function generate genvar highz0 " +
|
||||
"highz1 if ifnone incdir include initial inout input instance integer join large liblist library localparam " +
|
||||
"macromodule medium module nand negedge nmos nor noshowcancelled not notif0 notif1 or output parameter pmos " +
|
||||
"posedge primitive pull0 pull1 pulldown pullup pulsestyle_onevent pulsestyle_ondetect rcmos real realtime " +
|
||||
"reg release repeat rnmos rpmos rtran rtranif0 rtranif1 scalared showcancelled signed small specify specparam " +
|
||||
"strong0 strong1 supply0 supply1 table task time tran tranif0 tranif1 tri tri0 tri1 triand trior trireg " +
|
||||
"unsigned use vectored wait wand weak0 weak1 while wire wor xnor xor";
|
||||
|
||||
var verilogBlockKeywords = "begin bufif0 bufif1 case casex casez config else end endcase endconfig endfunction " +
|
||||
"endgenerate endmodule endprimitive endspecify endtable endtask for forever function generate if ifnone " +
|
||||
"macromodule module primitive repeat specify table task while";
|
||||
|
||||
function metaHook(stream) {
|
||||
stream.eatWhile(/[\w\$_]/);
|
||||
return "meta";
|
||||
}
|
||||
|
||||
CodeMirror.defineMIME("text/x-verilog", {
|
||||
name: "verilog",
|
||||
keywords: words(verilogKeywords),
|
||||
blockKeywords: words(verilogBlockKeywords),
|
||||
atoms: words("null"),
|
||||
hooks: {"`": metaHook, "$": metaHook}
|
||||
});
|
||||
}());
|
||||
@@ -1,52 +0,0 @@
|
||||
<!doctype html>
|
||||
|
||||
<title>CodeMirror: Z80 assembly mode</title>
|
||||
<meta charset="utf-8"/>
|
||||
<link rel=stylesheet href="../../doc/docs.css">
|
||||
|
||||
<link rel="stylesheet" href="../../lib/codemirror.css">
|
||||
<script src="../../lib/codemirror.js"></script>
|
||||
<script src="z80.js"></script>
|
||||
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
||||
<div id=nav>
|
||||
<a href="http://codemirror.net"><img id=logo src="../../doc/logo.png"></a>
|
||||
|
||||
<ul>
|
||||
<li><a href="../../index.html">Home</a>
|
||||
<li><a href="../../doc/manual.html">Manual</a>
|
||||
<li><a href="https://github.com/marijnh/codemirror">Code</a>
|
||||
</ul>
|
||||
<ul>
|
||||
<li><a href="../index.html">Language modes</a>
|
||||
<li><a class=active href="#">Z80 assembly</a>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<article>
|
||||
<h2>Z80 assembly mode</h2>
|
||||
|
||||
|
||||
<div><textarea id="code" name="code">
|
||||
#include "ti83plus.inc"
|
||||
#define progStart $9D95
|
||||
.org progStart-2
|
||||
.db $BB,$6D
|
||||
bcall(_ClrLCDFull)
|
||||
ld HL, 0
|
||||
ld (PenCol), HL
|
||||
ld HL, Message
|
||||
bcall(_PutS) ; Displays the string
|
||||
bcall(_NewLine)
|
||||
ret
|
||||
Message:
|
||||
.db "Hello world!",0
|
||||
</textarea></div>
|
||||
|
||||
<script>
|
||||
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
||||
lineNumbers: true
|
||||
});
|
||||
</script>
|
||||
|
||||
<p><strong>MIME type defined:</strong> <code>text/x-z80</code>.</p>
|
||||
</article>
|
||||
@@ -1,85 +0,0 @@
|
||||
CodeMirror.defineMode('z80', function() {
|
||||
var keywords1 = /^(exx?|(ld|cp|in)([di]r?)?|pop|push|ad[cd]|cpl|daa|dec|inc|neg|sbc|sub|and|bit|[cs]cf|x?or|res|set|r[lr]c?a?|r[lr]d|s[lr]a|srl|djnz|nop|rst|[de]i|halt|im|ot[di]r|out[di]?)\b/i;
|
||||
var keywords2 = /^(call|j[pr]|ret[in]?)\b/i;
|
||||
var keywords3 = /^b_?(call|jump)\b/i;
|
||||
var variables1 = /^(af?|bc?|c|de?|e|hl?|l|i[xy]?|r|sp)\b/i;
|
||||
var variables2 = /^(n?[zc]|p[oe]?|m)\b/i;
|
||||
var errors = /^([hl][xy]|i[xy][hl]|slia|sll)\b/i;
|
||||
var numbers = /^([\da-f]+h|[0-7]+o|[01]+b|\d+)\b/i;
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {context: 0};
|
||||
},
|
||||
token: function(stream, state) {
|
||||
if (!stream.column())
|
||||
state.context = 0;
|
||||
|
||||
if (stream.eatSpace())
|
||||
return null;
|
||||
|
||||
var w;
|
||||
|
||||
if (stream.eatWhile(/\w/)) {
|
||||
w = stream.current();
|
||||
|
||||
if (stream.indentation()) {
|
||||
if (state.context == 1 && variables1.test(w))
|
||||
return 'variable-2';
|
||||
|
||||
if (state.context == 2 && variables2.test(w))
|
||||
return 'variable-3';
|
||||
|
||||
if (keywords1.test(w)) {
|
||||
state.context = 1;
|
||||
return 'keyword';
|
||||
} else if (keywords2.test(w)) {
|
||||
state.context = 2;
|
||||
return 'keyword';
|
||||
} else if (keywords3.test(w)) {
|
||||
state.context = 3;
|
||||
return 'keyword';
|
||||
}
|
||||
|
||||
if (errors.test(w))
|
||||
return 'error';
|
||||
} else if (numbers.test(w)) {
|
||||
return 'number';
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (stream.eat(';')) {
|
||||
stream.skipToEnd();
|
||||
return 'comment';
|
||||
} else if (stream.eat('"')) {
|
||||
while (w = stream.next()) {
|
||||
if (w == '"')
|
||||
break;
|
||||
|
||||
if (w == '\\')
|
||||
stream.next();
|
||||
}
|
||||
return 'string';
|
||||
} else if (stream.eat('\'')) {
|
||||
if (stream.match(/\\?.'/))
|
||||
return 'number';
|
||||
} else if (stream.eat('.') || stream.sol() && stream.eat('#')) {
|
||||
state.context = 4;
|
||||
|
||||
if (stream.eatWhile(/\w/))
|
||||
return 'def';
|
||||
} else if (stream.eat('$')) {
|
||||
if (stream.eatWhile(/[\da-f]/i))
|
||||
return 'number';
|
||||
} else if (stream.eat('%')) {
|
||||
if (stream.eatWhile(/[01]/))
|
||||
return 'number';
|
||||
} else {
|
||||
stream.next();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/x-z80", "z80");
|
||||
@@ -1,77 +0,0 @@
|
||||
<style>
|
||||
.acw-chap pre, .acw-chap pre span, span.acw-char-check, .acw-chap .selection-area div
|
||||
{
|
||||
font:11px 'Courier', monospaced;
|
||||
line-height:11px;
|
||||
margin:0;
|
||||
padding:0;
|
||||
border:0;
|
||||
}
|
||||
|
||||
.acw-chap .wrapped-row
|
||||
{
|
||||
background-image:url('{{=URL(r=request,c='static',f='eamy')}}/chap-wrapped-row.gif');
|
||||
background-repeat:no-repeat;
|
||||
background-position:25px 4px;
|
||||
}
|
||||
.acw-chap .sidebar
|
||||
{
|
||||
background-image:url('{{=URL(r=request,c='static',f='eamy')}}/chap-bg-sidebar.gif');
|
||||
line-height:11px;
|
||||
}
|
||||
.acw-chap .sidebar .row-number
|
||||
{
|
||||
text-align:right;
|
||||
font-size:9px;
|
||||
font-family:'Lucida Grande', Verdana, Arial, Helvetica, sans-serif;
|
||||
color:#999;
|
||||
}
|
||||
|
||||
.acw-chap .folding-expand-inner
|
||||
{
|
||||
width:14px;
|
||||
height:10px;
|
||||
margin-left:2px;
|
||||
display:inline;
|
||||
background-image:url('{{=URL(r=request,c='static',f='eamy')}}/chap-folding-expand-inner.gif');
|
||||
}
|
||||
.acw-chap .folding-expand
|
||||
{
|
||||
background-image:url('{{=URL(r=request,c='static',f='eamy')}}/chap-folding-expand.gif');
|
||||
}
|
||||
.acw-chap .folding-start
|
||||
{
|
||||
background-image:url('{{=URL(r=request,c='static',f='eamy')}}/chap-folding-start.gif');
|
||||
}
|
||||
.acw-chap .folding-stop
|
||||
{
|
||||
background-image:url('{{=URL(r=request,c='static',f='eamy')}}/chap-folding-stop.gif');
|
||||
}
|
||||
.acw-chap .bookmark-default
|
||||
{
|
||||
background-image:url('{{=URL(r=request,c='static',f='eamy')}}/chap-bookmark-default.gif');
|
||||
}
|
||||
.acw-chap .void
|
||||
{
|
||||
background-image:url('{{=URL(r=request,c='static',f='eamy')}}/void.gif');
|
||||
}
|
||||
</style>
|
||||
<script src="{{=URL(r=request,c='static',f='eamy/eamy.js')}}" type="text/javascript"></script>
|
||||
<script src="{{=URL(r=request,c='static',f='js/jquery.hotkeys.js')}}" type="text/javascript" charset="utf-8"></script>
|
||||
{{if request.args[1]=="views":}}
|
||||
<script src="{{=URL(r=request,c='static',f='eamy/bundle_markup.js')}}" type="text/javascript"></script>
|
||||
{{else:}}
|
||||
<script src="{{=URL(r=request,c='static',f='eamy/bundle_python.js')}}" type="text/javascript"></script>
|
||||
{{pass}}
|
||||
<script language="Javascript" type="text/javascript" src="/{{=request.application}}/static/js/ajax_editor.js"></script>
|
||||
|
||||
<script language="Javascript" type="text/javascript">
|
||||
jQuery(document).ready(function(){
|
||||
setTimeout("keepalive('{{=URL('keepalive')}}')",10000);
|
||||
|
||||
});
|
||||
jQuery(document).bind('keydown', 'alt+f1',function (evt){
|
||||
doClickSave();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
#!/bin/sh
|
||||
#
|
||||
# run unit tests under nose if available,
|
||||
# optionally with coverage
|
||||
#
|
||||
# test.sh [cover [gluon.rewrite]]
|
||||
#
|
||||
# easy_install nose
|
||||
# easy_install coverage
|
||||
#
|
||||
NOSETESTS=nosetests
|
||||
COVER=gluon # change to (eg) gluon.rewrite to collect coverage stats on a single module
|
||||
PROCESSES=4
|
||||
|
||||
WHICH=`which $NOSETESTS`
|
||||
if [ "$WHICH" == "" ]; then
|
||||
# if nose isn't available, run the tests directly
|
||||
for testmod in test_*.py; do
|
||||
python $testmod
|
||||
done
|
||||
else
|
||||
if [ "$1" = "cover" ]; then
|
||||
# note: coverage doesn't handle multiple processes
|
||||
if [ "$2" != "" ]; then
|
||||
COVER=$2
|
||||
fi
|
||||
$NOSETESTS --with-coverage --cover-package=$COVER --cover-erase
|
||||
elif [ "$1" = "doctest" ]; then
|
||||
# this has to run in gluon's parent; needs work
|
||||
#
|
||||
# the problem is that doctests run this way
|
||||
# have a very different environment,
|
||||
# apparently due to imports that don't happen
|
||||
# in the normal course of running
|
||||
# doctest via __main__.
|
||||
#
|
||||
echo doctest not supported >&2
|
||||
exit 1
|
||||
if [ ! -d gluon ]; then
|
||||
cd ../..
|
||||
fi
|
||||
$NOSETESTS --with-doctest
|
||||
else
|
||||
$NOSETESTS --processes=$PROCESSES
|
||||
fi
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user