AmberRack 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +74 -0
- data/.rvmrc +4 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +62 -0
- data/README.md +17 -0
- data/Rakefile +24 -0
- data/amber-rack.gemspec +33 -0
- data/app/amber_app.rb +35 -0
- data/app/javascripts/Benchfib.deploy.js +159 -0
- data/app/javascripts/Benchfib.js +159 -0
- data/app/javascripts/Canvas.deploy.js +1464 -0
- data/app/javascripts/Canvas.js +1464 -0
- data/app/javascripts/Compiler.deploy.js +1587 -0
- data/app/javascripts/Compiler.js +1587 -0
- data/app/javascripts/Examples.deploy.js +800 -0
- data/app/javascripts/Examples.js +800 -0
- data/app/javascripts/IDE.deploy.js +3457 -0
- data/app/javascripts/IDE.js +3457 -0
- data/app/javascripts/IDE.js.bak +3420 -0
- data/app/javascripts/JQuery.deploy.js +898 -0
- data/app/javascripts/JQuery.js +898 -0
- data/app/javascripts/Kernel.deploy.js +6761 -0
- data/app/javascripts/Kernel.js +6761 -0
- data/app/javascripts/Parser.deploy.js +1655 -0
- data/app/javascripts/Parser.js +1655 -0
- data/app/javascripts/Raphael-Core.js +0 -0
- data/app/javascripts/Raphael-Graph.js +0 -0
- data/app/javascripts/SUnit.deploy.js +1059 -0
- data/app/javascripts/SUnit.js +1059 -0
- data/app/javascripts/application.js +2 -0
- data/app/javascripts/boot.js +466 -0
- data/app/javascripts/init.js +2 -0
- data/app/javascripts/jquery-1.4.4.min.js +167 -0
- data/app/javascripts/jquery-ui-1.8.9.custom.min.js +781 -0
- data/app/javascripts/jquery.textarea.js +267 -0
- data/app/javascripts/jtalk.js +78 -0
- data/app/javascripts/lib/CodeMirror/LICENSE +19 -0
- data/app/javascripts/lib/CodeMirror/README.md +6 -0
- data/app/javascripts/lib/CodeMirror/compress.html +92 -0
- data/app/javascripts/lib/CodeMirror/css/baboon.png +0 -0
- data/app/javascripts/lib/CodeMirror/css/baboon_vector.svg +153 -0
- data/app/javascripts/lib/CodeMirror/css/docs.css +154 -0
- data/app/javascripts/lib/CodeMirror/demo/activeline.html +72 -0
- data/app/javascripts/lib/CodeMirror/demo/changemode.html +51 -0
- data/app/javascripts/lib/CodeMirror/demo/complete.html +79 -0
- data/app/javascripts/lib/CodeMirror/demo/complete.js +151 -0
- data/app/javascripts/lib/CodeMirror/demo/fullscreen.html +158 -0
- data/app/javascripts/lib/CodeMirror/demo/marker.html +53 -0
- data/app/javascripts/lib/CodeMirror/demo/mustache.html +57 -0
- data/app/javascripts/lib/CodeMirror/demo/preview.html +75 -0
- data/app/javascripts/lib/CodeMirror/demo/resize.html +44 -0
- data/app/javascripts/lib/CodeMirror/demo/runmode.html +50 -0
- data/app/javascripts/lib/CodeMirror/demo/search.html +106 -0
- data/app/javascripts/lib/CodeMirror/demo/theme.html +53 -0
- data/app/javascripts/lib/CodeMirror/index.html +239 -0
- data/app/javascripts/lib/CodeMirror/internals.html +389 -0
- data/app/javascripts/lib/CodeMirror/lib/codemirror.css +67 -0
- data/app/javascripts/lib/CodeMirror/lib/codemirror.js +2144 -0
- data/app/javascripts/lib/CodeMirror/lib/overlay.js +51 -0
- data/app/javascripts/lib/CodeMirror/lib/runmode.js +27 -0
- data/app/javascripts/lib/CodeMirror/manual.html +854 -0
- data/app/javascripts/lib/CodeMirror/mode/clike/clike.js +247 -0
- data/app/javascripts/lib/CodeMirror/mode/clike/index.html +102 -0
- data/app/javascripts/lib/CodeMirror/mode/css/css.js +124 -0
- data/app/javascripts/lib/CodeMirror/mode/css/index.html +56 -0
- data/app/javascripts/lib/CodeMirror/mode/diff/diff.css +3 -0
- data/app/javascripts/lib/CodeMirror/mode/diff/diff.js +13 -0
- data/app/javascripts/lib/CodeMirror/mode/diff/index.html +99 -0
- data/app/javascripts/lib/CodeMirror/mode/haskell/haskell.js +242 -0
- data/app/javascripts/lib/CodeMirror/mode/haskell/index.html +60 -0
- data/app/javascripts/lib/CodeMirror/mode/htmlmixed/htmlmixed.js +79 -0
- data/app/javascripts/lib/CodeMirror/mode/htmlmixed/index.html +52 -0
- data/app/javascripts/lib/CodeMirror/mode/javascript/index.html +78 -0
- data/app/javascripts/lib/CodeMirror/mode/javascript/javascript.js +348 -0
- data/app/javascripts/lib/CodeMirror/mode/lua/index.html +72 -0
- data/app/javascripts/lib/CodeMirror/mode/lua/lua.js +138 -0
- data/app/javascripts/lib/CodeMirror/mode/php/index.html +49 -0
- data/app/javascripts/lib/CodeMirror/mode/php/php.js +110 -0
- data/app/javascripts/lib/CodeMirror/mode/plsql/index.html +63 -0
- data/app/javascripts/lib/CodeMirror/mode/plsql/plsql.js +217 -0
- data/app/javascripts/lib/CodeMirror/mode/python/LICENSE.txt +21 -0
- data/app/javascripts/lib/CodeMirror/mode/python/index.html +123 -0
- data/app/javascripts/lib/CodeMirror/mode/python/python.js +321 -0
- data/app/javascripts/lib/CodeMirror/mode/rst/index.html +526 -0
- data/app/javascripts/lib/CodeMirror/mode/rst/rst.css +75 -0
- data/app/javascripts/lib/CodeMirror/mode/rst/rst.js +333 -0
- data/app/javascripts/lib/CodeMirror/mode/scheme/index.html +65 -0
- data/app/javascripts/lib/CodeMirror/mode/scheme/scheme.js +181 -0
- data/app/javascripts/lib/CodeMirror/mode/smalltalk/index.html +56 -0
- data/app/javascripts/lib/CodeMirror/mode/smalltalk/smalltalk.js +134 -0
- data/app/javascripts/lib/CodeMirror/mode/sparql/index.html +41 -0
- data/app/javascripts/lib/CodeMirror/mode/sparql/sparql.js +143 -0
- data/app/javascripts/lib/CodeMirror/mode/stex/index.html +96 -0
- data/app/javascripts/lib/CodeMirror/mode/stex/stex.js +167 -0
- data/app/javascripts/lib/CodeMirror/mode/xml/index.html +42 -0
- data/app/javascripts/lib/CodeMirror/mode/xml/xml.js +231 -0
- data/app/javascripts/lib/CodeMirror/mode/yaml/index.html +68 -0
- data/app/javascripts/lib/CodeMirror/mode/yaml/yaml.js +95 -0
- data/app/javascripts/lib/CodeMirror/oldrelease.html +178 -0
- data/app/javascripts/lib/CodeMirror/test/index.html +29 -0
- data/app/javascripts/lib/CodeMirror/test/test.js +249 -0
- data/app/javascripts/lib/CodeMirror/theme/default.css +18 -0
- data/app/javascripts/lib/CodeMirror/theme/elegant.css +9 -0
- data/app/javascripts/lib/CodeMirror/theme/jtalk.css +21 -0
- data/app/javascripts/lib/CodeMirror/theme/neat.css +8 -0
- data/app/javascripts/lib/CodeMirror/theme/night.css +20 -0
- data/app/javascripts/lib/jQuery/jquery-1.4.4.min.js +167 -0
- data/app/javascripts/lib/jQuery/jquery-ui-1.8.9.custom.min.js +781 -0
- data/app/javascripts/lib/jQuery/jquery.textarea.js +267 -0
- data/app/smalltalk/Canvas.st +481 -0
- data/app/smalltalk/IDE.st +1752 -0
- data/config.ru +2 -0
- data/lib/amber-rack.rb +4 -0
- data/lib/amber-rack/version.rb +3 -0
- data/public/CodeMirror/LICENSE +19 -0
- data/public/CodeMirror/README.md +6 -0
- data/public/CodeMirror/compress.html +92 -0
- data/public/CodeMirror/css/baboon.png +0 -0
- data/public/CodeMirror/css/baboon_vector.svg +153 -0
- data/public/CodeMirror/css/docs.css +154 -0
- data/public/CodeMirror/demo/activeline.html +72 -0
- data/public/CodeMirror/demo/changemode.html +51 -0
- data/public/CodeMirror/demo/complete.html +79 -0
- data/public/CodeMirror/demo/complete.js +151 -0
- data/public/CodeMirror/demo/fullscreen.html +158 -0
- data/public/CodeMirror/demo/marker.html +53 -0
- data/public/CodeMirror/demo/mustache.html +57 -0
- data/public/CodeMirror/demo/preview.html +75 -0
- data/public/CodeMirror/demo/resize.html +44 -0
- data/public/CodeMirror/demo/runmode.html +50 -0
- data/public/CodeMirror/demo/search.html +106 -0
- data/public/CodeMirror/demo/theme.html +53 -0
- data/public/CodeMirror/index.html +239 -0
- data/public/CodeMirror/internals.html +389 -0
- data/public/CodeMirror/lib/codemirror.css +67 -0
- data/public/CodeMirror/lib/codemirror.js +2144 -0
- data/public/CodeMirror/lib/overlay.js +51 -0
- data/public/CodeMirror/lib/runmode.js +27 -0
- data/public/CodeMirror/manual.html +854 -0
- data/public/CodeMirror/mode/clike/clike.js +247 -0
- data/public/CodeMirror/mode/clike/index.html +102 -0
- data/public/CodeMirror/mode/css/css.js +124 -0
- data/public/CodeMirror/mode/css/index.html +56 -0
- data/public/CodeMirror/mode/diff/diff.css +3 -0
- data/public/CodeMirror/mode/diff/diff.js +13 -0
- data/public/CodeMirror/mode/diff/index.html +99 -0
- data/public/CodeMirror/mode/haskell/haskell.js +242 -0
- data/public/CodeMirror/mode/haskell/index.html +60 -0
- data/public/CodeMirror/mode/htmlmixed/htmlmixed.js +79 -0
- data/public/CodeMirror/mode/htmlmixed/index.html +52 -0
- data/public/CodeMirror/mode/javascript/index.html +78 -0
- data/public/CodeMirror/mode/javascript/javascript.js +348 -0
- data/public/CodeMirror/mode/lua/index.html +72 -0
- data/public/CodeMirror/mode/lua/lua.js +138 -0
- data/public/CodeMirror/mode/php/index.html +49 -0
- data/public/CodeMirror/mode/php/php.js +110 -0
- data/public/CodeMirror/mode/plsql/index.html +63 -0
- data/public/CodeMirror/mode/plsql/plsql.js +217 -0
- data/public/CodeMirror/mode/python/LICENSE.txt +21 -0
- data/public/CodeMirror/mode/python/index.html +123 -0
- data/public/CodeMirror/mode/python/python.js +321 -0
- data/public/CodeMirror/mode/rst/index.html +526 -0
- data/public/CodeMirror/mode/rst/rst.css +75 -0
- data/public/CodeMirror/mode/rst/rst.js +333 -0
- data/public/CodeMirror/mode/scheme/index.html +65 -0
- data/public/CodeMirror/mode/scheme/scheme.js +181 -0
- data/public/CodeMirror/mode/smalltalk/index.html +56 -0
- data/public/CodeMirror/mode/smalltalk/smalltalk.js +134 -0
- data/public/CodeMirror/mode/sparql/index.html +41 -0
- data/public/CodeMirror/mode/sparql/sparql.js +143 -0
- data/public/CodeMirror/mode/stex/index.html +96 -0
- data/public/CodeMirror/mode/stex/stex.js +167 -0
- data/public/CodeMirror/mode/xml/index.html +42 -0
- data/public/CodeMirror/mode/xml/xml.js +231 -0
- data/public/CodeMirror/mode/yaml/index.html +68 -0
- data/public/CodeMirror/mode/yaml/yaml.js +95 -0
- data/public/CodeMirror/oldrelease.html +178 -0
- data/public/CodeMirror/test/index.html +29 -0
- data/public/CodeMirror/test/test.js +249 -0
- data/public/CodeMirror/theme/default.css +18 -0
- data/public/CodeMirror/theme/elegant.css +9 -0
- data/public/CodeMirror/theme/jtalk.css +21 -0
- data/public/CodeMirror/theme/neat.css +8 -0
- data/public/CodeMirror/theme/night.css +20 -0
- data/public/css/jtalk.css +362 -0
- data/public/css/style.css +456 -0
- data/public/css/sunit.css +66 -0
- data/public/ide/fork_me.png +0 -0
- data/public/ide/screen2.png +0 -0
- data/public/ide/style.css +456 -0
- data/public/ide/syntax.css +61 -0
- data/public/ide/text_header.png +0 -0
- data/public/ide/title_container1.png +0 -0
- data/public/images/background_box.png +0 -0
- data/public/images/background_header.png +0 -0
- data/public/images/balloon_header.png +0 -0
- data/views/index.haml +66 -0
- metadata +341 -0
@@ -0,0 +1,181 @@
|
|
1
|
+
/**
|
2
|
+
* Author: Koh Zi Han, based on implementation by Koh Zi Chun
|
3
|
+
*/
|
4
|
+
CodeMirror.defineMode("scheme", function (config, mode) {
|
5
|
+
var numRegex = /[0-9]/;
|
6
|
+
var BUILTIN = "builtin", COMMENT = "comment", STRING = "string",
|
7
|
+
ATOM = "atom", NUMBER = "number", BRACKET = "bracket";
|
8
|
+
var INDENT_WORD_SKIP = 2, KEYWORDS_SKIP = 1;
|
9
|
+
|
10
|
+
function makeKeywords(str) {
|
11
|
+
var obj = {}, words = str.split(" ");
|
12
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
13
|
+
return obj;
|
14
|
+
}
|
15
|
+
|
16
|
+
var keywords = makeKeywords("case-lambda call/cc class define-class exit-handler field import inherit init-field interface let*-values let-values let/ec mixin opt-lambda override protect provide public rename require require-for-syntax syntax syntax-case syntax-error unit/sig unless when with-syntax and begin call-with-current-continuation call-with-input-file call-with-output-file case cond define define-syntax delay do dynamic-wind else for-each if lambda let let* let-syntax letrec letrec-syntax map or syntax-rules abs acos angle append apply asin assoc assq assv atan boolean? caar cadr call-with-input-file call-with-output-file call-with-values car cdddar cddddr cdr ceiling char->integer char-alphabetic? char-ci<=? char-ci<? char-ci=? char-ci>=? char-ci>? char-downcase char-lower-case? char-numeric? char-ready? char-upcase char-upper-case? char-whitespace? char<=? char<? char=? char>=? char>? char? close-input-port close-output-port complex? cons cos current-input-port current-output-port denominator display eof-object? eq? equal? eqv? eval even? exact->inexact exact? exp expt #f floor force gcd imag-part inexact->exact inexact? input-port? integer->char integer? interaction-environment lcm length list list->string list->vector list-ref list-tail list? load log magnitude make-polar make-rectangular make-string make-vector max member memq memv min modulo negative? newline not null-environment null? number->string number? numerator odd? open-input-file open-output-file output-port? pair? peek-char port? positive? procedure? quasiquote quote quotient rational? rationalize read read-char real-part real? remainder reverse round scheme-report-environment set! set-car! set-cdr! sin sqrt string string->list string->number string->symbol string-append string-ci<=? string-ci<? string-ci=? string-ci>=? string-ci>? string-copy string-fill! string-length string-ref string-set! string<=? string<? string=? string>=? string>? string? substring symbol->string symbol? #t tan transcript-off transcript-on truncate values vector vector->list vector-fill! vector-length vector-ref vector-set! with-input-from-file with-output-to-file write write-char zero?");
|
17
|
+
var indentKeys = makeKeywords("define let letrec let* lambda begin");
|
18
|
+
|
19
|
+
|
20
|
+
function stateStack(indent, type, prev) { // represents a state stack object
|
21
|
+
this.indent = indent;
|
22
|
+
this.type = type;
|
23
|
+
this.prev = prev;
|
24
|
+
}
|
25
|
+
|
26
|
+
function pushStack(state, indent, type) {
|
27
|
+
state.indentStack = new stateStack(indent, type, state.indentStack);
|
28
|
+
}
|
29
|
+
|
30
|
+
function popStack(state) {
|
31
|
+
state.indentStack = state.indentStack.prev;
|
32
|
+
}
|
33
|
+
|
34
|
+
return {
|
35
|
+
startState: function () {
|
36
|
+
return {
|
37
|
+
indentStack: null,
|
38
|
+
indentation: 0,
|
39
|
+
mode: false,
|
40
|
+
sExprComment: false
|
41
|
+
};
|
42
|
+
},
|
43
|
+
|
44
|
+
token: function (stream, state) {
|
45
|
+
if (state.indentStack == null && stream.sol()) {
|
46
|
+
// update indentation, but only if indentStack is empty
|
47
|
+
state.indentation = stream.indentation();
|
48
|
+
}
|
49
|
+
|
50
|
+
// skip spaces
|
51
|
+
if (stream.eatSpace()) {
|
52
|
+
return null;
|
53
|
+
}
|
54
|
+
var returnType = null;
|
55
|
+
|
56
|
+
switch(state.mode){
|
57
|
+
case "string": // multi-line string parsing mode
|
58
|
+
var next, escaped = false;
|
59
|
+
while ((next = stream.next()) != null) {
|
60
|
+
if (next == "\"" && !escaped) {
|
61
|
+
|
62
|
+
state.mode = false;
|
63
|
+
break;
|
64
|
+
}
|
65
|
+
escaped = !escaped && next == "\\";
|
66
|
+
}
|
67
|
+
returnType = STRING; // continue on in scheme-string mode
|
68
|
+
break;
|
69
|
+
case "comment": // comment parsing mode
|
70
|
+
var next, maybeEnd = false;
|
71
|
+
while ((next = stream.next()) != null) {
|
72
|
+
if (next == "#" && maybeEnd) {
|
73
|
+
|
74
|
+
state.mode = false;
|
75
|
+
break;
|
76
|
+
}
|
77
|
+
maybeEnd = (next == "|");
|
78
|
+
}
|
79
|
+
returnType = COMMENT;
|
80
|
+
break;
|
81
|
+
case "s-expr-comment": // s-expr commenting mode
|
82
|
+
state.mode = false;
|
83
|
+
if(stream.peek() == "(" || stream.peek() == "["){
|
84
|
+
// actually start scheme s-expr commenting mode
|
85
|
+
state.sExprComment = 0;
|
86
|
+
}else{
|
87
|
+
// if not we just comment the entire of the next token
|
88
|
+
stream.eatWhile(/[^/s]/); // eat non spaces
|
89
|
+
returnType = COMMENT;
|
90
|
+
break;
|
91
|
+
}
|
92
|
+
default: // default parsing mode
|
93
|
+
var ch = stream.next();
|
94
|
+
|
95
|
+
if (ch == "\"") {
|
96
|
+
state.mode = "string";
|
97
|
+
returnType = STRING;
|
98
|
+
|
99
|
+
} else if (ch == "'") {
|
100
|
+
returnType = ATOM;
|
101
|
+
} else if (ch == '#') {
|
102
|
+
if (stream.eat("|")) { // Multi-line comment
|
103
|
+
state.mode = "comment"; // toggle to comment mode
|
104
|
+
returnType = COMMENT;
|
105
|
+
} else if (stream.eat(/[tf]/)) { // #t/#f (atom)
|
106
|
+
returnType = ATOM;
|
107
|
+
} else if (stream.eat(';')) { // S-Expr comment
|
108
|
+
state.mode = "s-expr-comment";
|
109
|
+
returnType = COMMENT;
|
110
|
+
}
|
111
|
+
|
112
|
+
} else if (ch == ";") { // comment
|
113
|
+
stream.skipToEnd(); // rest of the line is a comment
|
114
|
+
returnType = COMMENT;
|
115
|
+
|
116
|
+
} else if (numRegex.exec(ch) != null) { // numbers
|
117
|
+
returnType = NUMBER;
|
118
|
+
|
119
|
+
} else if (ch == "(" || ch == "[") {
|
120
|
+
var keyWord = ''; var indentTemp = stream.column();
|
121
|
+
/**
|
122
|
+
Either
|
123
|
+
(indent-word ..
|
124
|
+
(non-indent-word ..
|
125
|
+
(;something else, bracket, etc.
|
126
|
+
*/
|
127
|
+
|
128
|
+
while ((letter = stream.eat(/[^\s\(\[\;\)\]]/)) != null) {
|
129
|
+
keyWord += letter;
|
130
|
+
}
|
131
|
+
|
132
|
+
if (keyWord.length > 0 && indentKeys.propertyIsEnumerable(keyWord)) { // indent-word
|
133
|
+
|
134
|
+
pushStack(state, indentTemp + INDENT_WORD_SKIP, ch);
|
135
|
+
} else { // non-indent word
|
136
|
+
// we continue eating the spaces
|
137
|
+
stream.eatSpace();
|
138
|
+
if (stream.eol() || stream.peek() == ";") {
|
139
|
+
// nothing significant after
|
140
|
+
// we restart indentation 1 space after
|
141
|
+
pushStack(state, indentTemp + 1, ch);
|
142
|
+
} else {
|
143
|
+
pushStack(state, indentTemp + stream.current().length, ch); // else we match
|
144
|
+
}
|
145
|
+
}
|
146
|
+
stream.backUp(stream.current().length - 1); // undo all the eating
|
147
|
+
|
148
|
+
if(typeof state.sExprComment == "number") state.sExprComment++;
|
149
|
+
|
150
|
+
returnType = BRACKET;
|
151
|
+
} else if (ch == ")" || ch == "]") {
|
152
|
+
returnType = BRACKET;
|
153
|
+
if (state.indentStack != null && state.indentStack.type == (ch == ")" ? "(" : "[")) {
|
154
|
+
popStack(state);
|
155
|
+
|
156
|
+
if(typeof state.sExprComment == "number"){
|
157
|
+
if(--state.sExprComment == 0){
|
158
|
+
returnType = COMMENT; // final closing bracket
|
159
|
+
state.sExprComment = false; // turn off s-expr commenting mode
|
160
|
+
}
|
161
|
+
}
|
162
|
+
}
|
163
|
+
} else {
|
164
|
+
stream.eatWhile(/[\w\$_]/);
|
165
|
+
|
166
|
+
if (keywords && keywords.propertyIsEnumerable(stream.current())) {
|
167
|
+
returnType = BUILTIN;
|
168
|
+
} else returnType = null;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
return (typeof state.sExprComment == "number") ? COMMENT : returnType;
|
172
|
+
},
|
173
|
+
|
174
|
+
indent: function (state, textAfter) {
|
175
|
+
if (state.indentStack == null) return state.indentation;
|
176
|
+
return state.indentStack.indent;
|
177
|
+
}
|
178
|
+
};
|
179
|
+
});
|
180
|
+
|
181
|
+
CodeMirror.defineMIME("text/x-scheme", "css");
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CodeMirror 2: Smalltalk mode</title>
|
5
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
6
|
+
<script src="../../lib/codemirror.js"></script>
|
7
|
+
<script src="smalltalk.js"></script>
|
8
|
+
<link rel="stylesheet" href="../../theme/default.css">
|
9
|
+
<link rel="stylesheet" href="../../css/docs.css">
|
10
|
+
<style>
|
11
|
+
.CodeMirror {border: 2px solid #dee; border-right-width: 10px;}
|
12
|
+
.CodeMirror-gutter {border: none; background: #dee;}
|
13
|
+
.CodeMirror-gutter pre {color: white; font-weight: bold;}
|
14
|
+
</style>
|
15
|
+
</head>
|
16
|
+
<body>
|
17
|
+
<h1>CodeMirror 2: Smalltalk mode</h1>
|
18
|
+
|
19
|
+
<form><textarea id="code" name="code">
|
20
|
+
"
|
21
|
+
This is a test of the Smalltalk code
|
22
|
+
"
|
23
|
+
Seaside.WAComponent subclass: #MyCounter [
|
24
|
+
| count |
|
25
|
+
MyCounter class >> canBeRoot [ ^true ]
|
26
|
+
|
27
|
+
initialize [
|
28
|
+
super initialize.
|
29
|
+
count := 0.
|
30
|
+
]
|
31
|
+
states [ ^{ self } ]
|
32
|
+
renderContentOn: html [
|
33
|
+
html heading: count.
|
34
|
+
html anchor callback: [ count := count + 1 ]; with: '++'.
|
35
|
+
html space.
|
36
|
+
html anchor callback: [ count := count - 1 ]; with: '--'.
|
37
|
+
]
|
38
|
+
]
|
39
|
+
|
40
|
+
MyCounter registerAsApplication: 'mycounter'
|
41
|
+
</textarea></form>
|
42
|
+
|
43
|
+
<script>
|
44
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
45
|
+
lineNumbers: true,
|
46
|
+
matchBrackets: true,
|
47
|
+
mode: "text/x-stsrc",
|
48
|
+
indentUnit: 4
|
49
|
+
});
|
50
|
+
</script>
|
51
|
+
|
52
|
+
<p>Simple Smalltalk mode.</p>
|
53
|
+
|
54
|
+
<p><strong>MIME types defined:</strong> <code>text/x-stsrc</code>.</p>
|
55
|
+
</body>
|
56
|
+
</html>
|
@@ -0,0 +1,134 @@
|
|
1
|
+
CodeMirror.defineMode("smalltalk", function(config, parserConfig) {
|
2
|
+
var keywords = {"true": 1, "false": 1, nil: 1, self: 1, "super": 1, thisContext: 1};
|
3
|
+
var indentUnit = config.indentUnit;
|
4
|
+
|
5
|
+
function chain(stream, state, f) {
|
6
|
+
state.tokenize = f;
|
7
|
+
return f(stream, state);
|
8
|
+
}
|
9
|
+
|
10
|
+
var type;
|
11
|
+
function ret(tp, style) {
|
12
|
+
type = tp;
|
13
|
+
return style;
|
14
|
+
}
|
15
|
+
|
16
|
+
function tokenBase(stream, state) {
|
17
|
+
var ch = stream.next();
|
18
|
+
if (ch == '"')
|
19
|
+
return chain(stream, state, tokenComment(ch));
|
20
|
+
else if (ch == "'")
|
21
|
+
return chain(stream, state, tokenString(ch));
|
22
|
+
else if (ch == "#") {
|
23
|
+
stream.eatWhile(/[\w\$_]/);
|
24
|
+
return ret("string", "string");
|
25
|
+
}
|
26
|
+
else if(ch == "^") {
|
27
|
+
return ret("return", "return");
|
28
|
+
}
|
29
|
+
else if(/[A-Z]/.test(ch)) {
|
30
|
+
stream.eatWhile(/[^\s]/);
|
31
|
+
return ret("className", "className");
|
32
|
+
}
|
33
|
+
else if (/\d/.test(ch)) {
|
34
|
+
stream.eatWhile(/[\w\.]/);
|
35
|
+
return ret("number", "number");
|
36
|
+
}
|
37
|
+
else if (/[\[\]()]/.test(ch)) {
|
38
|
+
return ret(ch, null);
|
39
|
+
}
|
40
|
+
else {
|
41
|
+
if(ch == ":") {
|
42
|
+
if(stream.eat("=")) {
|
43
|
+
return ret("assignment", "assignment");
|
44
|
+
}
|
45
|
+
}
|
46
|
+
stream.eatWhile(/[\w\$_]/);
|
47
|
+
if (keywords && keywords.propertyIsEnumerable(stream.current())) return ret("keyword", "keyword");
|
48
|
+
return ret("operator", "operator");
|
49
|
+
}
|
50
|
+
}
|
51
|
+
|
52
|
+
function tokenString(quote) {
|
53
|
+
return function(stream, state) {
|
54
|
+
var escaped = false, next, end = false;
|
55
|
+
while ((next = stream.next()) != null) {
|
56
|
+
if (next == quote && !escaped) {end = true; break;}
|
57
|
+
escaped = !escaped && next == "\\";
|
58
|
+
}
|
59
|
+
if (end || !(escaped))
|
60
|
+
state.tokenize = tokenBase;
|
61
|
+
return ret("string", "string");
|
62
|
+
};
|
63
|
+
}
|
64
|
+
|
65
|
+
function tokenComment(quote) {
|
66
|
+
return function(stream, state) {
|
67
|
+
var next, end = false;
|
68
|
+
while ((next = stream.next()) != null) {
|
69
|
+
if (next == quote) {end = true; break;}
|
70
|
+
}
|
71
|
+
if (end)
|
72
|
+
state.tokenize = tokenBase;
|
73
|
+
return ret("comment", "comment");
|
74
|
+
};
|
75
|
+
}
|
76
|
+
|
77
|
+
function Context(indented, column, type, align, prev) {
|
78
|
+
this.indented = indented;
|
79
|
+
this.column = column;
|
80
|
+
this.type = type;
|
81
|
+
this.align = align;
|
82
|
+
this.prev = prev;
|
83
|
+
}
|
84
|
+
|
85
|
+
function pushContext(state, col, type) {
|
86
|
+
return state.context = new Context(state.indented, col, type, null, state.context);
|
87
|
+
}
|
88
|
+
function popContext(state) {
|
89
|
+
return state.context = state.context.prev;
|
90
|
+
}
|
91
|
+
|
92
|
+
// Interface
|
93
|
+
|
94
|
+
return {
|
95
|
+
startState: function(basecolumn) {
|
96
|
+
return {
|
97
|
+
tokenize: tokenBase,
|
98
|
+
context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
|
99
|
+
indented: 0,
|
100
|
+
startOfLine: true
|
101
|
+
};
|
102
|
+
},
|
103
|
+
|
104
|
+
token: function(stream, state) {
|
105
|
+
var ctx = state.context;
|
106
|
+
if (stream.sol()) {
|
107
|
+
if (ctx.align == null) ctx.align = false;
|
108
|
+
state.indented = stream.indentation();
|
109
|
+
state.startOfLine = true;
|
110
|
+
}
|
111
|
+
if (stream.eatSpace()) return null;
|
112
|
+
var style = state.tokenize(stream, state);
|
113
|
+
if (type == "comment") return style;
|
114
|
+
if (ctx.align == null) ctx.align = true;
|
115
|
+
|
116
|
+
if (type == "[") pushContext(state, stream.column(), "]");
|
117
|
+
else if (type == "(") pushContext(state, stream.column(), ")");
|
118
|
+
else if (type == ctx.type) popContext(state);
|
119
|
+
state.startOfLine = false;
|
120
|
+
return style;
|
121
|
+
},
|
122
|
+
|
123
|
+
indent: function(state, textAfter) {
|
124
|
+
if (state.tokenize != tokenBase) return 0;
|
125
|
+
var firstChar = textAfter && textAfter.charAt(0), ctx = state.context, closing = firstChar == ctx.type;
|
126
|
+
if (ctx.align) return ctx.column + (closing ? 0 : 1);
|
127
|
+
else return ctx.indented + (closing ? 0 : indentUnit);
|
128
|
+
},
|
129
|
+
|
130
|
+
electricChars: "]"
|
131
|
+
};
|
132
|
+
});
|
133
|
+
|
134
|
+
CodeMirror.defineMIME("text/x-stsrc", {name: "smalltalk"});
|
@@ -0,0 +1,41 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CodeMirror 2: SPARQL mode</title>
|
5
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
6
|
+
<script src="../../lib/codemirror.js"></script>
|
7
|
+
<script src="sparql.js"></script>
|
8
|
+
<link rel="stylesheet" href="../../theme/default.css">
|
9
|
+
<style>.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
10
|
+
<link rel="stylesheet" href="../../css/docs.css">
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<h1>CodeMirror 2: SPARQL mode</h1>
|
14
|
+
<form><textarea id="code" name="code">
|
15
|
+
PREFIX a: <http://www.w3.org/2000/10/annotation-ns#>
|
16
|
+
PREFIX dc: <http://purl.org/dc/elements/1.1/>
|
17
|
+
PREFIX foaf: <http://xmlns.com/foaf/0.1/>
|
18
|
+
|
19
|
+
# Comment!
|
20
|
+
|
21
|
+
SELECT ?given ?family
|
22
|
+
WHERE {
|
23
|
+
?annot a:annotates <http://www.w3.org/TR/rdf-sparql-query/> .
|
24
|
+
?annot dc:creator ?c .
|
25
|
+
OPTIONAL {?c foaf:given ?given ;
|
26
|
+
foaf:family ?family } .
|
27
|
+
FILTER isBlank(?c)
|
28
|
+
}
|
29
|
+
</textarea></form>
|
30
|
+
<script>
|
31
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
32
|
+
mode: "application/x-sparql-query",
|
33
|
+
tabMode: "indent",
|
34
|
+
matchBrackets: true
|
35
|
+
});
|
36
|
+
</script>
|
37
|
+
|
38
|
+
<p><strong>MIME types defined:</strong> <code>application/x-sparql-query</code>.</p>
|
39
|
+
|
40
|
+
</body>
|
41
|
+
</html>
|
@@ -0,0 +1,143 @@
|
|
1
|
+
CodeMirror.defineMode("sparql", function(config) {
|
2
|
+
var indentUnit = config.indentUnit;
|
3
|
+
var curPunc;
|
4
|
+
|
5
|
+
function wordRegexp(words) {
|
6
|
+
return new RegExp("^(?:" + words.join("|") + ")$", "i");
|
7
|
+
}
|
8
|
+
var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri",
|
9
|
+
"isblank", "isliteral", "union", "a"]);
|
10
|
+
var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe",
|
11
|
+
"ask", "from", "named", "where", "order", "limit", "offset", "filter", "optional",
|
12
|
+
"graph", "by", "asc", "desc"]);
|
13
|
+
var operatorChars = /[*+\-<>=&|]/;
|
14
|
+
|
15
|
+
function tokenBase(stream, state) {
|
16
|
+
var ch = stream.next();
|
17
|
+
curPunc = null;
|
18
|
+
if (ch == "$" || ch == "?") {
|
19
|
+
stream.match(/^[\w\d]*/);
|
20
|
+
return "variable-2";
|
21
|
+
}
|
22
|
+
else if (ch == "<" && !stream.match(/^[\s\u00a0=]/, false)) {
|
23
|
+
stream.match(/^[^\s\u00a0>]*>?/);
|
24
|
+
return "atom";
|
25
|
+
}
|
26
|
+
else if (ch == "\"" || ch == "'") {
|
27
|
+
state.tokenize = tokenLiteral(ch);
|
28
|
+
return state.tokenize(stream, state);
|
29
|
+
}
|
30
|
+
else if (/[{}\(\),\.;\[\]]/.test(ch)) {
|
31
|
+
curPunc = ch;
|
32
|
+
return null;
|
33
|
+
}
|
34
|
+
else if (ch == "#") {
|
35
|
+
stream.skipToEnd();
|
36
|
+
return "comment";
|
37
|
+
}
|
38
|
+
else if (operatorChars.test(ch)) {
|
39
|
+
stream.eatWhile(operatorChars);
|
40
|
+
return null;
|
41
|
+
}
|
42
|
+
else if (ch == ":") {
|
43
|
+
stream.eatWhile(/[\w\d\._\-]/);
|
44
|
+
return "atom";
|
45
|
+
}
|
46
|
+
else {
|
47
|
+
stream.eatWhile(/[_\w\d]/);
|
48
|
+
if (stream.eat(":")) {
|
49
|
+
stream.eatWhile(/[\w\d_\-]/);
|
50
|
+
return "atom";
|
51
|
+
}
|
52
|
+
var word = stream.current(), type;
|
53
|
+
if (ops.test(word))
|
54
|
+
return null;
|
55
|
+
else if (keywords.test(word))
|
56
|
+
return "keyword";
|
57
|
+
else
|
58
|
+
return "variable";
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
function tokenLiteral(quote) {
|
63
|
+
return function(stream, state) {
|
64
|
+
var escaped = false, ch;
|
65
|
+
while ((ch = stream.next()) != null) {
|
66
|
+
if (ch == quote && !escaped) {
|
67
|
+
state.tokenize = tokenBase;
|
68
|
+
break;
|
69
|
+
}
|
70
|
+
escaped = !escaped && ch == "\\";
|
71
|
+
}
|
72
|
+
return "string";
|
73
|
+
};
|
74
|
+
}
|
75
|
+
|
76
|
+
function pushContext(state, type, col) {
|
77
|
+
state.context = {prev: state.context, indent: state.indent, col: col, type: type};
|
78
|
+
}
|
79
|
+
function popContext(state) {
|
80
|
+
state.indent = state.context.indent;
|
81
|
+
state.context = state.context.prev;
|
82
|
+
}
|
83
|
+
|
84
|
+
return {
|
85
|
+
startState: function(base) {
|
86
|
+
return {tokenize: tokenBase,
|
87
|
+
context: null,
|
88
|
+
indent: 0,
|
89
|
+
col: 0};
|
90
|
+
},
|
91
|
+
|
92
|
+
token: function(stream, state) {
|
93
|
+
if (stream.sol()) {
|
94
|
+
if (state.context && state.context.align == null) state.context.align = false;
|
95
|
+
state.indent = stream.indentation();
|
96
|
+
}
|
97
|
+
if (stream.eatSpace()) return null;
|
98
|
+
var style = state.tokenize(stream, state);
|
99
|
+
|
100
|
+
if (style != "comment" && state.context && state.context.align == null && state.context.type != "pattern") {
|
101
|
+
state.context.align = true;
|
102
|
+
}
|
103
|
+
|
104
|
+
if (curPunc == "(") pushContext(state, ")", stream.column());
|
105
|
+
else if (curPunc == "[") pushContext(state, "]", stream.column());
|
106
|
+
else if (curPunc == "{") pushContext(state, "}", stream.column());
|
107
|
+
else if (/[\]\}\)]/.test(curPunc)) {
|
108
|
+
while (state.context && state.context.type == "pattern") popContext(state);
|
109
|
+
if (state.context && curPunc == state.context.type) popContext(state);
|
110
|
+
}
|
111
|
+
else if (curPunc == "." && state.context && state.context.type == "pattern") popContext(state);
|
112
|
+
else if (/atom|string|variable/.test(style) && state.context) {
|
113
|
+
if (/[\}\]]/.test(state.context.type))
|
114
|
+
pushContext(state, "pattern", stream.column());
|
115
|
+
else if (state.context.type == "pattern" && !state.context.align) {
|
116
|
+
state.context.align = true;
|
117
|
+
state.context.col = stream.column();
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
return style;
|
122
|
+
},
|
123
|
+
|
124
|
+
indent: function(state, textAfter) {
|
125
|
+
var firstChar = textAfter && textAfter.charAt(0);
|
126
|
+
var context = state.context;
|
127
|
+
if (/[\]\}]/.test(firstChar))
|
128
|
+
while (context && context.type == "pattern") context = context.prev;
|
129
|
+
|
130
|
+
var closing = context && firstChar == context.type;
|
131
|
+
if (!context)
|
132
|
+
return 0;
|
133
|
+
else if (context.type == "pattern")
|
134
|
+
return context.col;
|
135
|
+
else if (context.align)
|
136
|
+
return context.col + (closing ? 0 : 1);
|
137
|
+
else
|
138
|
+
return context.indent + (closing ? 0 : indentUnit);
|
139
|
+
}
|
140
|
+
};
|
141
|
+
});
|
142
|
+
|
143
|
+
CodeMirror.defineMIME("application/x-sparql-query", "sparql");
|