C-like mode
C++ example
Objective-C example
Java example
Scala example
Kotlin mode
Ceylon mode
Simple mode that tries to handle C-like languages as well as it
can. Takes two configuration parameters: keywords
, an
object whose property names are the keywords in the language,
and useCPP
, which determines whether C preprocessor
directives are recognized.
MIME types defined: text/x-csrc
(C), text/x-c++src
(C++), text/x-java
(Java), text/x-csharp
(C#),
text/x-objectivec
(Objective-C),
text/x-scala
(Scala), text/x-vertex
x-shader/x-fragment
(shader programs),
text/x-squirrel
(Squirrel) and
text/x-ceylon
(Ceylon)
clike/test.js 0000644 00000003617 15051524051 0007155 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function() {
var mode = CodeMirror.getMode({indentUnit: 2}, "text/x-c");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
MT("indent",
"[variable-3 void] [def foo]([variable-3 void*] [variable a], [variable-3 int] [variable b]) {",
" [variable-3 int] [variable c] [operator =] [variable b] [operator +]",
" [number 1];",
" [keyword return] [operator *][variable a];",
"}");
MT("indent_switch",
"[keyword switch] ([variable x]) {",
" [keyword case] [number 10]:",
" [keyword return] [number 20];",
" [keyword default]:",
" [variable printf]([string \"foo %c\"], [variable x]);",
"}");
MT("def",
"[variable-3 void] [def foo]() {}",
"[keyword struct] [def bar]{}",
"[variable-3 int] [variable-3 *][def baz]() {}");
MT("def_new_line",
"::[variable std]::[variable SomeTerribleType][operator <][variable T][operator >]",
"[def SomeLongMethodNameThatDoesntFitIntoOneLine]([keyword const] [variable MyType][operator &] [variable param]) {}")
MT("double_block",
"[keyword for] (;;)",
" [keyword for] (;;)",
" [variable x][operator ++];",
"[keyword return];");
MT("preprocessor",
"[meta #define FOO 3]",
"[variable-3 int] [variable foo];",
"[meta #define BAR\\]",
"[meta 4]",
"[variable-3 unsigned] [variable-3 int] [variable bar] [operator =] [number 8];",
"[meta #include ][comment // comment]")
var mode_cpp = CodeMirror.getMode({indentUnit: 2}, "text/x-c++src");
function MTCPP(name) { test.mode(name, mode_cpp, Array.prototype.slice.call(arguments, 1)); }
MTCPP("cpp14_literal",
"[number 10'000];",
"[number 0b10'000];",
"[number 0x10'000];",
"[string '100000'];");
})();
clike/scala.html 0000644 00000067546 15051524051 0007624 0 ustar 00
CodeMirror: Scala mode
Scala mode
tiddlywiki/tiddlywiki.js 0000644 00000020476 15051524051 0011443 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
/***
|''Name''|tiddlywiki.js|
|''Description''|Enables TiddlyWikiy syntax highlighting using CodeMirror|
|''Author''|PMario|
|''Version''|0.1.7|
|''Status''|''stable''|
|''Source''|[[GitHub|https://github.com/pmario/CodeMirror2/blob/tw-syntax/mode/tiddlywiki]]|
|''Documentation''|http://codemirror.tiddlyspace.com/|
|''License''|[[MIT License|http://www.opensource.org/licenses/mit-license.php]]|
|''CoreVersion''|2.5.0|
|''Requires''|codemirror.js|
|''Keywords''|syntax highlighting color code mirror codemirror|
! Info
CoreVersion parameter is needed for TiddlyWiki only!
***/
(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("tiddlywiki", function () {
// Tokenizer
var textwords = {};
var keywords = {
"allTags": true, "closeAll": true, "list": true,
"newJournal": true, "newTiddler": true,
"permaview": true, "saveChanges": true,
"search": true, "slider": true, "tabs": true,
"tag": true, "tagging": true, "tags": true,
"tiddler": true, "timeline": true,
"today": true, "version": true, "option": true,
"with": true, "filter": true
};
var isSpaceName = /[\w_\-]/i,
reHR = /^\-\-\-\-+$/, //
reWikiCommentStart = /^\/\*\*\*$/, // /***
reWikiCommentStop = /^\*\*\*\/$/, // ***/
reBlockQuote = /^<<<$/,
reJsCodeStart = /^\/\/\{\{\{$/, // //{{{ js block start
reJsCodeStop = /^\/\/\}\}\}$/, // //}}} js stop
reXmlCodeStart = /^$/, // xml block start
reXmlCodeStop = /^$/, // xml stop
reCodeBlockStart = /^\{\{\{$/, // {{{ TW text div block start
reCodeBlockStop = /^\}\}\}$/, // }}} TW text stop
reUntilCodeStop = /.*?\}\}\}/;
function chain(stream, state, f) {
state.tokenize = f;
return f(stream, state);
}
function tokenBase(stream, state) {
var sol = stream.sol(), ch = stream.peek();
state.block = false; // indicates the start of a code block.
// check start of blocks
if (sol && /[<\/\*{}\-]/.test(ch)) {
if (stream.match(reCodeBlockStart)) {
state.block = true;
return chain(stream, state, twTokenCode);
}
if (stream.match(reBlockQuote))
return 'quote';
if (stream.match(reWikiCommentStart) || stream.match(reWikiCommentStop))
return 'comment';
if (stream.match(reJsCodeStart) || stream.match(reJsCodeStop) || stream.match(reXmlCodeStart) || stream.match(reXmlCodeStop))
return 'comment';
if (stream.match(reHR))
return 'hr';
}
stream.next();
if (sol && /[\/\*!#;:>|]/.test(ch)) {
if (ch == "!") { // tw header
stream.skipToEnd();
return "header";
}
if (ch == "*") { // tw list
stream.eatWhile('*');
return "comment";
}
if (ch == "#") { // tw numbered list
stream.eatWhile('#');
return "comment";
}
if (ch == ";") { // definition list, term
stream.eatWhile(';');
return "comment";
}
if (ch == ":") { // definition list, description
stream.eatWhile(':');
return "comment";
}
if (ch == ">") { // single line quote
stream.eatWhile(">");
return "quote";
}
if (ch == '|')
return 'header';
}
if (ch == '{' && stream.match(/\{\{/))
return chain(stream, state, twTokenCode);
// rudimentary html:// file:// link matching. TW knows much more ...
if (/[hf]/i.test(ch) &&
/[ti]/i.test(stream.peek()) &&
stream.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i))
return "link";
// just a little string indicator, don't want to have the whole string covered
if (ch == '"')
return 'string';
if (ch == '~') // _no_ CamelCase indicator should be bold
return 'brace';
if (/[\[\]]/.test(ch) && stream.match(ch)) // check for [[..]]
return 'brace';
if (ch == "@") { // check for space link. TODO fix @@...@@ highlighting
stream.eatWhile(isSpaceName);
return "link";
}
if (/\d/.test(ch)) { // numbers
stream.eatWhile(/\d/);
return "number";
}
if (ch == "/") { // tw invisible comment
if (stream.eat("%")) {
return chain(stream, state, twTokenComment);
} else if (stream.eat("/")) { //
return chain(stream, state, twTokenEm);
}
}
if (ch == "_" && stream.eat("_")) // tw underline
return chain(stream, state, twTokenUnderline);
// strikethrough and mdash handling
if (ch == "-" && stream.eat("-")) {
// if strikethrough looks ugly, change CSS.
if (stream.peek() != ' ')
return chain(stream, state, twTokenStrike);
// mdash
if (stream.peek() == ' ')
return 'brace';
}
if (ch == "'" && stream.eat("'")) // tw bold
return chain(stream, state, twTokenStrong);
if (ch == "<" && stream.eat("<")) // tw macro
return chain(stream, state, twTokenMacro);
// core macro handling
stream.eatWhile(/[\w\$_]/);
return textwords.propertyIsEnumerable(stream.current()) ? "keyword" : null
}
// tw invisible comment
function twTokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = tokenBase;
break;
}
maybeEnd = (ch == "%");
}
return "comment";
}
// tw strong / bold
function twTokenStrong(stream, state) {
var maybeEnd = false,
ch;
while (ch = stream.next()) {
if (ch == "'" && maybeEnd) {
state.tokenize = tokenBase;
break;
}
maybeEnd = (ch == "'");
}
return "strong";
}
// tw code
function twTokenCode(stream, state) {
var sb = state.block;
if (sb && stream.current()) {
return "comment";
}
if (!sb && stream.match(reUntilCodeStop)) {
state.tokenize = tokenBase;
return "comment";
}
if (sb && stream.sol() && stream.match(reCodeBlockStop)) {
state.tokenize = tokenBase;
return "comment";
}
stream.next();
return "comment";
}
// tw em / italic
function twTokenEm(stream, state) {
var maybeEnd = false,
ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = tokenBase;
break;
}
maybeEnd = (ch == "/");
}
return "em";
}
// tw underlined text
function twTokenUnderline(stream, state) {
var maybeEnd = false,
ch;
while (ch = stream.next()) {
if (ch == "_" && maybeEnd) {
state.tokenize = tokenBase;
break;
}
maybeEnd = (ch == "_");
}
return "underlined";
}
// tw strike through text looks ugly
// change CSS if needed
function twTokenStrike(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "-" && maybeEnd) {
state.tokenize = tokenBase;
break;
}
maybeEnd = (ch == "-");
}
return "strikethrough";
}
// macro
function twTokenMacro(stream, state) {
if (stream.current() == '<<') {
return 'macro';
}
var ch = stream.next();
if (!ch) {
state.tokenize = tokenBase;
return null;
}
if (ch == ">") {
if (stream.peek() == '>') {
stream.next();
state.tokenize = tokenBase;
return "macro";
}
}
stream.eatWhile(/[\w\$_]/);
return keywords.propertyIsEnumerable(stream.current()) ? "keyword" : null
}
// Interface
return {
startState: function () {
return {tokenize: tokenBase};
},
token: function (stream, state) {
if (stream.eatSpace()) return null;
var style = state.tokenize(stream, state);
return style;
}
};
});
CodeMirror.defineMIME("text/x-tiddlywiki", "tiddlywiki");
});
tiddlywiki/index.html 0000644 00000010743 15051524051 0010721 0 ustar 00
CodeMirror: TiddlyWiki mode
TiddlyWiki mode
!TiddlyWiki Formatting
* Rendered versions can be found at: http://www.tiddlywiki.com/#Reference
|!Option | !Syntax |
|bold font | ''bold'' |
|italic type | //italic// |
|underlined text | __underlined__ |
|strikethrough text | --strikethrough-- |
|superscript text | super^^script^^ |
|subscript text | sub~~script~~ |
|highlighted text | @@highlighted@@ |
|preformatted text | {{{preformatted}}} |
!Block Elements
<<<
!Heading 1
!!Heading 2
!!!Heading 3
!!!!Heading 4
!!!!!Heading 5
<<<
!!Lists
<<<
* unordered list, level 1
** unordered list, level 2
*** unordered list, level 3
# ordered list, level 1
## ordered list, level 2
### unordered list, level 3
; definition list, term
: definition list, description
<<<
!!Blockquotes
<<<
> blockquote, level 1
>> blockquote, level 2
>>> blockquote, level 3
> blockquote
<<<
!!Preformatted Text
<<<
{{{
preformatted (e.g. code)
}}}
<<<
!!Code Sections
<<<
{{{
Text style code
}}}
//{{{
JS styled code. TiddlyWiki mixed mode should support highlighter switching in the future.
//}}}
XML styled code. TiddlyWiki mixed mode should support highlighter switching in the future.
<<<
!!Tables
<<<
|CssClass|k
|!heading column 1|!heading column 2|
|row 1, column 1|row 1, column 2|
|row 2, column 1|row 2, column 2|
|>|COLSPAN|
|ROWSPAN| ... |
|~| ... |
|CssProperty:value;...| ... |
|caption|c
''Annotation:''
* The {{{>}}} marker creates a "colspan", causing the current cell to merge with the one to the right.
* The {{{~}}} marker creates a "rowspan", causing the current cell to merge with the one above.
<<<
!!Images /% TODO %/
cf. [[TiddlyWiki.com|http://www.tiddlywiki.com/#EmbeddedImages]]
!Hyperlinks
* [[WikiWords|WikiWord]] are automatically transformed to hyperlinks to the respective tiddler
** the automatic transformation can be suppressed by preceding the respective WikiWord with a tilde ({{{~}}}): {{{~WikiWord}}}
* [[PrettyLinks]] are enclosed in square brackets and contain the desired tiddler name: {{{[[tiddler name]]}}}
** optionally, a custom title or description can be added, separated by a pipe character ({{{|}}}): {{{[[title|target]]}}} '''N.B.:''' In this case, the target can also be any website (i.e. URL).
!Custom Styling
* {{{@@CssProperty:value;CssProperty:value;...@@}}} ''N.B.:'' CSS color definitions should use lowercase letters to prevent the inadvertent creation of WikiWords.
* {{customCssClass{...}}}
* raw HTML can be inserted by enclosing the respective code in HTML tags: {{{ ... }}}
!Special Markers
* {{{ }}} forces a manual line break
* {{{----}}} creates a horizontal ruler
* [[HTML entities|http://www.tiddlywiki.com/#HtmlEntities]]
* [[HTML entities local|HtmlEntities]]
* {{{<>}}} calls the respective [[macro|Macros]]
* To hide text within a tiddler so that it is not displayed, it can be wrapped in {{{/%}}} and {{{%/}}}. This can be a useful trick for hiding drafts or annotating complex markup.
* To prevent wiki markup from taking effect for a particular section, that section can be enclosed in three double quotes: e.g. {{{"""WikiWord"""}}}.
TiddlyWiki mode supports a single configuration.
MIME types defined: text/x-tiddlywiki
.
tiddlywiki/tiddlywiki.css 0000644 00000000334 15051524051 0011606 0 ustar 00 span.cm-underlined {
text-decoration: underline;
}
span.cm-strikethrough {
text-decoration: line-through;
}
span.cm-brace {
color: #170;
font-weight: bold;
}
span.cm-table {
color: blue;
font-weight: bold;
}
clojure/index.html 0000644 00000004766 15051524051 0010217 0 ustar 00
CodeMirror: Clojure mode
Clojure mode
; Conway's Game of Life, based on the work of:
;; Laurent Petit https://gist.github.com/1200343
;; Christophe Grand http://clj-me.cgrand.net/2011/08/19/conways-game-of-life
(ns ^{:doc "Conway's Game of Life."}
game-of-life)
;; Core game of life's algorithm functions
(defn neighbours
"Given a cell's coordinates, returns the coordinates of its neighbours."
[[x y]]
(for [dx [-1 0 1] dy (if (zero? dx) [-1 1] [-1 0 1])]
[(+ dx x) (+ dy y)]))
(defn step
"Given a set of living cells, computes the new set of living cells."
[cells]
(set (for [[cell n] (frequencies (mapcat neighbours cells))
:when (or (= n 3) (and (= n 2) (cells cell)))]
cell)))
;; Utility methods for displaying game on a text terminal
(defn print-board
"Prints a board on *out*, representing a step in the game."
[board w h]
(doseq [x (range (inc w)) y (range (inc h))]
(if (= y 0) (print "\n"))
(print (if (board [x y]) "[X]" " . "))))
(defn display-grids
"Prints a squence of boards on *out*, representing several steps."
[grids w h]
(doseq [board grids]
(print-board board w h)
(print "\n")))
;; Launches an example board
(def
^{:doc "board represents the initial set of living cells"}
board #{[2 1] [2 2] [2 3]})
(display-grids (take 3 (iterate step board)) 5 5)
;; Let's play with characters
(println \1 \a \# \\
\" \( \newline
\} \" \space
\tab \return \backspace
\u1000 \uAaAa \u9F9F)
;; Let's play with numbers
(+ 1 -1 1/2 -1/2 -0.5 0.5)
MIME types defined: text/x-clojure
.
clojure/clojure.js 0000644 00000037205 15051524051 0010215 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
/**
* Author: Hans Engel
* Branched from CodeMirror's Scheme mode (by Koh Zi Han, based on implementation by Koh Zi Chun)
*/
(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("clojure", function (options) {
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string", CHARACTER = "string-2",
ATOM = "atom", NUMBER = "number", BRACKET = "bracket", KEYWORD = "keyword", VAR = "variable";
var INDENT_WORD_SKIP = options.indentUnit || 2;
var NORMAL_INDENT_UNIT = options.indentUnit || 2;
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 nil");
var keywords = makeKeywords(
"defn defn- def def- defonce defmulti defmethod defmacro defstruct deftype defprotocol defrecord defproject deftest " +
"slice defalias defhinted defmacro- defn-memo defnk defnk defonce- defunbound defunbound- defvar defvar- let letfn " +
"do case cond condp for loop recur when when-not when-let when-first if if-let if-not . .. -> ->> doto and or dosync " +
"doseq dotimes dorun doall load import unimport ns in-ns refer try catch finally throw with-open with-local-vars " +
"binding gen-class gen-and-load-class gen-and-save-class handler-case handle");
var builtins = makeKeywords(
"* *' *1 *2 *3 *agent* *allow-unresolved-vars* *assert* *clojure-version* *command-line-args* *compile-files* " +
"*compile-path* *compiler-options* *data-readers* *e *err* *file* *flush-on-newline* *fn-loader* *in* " +
"*math-context* *ns* *out* *print-dup* *print-length* *print-level* *print-meta* *print-readably* *read-eval* " +
"*source-path* *unchecked-math* *use-context-classloader* *verbose-defrecords* *warn-on-reflection* + +' - -' -> " +
"->> ->ArrayChunk ->Vec ->VecNode ->VecSeq -cache-protocol-fn -reset-methods .. / < <= = == > >= EMPTY-NODE accessor " +
"aclone add-classpath add-watch agent agent-error agent-errors aget alength alias all-ns alter alter-meta! " +
"alter-var-root amap ancestors and apply areduce array-map aset aset-boolean aset-byte aset-char aset-double " +
"aset-float aset-int aset-long aset-short assert assoc assoc! assoc-in associative? atom await await-for await1 " +
"bases bean bigdec bigint biginteger binding bit-and bit-and-not bit-clear bit-flip bit-not bit-or bit-set " +
"bit-shift-left bit-shift-right bit-test bit-xor boolean boolean-array booleans bound-fn bound-fn* bound? butlast " +
"byte byte-array bytes case cat cast char char-array char-escape-string char-name-string char? chars chunk chunk-append " +
"chunk-buffer chunk-cons chunk-first chunk-next chunk-rest chunked-seq? class class? clear-agent-errors " +
"clojure-version coll? comment commute comp comparator compare compare-and-set! compile complement completing concat cond condp " +
"conj conj! cons constantly construct-proxy contains? count counted? create-ns create-struct cycle dec dec' decimal? " +
"declare dedupe default-data-readers definline definterface defmacro defmethod defmulti defn defn- defonce defprotocol " +
"defrecord defstruct deftype delay delay? deliver denominator deref derive descendants destructure disj disj! dissoc " +
"dissoc! distinct distinct? doall dorun doseq dosync dotimes doto double double-array doubles drop drop-last " +
"drop-while eduction empty empty? ensure enumeration-seq error-handler error-mode eval even? every-pred every? ex-data ex-info " +
"extend extend-protocol extend-type extenders extends? false? ffirst file-seq filter filterv find find-keyword " +
"find-ns find-protocol-impl find-protocol-method find-var first flatten float float-array float? floats flush fn fn? " +
"fnext fnil for force format frequencies future future-call future-cancel future-cancelled? future-done? future? " +
"gen-class gen-interface gensym get get-in get-method get-proxy-class get-thread-bindings get-validator group-by hash " +
"hash-combine hash-map hash-set identical? identity if-let if-not ifn? import in-ns inc inc' init-proxy instance? " +
"int int-array integer? interleave intern interpose into into-array ints io! isa? iterate iterator-seq juxt keep " +
"keep-indexed key keys keyword keyword? last lazy-cat lazy-seq let letfn line-seq list list* list? load load-file " +
"load-reader load-string loaded-libs locking long long-array longs loop macroexpand macroexpand-1 make-array " +
"make-hierarchy map map-indexed map? mapcat mapv max max-key memfn memoize merge merge-with meta method-sig methods " +
"min min-key mod munge name namespace namespace-munge neg? newline next nfirst nil? nnext not not-any? not-empty " +
"not-every? not= ns ns-aliases ns-imports ns-interns ns-map ns-name ns-publics ns-refers ns-resolve ns-unalias " +
"ns-unmap nth nthnext nthrest num number? numerator object-array odd? or parents partial partition partition-all " +
"partition-by pcalls peek persistent! pmap pop pop! pop-thread-bindings pos? pr pr-str prefer-method prefers " +
"primitives-classnames print print-ctor print-dup print-method print-simple print-str printf println println-str " +
"prn prn-str promise proxy proxy-call-with-super proxy-mappings proxy-name proxy-super push-thread-bindings pvalues " +
"quot rand rand-int rand-nth random-sample range ratio? rational? rationalize re-find re-groups re-matcher re-matches re-pattern " +
"re-seq read read-line read-string realized? reduce reduce-kv reductions ref ref-history-count ref-max-history " +
"ref-min-history ref-set refer refer-clojure reify release-pending-sends rem remove remove-all-methods " +
"remove-method remove-ns remove-watch repeat repeatedly replace replicate require reset! reset-meta! resolve rest " +
"restart-agent resultset-seq reverse reversible? rseq rsubseq satisfies? second select-keys send send-off seq seq? " +
"seque sequence sequential? set set-error-handler! set-error-mode! set-validator! set? short short-array shorts " +
"shuffle shutdown-agents slurp some some-fn sort sort-by sorted-map sorted-map-by sorted-set sorted-set-by sorted? " +
"special-symbol? spit split-at split-with str string? struct struct-map subs subseq subvec supers swap! symbol " +
"symbol? sync take take-last take-nth take-while test the-ns thread-bound? time to-array to-array-2d trampoline transduce " +
"transient tree-seq true? type unchecked-add unchecked-add-int unchecked-byte unchecked-char unchecked-dec " +
"unchecked-dec-int unchecked-divide-int unchecked-double unchecked-float unchecked-inc unchecked-inc-int " +
"unchecked-int unchecked-long unchecked-multiply unchecked-multiply-int unchecked-negate unchecked-negate-int "+
"unchecked-remainder-int unchecked-short unchecked-subtract unchecked-subtract-int underive unquote " +
"unquote-splicing update update-in update-proxy use val vals var-get var-set var? vary-meta vec vector vector-of " +
"vector? volatile! volatile? vreset! vswap! when when-first when-let when-not while with-bindings with-bindings* with-in-str with-loading-context " +
"with-local-vars with-meta with-open with-out-str with-precision with-redefs with-redefs-fn xml-seq zero? zipmap " +
"*default-data-reader-fn* as-> cond-> cond->> reduced reduced? send-via set-agent-send-executor! " +
"set-agent-send-off-executor! some-> some->>");
var indentKeys = makeKeywords(
// Built-ins
"ns fn def defn defmethod bound-fn if if-not case condp when while when-not when-first do future comment doto " +
"locking proxy with-open with-precision reify deftype defrecord defprotocol extend extend-protocol extend-type " +
"try catch " +
// Binding forms
"let letfn binding loop for doseq dotimes when-let if-let " +
// Data structures
"defstruct struct-map assoc " +
// clojure.test
"testing deftest " +
// contrib
"handler-case handle dotrace deftrace");
var tests = {
digit: /\d/,
digit_or_colon: /[\d:]/,
hex: /[0-9a-f]/i,
sign: /[+-]/,
exponent: /e/i,
keyword_char: /[^\s\(\[\;\)\]]/,
symbol: /[\w*+!\-\._?:<>\/\xa1-\uffff]/,
block_indent: /^(?:def|with)[^\/]+$|\/(?:def|with)/
};
function stateStack(indent, type, prev) { // represents a state stack object
this.indent = indent;
this.type = type;
this.prev = prev;
}
function pushStack(state, indent, type) {
state.indentStack = new stateStack(indent, type, state.indentStack);
}
function popStack(state) {
state.indentStack = state.indentStack.prev;
}
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);
} else 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;
}
// Eat character that starts after backslash \
function eatCharacter(stream) {
var first = stream.next();
// Read special literals: backspace, newline, space, return.
// Just read all lowercase letters.
if (first && first.match(/[a-z]/) && stream.match(/[a-z]+/, true)) {
return;
}
// Read unicode character: \u1000 \uA0a1
if (first === "u") {
stream.match(/[0-9a-z]{4}/i, true);
}
}
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 = stream.indentation();
}
// skip spaces
if (state.mode != "string" && stream.eatSpace()) {
return null;
}
var returnType = null;
switch(state.mode){
case "string": // multi-line string parsing mode
var next, escaped = false;
while ((next = stream.next()) != null) {
if (next == "\"" && !escaped) {
state.mode = false;
break;
}
escaped = !escaped && next == "\\";
}
returnType = STRING; // continue on in string mode
break;
default: // default parsing mode
var ch = stream.next();
if (ch == "\"") {
state.mode = "string";
returnType = STRING;
} else if (ch == "\\") {
eatCharacter(stream);
returnType = CHARACTER;
} else if (ch == "'" && !( tests.digit_or_colon.test(stream.peek()) )) {
returnType = ATOM;
} else if (ch == ";") { // comment
stream.skipToEnd(); // rest of the line is a comment
returnType = COMMENT;
} else if (isNumber(ch,stream)){
returnType = NUMBER;
} else if (ch == "(" || ch == "[" || ch == "{" ) {
var keyWord = '', indentTemp = stream.column(), letter;
/**
Either
(indent-word ..
(non-indent-word ..
(;something else, bracket, etc.
*/
if (ch == "(") while ((letter = stream.eat(tests.keyword_char)) != null) {
keyWord += letter;
}
if (keyWord.length > 0 && (indentKeys.propertyIsEnumerable(keyWord) ||
tests.block_indent.test(keyWord))) { // indent-word
pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
} else { // non-indent word
// we continue eating the spaces
stream.eatSpace();
if (stream.eol() || stream.peek() == ";") {
// nothing significant after
// we restart indentation the user defined spaces after
pushStack(state, indentTemp + NORMAL_INDENT_UNIT, ch);
} else {
pushStack(state, indentTemp + stream.current().length, ch); // else we match
}
}
stream.backUp(stream.current().length - 1); // undo all the eating
returnType = BRACKET;
} else if (ch == ")" || ch == "]" || ch == "}") {
returnType = BRACKET;
if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : (ch == "]" ? "[" :"{"))) {
popStack(state);
}
} else if ( ch == ":" ) {
stream.eatWhile(tests.symbol);
return ATOM;
} else {
stream.eatWhile(tests.symbol);
if (keywords && keywords.propertyIsEnumerable(stream.current())) {
returnType = KEYWORD;
} else if (builtins && builtins.propertyIsEnumerable(stream.current())) {
returnType = BUILTIN;
} else if (atoms && atoms.propertyIsEnumerable(stream.current())) {
returnType = ATOM;
} else {
returnType = VAR;
}
}
}
return returnType;
},
indent: function (state) {
if (state.indentStack == null) return state.indentation;
return state.indentStack.indent;
},
closeBrackets: {pairs: "()[]{}\"\""},
lineComment: ";;"
};
});
CodeMirror.defineMIME("text/x-clojure", "clojure");
CodeMirror.defineMIME("text/x-clojurescript", "clojure");
CodeMirror.defineMIME("application/edn", "clojure");
});
rust/rust.js 0000644 00000005721 15051524051 0007077 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function(mod) {
if (typeof exports == "object" && typeof module == "object") // CommonJS
mod(require("../../lib/codemirror"), require("../../addon/mode/simple"));
else if (typeof define == "function" && define.amd) // AMD
define(["../../lib/codemirror", "../../addon/mode/simple"], mod);
else // Plain browser env
mod(CodeMirror);
})(function(CodeMirror) {
"use strict";
CodeMirror.defineSimpleMode("rust",{
start: [
// string and byte string
{regex: /b?"/, token: "string", next: "string"},
// raw string and raw byte string
{regex: /b?r"/, token: "string", next: "string_raw"},
{regex: /b?r#+"/, token: "string", next: "string_raw_hash"},
// character
{regex: /'(?:[^'\\]|\\(?:[nrt0'"]|x[\da-fA-F]{2}|u\{[\da-fA-F]{6}\}))'/, token: "string-2"},
// byte
{regex: /b'(?:[^']|\\(?:['\\nrt0]|x[\da-fA-F]{2}))'/, token: "string-2"},
{regex: /(?:(?:[0-9][0-9_]*)(?:(?:[Ee][+-]?[0-9_]+)|\.[0-9_]+(?:[Ee][+-]?[0-9_]+)?)(?:f32|f64)?)|(?:0(?:b[01_]+|(?:o[0-7_]+)|(?:x[0-9a-fA-F_]+))|(?:[0-9][0-9_]*))(?:u8|u16|u32|u64|i8|i16|i32|i64|isize|usize)?/,
token: "number"},
{regex: /(let(?:\s+mut)?|fn|enum|mod|struct|type)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/, token: ["keyword", null, "def"]},
{regex: /(?:abstract|alignof|as|box|break|continue|const|crate|do|else|enum|extern|fn|for|final|if|impl|in|loop|macro|match|mod|move|offsetof|override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|unsafe|unsized|use|virtual|where|while|yield)\b/, token: "keyword"},
{regex: /\b(?:Self|isize|usize|char|bool|u8|u16|u32|u64|f16|f32|f64|i8|i16|i32|i64|str|Option)\b/, token: "atom"},
{regex: /\b(?:true|false|Some|None|Ok|Err)\b/, token: "builtin"},
{regex: /\b(fn)(\s+)([a-zA-Z_][a-zA-Z0-9_]*)/,
token: ["keyword", null ,"def"]},
{regex: /#!?\[.*\]/, token: "meta"},
{regex: /\/\/.*/, token: "comment"},
{regex: /\/\*/, token: "comment", next: "comment"},
{regex: /[-+\/*=<>!]+/, token: "operator"},
{regex: /[a-zA-Z_]\w*!/,token: "variable-3"},
{regex: /[a-zA-Z_]\w*/, token: "variable"},
{regex: /[\{\[\(]/, indent: true},
{regex: /[\}\]\)]/, dedent: true}
],
string: [
{regex: /"/, token: "string", next: "start"},
{regex: /(?:[^\\"]|\\(?:.|$))*/, token: "string"}
],
string_raw: [
{regex: /"/, token: "string", next: "start"},
{regex: /[^"]*/, token: "string"}
],
string_raw_hash: [
{regex: /"#+/, token: "string", next: "start"},
{regex: /(?:[^"]|"(?!#))*/, token: "string"}
],
comment: [
{regex: /.*?\*\//, token: "comment", next: "start"},
{regex: /.*/, token: "comment"}
],
meta: {
dontIndentStates: ["comment"],
electricInput: /^\s*\}$/,
blockCommentStart: "/*",
blockCommentEnd: "*/",
lineComment: "//",
fold: "brace"
}
});
CodeMirror.defineMIME("text/x-rustsrc", "rust");
});
rust/index.html 0000644 00000002774 15051524051 0007546 0 ustar 00
CodeMirror: Rust mode
Rust mode
// Demo code.
type foo = int;
enum bar {
some(int, foo),
none
}
fn check_crate(x: int) {
let v = 10;
match foo {
1 ... 3 {
print_foo();
if x {
blah().to_string();
}
}
(x, y) { "bye" }
_ { "hi" }
}
}
MIME types defined: text/x-rustsrc
.
rust/test.js 0000644 00000001740 15051524051 0007056 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
(function() {
var mode = CodeMirror.getMode({indentUnit: 4}, "rust");
function MT(name) {test.mode(name, mode, Array.prototype.slice.call(arguments, 1));}
MT('integer_test',
'[number 123i32]',
'[number 123u32]',
'[number 123_u32]',
'[number 0xff_u8]',
'[number 0o70_i16]',
'[number 0b1111_1111_1001_0000_i32]',
'[number 0usize]');
MT('float_test',
'[number 123.0f64]',
'[number 0.1f64]',
'[number 0.1f32]',
'[number 12E+99_f64]');
MT('string-literals-test',
'[string "foo"]',
'[string r"foo"]',
'[string "\\"foo\\""]',
'[string r#""foo""#]',
'[string "foo #\\"# bar"]',
'[string b"foo"]',
'[string br"foo"]',
'[string b"\\"foo\\""]',
'[string br#""foo""#]',
'[string br##"foo #" bar"##]',
"[string-2 'h']",
"[string-2 b'h']");
})();
pascal/pascal.js 0000644 00000005757 15051524051 0007624 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://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("pascal", function() {
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("and array begin case const div do downto else end file for forward integer " +
"boolean char function goto if in label mod nil not of or packed procedure " +
"program record repeat set string then to type until var while with");
var atoms = {"null": true};
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
function tokenBase(stream, state) {
var ch = stream.next();
if (ch == "#" && state.startOfLine) {
stream.skipToEnd();
return "meta";
}
if (ch == '"' || ch == "'") {
state.tokenize = tokenString(ch);
return state.tokenize(stream, state);
}
if (ch == "(" && stream.eat("*")) {
state.tokenize = tokenComment;
return tokenComment(stream, state);
}
if (/[\[\]{}\(\),;\:\.]/.test(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)) 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) state.tokenize = null;
return "string";
};
}
function tokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == ")" && maybeEnd) {
state.tokenize = null;
break;
}
maybeEnd = (ch == "*");
}
return "comment";
}
// Interface
return {
startState: function() {
return {tokenize: null};
},
token: function(stream, state) {
if (stream.eatSpace()) return null;
var style = (state.tokenize || tokenBase)(stream, state);
if (style == "comment" || style == "meta") return style;
return style;
},
electricChars: "{}"
};
});
CodeMirror.defineMIME("text/x-pascal", "pascal");
});
pascal/index.html 0000644 00000002640 15051524051 0010004 0 ustar 00
CodeMirror: Pascal mode
Pascal mode
(* Example Pascal code *)
while a <> b do writeln('Waiting');
if a > b then
writeln('Condition met')
else
writeln('Condition not met');
for i := 1 to 10 do
writeln('Iteration: ', i:1);
repeat
a := a + 1
until a = 10;
case i of
0: write('zero');
1: write('one');
2: write('two')
end;
MIME types defined: text/x-pascal
.
q/index.html 0000644 00000021406 15051524051 0007002 0 ustar 00
CodeMirror: Q mode
Q mode
/ utilities to quickly load a csv file - for more exhaustive analysis of the csv contents see csvguess.q
/ 2009.09.20 - updated to match latest csvguess.q
/ .csv.colhdrs[file] - return a list of colhdrs from file
/ info:.csv.info[file] - return a table of information about the file
/ columns are:
/ c - column name; ci - column index; t - load type; mw - max width;
/ dchar - distinct characters in values; rule - rule that caught the type
/ maybe - needs checking, _could_ be say a date, but perhaps just a float?
/ .csv.info0[file;onlycols] - like .csv.info except that it only analyses
/ example:
/ info:.csv.info0[file;(.csv.colhdrs file)like"*price"]
/ info:.csv.infolike[file;"*price"]
/ show delete from info where t=" "
/ .csv.data[file;info] - use the info from .csv.info to read the data
/ .csv.data10[file;info] - like .csv.data but only returns the first 10 rows
/ bulkload[file;info] - bulk loads file into table DATA (which must be already defined :: DATA:() )
/ .csv.read[file]/read10[file] - for when you don't care about checking/tweaking the before reading
\d .csv
DELIM:","
ZAPHDRS:0b / lowercase and remove _ from colhdrs (junk characters are always removed)
WIDTHHDR:25000 / number of characters read to get the header
READLINES:222 / number of lines read and used to guess the types
SYMMAXWIDTH:11 / character columns narrower than this are stored as symbols
SYMMAXGR:10 / max symbol granularity% before we give up and keep as a * string
FORCECHARWIDTH:30 / every field (of any type) with values this wide or more is forced to character "*"
DISCARDEMPTY:0b / completely ignore empty columns if true else set them to "C"
CHUNKSIZE:50000000 / used in fs2 (modified .Q.fs)
k)nameltrim:{$[~@x;.z.s'x;~(*x)in aA:.Q.a,.Q.A;(+/&\~x in aA)_x;x]}
k)fs2:{[f;s]((-7!s)>){[f;s;x]i:1+last@&0xa=r:1:(s;x;CHUNKSIZE);f@`\:i#r;x+i}[f;s]/0j}
cleanhdrs:{{$[ZAPHDRS;lower x except"_";x]}x where x in DELIM,.Q.an}
cancast:{nw:x$"";if[not x in"BXCS";nw:(min 0#;max 0#;::)@\:nw];$[not any nw in xjQuery(11&count y)#y;$[11.csv.FORCECHARWIDTH; / long values
info:update t:"C "[.csv.DISCARDEMPTY],rule:30,empty:1b from info where t="?",mw=0; / empty columns
info:update dchar:{asc distinct raze x}peach sdv from info where t="?";
info:update mdot:{max sum each"."=x}peach sdv from info where t="?",{"."in x}each dchar;
info:update t:"n",rule:40 from info where t="?",{any x in"0123456789"}each dchar; / vaguely numeric..
info:update t:"I",rule:50,ipa:1b from info where t="n",mw within 7 15,mdot=3,{all x in".0123456789"}each dchar,.csv.cancast["I"]peach sdv; / ip-address
info:update t:"J",rule:60 from info where t="n",mdot=0,{all x in"+-0123456789"}each dchar,.csv.cancast["J"]peach sdv;
info:update t:"I",rule:70 from info where t="J",mw<12,.csv.cancast["I"]peach sdv;
info:update t:"H",rule:80 from info where t="I",mw<7,.csv.cancast["H"]peach sdv;
info:update t:"F",rule:90 from info where t="n",mdot<2,mw>1,.csv.cancast["F"]peach sdv;
info:update t:"E",rule:100,maybe:1b from info where t="F",mw<9;
info:update t:"M",rule:110,maybe:1b from info where t in"nIHEF",mdot<2,mw within 4 7,.csv.cancast["M"]peach sdv;
info:update t:"D",rule:120,maybe:1b from info where t in"nI",mdot in 0 2,mw within 6 11,.csv.cancast["D"]peach sdv;
info:update t:"V",rule:130,maybe:1b from info where t="I",mw in 5 6,71,gr<.csv.SYMMAXGR; / symbols (max width permitting)
info:update t:"*",rule:280,maybe:0b from info where t="?"; / the rest as strings
/ flag those S/* columns which could be encoded to integers (.Q.j10/x10/j12/x12) to avoid symbols
info:update j12:1b from info where t in"S*",mw<13,{all x in .Q.nA}each dchar;
info:update j10:1b from info where t in"S*",mw<11,{all x in .Q.b6}each dchar;
select c,ci,t,maybe,empty,res,j10,j12,ipa,mw,mdot,rule,gr,ndv,dchar from info}
info:info0[;()] / by default don't restrict columns
infolike:{[file;pattern] info0[file;{x where x like y}[lower colhdrs[file];pattern]]} / .csv.infolike[file;"*time"]
\d .
/ DATA:()
bulkload:{[file;info]
if[not`DATA in system"v";'`DATA.not.defined];
if[count DATA;'`DATA.not.empty];
loadhdrs:exec c from info where not t=" ";loadfmts:exec t from info;
.csv.fs2[{[file;loadhdrs;loadfmts] `DATA insert $[count DATA;flip loadhdrs!(loadfmts;.csv.DELIM)0:file;loadhdrs xcol(loadfmts;enlist .csv.DELIM)0:file]}[file;loadhdrs;loadfmts]];
count DATA}
@[.:;"\\l csvutil.custom.q";::]; / save your custom settings in csvutil.custom.q to override those set at the beginning of the file
MIME type defined: text/x-q
.
q/q.js 0000644 00000014731 15051524051 0005606 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://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("q",function(config){
var indentUnit=config.indentUnit,
curPunc,
keywords=buildRE(["abs","acos","aj","aj0","all","and","any","asc","asin","asof","atan","attr","avg","avgs","bin","by","ceiling","cols","cor","cos","count","cov","cross","csv","cut","delete","deltas","desc","dev","differ","distinct","div","do","each","ej","enlist","eval","except","exec","exit","exp","fby","fills","first","fkeys","flip","floor","from","get","getenv","group","gtime","hclose","hcount","hdel","hopen","hsym","iasc","idesc","if","ij","in","insert","inter","inv","key","keys","last","like","list","lj","load","log","lower","lsq","ltime","ltrim","mavg","max","maxs","mcount","md5","mdev","med","meta","min","mins","mmax","mmin","mmu","mod","msum","neg","next","not","null","or","over","parse","peach","pj","plist","prd","prds","prev","prior","rand","rank","ratios","raze","read0","read1","reciprocal","reverse","rload","rotate","rsave","rtrim","save","scan","select","set","setenv","show","signum","sin","sqrt","ss","ssr","string","sublist","sum","sums","sv","system","tables","tan","til","trim","txf","type","uj","ungroup","union","update","upper","upsert","value","var","view","views","vs","wavg","where","where","while","within","wj","wj1","wsum","xasc","xbar","xcol","xcols","xdesc","xexp","xgroup","xkey","xlog","xprev","xrank"]),
E=/[|/&^!+:\\\-*%$=~#;@><,?_\'\"\[\(\]\)\s{}]/;
function buildRE(w){return new RegExp("^("+w.join("|")+")$");}
function tokenBase(stream,state){
var sol=stream.sol(),c=stream.next();
curPunc=null;
if(sol)
if(c=="/")
return(state.tokenize=tokenLineComment)(stream,state);
else if(c=="\\"){
if(stream.eol()||/\s/.test(stream.peek()))
return stream.skipToEnd(),/^\\\s*$/.test(stream.current())?(state.tokenize=tokenCommentToEOF)(stream, state):state.tokenize=tokenBase,"comment";
else
return state.tokenize=tokenBase,"builtin";
}
if(/\s/.test(c))
return stream.peek()=="/"?(stream.skipToEnd(),"comment"):"whitespace";
if(c=='"')
return(state.tokenize=tokenString)(stream,state);
if(c=='`')
return stream.eatWhile(/[A-Z|a-z|\d|_|:|\/|\.]/),"symbol";
if(("."==c&&/\d/.test(stream.peek()))||/\d/.test(c)){
var t=null;
stream.backUp(1);
if(stream.match(/^\d{4}\.\d{2}(m|\.\d{2}([D|T](\d{2}(:\d{2}(:\d{2}(\.\d{1,9})?)?)?)?)?)/)
|| stream.match(/^\d+D(\d{2}(:\d{2}(:\d{2}(\.\d{1,9})?)?)?)/)
|| stream.match(/^\d{2}:\d{2}(:\d{2}(\.\d{1,9})?)?/)
|| stream.match(/^\d+[ptuv]{1}/))
t="temporal";
else if(stream.match(/^0[NwW]{1}/)
|| stream.match(/^0x[\d|a-f|A-F]*/)
|| stream.match(/^[0|1]+[b]{1}/)
|| stream.match(/^\d+[chijn]{1}/)
|| stream.match(/-?\d*(\.\d*)?(e[+\-]?\d+)?(e|f)?/))
t="number";
return(t&&(!(c=stream.peek())||E.test(c)))?t:(stream.next(),"error");
}
if(/[A-Z|a-z]|\./.test(c))
return stream.eatWhile(/[A-Z|a-z|\.|_|\d]/),keywords.test(stream.current())?"keyword":"variable";
if(/[|/&^!+:\\\-*%$=~#;@><\.,?_\']/.test(c))
return null;
if(/[{}\(\[\]\)]/.test(c))
return null;
return"error";
}
function tokenLineComment(stream,state){
return stream.skipToEnd(),/\/\s*$/.test(stream.current())?(state.tokenize=tokenBlockComment)(stream,state):(state.tokenize=tokenBase),"comment";
}
function tokenBlockComment(stream,state){
var f=stream.sol()&&stream.peek()=="\\";
stream.skipToEnd();
if(f&&/^\\\s*$/.test(stream.current()))
state.tokenize=tokenBase;
return"comment";
}
function tokenCommentToEOF(stream){return stream.skipToEnd(),"comment";}
function tokenString(stream,state){
var escaped=false,next,end=false;
while((next=stream.next())){
if(next=="\""&&!escaped){end=true;break;}
escaped=!escaped&&next=="\\";
}
if(end)state.tokenize=tokenBase;
return"string";
}
function pushContext(state,type,col){state.context={prev:state.context,indent:state.indent,col:col,type:type};}
function popContext(state){state.indent=state.context.indent;state.context=state.context.prev;}
return{
startState:function(){
return{tokenize:tokenBase,
context:null,
indent:0,
col:0};
},
token:function(stream,state){
if(stream.sol()){
if(state.context&&state.context.align==null)
state.context.align=false;
state.indent=stream.indentation();
}
//if (stream.eatSpace()) return null;
var style=state.tokenize(stream,state);
if(style!="comment"&&state.context&&state.context.align==null&&state.context.type!="pattern"){
state.context.align=true;
}
if(curPunc=="(")pushContext(state,")",stream.column());
else if(curPunc=="[")pushContext(state,"]",stream.column());
else if(curPunc=="{")pushContext(state,"}",stream.column());
else if(/[\]\}\)]/.test(curPunc)){
while(state.context&&state.context.type=="pattern")popContext(state);
if(state.context&&curPunc==state.context.type)popContext(state);
}
else if(curPunc=="."&&state.context&&state.context.type=="pattern")popContext(state);
else if(/atom|string|variable/.test(style)&&state.context){
if(/[\}\]]/.test(state.context.type))
pushContext(state,"pattern",stream.column());
else if(state.context.type=="pattern"&&!state.context.align){
state.context.align=true;
state.context.col=stream.column();
}
}
return style;
},
indent:function(state,textAfter){
var firstChar=textAfter&&textAfter.charAt(0);
var context=state.context;
if(/[\]\}]/.test(firstChar))
while (context&&context.type=="pattern")context=context.prev;
var closing=context&&firstChar==context.type;
if(!context)
return 0;
else if(context.type=="pattern")
return context.col;
else if(context.align)
return context.col+(closing?0:1);
else
return context.indent+(closing?0:indentUnit);
}
};
});
CodeMirror.defineMIME("text/x-q","q");
});
xquery/xquery.js 0000644 00000034206 15051524051 0007777 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://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("xquery", function() {
// The keywords object is set to the result of this self executing
// function. Each keyword is a property of the keywords object whose
// value is {type: atype, style: astyle}
var keywords = function(){
// convenience functions used to build keywords object
function kw(type) {return {type: type, style: "keyword"};}
var A = kw("keyword a")
, B = kw("keyword b")
, C = kw("keyword c")
, operator = kw("operator")
, atom = {type: "atom", style: "atom"}
, punctuation = {type: "punctuation", style: null}
, qualifier = {type: "axis_specifier", style: "qualifier"};
// kwObj is what is return from this function at the end
var kwObj = {
'if': A, 'switch': A, 'while': A, 'for': A,
'else': B, 'then': B, 'try': B, 'finally': B, 'catch': B,
'element': C, 'attribute': C, 'let': C, 'implements': C, 'import': C, 'module': C, 'namespace': C,
'return': C, 'super': C, 'this': C, 'throws': C, 'where': C, 'private': C,
',': punctuation,
'null': atom, 'fn:false()': atom, 'fn:true()': atom
};
// a list of 'basic' keywords. For each add a property to kwObj with the value of
// {type: basic[i], style: "keyword"} e.g. 'after' --> {type: "after", style: "keyword"}
var basic = ['after','ancestor','ancestor-or-self','and','as','ascending','assert','attribute','before',
'by','case','cast','child','comment','declare','default','define','descendant','descendant-or-self',
'descending','document','document-node','element','else','eq','every','except','external','following',
'following-sibling','follows','for','function','if','import','in','instance','intersect','item',
'let','module','namespace','node','node','of','only','or','order','parent','precedes','preceding',
'preceding-sibling','processing-instruction','ref','return','returns','satisfies','schema','schema-element',
'self','some','sortby','stable','text','then','to','treat','typeswitch','union','variable','version','where',
'xquery', 'empty-sequence'];
for(var i=0, l=basic.length; i < l; i++) { kwObj[basic[i]] = kw(basic[i]);};
// a list of types. For each add a property to kwObj with the value of
// {type: "atom", style: "atom"}
var types = ['xs:string', 'xs:float', 'xs:decimal', 'xs:double', 'xs:integer', 'xs:boolean', 'xs:date', 'xs:dateTime',
'xs:time', 'xs:duration', 'xs:dayTimeDuration', 'xs:time', 'xs:yearMonthDuration', 'numeric', 'xs:hexBinary',
'xs:base64Binary', 'xs:anyURI', 'xs:QName', 'xs:byte','xs:boolean','xs:anyURI','xf:yearMonthDuration'];
for(var i=0, l=types.length; i < l; i++) { kwObj[types[i]] = atom;};
// each operator will add a property to kwObj with value of {type: "operator", style: "keyword"}
var operators = ['eq', 'ne', 'lt', 'le', 'gt', 'ge', ':=', '=', '>', '>=', '<', '<=', '.', '|', '?', 'and', 'or', 'div', 'idiv', 'mod', '*', '/', '+', '-'];
for(var i=0, l=operators.length; i < l; i++) { kwObj[operators[i]] = operator;};
// each axis_specifiers will add a property to kwObj with value of {type: "axis_specifier", style: "qualifier"}
var axis_specifiers = ["self::", "attribute::", "child::", "descendant::", "descendant-or-self::", "parent::",
"ancestor::", "ancestor-or-self::", "following::", "preceding::", "following-sibling::", "preceding-sibling::"];
for(var i=0, l=axis_specifiers.length; i < l; i++) { kwObj[axis_specifiers[i]] = qualifier; };
return kwObj;
}();
function chain(stream, state, f) {
state.tokenize = f;
return f(stream, state);
}
// the primary mode tokenizer
function tokenBase(stream, state) {
var ch = stream.next(),
mightBeFunction = false,
isEQName = isEQNameAhead(stream);
// an XML tag (if not in some sub, chained tokenizer)
if (ch == "<") {
if(stream.match("!--", true))
return chain(stream, state, tokenXMLComment);
if(stream.match("![CDATA", false)) {
state.tokenize = tokenCDATA;
return "tag";
}
if(stream.match("?", false)) {
return chain(stream, state, tokenPreProcessing);
}
var isclose = stream.eat("/");
stream.eatSpace();
var tagName = "", c;
while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
return chain(stream, state, tokenTag(tagName, isclose));
}
// start code block
else if(ch == "{") {
pushStateStack(state,{ type: "codeblock"});
return null;
}
// end code block
else if(ch == "}") {
popStateStack(state);
return null;
}
// if we're in an XML block
else if(isInXmlBlock(state)) {
if(ch == ">")
return "tag";
else if(ch == "/" && stream.eat(">")) {
popStateStack(state);
return "tag";
}
else
return "variable";
}
// if a number
else if (/\d/.test(ch)) {
stream.match(/^\d*(?:\.\d*)?(?:E[+\-]?\d+)?/);
return "atom";
}
// comment start
else if (ch === "(" && stream.eat(":")) {
pushStateStack(state, { type: "comment"});
return chain(stream, state, tokenComment);
}
// quoted string
else if ( !isEQName && (ch === '"' || ch === "'"))
return chain(stream, state, tokenString(ch));
// variable
else if(ch === "$") {
return chain(stream, state, tokenVariable);
}
// assignment
else if(ch ===":" && stream.eat("=")) {
return "keyword";
}
// open paren
else if(ch === "(") {
pushStateStack(state, { type: "paren"});
return null;
}
// close paren
else if(ch === ")") {
popStateStack(state);
return null;
}
// open paren
else if(ch === "[") {
pushStateStack(state, { type: "bracket"});
return null;
}
// close paren
else if(ch === "]") {
popStateStack(state);
return null;
}
else {
var known = keywords.propertyIsEnumerable(ch) && keywords[ch];
// if there's a EQName ahead, consume the rest of the string portion, it's likely a function
if(isEQName && ch === '\"') while(stream.next() !== '"'){}
if(isEQName && ch === '\'') while(stream.next() !== '\''){}
// gobble up a word if the character is not known
if(!known) stream.eatWhile(/[\w\$_-]/);
// gobble a colon in the case that is a lib func type call fn:doc
var foundColon = stream.eat(":");
// if there's not a second colon, gobble another word. Otherwise, it's probably an axis specifier
// which should get matched as a keyword
if(!stream.eat(":") && foundColon) {
stream.eatWhile(/[\w\$_-]/);
}
// if the next non whitespace character is an open paren, this is probably a function (if not a keyword of other sort)
if(stream.match(/^[ \t]*\(/, false)) {
mightBeFunction = true;
}
// is the word a keyword?
var word = stream.current();
known = keywords.propertyIsEnumerable(word) && keywords[word];
// if we think it's a function call but not yet known,
// set style to variable for now for lack of something better
if(mightBeFunction && !known) known = {type: "function_call", style: "variable def"};
// if the previous word was element, attribute, axis specifier, this word should be the name of that
if(isInXmlConstructor(state)) {
popStateStack(state);
return "variable";
}
// as previously checked, if the word is element,attribute, axis specifier, call it an "xmlconstructor" and
// push the stack so we know to look for it on the next word
if(word == "element" || word == "attribute" || known.type == "axis_specifier") pushStateStack(state, {type: "xmlconstructor"});
// if the word is known, return the details of that else just call this a generic 'word'
return known ? known.style : "variable";
}
}
// handle comments, including nested
function tokenComment(stream, state) {
var maybeEnd = false, maybeNested = false, nestedCount = 0, ch;
while (ch = stream.next()) {
if (ch == ")" && maybeEnd) {
if(nestedCount > 0)
nestedCount--;
else {
popStateStack(state);
break;
}
}
else if(ch == ":" && maybeNested) {
nestedCount++;
}
maybeEnd = (ch == ":");
maybeNested = (ch == "(");
}
return "comment";
}
// tokenizer for string literals
// optionally pass a tokenizer function to set state.tokenize back to when finished
function tokenString(quote, f) {
return function(stream, state) {
var ch;
if(isInString(state) && stream.current() == quote) {
popStateStack(state);
if(f) state.tokenize = f;
return "string";
}
pushStateStack(state, { type: "string", name: quote, tokenize: tokenString(quote, f) });
// if we're in a string and in an XML block, allow an embedded code block
if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
state.tokenize = tokenBase;
return "string";
}
while (ch = stream.next()) {
if (ch == quote) {
popStateStack(state);
if(f) state.tokenize = f;
break;
}
else {
// if we're in a string and in an XML block, allow an embedded code block in an attribute
if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
state.tokenize = tokenBase;
return "string";
}
}
}
return "string";
};
}
// tokenizer for variables
function tokenVariable(stream, state) {
var isVariableChar = /[\w\$_-]/;
// a variable may start with a quoted EQName so if the next character is quote, consume to the next quote
if(stream.eat("\"")) {
while(stream.next() !== '\"'){};
stream.eat(":");
} else {
stream.eatWhile(isVariableChar);
if(!stream.match(":=", false)) stream.eat(":");
}
stream.eatWhile(isVariableChar);
state.tokenize = tokenBase;
return "variable";
}
// tokenizer for XML tags
function tokenTag(name, isclose) {
return function(stream, state) {
stream.eatSpace();
if(isclose && stream.eat(">")) {
popStateStack(state);
state.tokenize = tokenBase;
return "tag";
}
// self closing tag without attributes?
if(!stream.eat("/"))
pushStateStack(state, { type: "tag", name: name, tokenize: tokenBase});
if(!stream.eat(">")) {
state.tokenize = tokenAttribute;
return "tag";
}
else {
state.tokenize = tokenBase;
}
return "tag";
};
}
// tokenizer for XML attributes
function tokenAttribute(stream, state) {
var ch = stream.next();
if(ch == "/" && stream.eat(">")) {
if(isInXmlAttributeBlock(state)) popStateStack(state);
if(isInXmlBlock(state)) popStateStack(state);
return "tag";
}
if(ch == ">") {
if(isInXmlAttributeBlock(state)) popStateStack(state);
return "tag";
}
if(ch == "=")
return null;
// quoted string
if (ch == '"' || ch == "'")
return chain(stream, state, tokenString(ch, tokenAttribute));
if(!isInXmlAttributeBlock(state))
pushStateStack(state, { type: "attribute", tokenize: tokenAttribute});
stream.eat(/[a-zA-Z_:]/);
stream.eatWhile(/[-a-zA-Z0-9_:.]/);
stream.eatSpace();
// the case where the attribute has not value and the tag was closed
if(stream.match(">", false) || stream.match("/", false)) {
popStateStack(state);
state.tokenize = tokenBase;
}
return "attribute";
}
// handle comments, including nested
function tokenXMLComment(stream, state) {
var ch;
while (ch = stream.next()) {
if (ch == "-" && stream.match("->", true)) {
state.tokenize = tokenBase;
return "comment";
}
}
}
// handle CDATA
function tokenCDATA(stream, state) {
var ch;
while (ch = stream.next()) {
if (ch == "]" && stream.match("]", true)) {
state.tokenize = tokenBase;
return "comment";
}
}
}
// handle preprocessing instructions
function tokenPreProcessing(stream, state) {
var ch;
while (ch = stream.next()) {
if (ch == "?" && stream.match(">", true)) {
state.tokenize = tokenBase;
return "comment meta";
}
}
}
// functions to test the current context of the state
function isInXmlBlock(state) { return isIn(state, "tag"); }
function isInXmlAttributeBlock(state) { return isIn(state, "attribute"); }
function isInXmlConstructor(state) { return isIn(state, "xmlconstructor"); }
function isInString(state) { return isIn(state, "string"); }
function isEQNameAhead(stream) {
// assume we've already eaten a quote (")
if(stream.current() === '"')
return stream.match(/^[^\"]+\"\:/, false);
else if(stream.current() === '\'')
return stream.match(/^[^\"]+\'\:/, false);
else
return false;
}
function isIn(state, type) {
return (state.stack.length && state.stack[state.stack.length - 1].type == type);
}
function pushStateStack(state, newState) {
state.stack.push(newState);
}
function popStateStack(state) {
state.stack.pop();
var reinstateTokenize = state.stack.length && state.stack[state.stack.length-1].tokenize;
state.tokenize = reinstateTokenize || tokenBase;
}
// the interface for the mode API
return {
startState: function() {
return {
tokenize: tokenBase,
cc: [],
stack: []
};
},
token: function(stream, state) {
if (stream.eatSpace()) return null;
var style = state.tokenize(stream, state);
return style;
},
blockCommentStart: "(:",
blockCommentEnd: ":)"
};
});
CodeMirror.defineMIME("application/xquery", "xquery");
});
xquery/index.html 0000644 00000020641 15051524051 0010077 0 ustar 00
CodeMirror: XQuery mode
XQuery mode
xquery version "1.0-ml";
(: this is
: a
"comment" :)
let $let := <x attr="value">"test"<func>function() $var {function()} {$var}</func></x>
let $joe:=1
return element element {
attribute attribute { 1 },
element test { 'a' },
attribute foo { "bar" },
fn:doc()[ foo/@bar eq $let ],
//x }
(: a more 'evil' test :)
(: Modified Blakeley example (: with nested comment :) ... :)
declare private function local:declare() {()};
declare private function local:private() {()};
declare private function local:function() {()};
declare private function local:local() {()};
let $let := <let>let $let := "let"</let>
return element element {
attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },
attribute fn:doc { "bar" castable as xs:string },
element text { text { "text" } },
fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],
//fn:doc
}
xquery version "1.0-ml";
(: Copyright 2006-2010 Mark Logic Corporation. :)
(:
: Licensed under the Apache License, Version 2.0 (the "License");
: you may not use this file except in compliance with the License.
: You may obtain a copy of the License at
:
: http://www.apache.org/licenses/LICENSE-2.0
:
: Unless required by applicable law or agreed to in writing, software
: distributed under the License is distributed on an "AS IS" BASIS,
: WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
: See the License for the specific language governing permissions and
: limitations under the License.
:)
module namespace json = "http://marklogic.com/json";
declare default function namespace "http://www.w3.org/2005/xpath-functions";
(: Need to backslash escape any double quotes, backslashes, and newlines :)
declare function json:escape($s as xs:string) as xs:string {
let $s := replace($s, "\\", "\\\\")
let $s := replace($s, """", "\\""")
let $s := replace($s, codepoints-to-string((13, 10)), "\\n")
let $s := replace($s, codepoints-to-string(13), "\\n")
let $s := replace($s, codepoints-to-string(10), "\\n")
return $s
};
declare function json:atomize($x as element()) as xs:string {
if (count($x/node()) = 0) then 'null'
else if ($x/@type = "number") then
let $castable := $x castable as xs:float or
$x castable as xs:double or
$x castable as xs:decimal
return
if ($castable) then xs:string($x)
else error(concat("Not a number: ", xdmp:describe($x)))
else if ($x/@type = "boolean") then
let $castable := $x castable as xs:boolean
return
if ($castable) then xs:string(xs:boolean($x))
else error(concat("Not a boolean: ", xdmp:describe($x)))
else concat('"', json:escape($x), '"')
};
(: Print the thing that comes after the colon :)
declare function json:print-value($x as element()) as xs:string {
if (count($x/*) = 0) then
json:atomize($x)
else if ($x/@quote = "true") then
concat('"', json:escape(xdmp:quote($x/node())), '"')
else
string-join(('{',
string-join(for $i in $x/* return json:print-name-value($i), ","),
'}'), "")
};
(: Print the name and value both :)
declare function json:print-name-value($x as element()) as xs:string? {
let $name := name($x)
let $first-in-array :=
count($x/preceding-sibling::*[name(.) = $name]) = 0 and
(count($x/following-sibling::*[name(.) = $name]) > 0 or $x/@array = "true")
let $later-in-array := count($x/preceding-sibling::*[name(.) = $name]) > 0
return
if ($later-in-array) then
() (: I was handled previously :)
else if ($first-in-array) then
string-join(('"', json:escape($name), '":[',
string-join((for $i in ($x, $x/following-sibling::*[name(.) = $name]) return json:print-value($i)), ","),
']'), "")
else
string-join(('"', json:escape($name), '":', json:print-value($x)), "")
};
(:~
Transforms an XML element into a JSON string representation. See http://json.org.
<p/>
Sample usage:
<pre>
xquery version "1.0-ml";
import module namespace json="http://marklogic.com/json" at "json.xqy";
json:serialize(<foo><bar>kid</bar></foo>)
</pre>
Sample transformations:
<pre>
<e/> becomes {"e":null}
<e>text</e> becomes {"e":"text"}
<e>quote " escaping</e> becomes {"e":"quote \" escaping"}
<e>backslash \ escaping</e> becomes {"e":"backslash \\ escaping"}
<e><a>text1</a><b>text2</b></e> becomes {"e":{"a":"text1","b":"text2"}}
<e><a>text1</a><a>text2</a></e> becomes {"e":{"a":["text1","text2"]}}
<e><a array="true">text1</a></e> becomes {"e":{"a":["text1"]}}
<e><a type="boolean">false</a></e> becomes {"e":{"a":false}}
<e><a type="number">123.5</a></e> becomes {"e":{"a":123.5}}
<e quote="true"><div attrib="value"/></e> becomes {"e":"<div attrib=\"value\"/>"}
</pre>
<p/>
Namespace URIs are ignored. Namespace prefixes are included in the JSON name.
<p/>
Attributes are ignored, except for the special attribute @array="true" that
indicates the JSON serialization should write the node, even if single, as an
array, and the attribute @type that can be set to "boolean" or "number" to
dictate the value should be written as that type (unquoted). There's also
an @quote attribute that when set to true writes the inner content as text
rather than as structured JSON, useful for sending some XHTML over the
wire.
<p/>
Text nodes within mixed content are ignored.
@param $x Element node to convert
@return String holding JSON serialized representation of $x
@author Jason Hunter
@version 1.0.1
Ported to xquery 1.0-ml; double escaped backslashes in json:escape
:)
declare function json:serialize($x as element()) as xs:string {
string-join(('{', json:print-name-value($x), '}'), "")
};
MIME types defined: application/xquery
.
Development of the CodeMirror XQuery mode was sponsored by
MarkLogic and developed by
Mike Brevoort .
xquery/test.js 0000644 00000011764 15051524051 0007425 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
// Don't take these too seriously -- the expected results appear to be
// based on the results of actual runs without any serious manual
// verification. If a change you made causes them to fail, the test is
// as likely to wrong as the code.
(function() {
var mode = CodeMirror.getMode({tabSize: 4}, "xquery");
function MT(name) { test.mode(name, mode, Array.prototype.slice.call(arguments, 1)); }
MT("eviltest",
"[keyword xquery] [keyword version] [variable "1][keyword .][atom 0][keyword -][variable ml"][def&variable ;] [comment (: this is : a \"comment\" :)]",
" [keyword let] [variable $let] [keyword :=] [variable <x] [variable attr][keyword =][variable "value">"test"<func>][def&variable ;function]() [variable $var] {[keyword function]()} {[variable $var]}[variable <][keyword /][variable func><][keyword /][variable x>]",
" [keyword let] [variable $joe][keyword :=][atom 1]",
" [keyword return] [keyword element] [variable element] {",
" [keyword attribute] [variable attribute] { [atom 1] },",
" [keyword element] [variable test] { [variable 'a'] }, [keyword attribute] [variable foo] { [variable "bar"] },",
" [def&variable fn:doc]()[[ [variable foo][keyword /][variable @bar] [keyword eq] [variable $let] ]],",
" [keyword //][variable x] } [comment (: a more 'evil' test :)]",
" [comment (: Modified Blakeley example (: with nested comment :) ... :)]",
" [keyword declare] [keyword private] [keyword function] [def&variable local:declare]() {()}[variable ;]",
" [keyword declare] [keyword private] [keyword function] [def&variable local:private]() {()}[variable ;]",
" [keyword declare] [keyword private] [keyword function] [def&variable local:function]() {()}[variable ;]",
" [keyword declare] [keyword private] [keyword function] [def&variable local:local]() {()}[variable ;]",
" [keyword let] [variable $let] [keyword :=] [variable <let>let] [variable $let] [keyword :=] [variable "let"<][keyword /let][variable >]",
" [keyword return] [keyword element] [variable element] {",
" [keyword attribute] [variable attribute] { [keyword try] { [def&variable xdmp:version]() } [keyword catch]([variable $e]) { [def&variable xdmp:log]([variable $e]) } },",
" [keyword attribute] [variable fn:doc] { [variable "bar"] [variable castable] [keyword as] [atom xs:string] },",
" [keyword element] [variable text] { [keyword text] { [variable "text"] } },",
" [def&variable fn:doc]()[[ [qualifier child::][variable eq][keyword /]([variable @bar] [keyword |] [qualifier attribute::][variable attribute]) [keyword eq] [variable $let] ]],",
" [keyword //][variable fn:doc]",
" }");
MT("testEmptySequenceKeyword",
"[string \"foo\"] [keyword instance] [keyword of] [keyword empty-sequence]()");
MT("testMultiAttr",
"[tag ][variable hello] [variable world][tag
]");
MT("test namespaced variable",
"[keyword declare] [keyword namespace] [variable e] [keyword =] [string \"http://example.com/ANamespace\"][variable ;declare] [keyword variable] [variable $e:exampleComThisVarIsNotRecognized] [keyword as] [keyword element]([keyword *]) [variable external;]");
MT("test EQName variable",
"[keyword declare] [keyword variable] [variable $\"http://www.example.com/ns/my\":var] [keyword :=] [atom 12][variable ;]",
"[tag ]{[variable $\"http://www.example.com/ns/my\":var]}[tag ]");
MT("test EQName function",
"[keyword declare] [keyword function] [def&variable \"http://www.example.com/ns/my\":fn] ([variable $a] [keyword as] [atom xs:integer]) [keyword as] [atom xs:integer] {",
" [variable $a] [keyword +] [atom 2]",
"}[variable ;]",
"[tag ]{[def&variable \"http://www.example.com/ns/my\":fn]([atom 12])}[tag ]");
MT("test EQName function with single quotes",
"[keyword declare] [keyword function] [def&variable 'http://www.example.com/ns/my':fn] ([variable $a] [keyword as] [atom xs:integer]) [keyword as] [atom xs:integer] {",
" [variable $a] [keyword +] [atom 2]",
"}[variable ;]",
"[tag ]{[def&variable 'http://www.example.com/ns/my':fn]([atom 12])}[tag ]");
MT("testProcessingInstructions",
"[def&variable data]([comment&meta ]) [keyword instance] [keyword of] [atom xs:string]");
MT("testQuoteEscapeDouble",
"[keyword let] [variable $rootfolder] [keyword :=] [string \"c:\\builds\\winnt\\HEAD\\qa\\scripts\\\"]",
"[keyword let] [variable $keysfolder] [keyword :=] [def&variable concat]([variable $rootfolder], [string \"keys\\\"])");
})();
ttcn/ttcn.js 0000644 00000023653 15051524051 0007031 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://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("ttcn", function(config, parserConfig) {
var indentUnit = config.indentUnit,
keywords = parserConfig.keywords || {},
builtin = parserConfig.builtin || {},
timerOps = parserConfig.timerOps || {},
portOps = parserConfig.portOps || {},
configOps = parserConfig.configOps || {},
verdictOps = parserConfig.verdictOps || {},
sutOps = parserConfig.sutOps || {},
functionOps = parserConfig.functionOps || {},
verdictConsts = parserConfig.verdictConsts || {},
booleanConsts = parserConfig.booleanConsts || {},
otherConsts = parserConfig.otherConsts || {},
types = parserConfig.types || {},
visibilityModifiers = parserConfig.visibilityModifiers || {},
templateMatch = parserConfig.templateMatch || {},
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 == "#"){
stream.skipToEnd();
return "atom preprocessor";
}
if (ch == "%"){
stream.eatWhile(/\b/);
return "atom ttcn3Macros";
}
if (/\d/.test(ch)) {
stream.eatWhile(/[\w\.]/);
return "number";
}
if (ch == "/") {
if (stream.eat("*")) {
state.tokenize = tokenComment;
return tokenComment(stream, state);
}
if (stream.eat("/")) {
stream.skipToEnd();
return "comment";
}
}
if (isOperatorChar.test(ch)) {
if(ch == "@"){
if(stream.match("try") || stream.match("catch")
|| stream.match("lazy")){
return "keyword";
}
}
stream.eatWhile(isOperatorChar);
return "operator";
}
stream.eatWhile(/[\w\$_\xa1-\uffff]/);
var cur = stream.current();
if (keywords.propertyIsEnumerable(cur)) return "keyword";
if (builtin.propertyIsEnumerable(cur)) return "builtin";
if (timerOps.propertyIsEnumerable(cur)) return "def timerOps";
if (configOps.propertyIsEnumerable(cur)) return "def configOps";
if (verdictOps.propertyIsEnumerable(cur)) return "def verdictOps";
if (portOps.propertyIsEnumerable(cur)) return "def portOps";
if (sutOps.propertyIsEnumerable(cur)) return "def sutOps";
if (functionOps.propertyIsEnumerable(cur)) return "def functionOps";
if (verdictConsts.propertyIsEnumerable(cur)) return "string verdictConsts";
if (booleanConsts.propertyIsEnumerable(cur)) return "string booleanConsts";
if (otherConsts.propertyIsEnumerable(cur)) return "string otherConsts";
if (types.propertyIsEnumerable(cur)) return "builtin types";
if (visibilityModifiers.propertyIsEnumerable(cur))
return "builtin visibilityModifiers";
if (templateMatch.propertyIsEnumerable(cur)) return "atom templateMatch";
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 afterQuote = stream.peek();
//look if the character after the quote is like the B in '10100010'B
if (afterQuote){
afterQuote = afterQuote.toLowerCase();
if(afterQuote == "b" || afterQuote == "h" || afterQuote == "o")
stream.next();
}
end = true; break;
}
escaped = !escaped && next == "\\";
}
if (end || !(escaped || multiLineStrings))
state.tokenize = null;
return "string";
};
}
function tokenComment(stream, state) {
var maybeEnd = false, ch;
while (ch = stream.next()) {
if (ch == "/" && maybeEnd) {
state.tokenize = null;
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) {
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: "{}",
blockCommentStart: "/*",
blockCommentEnd: "*/",
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;
}
function def(mimes, mode) {
if (typeof mimes == "string") mimes = [mimes];
var words = [];
function add(obj) {
if (obj) for (var prop in obj) if (obj.hasOwnProperty(prop))
words.push(prop);
}
add(mode.keywords);
add(mode.builtin);
add(mode.timerOps);
add(mode.portOps);
if (words.length) {
mode.helperType = mimes[0];
CodeMirror.registerHelper("hintWords", mimes[0], words);
}
for (var i = 0; i < mimes.length; ++i)
CodeMirror.defineMIME(mimes[i], mode);
}
def(["text/x-ttcn", "text/x-ttcn3", "text/x-ttcnpp"], {
name: "ttcn",
keywords: words("activate address alive all alt altstep and and4b any" +
" break case component const continue control deactivate" +
" display do else encode enumerated except exception" +
" execute extends extension external for from function" +
" goto group if import in infinity inout interleave" +
" label language length log match message mixed mod" +
" modifies module modulepar mtc noblock not not4b nowait" +
" of on optional or or4b out override param pattern port" +
" procedure record recursive rem repeat return runs select" +
" self sender set signature system template testcase to" +
" type union value valueof var variant while with xor xor4b"),
builtin: words("bit2hex bit2int bit2oct bit2str char2int char2oct encvalue" +
" decomp decvalue float2int float2str hex2bit hex2int" +
" hex2oct hex2str int2bit int2char int2float int2hex" +
" int2oct int2str int2unichar isbound ischosen ispresent" +
" isvalue lengthof log2str oct2bit oct2char oct2hex oct2int" +
" oct2str regexp replace rnd sizeof str2bit str2float" +
" str2hex str2int str2oct substr unichar2int unichar2char" +
" enum2int"),
types: words("anytype bitstring boolean char charstring default float" +
" hexstring integer objid octetstring universal verdicttype timer"),
timerOps: words("read running start stop timeout"),
portOps: words("call catch check clear getcall getreply halt raise receive" +
" reply send trigger"),
configOps: words("create connect disconnect done kill killed map unmap"),
verdictOps: words("getverdict setverdict"),
sutOps: words("action"),
functionOps: words("apply derefers refers"),
verdictConsts: words("error fail inconc none pass"),
booleanConsts: words("true false"),
otherConsts: words("null NULL omit"),
visibilityModifiers: words("private public friend"),
templateMatch: words("complement ifpresent subset superset permutation"),
multiLineStrings: true
});
});
ttcn/index.html 0000644 00000006642 15051524051 0007517 0 ustar 00
CodeMirror: TTCN mode
TTCN example
module Templates {
/* import types from ASN.1 */
import from Types language "ASN.1:1997" all;
/* During the conversion phase from ASN.1 to TTCN-3 */
/* - the minus sign (Message-Type) within the identifiers will be replaced by underscore (Message_Type)*/
/* - the ASN.1 identifiers matching a TTCN-3 keyword (objid) will be postfixed with an underscore (objid_)*/
// simple types
template SenderID localObjid := objid {itu_t(0) identified_organization(4) etsi(0)};
// complex types
/* ASN.1 Message-Type mapped to TTCN-3 Message_Type */
template Message receiveMsg(template (present) Message_Type p_messageType) := {
header := p_messageType,
body := ?
}
/* ASN.1 objid mapped to TTCN-3 objid_ */
template Message sendInviteMsg := {
header := inviteType,
body := {
/* optional fields may be assigned by omit or may be ignored/skipped */
description := "Invite Message",
data := 'FF'O,
objid_ := localObjid
}
}
template Message sendAcceptMsg modifies sendInviteMsg := {
header := acceptType,
body := {
description := "Accept Message"
}
};
template Message sendErrorMsg modifies sendInviteMsg := {
header := errorType,
body := {
description := "Error Message"
}
};
template Message expectedErrorMsg := {
header := errorType,
body := ?
};
template Message expectedInviteMsg modifies expectedErrorMsg := {
header := inviteType
};
template Message expectedAcceptMsg modifies expectedErrorMsg := {
header := acceptType
};
} with { encode "BER:1997" }
Language: Testing and Test Control Notation
(TTCN )
MIME types defined: text/x-ttcn,
text/x-ttcn3, text/x-ttcnpp
.
The development of this mode has been sponsored by Ericsson
.
Coded by Asmelash Tsegay Gebretsadkan
tcl/tcl.js 0000644 00000011470 15051524051 0006447 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://codemirror.net/LICENSE
//tcl mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara
(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("tcl", function() {
function parseWords(str) {
var obj = {}, words = str.split(" ");
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
return obj;
}
var keywords = parseWords("Tcl safe after append array auto_execok auto_import auto_load " +
"auto_mkindex auto_mkindex_old auto_qualify auto_reset bgerror " +
"binary break catch cd close concat continue dde eof encoding error " +
"eval exec exit expr fblocked fconfigure fcopy file fileevent filename " +
"filename flush for foreach format gets glob global history http if " +
"incr info interp join lappend lindex linsert list llength load lrange " +
"lreplace lsearch lset lsort memory msgcat namespace open package parray " +
"pid pkg::create pkg_mkIndex proc puts pwd re_syntax read regex regexp " +
"registry regsub rename resource return scan seek set socket source split " +
"string subst switch tcl_endOfWord tcl_findLibrary tcl_startOfNextWord " +
"tcl_wordBreakAfter tcl_startOfPreviousWord tcl_wordBreakBefore tcltest " +
"tclvars tell time trace unknown unset update uplevel upvar variable " +
"vwait");
var functions = parseWords("if elseif else and not or eq ne in ni for foreach while switch");
var isOperatorChar = /[+\-*&%=<>!?^\/\|]/;
function chain(stream, state, f) {
state.tokenize = f;
return f(stream, state);
}
function tokenBase(stream, state) {
var beforeParams = state.beforeParams;
state.beforeParams = false;
var ch = stream.next();
if ((ch == '"' || ch == "'") && state.inParams) {
return chain(stream, state, tokenString(ch));
} else if (/[\[\]{}\(\),;\.]/.test(ch)) {
if (ch == "(" && beforeParams) state.inParams = true;
else if (ch == ")") state.inParams = false;
return null;
} else if (/\d/.test(ch)) {
stream.eatWhile(/[\w\.]/);
return "number";
} else if (ch == "#") {
if (stream.eat("*"))
return chain(stream, state, tokenComment);
if (ch == "#" && stream.match(/ *\[ *\[/))
return chain(stream, state, tokenUnparsed);
stream.skipToEnd();
return "comment";
} else if (ch == '"') {
stream.skipTo(/"/);
return "comment";
} else if (ch == "$") {
stream.eatWhile(/[$_a-z0-9A-Z\.{:]/);
stream.eatWhile(/}/);
state.beforeParams = true;
return "builtin";
} else if (isOperatorChar.test(ch)) {
stream.eatWhile(isOperatorChar);
return "comment";
} else {
stream.eatWhile(/[\w\$_{}\xa1-\uffff]/);
var word = stream.current().toLowerCase();
if (keywords && keywords.propertyIsEnumerable(word))
return "keyword";
if (functions && functions.propertyIsEnumerable(word)) {
state.beforeParams = true;
return "keyword";
}
return null;
}
}
function 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) 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 tokenUnparsed(stream, state) {
var maybeEnd = 0, ch;
while (ch = stream.next()) {
if (ch == "#" && maybeEnd == 2) {
state.tokenize = tokenBase;
break;
}
if (ch == "]")
maybeEnd++;
else if (ch != " ")
maybeEnd = 0;
}
return "meta";
}
return {
startState: function() {
return {
tokenize: tokenBase,
beforeParams: false,
inParams: false
};
},
token: function(stream, state) {
if (stream.eatSpace()) return null;
return state.tokenize(stream, state);
}
};
});
CodeMirror.defineMIME("text/x-tcl", "tcl");
});
tcl/index.html 0000644 00000014231 15051524051 0007322 0 ustar 00
CodeMirror: Tcl mode
Tcl mode
##############################################################################################
## ## whois.tcl for eggdrop by Ford_Lawnmower irc.geekshed.net #Script-Help ## ##
##############################################################################################
## To use this script you must set channel flag +whois (ie .chanset #chan +whois) ##
##############################################################################################
## ____ __ ########################################### ##
## / __/___ _ ___ _ ___/ /____ ___ ___ ########################################### ##
## / _/ / _ `// _ `// _ // __// _ \ / _ \ ########################################### ##
## /___/ \_, / \_, / \_,_//_/ \___// .__/ ########################################### ##
## /___/ /___/ /_/ ########################################### ##
## ########################################### ##
##############################################################################################
## ## Start Setup. ## ##
##############################################################################################
namespace eval whois {
## change cmdchar to the trigger you want to use ## ##
variable cmdchar "!"
## change command to the word trigger you would like to use. ## ##
## Keep in mind, This will also change the .chanset +/-command ## ##
variable command "whois"
## change textf to the colors you want for the text. ## ##
variable textf "\017\00304"
## change tagf to the colors you want for tags: ## ##
variable tagf "\017\002"
## Change logo to the logo you want at the start of the line. ## ##
variable logo "\017\00304\002\[\00306W\003hois\00304\]\017"
## Change lineout to the results you want. Valid results are channel users modes topic ## ##
variable lineout "channel users modes topic"
##############################################################################################
## ## End Setup. ## ##
##############################################################################################
variable channel ""
setudef flag $whois::command
bind pub -|- [string trimleft $whois::cmdchar]${whois::command} whois::list
bind raw -|- "311" whois::311
bind raw -|- "312" whois::312
bind raw -|- "319" whois::319
bind raw -|- "317" whois::317
bind raw -|- "313" whois::multi
bind raw -|- "310" whois::multi
bind raw -|- "335" whois::multi
bind raw -|- "301" whois::301
bind raw -|- "671" whois::multi
bind raw -|- "320" whois::multi
bind raw -|- "401" whois::multi
bind raw -|- "318" whois::318
bind raw -|- "307" whois::307
}
proc whois::311 {from key text} {
if {[regexp -- {^[^\s]+\s(.+?)\s(.+?)\s(.+?)\s\*\s\:(.+)$} $text wholematch nick ident host realname]} {
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Host:${whois::textf} \
$nick \(${ident}@${host}\) ${whois::tagf}Realname:${whois::textf} $realname"
}
}
proc whois::multi {from key text} {
if {[regexp {\:(.*)$} $text match $key]} {
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Note:${whois::textf} [subst $$key]"
return 1
}
}
proc whois::312 {from key text} {
regexp {([^\s]+)\s\:} $text match server
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Server:${whois::textf} $server"
}
proc whois::319 {from key text} {
if {[regexp {.+\:(.+)$} $text match channels]} {
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Channels:${whois::textf} $channels"
}
}
proc whois::317 {from key text} {
if {[regexp -- {.*\s(\d+)\s(\d+)\s\:} $text wholematch idle signon]} {
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Connected:${whois::textf} \
[ctime $signon] ${whois::tagf}Idle:${whois::textf} [duration $idle]"
}
}
proc whois::301 {from key text} {
if {[regexp {^.+\s[^\s]+\s\:(.*)$} $text match awaymsg]} {
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Away:${whois::textf} $awaymsg"
}
}
proc whois::318 {from key text} {
namespace eval whois {
variable channel ""
}
variable whois::channel ""
}
proc whois::307 {from key text} {
putserv "PRIVMSG $whois::channel :${whois::logo} ${whois::tagf}Services:${whois::textf} Registered Nick"
}
proc whois::list {nick host hand chan text} {
if {[lsearch -exact [channel info $chan] "+${whois::command}"] != -1} {
namespace eval whois {
variable channel ""
}
variable whois::channel $chan
putserv "WHOIS $text"
}
}
putlog "\002*Loaded* \017\00304\002\[\00306W\003hois\00304\]\017 \002by \
Ford_Lawnmower irc.GeekShed.net #Script-Help"
MIME types defined: text/x-tcl
.
vhdl/index.html 0000644 00000004666 15051524051 0007510 0 ustar 00
CodeMirror: VHDL mode
VHDL mode
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;
Syntax highlighting and indentation for the VHDL language.
Configuration options:
atoms - List of atom words. Default: "null"
hooks - List of meta hooks. Default: ["`", "$"]
multiLineStrings - Whether multi-line strings are accepted. Default: false
MIME types defined: text/x-vhdl
.
vhdl/vhdl.js 0000644 00000015060 15051524051 0006774 0 ustar 00 // CodeMirror, copyright (c) by Marijn Haverbeke and others
// Distributed under an MIT license: http://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 = /[&|~>