File manager - Edit - /home/newsbmcs.com/public_html/static/img/logo/mode.tar
Back
go/go.js 0000644 00000013617 15030163777 0006135 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("go", function(config) { var indentUnit = config.indentUnit; var keywords = { "break":true, "case":true, "chan":true, "const":true, "continue":true, "default":true, "defer":true, "else":true, "fallthrough":true, "for":true, "func":true, "go":true, "goto":true, "if":true, "import":true, "interface":true, "map":true, "package":true, "range":true, "return":true, "select":true, "struct":true, "switch":true, "type":true, "var":true, "bool":true, "byte":true, "complex64":true, "complex128":true, "float32":true, "float64":true, "int8":true, "int16":true, "int32":true, "int64":true, "string":true, "uint8":true, "uint16":true, "uint32":true, "uint64":true, "int":true, "uint":true, "uintptr":true, "error": true, "rune":true }; var atoms = { "true":true, "false":true, "iota":true, "nil":true, "append":true, "cap":true, "close":true, "complex":true, "copy":true, "delete":true, "imag":true, "len":true, "make":true, "new":true, "panic":true, "print":true, "println":true, "real":true, "recover":true }; var isOperatorChar = /[+\-*&^%:=<>!|\/]/; var curPunc; function tokenBase(stream, state) { var ch = stream.next(); if (ch == '"' || ch == "'" || ch == "`") { state.tokenize = tokenString(ch); return state.tokenize(stream, state); } if (/[\d\.]/.test(ch)) { if (ch == ".") { stream.match(/^[0-9]+([eE][\-+]?[0-9]+)?/); } else if (ch == "0") { stream.match(/^[xX][0-9a-fA-F]+/) || stream.match(/^0[0-7]+/); } else { stream.match(/^[0-9]*\.?[0-9]*([eE][\-+]?[0-9]+)?/); } return "number"; } if (/[\[\]{}\(\),;\:\.]/.test(ch)) { curPunc = ch; return null; } 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\$_\xa1-\uffff]/); var cur = stream.current(); if (keywords.propertyIsEnumerable(cur)) { if (cur == "case" || cur == "default") curPunc = "case"; 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 && quote != "`" && next == "\\"; } if (end || !(escaped || quote == "`")) 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) { if (!state.context.prev) return; 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 (ctx.type == "case") ctx.type = "}"; } if (stream.eatSpace()) return null; curPunc = null; var style = (state.tokenize || tokenBase)(stream, state); if (style == "comment") return style; if (ctx.align == null) ctx.align = true; if (curPunc == "{") pushContext(state, stream.column(), "}"); else if (curPunc == "[") pushContext(state, stream.column(), "]"); else if (curPunc == "(") pushContext(state, stream.column(), ")"); else if (curPunc == "case") ctx.type = "case"; else if (curPunc == "}" && ctx.type == "}") popContext(state); else if (curPunc == ctx.type) popContext(state); state.startOfLine = false; return style; }, indent: function(state, textAfter) { if (state.tokenize != tokenBase && state.tokenize != null) return CodeMirror.Pass; var ctx = state.context, firstChar = textAfter && textAfter.charAt(0); if (ctx.type == "case" && /^(?:case|default)\b/.test(textAfter)) { state.context.type = "}"; return ctx.indented; } var closing = firstChar == ctx.type; if (ctx.align) return ctx.column + (closing ? 0 : 1); else return ctx.indented + (closing ? 0 : indentUnit); }, electricChars: "{}):", closeBrackets: "()[]{}''\"\"``", fold: "brace", blockCommentStart: "/*", blockCommentEnd: "*/", lineComment: "//" }; }); CodeMirror.defineMIME("text/x-go", "go"); }); go/index.html 0000644 00000004206 15030163777 0007161 0 ustar 00 <!doctype html> <title>CodeMirror: Go 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/elegant.css"> <script src="../../lib/codemirror.js"></script> <script src="../../addon/edit/matchbrackets.js"></script> <script src="go.js"></script> <style>.CodeMirror {border:1px solid #999; background:#ffc}</style> <div id=nav> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a> <ul> <li><a href="../../index.html">Home</a> <li><a href="../../doc/manual.html">Manual</a> <li><a href="https://github.com/codemirror/codemirror">Code</a> </ul> <ul> <li><a href="../index.html">Language modes</a> <li><a class=active href="#">Go</a> </ul> </div> <article> <h2>Go mode</h2> <form><textarea id="code" name="code"> // Prime Sieve in Go. // Taken from the Go specification. // Copyright © The Go Authors. package main import "fmt" // Send the sequence 2, 3, 4, ... to channel 'ch'. func generate(ch chan<- int) { for i := 2; ; i++ { ch <- i // Send 'i' to channel 'ch' } } // Copy the values from channel 'src' to channel 'dst', // removing those divisible by 'prime'. func filter(src <-chan int, dst chan<- int, prime int) { for i := range src { // Loop over values received from 'src'. if i%prime != 0 { dst <- i // Send 'i' to channel 'dst'. } } } // The prime sieve: Daisy-chain filter processes together. func sieve() { ch := make(chan int) // Create a new channel. go generate(ch) // Start generate() as a subprocess. for { prime := <-ch fmt.Print(prime, "\n") ch1 := make(chan int) go filter(ch, ch1, prime) ch = ch1 } } func main() { sieve() } </textarea></form> <script> var editor = CodeMirror.fromTextArea(document.getElementById("code"), { theme: "elegant", matchBrackets: true, indentUnit: 8, tabSize: 8, indentWithTabs: true, mode: "text/x-go" }); </script> <p><strong>MIME type:</strong> <code>text/x-go</code></p> </article> pegjs/pegjs.js 0000644 00000006772 15030163777 0007347 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../javascript/javascript")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../javascript/javascript"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("pegjs", function (config) { var jsMode = CodeMirror.getMode(config, "javascript"); function identifier(stream) { return stream.match(/^[a-zA-Z_][a-zA-Z0-9_]*/); } return { startState: function () { return { inString: false, stringType: null, inComment: false, inCharacterClass: false, braced: 0, lhs: true, localState: null }; }, token: function (stream, state) { if (stream) //check for state changes if (!state.inString && !state.inComment && ((stream.peek() == '"') || (stream.peek() == "'"))) { state.stringType = stream.peek(); stream.next(); // Skip quote state.inString = true; // Update state } if (!state.inString && !state.inComment && stream.match(/^\/\*/)) { state.inComment = true; } //return state if (state.inString) { while (state.inString && !stream.eol()) { if (stream.peek() === state.stringType) { stream.next(); // Skip quote state.inString = false; // Clear flag } else if (stream.peek() === '\\') { stream.next(); stream.next(); } else { stream.match(/^.[^\\\"\']*/); } } return state.lhs ? "property string" : "string"; // Token style } else if (state.inComment) { while (state.inComment && !stream.eol()) { if (stream.match(/\*\//)) { state.inComment = false; // Clear flag } else { stream.match(/^.[^\*]*/); } } return "comment"; } else if (state.inCharacterClass) { while (state.inCharacterClass && !stream.eol()) { if (!(stream.match(/^[^\]\\]+/) || stream.match(/^\\./))) { state.inCharacterClass = false; } } } else if (stream.peek() === '[') { stream.next(); state.inCharacterClass = true; return 'bracket'; } else if (stream.match(/^\/\//)) { stream.skipToEnd(); return "comment"; } else if (state.braced || stream.peek() === '{') { if (state.localState === null) { state.localState = CodeMirror.startState(jsMode); } var token = jsMode.token(stream, state.localState); var text = stream.current(); if (!token) { for (var i = 0; i < text.length; i++) { if (text[i] === '{') { state.braced++; } else if (text[i] === '}') { state.braced--; } }; } return token; } else if (identifier(stream)) { if (stream.peek() === ':') { return 'variable'; } return 'variable-2'; } else if (['[', ']', '(', ')'].indexOf(stream.peek()) != -1) { stream.next(); return 'bracket'; } else if (!stream.eatSpace()) { stream.next(); } return null; } }; }, "javascript"); }); pegjs/index.html 0000644 00000003532 15030163777 0007665 0 ustar 00 <!doctype html> <html> <head> <title>CodeMirror: PEG.js 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="../javascript/javascript.js"></script> <script src="pegjs.js"></script> <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> </head> <body> <div id=nav> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a> <ul> <li><a href="../../index.html">Home</a> <li><a href="../../doc/manual.html">Manual</a> <li><a href="https://github.com/codemirror/codemirror">Code</a> </ul> <ul> <li><a href="../index.html">Language modes</a> <li><a class=active href="#">PEG.js Mode</a> </ul> </div> <article> <h2>PEG.js Mode</h2> <form><textarea id="code" name="code"> /* * Classic example grammar, which recognizes simple arithmetic expressions like * "2*(3+4)". The parser generated from this grammar then computes their value. */ start = additive additive = left:multiplicative "+" right:additive { return left + right; } / multiplicative multiplicative = left:primary "*" right:multiplicative { return left * right; } / primary primary = integer / "(" additive:additive ")" { return additive; } integer "integer" = digits:[0-9]+ { return parseInt(digits.join(""), 10); } letter = [a-z]+</textarea></form> <script> var editor = CodeMirror.fromTextArea(document.getElementById("code"), { mode: {name: "pegjs"}, lineNumbers: true }); </script> <h3>The PEG.js Mode</h3> <p> Created by Forbes Lindesay.</p> </article> </body> </html> vhdl/index.html 0000644 00000004656 15030163777 0007522 0 ustar 00 <!doctype html> <title>CodeMirror: VHDL 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="vhdl.js"></script> <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> <div id=nav> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a> <ul> <li><a href="../../index.html">Home</a> <li><a href="../../doc/manual.html">Manual</a> <li><a href="https://github.com/codemirror/codemirror">Code</a> </ul> <ul> <li><a href="../index.html">Language modes</a> <li><a class=active href="#">VHDL</a> </ul> </div> <article> <h2>VHDL mode</h2> <div><textarea id="code" name="code"> LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.numeric_std.ALL; ENTITY tb IS END tb; ARCHITECTURE behavior OF tb IS --Inputs signal a : unsigned(2 downto 0) := (others => '0'); signal b : unsigned(2 downto 0) := (others => '0'); --Outputs signal a_eq_b : std_logic; signal a_le_b : std_logic; signal a_gt_b : std_logic; signal i,j : integer; BEGIN -- Instantiate the Unit Under Test (UUT) uut: entity work.comparator PORT MAP ( a => a, b => b, a_eq_b => a_eq_b, a_le_b => a_le_b, a_gt_b => a_gt_b ); -- Stimulus process stim_proc: process begin for i in 0 to 8 loop for j in 0 to 8 loop a <= to_unsigned(i,3); --integer to unsigned type conversion b <= to_unsigned(j,3); wait for 10 ns; end loop; end loop; end process; END; </textarea></div> <script> var editor = CodeMirror.fromTextArea(document.getElementById("code"), { lineNumbers: true, matchBrackets: true, mode: { name: "vhdl", } }); </script> <p> Syntax highlighting and indentation for the VHDL language. <h2>Configuration options:</h2> <ul> <li><strong>atoms</strong> - List of atom words. Default: "null"</li> <li><strong>hooks</strong> - List of meta hooks. Default: ["`", "$"]</li> <li><strong>multiLineStrings</strong> - Whether multi-line strings are accepted. Default: false</li> </ul> </p> <p><strong>MIME types defined:</strong> <code>text/x-vhdl</code>.</p> </article> vhdl/vhdl.js 0000644 00000015061 15030163777 0007010 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE // Originally written by Alf Nielsen, re-written by Michael Zhou (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; function words(str) { var obj = {}, words = str.split(","); for (var i = 0; i < words.length; ++i) { var allCaps = words[i].toUpperCase(); var firstCap = words[i].charAt(0).toUpperCase() + words[i].slice(1); obj[words[i]] = true; obj[allCaps] = true; obj[firstCap] = true; } return obj; } function metaHook(stream) { stream.eatWhile(/[\w\$_]/); return "meta"; } CodeMirror.defineMode("vhdl", function(config, parserConfig) { var indentUnit = config.indentUnit, atoms = parserConfig.atoms || words("null"), hooks = parserConfig.hooks || {"`": metaHook, "$": metaHook}, multiLineStrings = parserConfig.multiLineStrings; var keywords = words("abs,access,after,alias,all,and,architecture,array,assert,attribute,begin,block," + "body,buffer,bus,case,component,configuration,constant,disconnect,downto,else,elsif,end,end block,end case," + "end component,end for,end generate,end if,end loop,end process,end record,end units,entity,exit,file,for," + "function,generate,generic,generic map,group,guarded,if,impure,in,inertial,inout,is,label,library,linkage," + "literal,loop,map,mod,nand,new,next,nor,null,of,on,open,or,others,out,package,package body,port,port map," + "postponed,procedure,process,pure,range,record,register,reject,rem,report,return,rol,ror,select,severity,signal," + "sla,sll,sra,srl,subtype,then,to,transport,type,unaffected,units,until,use,variable,wait,when,while,with,xnor,xor"); var blockKeywords = words("architecture,entity,begin,case,port,else,elsif,end,for,function,if"); 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 = tokenString2(ch); return state.tokenize(stream, state); } 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("-")) { stream.skipToEnd(); return "comment"; } } if (isOperatorChar.test(ch)) { stream.eatWhile(isOperatorChar); return "operator"; } stream.eatWhile(/[\w\$_]/); var cur = stream.current(); if (keywords.propertyIsEnumerable(cur.toLowerCase())) { 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 tokenString2(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-2"; }; } 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: "{}" }; }); CodeMirror.defineMIME("text/x-vhdl", "vhdl"); }); groovy/groovy.js 0000644 00000017460 15030163777 0007775 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; 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 trait transient " + "try void volatile while"); var blockKeywords = words("catch class def do else enum finally for if interface switch trait try while"); var standaloneKeywords = words("return break continue"); 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, false)) { 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"; else if (standaloneKeywords.propertyIsEnumerable(cur)) curPunc = "standalone"; 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, newline) { return !last || last == "operator" || last == "->" || /[\.\[\{\(,;:]/.test(last) || last == "newstatement" || last == "keyword" || last == "proplabel" || (last == "standalone" && !newline); } 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, true)) { 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 CodeMirror.Pass; var firstChar = textAfter && textAfter.charAt(0), ctx = state.context; if (ctx.type == "statement" && !expectExpression(state.lastToken, true)) 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: "{}", closeBrackets: {triples: "'\""}, fold: "brace", blockCommentStart: "/*", blockCommentEnd: "*/", lineComment: "//" }; }); CodeMirror.defineMIME("text/x-groovy", "groovy"); }); groovy/index.html 0000644 00000004211 15030163777 0010075 0 ustar 00 <!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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a> <ul> <li><a href="../../index.html">Home</a> <li><a href="../../doc/manual.html">Manual</a> <li><a href="https://github.com/codemirror/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> asn.1/asn.1.js 0000644 00000017070 15030163777 0006760 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("asn.1", function(config, parserConfig) { var indentUnit = config.indentUnit, keywords = parserConfig.keywords || {}, cmipVerbs = parserConfig.cmipVerbs || {}, compareTypes = parserConfig.compareTypes || {}, status = parserConfig.status || {}, tags = parserConfig.tags || {}, storage = parserConfig.storage || {}, modifier = parserConfig.modifier || {}, accessTypes = parserConfig.accessTypes|| {}, multiLineStrings = parserConfig.multiLineStrings, indentStatements = parserConfig.indentStatements !== false; var isOperatorChar = /[\|\^]/; var curPunc; function tokenBase(stream, state) { var ch = stream.next(); if (ch == '"' || ch == "'") { state.tokenize = tokenString(ch); return state.tokenize(stream, state); } if (/[\[\]\(\){}:=,;]/.test(ch)) { curPunc = ch; return "punctuation"; } if (ch == "-"){ if (stream.eat("-")) { stream.skipToEnd(); return "comment"; } } if (/\d/.test(ch)) { stream.eatWhile(/[\w\.]/); return "number"; } if (isOperatorChar.test(ch)) { stream.eatWhile(isOperatorChar); return "operator"; } stream.eatWhile(/[\w\-]/); var cur = stream.current(); if (keywords.propertyIsEnumerable(cur)) return "keyword"; if (cmipVerbs.propertyIsEnumerable(cur)) return "variable cmipVerbs"; if (compareTypes.propertyIsEnumerable(cur)) return "atom compareTypes"; if (status.propertyIsEnumerable(cur)) return "comment status"; if (tags.propertyIsEnumerable(cur)) return "variable-3 tags"; if (storage.propertyIsEnumerable(cur)) return "builtin storage"; if (modifier.propertyIsEnumerable(cur)) return "string-2 modifier"; if (accessTypes.propertyIsEnumerable(cur)) return "atom accessTypes"; return "variable"; } function tokenString(quote) { return function(stream, state) { var escaped = false, next, end = false; while ((next = stream.next()) != null) { if (next == quote && !escaped){ var afterNext = stream.peek(); //look if the character if the quote is like the B in '10100010'B if (afterNext){ afterNext = afterNext.toLowerCase(); if(afterNext == "b" || afterNext == "h" || afterNext == "o") stream.next(); } end = true; break; } escaped = !escaped && next == "\\"; } if (end || !(escaped || multiLineStrings)) state.tokenize = null; return "string"; }; } 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) { var indent = state.indented; if (state.context && state.context.type == "statement") indent = state.context.indented; return state.context = new Context(indent, 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") return style; if (ctx.align == null) ctx.align = true; if ((curPunc == ";" || 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 (indentStatements && (((ctx.type == "}" || ctx.type == "top") && curPunc != ';') || (ctx.type == "statement" && curPunc == "newstatement"))) pushContext(state, stream.column(), "statement"); state.startOfLine = false; return style; }, electricChars: "{}", lineComment: "--", fold: "brace" }; }); function words(str) { var obj = {}, words = str.split(" "); for (var i = 0; i < words.length; ++i) obj[words[i]] = true; return obj; } CodeMirror.defineMIME("text/x-ttcn-asn", { name: "asn.1", keywords: words("DEFINITIONS OBJECTS IF DERIVED INFORMATION ACTION" + " REPLY ANY NAMED CHARACTERIZED BEHAVIOUR REGISTERED" + " WITH AS IDENTIFIED CONSTRAINED BY PRESENT BEGIN" + " IMPORTS FROM UNITS SYNTAX MIN-ACCESS MAX-ACCESS" + " MINACCESS MAXACCESS REVISION STATUS DESCRIPTION" + " SEQUENCE SET COMPONENTS OF CHOICE DistinguishedName" + " ENUMERATED SIZE MODULE END INDEX AUGMENTS EXTENSIBILITY" + " IMPLIED EXPORTS"), cmipVerbs: words("ACTIONS ADD GET NOTIFICATIONS REPLACE REMOVE"), compareTypes: words("OPTIONAL DEFAULT MANAGED MODULE-TYPE MODULE_IDENTITY" + " MODULE-COMPLIANCE OBJECT-TYPE OBJECT-IDENTITY" + " OBJECT-COMPLIANCE MODE CONFIRMED CONDITIONAL" + " SUBORDINATE SUPERIOR CLASS TRUE FALSE NULL" + " TEXTUAL-CONVENTION"), status: words("current deprecated mandatory obsolete"), tags: words("APPLICATION AUTOMATIC EXPLICIT IMPLICIT PRIVATE TAGS" + " UNIVERSAL"), storage: words("BOOLEAN INTEGER OBJECT IDENTIFIER BIT OCTET STRING" + " UTCTime InterfaceIndex IANAifType CMIP-Attribute" + " REAL PACKAGE PACKAGES IpAddress PhysAddress" + " NetworkAddress BITS BMPString TimeStamp TimeTicks" + " TruthValue RowStatus DisplayString GeneralString" + " GraphicString IA5String NumericString" + " PrintableString SnmpAdminAtring TeletexString" + " UTF8String VideotexString VisibleString StringStore" + " ISO646String T61String UniversalString Unsigned32" + " Integer32 Gauge Gauge32 Counter Counter32 Counter64"), modifier: words("ATTRIBUTE ATTRIBUTES MANDATORY-GROUP MANDATORY-GROUPS" + " GROUP GROUPS ELEMENTS EQUALITY ORDERING SUBSTRINGS" + " DEFINED"), accessTypes: words("not-accessible accessible-for-notify read-only" + " read-create read-write"), multiLineStrings: true }); }); asn.1/index.html 0000644 00000004340 15030163777 0007473 0 ustar 00 <!doctype html> <title>CodeMirror: ASN.1 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="asn.1.js"></script> <style> .CodeMirror { border-top: 1px solid black; border-bottom: 1px solid black; } </style> <div id=nav> <a href="https://codemirror.net"><h1>CodeMirror</h1> <img id=logo src="../../doc/logo.png" alt=""> </a> <ul> <li><a href="../../index.html">Home</a> <li><a href="../../doc/manual.html">Manual</a> <li><a href="https://github.com/codemirror/codemirror">Code</a> </ul> <ul> <li><a href="../index.html">Language modes</a> <li><a class=active href="http://en.wikipedia.org/wiki/Abstract_Syntax_Notation_One">ASN.1</a> </ul> </div> <article> <h2>ASN.1 example</h2> <div> <textarea id="ttcn-asn-code"> -- -- Sample ASN.1 Code -- MyModule DEFINITIONS ::= BEGIN MyTypes ::= SEQUENCE { myObjectId OBJECT IDENTIFIER, mySeqOf SEQUENCE OF MyInt, myBitString BIT STRING { muxToken(0), modemToken(1) } } MyInt ::= INTEGER (0..65535) END </textarea> </div> <script> var ttcnEditor = CodeMirror.fromTextArea(document.getElementById("ttcn-asn-code"), { lineNumbers: true, matchBrackets: true, mode: "text/x-ttcn-asn" }); ttcnEditor.setSize(400, 400); var mac = CodeMirror.keyMap.default == CodeMirror.keyMap.macDefault; CodeMirror.keyMap.default[(mac ? "Cmd" : "Ctrl") + "-Space"] = "autocomplete"; </script> <br/> <p><strong>Language:</strong> Abstract Syntax Notation One (<a href="http://www.itu.int/en/ITU-T/asn1/Pages/introduction.aspx">ASN.1</a>) </p> <p><strong>MIME types defined:</strong> <code>text/x-ttcn-asn</code></p> <br/> <p>The development of this mode has been sponsored by <a href="http://www.ericsson.com/">Ericsson </a>.</p> <p>Coded by Asmelash Tsegay Gebretsadkan </p> </article> mllike/mllike.js 0000644 00000021011 15030163777 0007640 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode('mllike', function(_config, parserConfig) { var words = { 'as': 'keyword', 'do': 'keyword', 'else': 'keyword', 'end': 'keyword', 'exception': 'keyword', 'fun': 'keyword', 'functor': 'keyword', 'if': 'keyword', 'in': 'keyword', 'include': 'keyword', 'let': 'keyword', 'of': 'keyword', 'open': 'keyword', 'rec': 'keyword', 'struct': 'keyword', 'then': 'keyword', 'type': 'keyword', 'val': 'keyword', 'while': 'keyword', 'with': 'keyword' }; var extraWords = parserConfig.extraWords || {}; for (var prop in extraWords) { if (extraWords.hasOwnProperty(prop)) { words[prop] = parserConfig.extraWords[prop]; } } var hintWords = []; for (var k in words) { hintWords.push(k); } CodeMirror.registerHelper("hintWords", "mllike", hintWords); function tokenBase(stream, state) { var ch = stream.next(); if (ch === '"') { state.tokenize = tokenString; return state.tokenize(stream, state); } if (ch === '{') { if (stream.eat('|')) { state.longString = true; state.tokenize = tokenLongString; return state.tokenize(stream, state); } } if (ch === '(') { if (stream.eat('*')) { state.commentLevel++; state.tokenize = tokenComment; return state.tokenize(stream, state); } } if (ch === '~' || ch === '?') { stream.eatWhile(/\w/); return 'variable-2'; } if (ch === '`') { stream.eatWhile(/\w/); return 'quote'; } if (ch === '/' && parserConfig.slashComments && stream.eat('/')) { stream.skipToEnd(); return 'comment'; } if (/\d/.test(ch)) { if (ch === '0' && stream.eat(/[bB]/)) { stream.eatWhile(/[01]/); } if (ch === '0' && stream.eat(/[xX]/)) { stream.eatWhile(/[0-9a-fA-F]/) } if (ch === '0' && stream.eat(/[oO]/)) { stream.eatWhile(/[0-7]/); } else { stream.eatWhile(/[\d_]/); if (stream.eat('.')) { stream.eatWhile(/[\d]/); } if (stream.eat(/[eE]/)) { stream.eatWhile(/[\d\-+]/); } } return 'number'; } if ( /[+\-*&%=<>!?|@\.~:]/.test(ch)) { return 'operator'; } if (/[\w\xa1-\uffff]/.test(ch)) { stream.eatWhile(/[\w\xa1-\uffff]/); var cur = stream.current(); return words.hasOwnProperty(cur) ? words[cur] : 'variable'; } return null } 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'; } function tokenLongString(stream, state) { var prev, next; while (state.longString && (next = stream.next()) != null) { if (prev === '|' && next === '}') state.longString = false; prev = next; } if (!state.longString) { state.tokenize = tokenBase; } return 'string'; } return { startState: function() {return {tokenize: tokenBase, commentLevel: 0, longString: false};}, token: function(stream, state) { if (stream.eatSpace()) return null; return state.tokenize(stream, state); }, blockCommentStart: "(*", blockCommentEnd: "*)", lineComment: parserConfig.slashComments ? "//" : null }; }); CodeMirror.defineMIME('text/x-ocaml', { name: 'mllike', extraWords: { 'and': 'keyword', 'assert': 'keyword', 'begin': 'keyword', 'class': 'keyword', 'constraint': 'keyword', 'done': 'keyword', 'downto': 'keyword', 'external': 'keyword', 'function': 'keyword', 'initializer': 'keyword', 'lazy': 'keyword', 'match': 'keyword', 'method': 'keyword', 'module': 'keyword', 'mutable': 'keyword', 'new': 'keyword', 'nonrec': 'keyword', 'object': 'keyword', 'private': 'keyword', 'sig': 'keyword', 'to': 'keyword', 'try': 'keyword', 'value': 'keyword', 'virtual': 'keyword', 'when': 'keyword', // builtins 'raise': 'builtin', 'failwith': 'builtin', 'true': 'builtin', 'false': 'builtin', // Pervasives builtins 'asr': 'builtin', 'land': 'builtin', 'lor': 'builtin', 'lsl': 'builtin', 'lsr': 'builtin', 'lxor': 'builtin', 'mod': 'builtin', 'or': 'builtin', // More Pervasives 'raise_notrace': 'builtin', 'trace': 'builtin', 'exit': 'builtin', 'print_string': 'builtin', 'print_endline': 'builtin', 'int': 'type', 'float': 'type', 'bool': 'type', 'char': 'type', 'string': 'type', 'unit': 'type', // Modules 'List': 'builtin' } }); CodeMirror.defineMIME('text/x-fsharp', { name: 'mllike', extraWords: { 'abstract': 'keyword', 'assert': 'keyword', 'base': 'keyword', 'begin': 'keyword', 'class': 'keyword', 'default': 'keyword', 'delegate': 'keyword', 'do!': 'keyword', 'done': 'keyword', 'downcast': 'keyword', 'downto': 'keyword', 'elif': 'keyword', 'extern': 'keyword', 'finally': 'keyword', 'for': 'keyword', 'function': 'keyword', 'global': 'keyword', 'inherit': 'keyword', 'inline': 'keyword', 'interface': 'keyword', 'internal': 'keyword', 'lazy': 'keyword', 'let!': 'keyword', 'match': 'keyword', 'member': 'keyword', 'module': 'keyword', 'mutable': 'keyword', 'namespace': 'keyword', 'new': 'keyword', 'null': 'keyword', 'override': 'keyword', 'private': 'keyword', 'public': 'keyword', 'return!': 'keyword', 'return': 'keyword', 'select': 'keyword', 'static': 'keyword', 'to': 'keyword', 'try': 'keyword', 'upcast': 'keyword', 'use!': 'keyword', 'use': 'keyword', 'void': 'keyword', 'when': 'keyword', 'yield!': 'keyword', 'yield': 'keyword', // Reserved words 'atomic': 'keyword', 'break': 'keyword', 'checked': 'keyword', 'component': 'keyword', 'const': 'keyword', 'constraint': 'keyword', 'constructor': 'keyword', 'continue': 'keyword', 'eager': 'keyword', 'event': 'keyword', 'external': 'keyword', 'fixed': 'keyword', 'method': 'keyword', 'mixin': 'keyword', 'object': 'keyword', 'parallel': 'keyword', 'process': 'keyword', 'protected': 'keyword', 'pure': 'keyword', 'sealed': 'keyword', 'tailcall': 'keyword', 'trait': 'keyword', 'virtual': 'keyword', 'volatile': 'keyword', // builtins 'List': 'builtin', 'Seq': 'builtin', 'Map': 'builtin', 'Set': 'builtin', 'Option': 'builtin', 'int': 'builtin', 'string': 'builtin', 'not': 'builtin', 'true': 'builtin', 'false': 'builtin', 'raise': 'builtin', 'failwith': 'builtin' }, slashComments: true }); CodeMirror.defineMIME('text/x-sml', { name: 'mllike', extraWords: { 'abstype': 'keyword', 'and': 'keyword', 'andalso': 'keyword', 'case': 'keyword', 'datatype': 'keyword', 'fn': 'keyword', 'handle': 'keyword', 'infix': 'keyword', 'infixr': 'keyword', 'local': 'keyword', 'nonfix': 'keyword', 'op': 'keyword', 'orelse': 'keyword', 'raise': 'keyword', 'withtype': 'keyword', 'eqtype': 'keyword', 'sharing': 'keyword', 'sig': 'keyword', 'signature': 'keyword', 'structure': 'keyword', 'where': 'keyword', 'true': 'keyword', 'false': 'keyword', // types 'int': 'builtin', 'real': 'builtin', 'string': 'builtin', 'char': 'builtin', 'bool': 'builtin' }, slashComments: true }); }); mllike/index.html 0000644 00000011104 15030163777 0010024 0 ustar 00 <!doctype html> <title>CodeMirror: ML-like 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=mllike.js></script> <style type=text/css> .CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;} </style> <div id=nav> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a> <ul> <li><a href="../../index.html">Home</a> <li><a href="../../doc/manual.html">Manual</a> <li><a href="https://github.com/codemirror/codemirror">Code</a> </ul> <ul> <li><a href="../index.html">Language modes</a> <li><a class=active href="#">ML-like</a> </ul> </div> <article> <h2>OCaml mode</h2> <textarea id="ocamlCode"> (* 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 *) module type S = sig type t end let x = {| this is a long string with many lines and stuff |} let b = 0b00110 let h = 0x123abcd let e = 1e-10 let i = 1. let x = 30_000 let o = 0o1234 [1; 2; 3] (* lists *) 1 @ 2 1. +. 2. </textarea> <h2>F# mode</h2> <textarea id="fsharpCode"> module CodeMirror.FSharp let rec fib = function | 0 -> 0 | 1 -> 1 | n -> fib (n - 1) + fib (n - 2) type Point = { x : int y : int } type Color = | Red | Green | Blue [0 .. 10] |> List.map ((+) 2) |> List.fold (fun x y -> x + y) 0 |> printf "%i" </textarea> <script> var ocamlEditor = CodeMirror.fromTextArea(document.getElementById('ocamlCode'), { mode: 'text/x-ocaml', lineNumbers: true, matchBrackets: true }); var fsharpEditor = CodeMirror.fromTextArea(document.getElementById('fsharpCode'), { mode: 'text/x-fsharp', lineNumbers: true, matchBrackets: true }); </script> <p><strong>MIME types defined:</strong> <code>text/x-ocaml</code> (OCaml) and <code>text/x-fsharp</code> (F#).</p> </article> haskell/index.html 0000644 00000004212 15030163777 0010174 0 ustar 00 <!doctype html> <title>CodeMirror: Haskell 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/elegant.css"> <script src="../../lib/codemirror.js"></script> <script src="../../addon/edit/matchbrackets.js"></script> <script src="haskell.js"></script> <style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> <div id=nav> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a> <ul> <li><a href="../../index.html">Home</a> <li><a href="../../doc/manual.html">Manual</a> <li><a href="https://github.com/codemirror/codemirror">Code</a> </ul> <ul> <li><a href="../index.html">Language modes</a> <li><a class=active href="#">Haskell</a> </ul> </div> <article> <h2>Haskell mode</h2> <form><textarea id="code" name="code"> module UniquePerms ( uniquePerms ) where -- | Find all unique permutations of a list where there might be duplicates. uniquePerms :: (Eq a) => [a] -> [[a]] uniquePerms = permBag . makeBag -- | An unordered collection where duplicate values are allowed, -- but represented with a single value and a count. type Bag a = [(a, Int)] makeBag :: (Eq a) => [a] -> Bag a makeBag [] = [] makeBag (a:as) = mix a $ makeBag as where mix a [] = [(a,1)] mix a (bn@(b,n):bs) | a == b = (b,n+1):bs | otherwise = bn : mix a bs permBag :: Bag a -> [[a]] permBag [] = [[]] permBag bs = concatMap (\(f,cs) -> map (f:) $ permBag cs) . oneOfEach $ bs where oneOfEach [] = [] oneOfEach (an@(a,n):bs) = let bs' = if n == 1 then bs else (a,n-1):bs in (a,bs') : mapSnd (an:) (oneOfEach bs) apSnd f (a,b) = (a, f b) mapSnd = map . apSnd </textarea></form> <script> var editor = CodeMirror.fromTextArea(document.getElementById("code"), { lineNumbers: true, matchBrackets: true, theme: "elegant" }); </script> <p><strong>MIME types defined:</strong> <code>text/x-haskell</code>.</p> </article> haskell/haskell.js 0000644 00000017745 15030163777 0010177 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode("haskell", function(_config, modeConfig) { function switchState(source, setState, f) { setState(f); return f(source, setState); } // These should all be Unicode extended, as per the Haskell 2010 report var smallRE = /[a-z_]/; var largeRE = /[A-Z]/; var digitRE = /\d/; var hexitRE = /[0-9A-Fa-f]/; var octitRE = /[0-7]/; var idRE = /[a-z_A-Z0-9'\xa1-\uffff]/; var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:]/; var specialRE = /[(),;[\]`{}]/; var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer function normal(source, setState) { if (source.eatWhile(whiteCharRE)) { return null; } var ch = source.next(); if (specialRE.test(ch)) { if (ch == '{' && source.eat('-')) { var t = "comment"; if (source.eat('#')) { t = "meta"; } return switchState(source, setState, ncomment(t, 1)); } return null; } if (ch == '\'') { if (source.eat('\\')) { source.next(); // should handle other escapes here } else { source.next(); } if (source.eat('\'')) { return "string"; } return "string error"; } if (ch == '"') { return switchState(source, setState, stringLiteral); } if (largeRE.test(ch)) { source.eatWhile(idRE); if (source.eat('.')) { return "qualifier"; } return "variable-2"; } if (smallRE.test(ch)) { source.eatWhile(idRE); return "variable"; } if (digitRE.test(ch)) { if (ch == '0') { if (source.eat(/[xX]/)) { source.eatWhile(hexitRE); // should require at least 1 return "integer"; } if (source.eat(/[oO]/)) { source.eatWhile(octitRE); // should require at least 1 return "number"; } } source.eatWhile(digitRE); var t = "number"; if (source.match(/^\.\d+/)) { t = "number"; } if (source.eat(/[eE]/)) { t = "number"; source.eat(/[-+]/); source.eatWhile(digitRE); // should require at least 1 } return t; } if (ch == "." && source.eat(".")) return "keyword"; if (symbolRE.test(ch)) { if (ch == '-' && source.eat(/-/)) { source.eatWhile(/-/); if (!source.eat(symbolRE)) { source.skipToEnd(); return "comment"; } } var t = "variable"; if (ch == ':') { t = "variable-2"; } source.eatWhile(symbolRE); return t; } return "error"; } function ncomment(type, nest) { if (nest == 0) { return normal; } return function(source, setState) { var currNest = nest; while (!source.eol()) { var ch = source.next(); if (ch == '{' && source.eat('-')) { ++currNest; } else if (ch == '-' && source.eat('}')) { --currNest; if (currNest == 0) { setState(normal); return type; } } } setState(ncomment(type, currNest)); return type; }; } function stringLiteral(source, setState) { while (!source.eol()) { var ch = source.next(); if (ch == '"') { setState(normal); return "string"; } if (ch == '\\') { if (source.eol() || source.eat(whiteCharRE)) { setState(stringGap); return "string"; } if (source.eat('&')) { } else { source.next(); // should handle other escapes here } } } setState(normal); return "string error"; } function stringGap(source, setState) { if (source.eat('\\')) { return switchState(source, setState, stringLiteral); } source.next(); setState(normal); return "error"; } var wellKnownWords = (function() { var wkw = {}; function setType(t) { return function () { for (var i = 0; i < arguments.length; i++) wkw[arguments[i]] = t; }; } setType("keyword")( "case", "class", "data", "default", "deriving", "do", "else", "foreign", "if", "import", "in", "infix", "infixl", "infixr", "instance", "let", "module", "newtype", "of", "then", "type", "where", "_"); setType("keyword")( "\.\.", ":", "::", "=", "\\", "<-", "->", "@", "~", "=>"); setType("builtin")( "!!", "$!", "$", "&&", "+", "++", "-", ".", "/", "/=", "<", "<*", "<=", "<$>", "<*>", "=<<", "==", ">", ">=", ">>", ">>=", "^", "^^", "||", "*", "*>", "**"); setType("builtin")( "Applicative", "Bool", "Bounded", "Char", "Double", "EQ", "Either", "Enum", "Eq", "False", "FilePath", "Float", "Floating", "Fractional", "Functor", "GT", "IO", "IOError", "Int", "Integer", "Integral", "Just", "LT", "Left", "Maybe", "Monad", "Nothing", "Num", "Ord", "Ordering", "Rational", "Read", "ReadS", "Real", "RealFloat", "RealFrac", "Right", "Show", "ShowS", "String", "True"); setType("builtin")( "abs", "acos", "acosh", "all", "and", "any", "appendFile", "asTypeOf", "asin", "asinh", "atan", "atan2", "atanh", "break", "catch", "ceiling", "compare", "concat", "concatMap", "const", "cos", "cosh", "curry", "cycle", "decodeFloat", "div", "divMod", "drop", "dropWhile", "either", "elem", "encodeFloat", "enumFrom", "enumFromThen", "enumFromThenTo", "enumFromTo", "error", "even", "exp", "exponent", "fail", "filter", "flip", "floatDigits", "floatRadix", "floatRange", "floor", "fmap", "foldl", "foldl1", "foldr", "foldr1", "fromEnum", "fromInteger", "fromIntegral", "fromRational", "fst", "gcd", "getChar", "getContents", "getLine", "head", "id", "init", "interact", "ioError", "isDenormalized", "isIEEE", "isInfinite", "isNaN", "isNegativeZero", "iterate", "last", "lcm", "length", "lex", "lines", "log", "logBase", "lookup", "map", "mapM", "mapM_", "max", "maxBound", "maximum", "maybe", "min", "minBound", "minimum", "mod", "negate", "not", "notElem", "null", "odd", "or", "otherwise", "pi", "pred", "print", "product", "properFraction", "pure", "putChar", "putStr", "putStrLn", "quot", "quotRem", "read", "readFile", "readIO", "readList", "readLn", "readParen", "reads", "readsPrec", "realToFrac", "recip", "rem", "repeat", "replicate", "return", "reverse", "round", "scaleFloat", "scanl", "scanl1", "scanr", "scanr1", "seq", "sequence", "sequence_", "show", "showChar", "showList", "showParen", "showString", "shows", "showsPrec", "significand", "signum", "sin", "sinh", "snd", "span", "splitAt", "sqrt", "subtract", "succ", "sum", "tail", "take", "takeWhile", "tan", "tanh", "toEnum", "toInteger", "toRational", "truncate", "uncurry", "undefined", "unlines", "until", "unwords", "unzip", "unzip3", "userError", "words", "writeFile", "zip", "zip3", "zipWith", "zipWith3"); var override = modeConfig.overrideKeywords; if (override) for (var word in override) if (override.hasOwnProperty(word)) wkw[word] = override[word]; return wkw; })(); return { startState: function () { return { f: normal }; }, copyState: function (s) { return { f: s.f }; }, token: function(stream, state) { var t = state.f(stream, function(s) { state.f = s; }); var w = stream.current(); return wellKnownWords.hasOwnProperty(w) ? wellKnownWords[w] : t; }, blockCommentStart: "{-", blockCommentEnd: "-}", lineComment: "--" }; }); CodeMirror.defineMIME("text/x-haskell", "haskell"); }); cobol/cobol.js 0000644 00000024061 15030163777 0007312 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE /** * Author: Gautam Mehta * Branched from CodeMirror's Scheme mode */ (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; 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"); }); cobol/index.html 0000644 00000017634 15030163777 0007663 0 ustar 00 <!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="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a> <ul> <li><a href="../../index.html">Home</a> <li><a href="../../doc/manual.html">Manual</a> <li><a href="https://github.com/codemirror/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.fontSize = 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> z80/index.html 0000644 00000002566 15030163777 0007204 0 ustar 00 <!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>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style> <div id=nav> <a href="https://codemirror.net"><h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""></a> <ul> <li><a href="../../index.html">Home</a> <li><a href="../../doc/manual.html">Manual</a> <li><a href="https://github.com/codemirror/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 (CurCol),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 types defined:</strong> <code>text/x-z80</code>, <code>text/x-ez80</code>.</p> </article> z80/z80.js 0000644 00000006772 15030163777 0006171 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function(mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror")); else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror"], mod); else // Plain browser env mod(CodeMirror); })(function(CodeMirror) { "use strict"; CodeMirror.defineMode('z80', function(_config, parserConfig) { var ez80 = parserConfig.ez80; var keywords1, keywords2; if (ez80) { keywords1 = /^(exx?|(ld|cp)([di]r?)?|[lp]ea|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|[de]i|halt|im|in([di]mr?|ir?|irx|2r?)|ot(dmr?|[id]rx|imr?)|out(0?|[di]r?|[di]2r?)|tst(io)?|slp)(\.([sl]?i)?[sl])?\b/i; keywords2 = /^(((call|j[pr]|rst|ret[in]?)(\.([sl]?i)?[sl])?)|(rs|st)mix)\b/i; } else { 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; keywords2 = /^(call|j[pr]|ret[in]?|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+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/)) { if (ez80 && stream.eat('.')) { stream.eatWhile(/\w/); } w = stream.current(); if (stream.indentation()) { if ((state.context == 1 || state.context == 4) && variables1.test(w)) { state.context = 4; return 'var2'; } if (state.context == 2 && variables2.test(w)) { state.context = 4; return 'var3'; } if (keywords1.test(w)) { state.context = 1; return 'keyword'; } else if (keywords2.test(w)) { state.context = 2; return 'keyword'; } else if (state.context == 4 && numbers.test(w)) { return 'number'; } if (errors.test(w)) return 'error'; } else if (stream.match(numbers)) { 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 = 5; 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"); CodeMirror.defineMIME("text/x-ez80", { name: "z80", ez80: true }); }); haskell-literate/haskell-literate.js 0000644 00000002557 15030163777 0013610 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function (mod) { if (typeof exports == "object" && typeof module == "object") // CommonJS mod(require("../../lib/codemirror"), require("../haskell/haskell")) else if (typeof define == "function" && define.amd) // AMD define(["../../lib/codemirror", "../haskell/haskell"], mod) else // Plain browser env mod(CodeMirror) })(function (CodeMirror) { "use strict" CodeMirror.defineMode("haskell-literate", function (config, parserConfig) { var baseMode = CodeMirror.getMode(config, (parserConfig && parserConfig.base) || "haskell") return { startState: function () { return { inCode: false, baseState: CodeMirror.startState(baseMode) } }, token: function (stream, state) { if (stream.sol()) { if (state.inCode = stream.eat(">")) return "meta" } if (state.inCode) { return baseMode.token(stream, state.baseState) } else { stream.skipToEnd() return "comment" } }, innerMode: function (state) { return state.inCode ? {state: state.baseState, mode: baseMode} : null } } }, "haskell") CodeMirror.defineMIME("text/x-literate-haskell", "haskell-literate") }); haskell-literate/index.html 0000644 00000022246 15030163777 0012012 0 ustar 00 <!doctype html> <title>CodeMirror: Haskell-literate 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="haskell-literate.js"></script> <script src="../haskell/haskell.js"></script> <style>.CodeMirror { border-top : 1px solid #DDDDDD; border-bottom : 1px solid #DDDDDD; }</style> <div id=nav> <a href="https://codemirror.net"><h1>CodeMirror</h1><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/codemirror/codemirror">Code</a> </ul> <ul> <li><a href="../index.html">Language modes</a> <li><a class=active href="#">Haskell-literate</a> </ul> </div> <article> <h2>Haskell literate mode</h2> <form> <textarea id="code" name="code"> > {-# LANGUAGE OverloadedStrings #-} > {-# OPTIONS_GHC -fno-warn-unused-do-bind #-} > import Control.Applicative ((<$>), (<*>)) > import Data.Maybe (isJust) > import Data.Text (Text) > import Text.Blaze ((!)) > import qualified Data.Text as T > import qualified Happstack.Server as Happstack > import qualified Text.Blaze.Html5 as H > import qualified Text.Blaze.Html5.Attributes as A > import Text.Digestive > import Text.Digestive.Blaze.Html5 > import Text.Digestive.Happstack > import Text.Digestive.Util Simple forms and validation --------------------------- Let's start by creating a very simple datatype to represent a user: > data User = User > { userName :: Text > , userMail :: Text > } deriving (Show) And dive in immediately to create a `Form` for a user. The `Form v m a` type has three parameters: - `v`: the type for messages and errors (usually a `String`-like type, `Text` in this case); - `m`: the monad we are operating in, not specified here; - `a`: the return type of the `Form`, in this case, this is obviously `User`. > userForm :: Monad m => Form Text m User We create forms by using the `Applicative` interface. A few form types are provided in the `Text.Digestive.Form` module, such as `text`, `string`, `bool`... In the `digestive-functors` library, the developer is required to label each field using the `.:` operator. This might look like a bit of a burden, but it allows you to do some really useful stuff, like separating the `Form` from the actual HTML layout. > userForm = User > <$> "name" .: text Nothing > <*> "mail" .: check "Not a valid email address" checkEmail (text Nothing) The `check` function enables you to validate the result of a form. For example, we can validate the email address with a really naive `checkEmail` function. > checkEmail :: Text -> Bool > checkEmail = isJust . T.find (== '@') More validation --------------- For our example, we also want descriptions of Haskell libraries, and in order to do that, we need package versions... > type Version = [Int] We want to let the user input a version number such as `0.1.0.0`. This means we need to validate if the input `Text` is of this form, and then we need to parse it to a `Version` type. Fortunately, we can do this in a single function: `validate` allows conversion between values, which can optionally fail. `readMaybe :: Read a => String -> Maybe a` is a utility function imported from `Text.Digestive.Util`. > validateVersion :: Text -> Result Text Version > validateVersion = maybe (Error "Cannot parse version") Success . > mapM (readMaybe . T.unpack) . T.split (== '.') A quick test in GHCi: ghci> validateVersion (T.pack "0.3.2.1") Success [0,3,2,1] ghci> validateVersion (T.pack "0.oops") Error "Cannot parse version" It works! This means we can now easily add a `Package` type and a `Form` for it: > data Category = Web | Text | Math > deriving (Bounded, Enum, Eq, Show) > data Package = Package Text Version Category > deriving (Show) > packageForm :: Monad m => Form Text m Package > packageForm = Package > <$> "name" .: text Nothing > <*> "version" .: validate validateVersion (text (Just "0.0.0.1")) > <*> "category" .: choice categories Nothing > where > categories = [(x, T.pack (show x)) | x <- [minBound .. maxBound]] Composing forms --------------- A release has an author and a package. Let's use this to illustrate the composability of the digestive-functors library: we can reuse the forms we have written earlier on. > data Release = Release User Package > deriving (Show) > releaseForm :: Monad m => Form Text m Release > releaseForm = Release > <$> "author" .: userForm > <*> "package" .: packageForm Views ----- As mentioned before, one of the advantages of using digestive-functors is separation of forms and their actual HTML layout. In order to do this, we have another type, `View`. We can get a `View` from a `Form` by supplying input. A `View` contains more information than a `Form`, it has: - the original form; - the input given by the user; - any errors that have occurred. It is this view that we convert to HTML. For this tutorial, we use the [blaze-html] library, and some helpers from the `digestive-functors-blaze` library. [blaze-html]: http://jaspervdj.be/blaze/ Let's write a view for the `User` form. As you can see, we here refer to the different fields in the `userForm`. The `errorList` will generate a list of errors for the `"mail"` field. > userView :: View H.Html -> H.Html > userView view = do > label "name" view "Name: " > inputText "name" view > H.br > > errorList "mail" view > label "mail" view "Email address: " > inputText "mail" view > H.br Like forms, views are also composable: let's illustrate that by adding a view for the `releaseForm`, in which we reuse `userView`. In order to do this, we take only the parts relevant to the author from the view by using `subView`. We can then pass the resulting view to our own `userView`. We have no special view code for `Package`, so we can just add that to `releaseView` as well. `childErrorList` will generate a list of errors for each child of the specified form. In this case, this means a list of errors from `"package.name"` and `"package.version"`. Note how we use `foo.bar` to refer to nested forms. > releaseView :: View H.Html -> H.Html > releaseView view = do > H.h2 "Author" > userView $ subView "author" view > > H.h2 "Package" > childErrorList "package" view > > label "package.name" view "Name: " > inputText "package.name" view > H.br > > label "package.version" view "Version: " > inputText "package.version" view > H.br > > label "package.category" view "Category: " > inputSelect "package.category" view > H.br The attentive reader might have wondered what the type parameter for `View` is: it is the `String`-like type used for e.g. error messages. But wait! We have releaseForm :: Monad m => Form Text m Release releaseView :: View H.Html -> H.Html ... doesn't this mean that we need a `View Text` rather than a `View Html`? The answer is yes -- but having `View Html` allows us to write these views more easily with the `digestive-functors-blaze` library. Fortunately, we will be able to fix this using the `Functor` instance of `View`. fmap :: Monad m => (v -> w) -> View v -> View w A backend --------- To finish this tutorial, we need to be able to actually run this code. We need an HTTP server for that, and we use [Happstack] for this tutorial. The `digestive-functors-happstack` library gives about everything we need for this. [Happstack]: http://happstack.com/ > site :: Happstack.ServerPart Happstack.Response > site = do > Happstack.decodeBody $ Happstack.defaultBodyPolicy "/tmp" 4096 4096 4096 > r <- runForm "test" releaseForm > case r of > (view, Nothing) -> do > let view' = fmap H.toHtml view > Happstack.ok $ Happstack.toResponse $ > template $ > form view' "/" $ do > releaseView view' > H.br > inputSubmit "Submit" > (_, Just release) -> Happstack.ok $ Happstack.toResponse $ > template $ do > css > H.h1 "Release received" > H.p $ H.toHtml $ show release > > main :: IO () > main = Happstack.simpleHTTP Happstack.nullConf site Utilities --------- > template :: H.Html -> H.Html > template body = H.docTypeHtml $ do > H.head $ do > H.title "digestive-functors tutorial" > css > H.body body > css :: H.Html > css = H.style ! A.type_ "text/css" $ do > "label {width: 130px; float: left; clear: both}" > "ul.digestive-functors-error-list {" > " color: red;" > " list-style-type: none;" > " padding-left: 0px;" > "}" </textarea> </form> <p><strong>MIME types defined:</strong> <code>text/x-literate-haskell</code>.</p> <p>Parser configuration parameters recognized: <code>base</code> to set the base mode (defaults to <code>"haskell"</code>).</p> <script> var editor = CodeMirror.fromTextArea(document.getElementById("code"), {mode: "haskell-literate"}); </script> </article> wast/test.js 0000644 00000040327 15030163777 0007056 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others // Distributed under an MIT license: https://codemirror.net/LICENSE (function() { var mode = CodeMirror.getMode({indentUnit: 4}, "wast"); function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));} MT('number-test', '[number 0]', '[number 123]', '[number nan]', '[number inf]', '[number infinity]', '[number 0.1]', '[number 123.0]', '[number 12E+99]'); MT('string-literals-test', '[string "foo"]', '[string "\\"foo\\""]', '[string "foo #\\"# bar"]'); MT('atom-test', '[atom anyfunc]', '[atom i32]', '[atom i64]', '[atom f32]', '[atom f64]'); MT('keyword-test', '[keyword br]', '[keyword if]', '[keyword loop]', '[keyword i32.add]', '[keyword local.get]'); MT('control-instructions', '[keyword unreachable]', '[keyword nop]', '[keyword br] [variable-2 $label0]', '[keyword br_if] [variable-2 $label0]', '[keyword br_table] [variable-2 $label0] [variable-2 $label1] [variable-2 $label3]', '[keyword return]', '[keyword call] [variable-2 $func0]', '[keyword call_indirect] ([keyword param] [atom f32] [atom f64]) ([keyword result] [atom i32] [atom i64])', '[keyword return_call] [variable-2 $func0]', '[keyword return_call_indirect] ([keyword param] [atom f32] [atom f64]) ([keyword result] [atom i32] [atom i64])'); MT('memory-instructions', '[keyword i32.load] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i32.load8_s] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i32.load8_u] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i32.load16_s] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i32.load16_u] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i32.store] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i32.store8] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i32.store16] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i64.store] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i64.load] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i64.load8_s] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i64.load8_u] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i64.load16_s] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i64.load16_u] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i64.load32_s] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i64.load32_u] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i64.store8] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i64.store16] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword i64.store32] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword f32.load] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword f32.store] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword f64.load] [keyword offset]=[number 4] [keyword align]=[number 4]', '[keyword f64.store] [keyword offset]=[number 4] [keyword align]=[number 4]'); MT('atomic-memory-instructions', '[keyword memory.atomic.notify] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword memory.atomic.wait32] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword memory.atomic.wait64] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.load] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.load8_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.load16_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.store] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.store8] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.store16] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.load] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.load8_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.load16_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.load32_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.store] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.store8] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.store16] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.store32] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw.add] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw8.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw16.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw.add] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw8.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw16.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw32.add_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw.sub] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw8.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw16.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw.sub] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw8.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw16.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw32.sub_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw.and] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw8.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw16.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw.and] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw8.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw16.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw32.and_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw.or] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw8.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw16.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw.or] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw8.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw16.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw32.or_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw.xor] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw8.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw16.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw.xor] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw8.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw16.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw32.xor_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw.xchg] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw8.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw16.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw.xchg] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw8.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw16.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw32.xchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw.cmpxchg] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw8.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i32.atomic.rmw16.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw.cmpxchg] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw8.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw16.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i64.atomic.rmw32.cmpxchg_u] [keyword offset]=[number 32] [keyword align]=[number 4]'); MT('simd-instructions', '[keyword v128.load] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword i16x8.load8x8_s] [keyword offset]=[number 64] [keyword align]=[number 0]', '[keyword i16x8.load8x8_u] [keyword offset]=[number 64] [keyword align]=[number 0]', '[keyword i32x4.load16x4_s] [keyword offset]=[number 64] [keyword align]=[number 0]', '[keyword i32x4.load16x4_u] [keyword offset]=[number 64] [keyword align]=[number 0]', '[keyword i64x2.load32x2_s] [keyword offset]=[number 64] [keyword align]=[number 0]', '[keyword i64x2.load32x2_u] [keyword offset]=[number 64] [keyword align]=[number 0]', '[keyword v8x16.load_splat] [keyword offset]=[number 64] [keyword align]=[number 0]', '[keyword v16x8.load_splat] [keyword offset]=[number 64] [keyword align]=[number 0]', '[keyword v32x4.load_splat] [keyword offset]=[number 64] [keyword align]=[number 0]', '[keyword v64x2.load_splat] [keyword offset]=[number 64] [keyword align]=[number 0]', '[keyword v128.store] [keyword offset]=[number 32] [keyword align]=[number 4]', '[keyword v128.const] [number 0] [number 1] [number 2] [number 3] [number 4] [number 5] [number 6] [number 7] [number 8] [number 9] [number 10] [number 11] [number 12] [number 13] [number 14] [number 15]', '[keyword v8x16.shuffle] [number 0] [number 1] [number 2] [number 3] [number 4] [number 5] [number 6] [number 7] [number 8] [number 9] [number 10] [number 11] [number 12] [number 13] [number 14] [number 15]', '[keyword v8x16.swizzle]', '[keyword i8x16.splat]', '[keyword i16x8.splat]', '[keyword i32x4.splat]', '[keyword i64x2.splat]', '[keyword f32x4.splat]', '[keyword f64x2.splat]', '[keyword i8x16.extract_lane_s] [number 1]', '[keyword i8x16.extract_lane_u] [number 1]', '[keyword i8x16.replace_lane] [number 1]', '[keyword i16x8.extract_lane_s] [number 1]', '[keyword i16x8.extract_lane_u] [number 1]', '[keyword i16x8.replace_lane] [number 1]', '[keyword i32x4.extract_lane] [number 1]', '[keyword i32x4.replace_lane] [number 1]', '[keyword i64x2.extract_lane] [number 1]', '[keyword i64x2.replace_lane] [number 1]', '[keyword f32x4.extract_lane] [number 1]', '[keyword f32x4.replace_lane] [number 1]', '[keyword f64x2.extract_lane] [number 1]', '[keyword f64x2.replace_lane] [number 1]', '[keyword i8x16.eq]', '[keyword i8x16.ne]', '[keyword i8x16.lt_s]', '[keyword i8x16.lt_u]', '[keyword i8x16.gt_s]', '[keyword i8x16.gt_u]', '[keyword i8x16.le_s]', '[keyword i8x16.le_u]', '[keyword i8x16.ge_s]', '[keyword i8x16.ge_u]', '[keyword i16x8.eq]', '[keyword i16x8.ne]', '[keyword i16x8.lt_s]', '[keyword i16x8.lt_u]', '[keyword i16x8.gt_s]', '[keyword i16x8.gt_u]', '[keyword i16x8.le_s]', '[keyword i16x8.le_u]', '[keyword i16x8.ge_s]', '[keyword i16x8.ge_u]', '[keyword i32x4.eq]', '[keyword i32x4.ne]', '[keyword i32x4.lt_s]', '[keyword i32x4.lt_u]', '[keyword i32x4.gt_s]', '[keyword i32x4.gt_u]', '[keyword i32x4.le_s]', '[keyword i32x4.le_u]', '[keyword i32x4.ge_s]', '[keyword i32x4.ge_u]', '[keyword f32x4.eq]', '[keyword f32x4.ne]', '[keyword f32x4.lt]', '[keyword f32x4.gt]', '[keyword f32x4.le]', '[keyword f32x4.ge]', '[keyword f64x2.eq]', '[keyword f64x2.ne]', '[keyword f64x2.lt]', '[keyword f64x2.gt]', '[keyword f64x2.le]', '[keyword f64x2.ge]', '[keyword v128.not]', '[keyword v128.and]', '[keyword v128.andnot]', '[keyword v128.or]', '[keyword v128.xor]', '[keyword v128.bitselect]', '[keyword i8x16.abs]', '[keyword i8x16.neg]', '[keyword i8x16.any_true]', '[keyword i8x16.all_true]', '[keyword i8x16.bitmask]', '[keyword i8x16.narrow_i16x8_s]', '[keyword i8x16.narrow_i16x8_u]', '[keyword i8x16.shl]', '[keyword i8x16.shr_s]', '[keyword i8x16.shr_u]', '[keyword i8x16.add]', '[keyword i8x16.add_saturate_s]', '[keyword i8x16.add_saturate_u]', '[keyword i8x16.sub]', '[keyword i8x16.sub_saturate_s]', '[keyword i8x16.sub_saturate_u]', '[keyword i8x16.min_s]', '[keyword i8x16.min_u]', '[keyword i8x16.max_s]', '[keyword i8x16.max_u]', '[keyword i8x16.avgr_u]', '[keyword i16x8.abs]', '[keyword i16x8.neg]', '[keyword i16x8.any_true]', '[keyword i16x8.all_true]', '[keyword i16x8.bitmask]', '[keyword i16x8.narrow_i32x4_s]', '[keyword i16x8.narrow_i32x4_u]', '[keyword i16x8.widen_low_i8x16_s]', '[keyword i16x8.widen_high_i8x16_s]', '[keyword i16x8.widen_low_i8x16_u]', '[keyword i16x8.widen_high_i8x16_u]', '[keyword i16x8.shl]', '[keyword i16x8.shr_s]', '[keyword i16x8.shr_u]', '[keyword i16x8.add]', '[keyword i16x8.add_saturate_s]', '[keyword i16x8.add_saturate_u]', '[keyword i16x8.sub]', '[keyword i16x8.sub_saturate_s]', '[keyword i16x8.sub_saturate_u]', '[keyword i16x8.mul]', '[keyword i16x8.min_s]', '[keyword i16x8.min_u]', '[keyword i16x8.max_s]', '[keyword i16x8.max_u]', '[keyword i16x8.avgr_u]', '[keyword i32x4.abs]', '[keyword i32x4.neg]', '[keyword i32x4.any_true]', '[keyword i32x4.all_true]', '[keyword i32x4.bitmask]', '[keyword i32x4.widen_low_i16x8_s]', '[keyword i32x4.widen_high_i16x8_s]', '[keyword i32x4.widen_low_i16x8_u]', '[keyword i32x4.widen_high_i16x8_u]', '[keyword i32x4.shl]', '[keyword i32x4.shr_s]', '[keyword i32x4.shr_u]', '[keyword i32x4.add]', '[keyword i32x4.sub]', '[keyword i32x4.mul]', '[keyword i32x4.min_s]', '[keyword i32x4.min_u]', '[keyword i32x4.max_s]', '[keyword i32x4.max_u]', '[keyword i64x2.neg]', '[keyword i64x2.shl]', '[keyword i64x2.shr_s]', '[keyword i64x2.shr_u]', '[keyword i64x2.add]', '[keyword i64x2.sub]', '[keyword i64x2.mul]', '[keyword f32x4.abs]', '[keyword f32x4.neg]', '[keyword f32x4.sqrt]', '[keyword f32x4.add]', '[keyword f32x4.sub]', '[keyword f32x4.mul]', '[keyword f32x4.div]', '[keyword f32x4.min]', '[keyword f32x4.max]', '[keyword f64x2.abs]', '[keyword f64x2.neg]', '[keyword f64x2.sqrt]', '[keyword f64x2.add]', '[keyword f64x2.sub]', '[keyword f64x2.mul]', '[keyword f64x2.div]', '[keyword f64x2.min]', '[keyword f64x2.max]', '[keyword i32x4.trunc_sat_f32x4_s]', '[keyword i32x4.trunc_sat_f32x4_u]', '[keyword f32x4.convert_i32x4_s]', '[keyword f32x4.convert_i32x4_u]'); })(); wast/index.html 0000644 00000003355 15030163777 0007536 0 ustar 00 <!DOCTYPE html> <title>CodeMirror: Rust 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/simple.js"></script> <script src="wast.js"></script> <style> .CodeMirror { border-top: 1px solid black; border-bottom: 1px solid black; } </style> <div id=nav> <a href="https://codemirror.net"> <h1>CodeMirror</h1><img id=logo src="../../doc/logo.png" alt=""> </a> <ul> <li><a href="../../index.html">Home</a> <li><a href="../../doc/manual.html">Manual</a> <li><a href="https://github.com/codemirror/codemirror">Code</a> </ul> <ul> <li><a href="../index.html">Language modes</a> <li><a class=active href="#">WebAssembly</a> </ul> </div> <article> <h2>WebAssembly mode</h2> <div><textarea id="code" name="code"> /* Example WebAssembly */ (module $foo (export "fac" (func $fac)) (export "plus" (func $plus)) (func $fac (type $t0) (param $p0 i64) (result i64) (if $I0 (result i64) (i64.lt_s (local.get $p0) (i64.const 1)) (then (i64.const 1)) (else (i64.mul (local.get $p0) (call $fac (i64.sub (local.get $p0) (i64.const 1))))))) (func $plus (param $x i32) (param $y i32) (result i32) (i32.add (local.get $x) (local.get $y))))</textarea></div> <script> var editor = CodeMirror.fromTextArea(document.getElementById("code"), { lineNumbers: true, lineWrapping: true, indentUnit: 4, mode: "wast" }); </script> <p><strong>MIME types defined:</strong> <code>text/webassembly</code>.</p> </article>