LaravelTest
140 строк · 4.8 Кб
1// CodeMirror, copyright (c) by Marijn Haverbeke and others
2// Distributed under an MIT license: https://codemirror.net/LICENSE
3
4//tcl mode by Ford_Lawnmower :: Based on Velocity mode by Steve O'Hara
5
6(function(mod) {7if (typeof exports == "object" && typeof module == "object") // CommonJS8mod(require("../../lib/codemirror"));9else if (typeof define == "function" && define.amd) // AMD10define(["../../lib/codemirror"], mod);11else // Plain browser env12mod(CodeMirror);13})(function(CodeMirror) {14"use strict";15
16CodeMirror.defineMode("tcl", function() {17function parseWords(str) {18var obj = {}, words = str.split(" ");19for (var i = 0; i < words.length; ++i) obj[words[i]] = true;20return obj;21}22var keywords = parseWords("Tcl safe after append array auto_execok auto_import auto_load " +23"auto_mkindex auto_mkindex_old auto_qualify auto_reset bgerror " +24"binary break catch cd close concat continue dde eof encoding error " +25"eval exec exit expr fblocked fconfigure fcopy file fileevent filename " +26"filename flush for foreach format gets glob global history http if " +27"incr info interp join lappend lindex linsert list llength load lrange " +28"lreplace lsearch lset lsort memory msgcat namespace open package parray " +29"pid pkg::create pkg_mkIndex proc puts pwd re_syntax read regex regexp " +30"registry regsub rename resource return scan seek set socket source split " +31"string subst switch tcl_endOfWord tcl_findLibrary tcl_startOfNextWord " +32"tcl_wordBreakAfter tcl_startOfPreviousWord tcl_wordBreakBefore tcltest " +33"tclvars tell time trace unknown unset update uplevel upvar variable " +34"vwait");35var functions = parseWords("if elseif else and not or eq ne in ni for foreach while switch");36var isOperatorChar = /[+\-*&%=<>!?^\/\|]/;37function chain(stream, state, f) {38state.tokenize = f;39return f(stream, state);40}41function tokenBase(stream, state) {42var beforeParams = state.beforeParams;43state.beforeParams = false;44var ch = stream.next();45if ((ch == '"' || ch == "'") && state.inParams) {46return chain(stream, state, tokenString(ch));47} else if (/[\[\]{}\(\),;\.]/.test(ch)) {48if (ch == "(" && beforeParams) state.inParams = true;49else if (ch == ")") state.inParams = false;50return null;51} else if (/\d/.test(ch)) {52stream.eatWhile(/[\w\.]/);53return "number";54} else if (ch == "#") {55if (stream.eat("*"))56return chain(stream, state, tokenComment);57if (ch == "#" && stream.match(/ *\[ *\[/))58return chain(stream, state, tokenUnparsed);59stream.skipToEnd();60return "comment";61} else if (ch == '"') {62stream.skipTo(/"/);63return "comment";64} else if (ch == "$") {65stream.eatWhile(/[$_a-z0-9A-Z\.{:]/);66stream.eatWhile(/}/);67state.beforeParams = true;68return "builtin";69} else if (isOperatorChar.test(ch)) {70stream.eatWhile(isOperatorChar);71return "comment";72} else {73stream.eatWhile(/[\w\$_{}\xa1-\uffff]/);74var word = stream.current().toLowerCase();75if (keywords && keywords.propertyIsEnumerable(word))76return "keyword";77if (functions && functions.propertyIsEnumerable(word)) {78state.beforeParams = true;79return "keyword";80}81return null;82}83}84function tokenString(quote) {85return function(stream, state) {86var escaped = false, next, end = false;87while ((next = stream.next()) != null) {88if (next == quote && !escaped) {89end = true;90break;91}92escaped = !escaped && next == "\\";93}94if (end) state.tokenize = tokenBase;95return "string";96};97}98function tokenComment(stream, state) {99var maybeEnd = false, ch;100while (ch = stream.next()) {101if (ch == "#" && maybeEnd) {102state.tokenize = tokenBase;103break;104}105maybeEnd = (ch == "*");106}107return "comment";108}109function tokenUnparsed(stream, state) {110var maybeEnd = 0, ch;111while (ch = stream.next()) {112if (ch == "#" && maybeEnd == 2) {113state.tokenize = tokenBase;114break;115}116if (ch == "]")117maybeEnd++;118else if (ch != " ")119maybeEnd = 0;120}121return "meta";122}123return {124startState: function() {125return {126tokenize: tokenBase,127beforeParams: false,128inParams: false129};130},131token: function(stream, state) {132if (stream.eatSpace()) return null;133return state.tokenize(stream, state);134},135lineComment: "#"136};137});138CodeMirror.defineMIME("text/x-tcl", "tcl");139
140});141